]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Don't request the focus for the view because of a completed directory lister, instead...
authorPeter Penz <peter.penz19@gmail.com>
Fri, 19 Dec 2008 06:41:26 +0000 (06:41 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Fri, 19 Dec 2008 06:41:26 +0000 (06:41 +0000)
BUG: 178070

svn path=/trunk/KDE/kdebase/apps/; revision=898819

src/dolphinviewcontainer.cpp
src/dolphinviewcontainer.h

index 8b3def9f3a899b3ff126e9f5e8daa87b2a9329e4..1b64f980343b3d25263878c260f3516727dca442 100644 (file)
@@ -271,10 +271,6 @@ void DolphinViewContainer::slotDirListerCompleted()
         KonqFileItemCapabilities capabilities(KFileItemList() << item);
         createNew->setEnabled(capabilities.supportsWriting());
     }
-
-    if (isActive()) {
-        m_view->setFocus();
-    }
 }
 
 void DolphinViewContainer::showItemInfo(const KFileItem& item)
@@ -386,6 +382,17 @@ void DolphinViewContainer::restoreView(const KUrl& url)
     } else {
         showErrorMessage(i18nc("@info:status", "Invalid protocol"));
     }
+
+    if (isActive()) {
+        // When an URL has been entered, the view should get the focus.
+        // The focus must be requested asynchronously, as changing the URL might create
+        // a new view widget. Using QTimer::singleShow() works reliable, however
+        // QMetaObject::invokeMethod() with a queued connection does not work, which might
+        // indicate that we should pass a hint to DolphinView::updateView()
+        // regarding the focus instead. To test: Enter an URL and press CTRL+Enter.
+        // Expected result: The view should get the focus.
+        QTimer::singleShot(0, this, SLOT(requestFocus()));
+    }
 }
 
 void DolphinViewContainer::saveRootUrl(const KUrl& url)
@@ -408,6 +415,11 @@ void DolphinViewContainer::redirect(const KUrl& oldUrl, const KUrl& newUrl)
     m_urlNavigator->blockSignals(block);
 }
 
+void DolphinViewContainer::requestFocus()
+{
+    m_view->setFocus();
+}
+
 void DolphinViewContainer::slotItemTriggered(const KFileItem& item)
 {
     KUrl url = item.targetUrl();
index d2adb5ed7f33e45e7cce2b1ce6acaaa90256fb36..eb70c37e1aca5da2f010d50fd0841b7f44a89350 100644 (file)
@@ -229,6 +229,9 @@ private slots:
      */
     void redirect(const KUrl& oldUrl, const KUrl& newUrl);
 
+    /** Requests the focus for the view \a m_view. */
+    void requestFocus();
+
 private:
     bool m_showProgress;