[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/4.5/kdenetwork/krdc
From:       Tony Neal Murray <murraytony () gmail ! com>
Date:       2010-09-21 3:08:25
Message-ID: 20100921030825.53B03AC876 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1177733 by murrant:

Backport r1177173 by murrant from trunk to the 4.5 branch:

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



 M  +1 -8      config/general.ui  
 M  +29 -38    mainwindow.cpp  
 M  +6 -2      mainwindow.h  


--- branches/KDE/4.5/kdenetwork/krdc/config/general.ui #1177732:1177733
@@ -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">
@@ -26,13 +26,6 @@
     </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">
       <string>Remember passwords (KWallet)</string>
--- branches/KDE/4.5/kdenetwork/krdc/mainwindow.cpp #1177732:1177733
@@ -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,19 @@
     }
 }
 
+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;
 
     if (!url.isValid() || (url.host().isEmpty() && url.port() < 0)
         || (!url.path().isEmpty() && url.path() != QLatin1String("/"))) {
@@ -298,8 +308,10 @@
         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;
@@ -892,9 +904,6 @@
 
 void MainWindow::updateConfiguration()
 {
-    if (m_addressNavigator)
-        m_addressNavigator->setUrlEditable(Settings::normalUrlInputLine());
-
     if (!Settings::showStatusBar())
         statusBar()->deleteLater();
     else
@@ -1072,32 +1081,28 @@
 
     {
         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.")); +        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."));  
-        QLabel *addressLabel = new QLabel(i18n("Connect to:"), \
                m_newConnectionWidget);
-
         KPushButton *connectButton = new KPushButton(m_newConnectionWidget);
         connectButton->setToolTip(i18n("Goto Address"));
         connectButton->setIcon(KIcon("go-jump-locationbar"));
         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);
@@ -1164,22 +1169,8 @@
         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 + "://"));
+    m_addressInput->setFocus();
         }
-        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();
-}
 
 QList<RemoteView *> MainWindow::remoteViewList() const
 {
--- branches/KDE/4.5/kdenetwork/krdc/mainwindow.h #1177732:1177733
@@ -1,6 +1,7 @@
 /****************************************************************************
 **
 ** 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 @@
     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;
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic