From c22df71df28315b8b1964671d3452fad5b6ae0f5 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Sat, 25 May 2019 21:32:13 -0600 Subject: [PATCH] When filter bar is focused, switch to view when tab key is pressed 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 | 26 ++++++++++++++------------ src/filterbar/filterbar.cpp | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index e21262977..1e5d0f7d1 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -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); diff --git a/src/filterbar/filterbar.cpp b/src/filterbar/filterbar.cpp index 68da73a71..50af2c6c7 100644 --- a/src/filterbar/filterbar.cpp +++ b/src/filterbar/filterbar.cpp @@ -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() -- 2.47.3