]> cloud.milkyroute.net Git - dolphin.git/commitdiff
- When the filterbar has been activated as startup setting, still the view should...
authorPeter Penz <peter.penz19@gmail.com>
Mon, 11 Jan 2010 09:21:16 +0000 (09:21 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Mon, 11 Jan 2010 09:21:16 +0000 (09:21 +0000)
- Assure that the keyboard focus does not get lost when a tab is opened in background.

CCBUG: 183394

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

src/dolphinmainwindow.cpp
src/dolphinmainwindow.h

index d9b534e3f64ff72cfa0caa99b8fa7b19820fd797..0523085ae7a46d8c6ae39a025e199ebc8fc59ab5 100644 (file)
@@ -397,6 +397,8 @@ void DolphinMainWindow::openNewTab()
 
 void DolphinMainWindow::openNewTab(const KUrl& url)
 {
+    QWidget* focusWidget = QApplication::focusWidget();
+
     if (m_viewTab.count() == 1) {
         // Only one view is open currently and hence no tab is shown at
         // all. Before creating a tab for 'url', provide a tab for the current URL.
@@ -429,6 +431,12 @@ void DolphinMainWindow::openNewTab(const KUrl& url)
         m_viewTab[tabIndex].secondaryView->setActive(true);
         m_viewTab[tabIndex].isPrimaryViewActive = false;
     }
+
+    if (focusWidget != 0) {
+        // The DolphinViewContainer grabbed the keyboard focus. As the tab is opened
+        // in background, assure that the previous focused widget gets the focus back.
+        focusWidget->setFocus();
+    }
 }
 
 void DolphinMainWindow::activateNextTab()
@@ -487,6 +495,14 @@ void DolphinMainWindow::toggleActiveView()
     setActiveViewContainer(m_activeViewContainer == right ? left : right);
 }
 
+void DolphinMainWindow::showEvent(QShowEvent* event)
+{
+    KXmlGuiWindow::showEvent(event);
+    if (!event->spontaneous()) {
+        m_activeViewContainer->view()->setFocus();
+    }
+}
+
 void DolphinMainWindow::closeEvent(QCloseEvent* event)
 {
     DolphinSettings& settings = DolphinSettings::instance();
index cfdc21618d76725783de87f2815cd982798ed1d0..269c71844d281ac88f70ece8553c8c3c55d7e5d0 100644 (file)
@@ -165,6 +165,9 @@ signals:
     void requestItemInfo(const KFileItem& item);
 
 protected:
+    /** @see QWidget::showEvent() */
+    virtual void showEvent(QShowEvent* event);
+
     /** @see QMainWindow::closeEvent() */
     virtual void closeEvent(QCloseEvent* event);