From 96323e049c700fcd63d93f00c5b92a8ddfe0cb27 Mon Sep 17 00:00:00 2001 From: Serg Podtynnyi Date: Wed, 25 Jan 2023 00:04:54 +0700 Subject: [PATCH] Clear filter bar on clicking current folder in places Reset the filter bar when user clicks on the current folder in places list, also rename slot function to be more clear. BUG: 259382 --- src/dolphinmainwindow.cpp | 2 ++ src/dolphinviewcontainer.cpp | 7 ++++++- src/dolphinviewcontainer.h | 1 + src/filterbar/filterbar.cpp | 2 +- src/filterbar/filterbar.h | 2 +- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 9f021684c..d69514b7a 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1414,6 +1414,8 @@ void DolphinMainWindow::slotPlaceActivated(const QUrl& url) DolphinViewContainer* view = activeViewContainer(); if (view->url() == url) { + view->clearFilterBar(); // Fixes bug 259382. + // We can end up here if the user clicked a device in the Places Panel // which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385. reloadView(); diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index a38833481..10e886018 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -125,7 +125,7 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) : // Initialize the main view m_view = new DolphinView(url, this); connect(m_view, &DolphinView::urlChanged, - m_filterBar, &FilterBar::slotUrlChanged); + m_filterBar, &FilterBar::clearIfUnlocked); connect(m_view, &DolphinView::urlChanged, m_messageWidget, &KMessageWidget::hide); // m_urlNavigator stays in sync with m_view's location changes and @@ -797,6 +797,11 @@ void DolphinViewContainer::closeFilterBar() Q_EMIT showFilterBarChanged(false); } +void DolphinViewContainer::clearFilterBar() +{ + m_filterBar->clearIfUnlocked(); +} + void DolphinViewContainer::setNameFilter(const QString& nameFilter) { m_view->hideToolTip(ToolTipManager::HideBehavior::Instantly); diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h index 83d3ed1a1..dbaf18261 100644 --- a/src/dolphinviewcontainer.h +++ b/src/dolphinviewcontainer.h @@ -204,6 +204,7 @@ public: */ void disableUrlNavigatorSelectionRequests(); void enableUrlNavigatorSelectionRequests(); + void clearFilterBar(); public Q_SLOTS: /** diff --git a/src/filterbar/filterbar.cpp b/src/filterbar/filterbar.cpp index 6d8b1e485..c1fb344b1 100644 --- a/src/filterbar/filterbar.cpp +++ b/src/filterbar/filterbar.cpp @@ -74,7 +74,7 @@ void FilterBar::clear() m_filterInput->clear(); } -void FilterBar::slotUrlChanged() +void FilterBar::clearIfUnlocked() { if (!m_lockButton || !(m_lockButton->isChecked())) { clear(); diff --git a/src/filterbar/filterbar.h b/src/filterbar/filterbar.h index d6ca402af..73b1c566e 100644 --- a/src/filterbar/filterbar.h +++ b/src/filterbar/filterbar.h @@ -39,7 +39,7 @@ public Q_SLOTS: /** Clears the input field. */ void clear(); /** Clears the input field if the "lock button" is disabled. */ - void slotUrlChanged(); + void clearIfUnlocked(); /** The input field is cleared also if the "lock button" is released. */ void slotToggleLockButton(bool checked); -- 2.47.3