]> cloud.milkyroute.net Git - dolphin.git/commitdiff
When filter bar is focused, switch to view when tab key is pressed
authorNate Graham <nate@kde.org>
Sun, 26 May 2019 03:32:13 +0000 (21:32 -0600)
committerNate Graham <nate@kde.org>
Sun, 26 May 2019 03:32:29 +0000 (21:32 -0600)
Summary:
Various people have requested that the tab key move keyboard focus from the filter bar's
text edit field to the main view. It already does this when the Enter and return keys
are pressed, but apparently this is not very intuitive and people expect Tab to work too.

This patch makes that behavior possible by moving the Lock button to the left of the
text edit field, and re-arranging the code so that the filter bar is initialized first.
This works because Qt assigns tab ordering by default according to the order of widget
construction. So if we simply construct the main view right after the filter bar, then
the tab ordering is set up this way automatically.

BUG: 403379
BUG: 403356
FIXED-IN: 19.08.0

Test Plan:
1. Activate Filter bar
2. Hit Tab key
3. View has become focused
4. Play around in Dolphin for a while and notice no regressions or crashes

Reviewers: #dolphin, elvisangelaccio

Reviewed By: #dolphin, elvisangelaccio

Subscribers: kfm-devel

Tags: #dolphin

Differential Revision: https://phabricator.kde.org/D21177

src/dolphinviewcontainer.cpp
src/filterbar/filterbar.cpp

index e21262977a66039886a5c4e8c6ce103e0bf1f12b..1e5d0f7d18c21fdc549bf0fff7bc893097ce3a7f 100644 (file)
@@ -120,7 +120,21 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
     }
 #endif
 
+    // Initialize filter bar
+    m_filterBar = new FilterBar(this);
+    m_filterBar->setVisible(settings->filterBar());
+
+    connect(m_filterBar, &FilterBar::filterChanged,
+            this, &DolphinViewContainer::setNameFilter);
+    connect(m_filterBar, &FilterBar::closeRequest,
+            this, &DolphinViewContainer::closeFilterBar);
+    connect(m_filterBar, &FilterBar::focusViewRequest,
+            this, &DolphinViewContainer::requestFocus);
+
+    // Initialize the main view
     m_view = new DolphinView(url, this);
+    connect(m_view, &DolphinView::urlChanged,
+            m_filterBar, &FilterBar::slotUrlChanged);
     connect(m_view, &DolphinView::urlChanged,
             m_urlNavigator, &KUrlNavigator::setLocationUrl);
     connect(m_view, &DolphinView::urlChanged,
@@ -198,18 +212,6 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
     connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished,
             this, &DolphinViewContainer::delayedStatusBarUpdate);
 
-    // Initialize filter bar
-    m_filterBar = new FilterBar(this);
-    m_filterBar->setVisible(settings->filterBar());
-    connect(m_filterBar, &FilterBar::filterChanged,
-            this, &DolphinViewContainer::setNameFilter);
-    connect(m_filterBar, &FilterBar::closeRequest,
-            this, &DolphinViewContainer::closeFilterBar);
-    connect(m_filterBar, &FilterBar::focusViewRequest,
-            this, &DolphinViewContainer::requestFocus);
-    connect(m_view, &DolphinView::urlChanged,
-            m_filterBar, &FilterBar::slotUrlChanged);
-
     navigatorLayout->addWidget(m_urlNavigator);
     navigatorLayout->addWidget(m_emptyTrashButton);
 
index 68da73a71d2d57ba6a259132e926b54da72f694f..50af2c6c7bd6e46b627afd67544576360fc6e895 100644 (file)
@@ -61,8 +61,8 @@ FilterBar::FilterBar(QWidget* parent) :
     QHBoxLayout* hLayout = new QHBoxLayout(this);
     hLayout->setContentsMargins(0, 0, 0, 0);
     hLayout->addWidget(closeButton);
-    hLayout->addWidget(m_filterInput);
     hLayout->addWidget(m_lockButton);
+    hLayout->addWidget(m_filterInput);
 }
 
 FilterBar::~FilterBar()