Commit 0a7b0b53 authored by Tony Murray's avatar Tony Murray

Replace KUrlNavigator with a KComboBox and a KLineEdit. This patch is...

Replace KUrlNavigator with a KComboBox and a KLineEdit.  This patch is intended to be backported to 4.5.

svn path=/trunk/KDE/kdenetwork/krdc/; revision=1177173
parent b8245d7a
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>363</width>
<height>496</height>
<height>464</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
......@@ -25,13 +25,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_NormalUrlInputLine">
<property name="text">
<string>Use normal inputline for address input</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_WalletSupport">
<property name="text">
......
......@@ -58,13 +58,13 @@
#include <KStatusBar>
#include <KToggleAction>
#include <KToggleFullScreenAction>
#include <KUrlNavigator>
#include <KServiceTypeTrader>
#include <QClipboard>
#include <QDockWidget>
#include <QFontMetrics>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QHeaderView>
#include <QLabel>
#include <QLayout>
......@@ -73,11 +73,13 @@
#include <QTableView>
#include <QTimer>
#include <QToolBar>
#include <QVBoxLayout>
MainWindow::MainWindow(QWidget *parent)
: KXmlGuiWindow(parent),
m_fullscreenWindow(0),
m_addressNavigator(0),
m_protocolInput(0),
m_addressInput(0),
m_toolBar(0),
m_currentRemoteView(-1),
m_systemTrayIcon(0),
......@@ -284,11 +286,20 @@ void MainWindow::restoreOpenSessions()
}
}
KUrl MainWindow::getInputUrl()
{
KUrl inputUrl;
inputUrl.setAuthority(m_addressInput->text());
inputUrl.setProtocol(m_protocolInput->currentText());
return inputUrl;
}
void MainWindow::newConnection(const KUrl &newUrl, bool switchFullscreenWhenConnected, const QString &tabName)
{
m_switchFullscreenWhenConnected = switchFullscreenWhenConnected;
const KUrl url = newUrl.isEmpty() ? m_addressNavigator->uncommittedUrl() : newUrl;
const KUrl url = newUrl.isEmpty() ? getInputUrl() : newUrl;
kDebug(5010) << url.host();
if (!url.isValid() || (url.host().isEmpty() && url.port() < 0)
|| (!url.path().isEmpty() && url.path() != QLatin1String("/"))) {
......@@ -298,8 +309,10 @@ void MainWindow::newConnection(const KUrl &newUrl, bool switchFullscreenWhenConn
return;
}
if (m_addressNavigator) {
m_addressNavigator->setLocationUrl(url);
if (m_protocolInput && m_addressInput) {
int index = m_protocolInput->findText(url.protocol());
if (index>=0) m_protocolInput->setCurrentIndex(index);
m_addressInput->setText(url.authority());
}
RemoteView *view = 0;
......@@ -893,9 +906,6 @@ void MainWindow::preferences()
void MainWindow::updateConfiguration()
{
if (m_addressNavigator)
m_addressNavigator->setUrlEditable(Settings::normalUrlInputLine());
if (!Settings::showStatusBar())
statusBar()->deleteLater();
else
......@@ -1073,24 +1083,19 @@ QWidget* MainWindow::newConnectionWidget()
{
QHBoxLayout *connectLayout = new QHBoxLayout;
const QString initialProtocol(!m_remoteViewFactories.isEmpty() ? (*m_remoteViewFactories.begin())->scheme() : QString());
KUrl url;
url.setProtocol(initialProtocol);
url.setPath(QLatin1String("//"));
m_addressNavigator = new KUrlNavigator(0, url, m_newConnectionWidget);
QStringList schemes;
QLabel *addressLabel = new QLabel(i18n("Connect to:"), m_newConnectionWidget);
m_protocolInput = new KComboBox(m_newConnectionWidget);
m_addressInput = new KLineEdit(m_newConnectionWidget);
m_addressInput->setClearButtonShown(true);
foreach(RemoteViewFactory *factory, m_remoteViewFactories) {
schemes << factory->scheme();
m_protocolInput->addItem(factory->scheme());
}
m_addressNavigator->setCustomProtocols(schemes);
m_addressNavigator->setUrlEditable(Settings::normalUrlInputLine());
connect(m_addressNavigator, SIGNAL(returnPressed()), SLOT(newConnection()));
m_addressNavigator->setFocus();
m_addressNavigator->setToolTip(i18n("Type an IP or DNS Name here. Clear the line to get a list of connection methods."));
QLabel *addressLabel = new QLabel(i18n("Connect to:"), m_newConnectionWidget);
connect(m_addressInput, SIGNAL(returnPressed()), SLOT(newConnection()));
m_addressInput->setFocus();
m_addressInput->setToolTip(i18n("Type an IP or DNS Name here. Clear the line to get a list of connection methods."));
KPushButton *connectButton = new KPushButton(m_newConnectionWidget);
connectButton->setToolTip(i18n("Goto Address"));
......@@ -1098,7 +1103,8 @@ QWidget* MainWindow::newConnectionWidget()
connect(connectButton, SIGNAL(clicked()), SLOT(newConnection()));
connectLayout->addWidget(addressLabel);
connectLayout->addWidget(m_addressNavigator, 1);
connectLayout->addWidget(m_protocolInput);
connectLayout->addWidget(m_addressInput, 1);
connectLayout->addWidget(connectButton);
connectLayout->setContentsMargins(QMargins(0, 6, 0, 10));
startLayout->addLayout(connectLayout);
......@@ -1165,21 +1171,7 @@ void MainWindow::newConnectionPage()
const int index = m_tabWidget->addTab(newConnectionWidget(), i18n("New Connection"));
m_tabWidget->setCurrentIndex(index);
}
#if 0 // not usable anymore, probably use it in another way? -uwolfer
QObject *senderObject = qobject_cast<QObject*>(sender());
if (senderObject) {
const QString scheme(senderObject->property("schemeString").toString());
if (!scheme.isEmpty()) {
m_addressNavigator->setUrl(KUrl(scheme + "://"));
}
const QString toolTip(senderObject->property("toolTipString").toString());
if (!toolTip.isEmpty()) {
QToolTip::showText(m_addressNavigator->pos() + pos() + QPoint(m_addressNavigator->width() / 2,
m_addressNavigator->height() / 2), toolTip, this);
}
}
#endif
m_addressNavigator->setFocus();
m_addressInput->setFocus();
}
QList<RemoteView *> MainWindow::remoteViewList() const
......
/****************************************************************************
**
** Copyright (C) 2007 - 2008 Urs Wolfer <uwolfer @ kde.org>
** Copyright (C) 2009 - 2010 Tony Murray <murraytony @ gmail.com>
**
** This file is part of KDE.
**
......@@ -35,10 +36,11 @@
#include <TelepathyQt4/ClientRegistrar>
#endif
class KComboBox;
class KLineEdit;
class KPushButton;
class KToggleAction;
class KTabWidget;
class KUrlNavigator;
class BookmarkManager;
class FloatingToolBar;
......@@ -113,13 +115,15 @@ private:
RemoteViewFactory *createPluginFromService(const KService::Ptr &service);
void showSettingsDialog(const QString &url);
QScrollArea *createScrollArea(QWidget *parent, RemoteView *remoteView);
KUrl getInputUrl();
QWidget *m_fullscreenWindow;
QByteArray m_mainWindowGeometry;
KToggleAction *m_menubarAction;
TabbedViewWidget *m_tabWidget;
KUrlNavigator *m_addressNavigator;
KComboBox *m_protocolInput;
KLineEdit *m_addressInput;
FloatingToolBar *m_toolBar;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment