diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -255,6 +255,9 @@ /** Replaces the URL navigator by a search box to find files. */ void find(); + /** Updates the state of the search action according to the view container. */ + void updateSearchAction(bool enabled); + /** * Updates the text of the paste action dependent on * the number of items which are in the clipboard. diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -614,7 +614,15 @@ void DolphinMainWindow::find() { - m_activeViewContainer->setSearchModeEnabled(true); + m_activeViewContainer->setSearchModeEnabled( + actionCollection()->action(KStandardAction::name(KStandardAction::Find))->isChecked() + ); +} + +void DolphinMainWindow::updateSearchAction(bool enabled) +{ + QAction* searchAction = actionCollection()->action(KStandardAction::name(KStandardAction::Find)); + searchAction->setChecked(enabled); } void DolphinMainWindow::updatePasteAction() @@ -1216,6 +1224,7 @@ QAction *searchAction = KStandardAction::find(this, &DolphinMainWindow::find, actionCollection()); searchAction->setText(i18n("Search...")); + searchAction->setCheckable(true); searchAction->setToolTip(i18nc("@info:tooltip", "Search for files and folders")); searchAction->setWhatsThis(xi18nc("@info:whatsthis find", "This helps you " "find files and folders by opening a find bar. " @@ -1805,6 +1814,8 @@ this, &DolphinMainWindow::updateFilterBarAction); connect(container, &DolphinViewContainer::writeStateChanged, this, &DolphinMainWindow::slotWriteStateChanged); + connect(container, &DolphinViewContainer::searchModeEnabledChanged, + this, &DolphinMainWindow::updateSearchAction); const DolphinView* view = container->view(); connect(view, &DolphinView::selectionChanged, diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h --- a/src/dolphinviewcontainer.h +++ b/src/dolphinviewcontainer.h @@ -165,6 +165,10 @@ * Is emitted whenever the filter bar has changed its visibility state. */ void showFilterBarChanged(bool shown); + /** + * Is emitted whenever the search mode has changed its state. + */ + void searchModeEnabledChanged(bool enabled); /** * Is emitted when the write state of the folder has been changed. The application diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -412,6 +412,8 @@ } m_searchModeEnabled = enabled; + + emit searchModeEnabledChanged(enabled); } bool DolphinViewContainer::isSearchModeEnabled() const