diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/dolphinmainwindow.cpp | 26 | ||||
| -rw-r--r-- | src/dolphinmainwindow.h | 3 | ||||
| -rw-r--r-- | src/dolphinui.rc | 6 | ||||
| -rw-r--r-- | src/dolphinviewcontainer.cpp | 2 | ||||
| -rw-r--r-- | src/dolphinviewcontainer.h | 17 |
5 files changed, 46 insertions, 8 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index bdf5dbac5..9368a9028 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -617,6 +617,12 @@ void DolphinMainWindow::find() m_activeViewContainer->setSearchModeEnabled(true); } +void DolphinMainWindow::updateSearchAction() +{ + QAction* toggleSearchAction = actionCollection()->action(QStringLiteral("toggle_search")); + toggleSearchAction->setChecked(m_activeViewContainer->isSearchModeEnabled()); +} + void DolphinMainWindow::updatePasteAction() { QAction* pasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste)); @@ -1084,6 +1090,9 @@ void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer) m_activeViewContainer = viewContainer; if (oldViewContainer) { + const QAction* toggleSearchAction = actionCollection()->action(QStringLiteral("toggle_search")); + toggleSearchAction->disconnect(oldViewContainer); + // Disconnect all signals between the old view container (container, // view and url navigator) and main window. oldViewContainer->disconnect(this); @@ -1104,6 +1113,7 @@ void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer) updatePasteAction(); updateViewActions(); updateGoActions(); + updateSearchAction(); const QUrl url = viewContainer->url(); emit urlChanged(url); @@ -1225,6 +1235,17 @@ void DolphinMainWindow::setupActions() "the find bar so we can have a look at it while the settings are " "explained.</para>")); + // toggle_search acts as a copy of the main searchAction to be used mainly + // in the toolbar, with no default shortcut attached, to avoid messing with + // existing workflows (search bar always open and Ctrl-F to focus) + QAction *toggleSearchAction = actionCollection()->addAction(QStringLiteral("toggle_search")); + toggleSearchAction->setText(i18nc("@action:inmenu", "Toggle Search Bar")); + toggleSearchAction->setIconText(i18nc("@action:intoolbar", "Search")); + toggleSearchAction->setIcon(searchAction->icon()); + toggleSearchAction->setToolTip(searchAction->toolTip()); + toggleSearchAction->setWhatsThis(searchAction->whatsThis()); + toggleSearchAction->setCheckable(true); + QAction* selectAllAction = KStandardAction::selectAll(this, &DolphinMainWindow::selectAll, actionCollection()); selectAllAction->setWhatsThis(xi18nc("@info:whatsthis", "This selects all " "files and folders in the current location.")); @@ -1803,6 +1824,11 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container) this, &DolphinMainWindow::updateFilterBarAction); connect(container, &DolphinViewContainer::writeStateChanged, this, &DolphinMainWindow::slotWriteStateChanged); + connect(container, &DolphinViewContainer::searchModeEnabledChanged, + this, &DolphinMainWindow::updateSearchAction); + + const QAction* toggleSearchAction = actionCollection()->action(QStringLiteral("toggle_search")); + connect(toggleSearchAction, &QAction::triggered, container, &DolphinViewContainer::setSearchModeEnabled); const DolphinView* view = container->view(); connect(view, &DolphinView::selectionChanged, diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index dcfd9bce2..8453bfb36 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -255,6 +255,9 @@ private slots: /** 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(); + /** * Updates the text of the paste action dependent on * the number of items which are in the clipboard. diff --git a/src/dolphinui.rc b/src/dolphinui.rc index 207c5d4c2..69663c471 100644 --- a/src/dolphinui.rc +++ b/src/dolphinui.rc @@ -1,5 +1,5 @@ <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> -<kpartgui name="dolphin" version="23"> +<kpartgui name="dolphin" version="24"> <MenuBar> <Menu name="file"> <Action name="new_menu" /> @@ -102,7 +102,7 @@ <Spacer name="spacer_0" /> <Action name="split_view" /> <Action name="split_stash" /> - <Action name="edit_find" /> + <Action name="toggle_search" /> </ToolBar> <ActionProperties scheme="Default"> <Action priority="0" name="go_back"/> @@ -118,6 +118,6 @@ <Action priority="0" name="edit_cut"/> <Action priority="0" name="edit_copy"/> <Action priority="0" name="edit_paste"/> - <Action priority="0" name="edit_find"/> + <Action priority="0" name="toggle_search"/> </ActionProperties> </kpartgui> diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 5d1d257e5..25ca6fdd9 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -412,6 +412,8 @@ void DolphinViewContainer::setSearchModeEnabled(bool enabled) } m_searchModeEnabled = enabled; + + emit searchModeEnabledChanged(enabled); } bool DolphinViewContainer::isSearchModeEnabled() const diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h index 2c4c7a7e1..5207d2d35 100644 --- a/src/dolphinviewcontainer.h +++ b/src/dolphinviewcontainer.h @@ -118,11 +118,8 @@ public: /** Returns true, if the filter bar is visible. */ bool isFilterBarVisible() const; - /** - * Enables the search mode, if \p enabled is true. In the search mode the URL navigator - * will be hidden and replaced by a line editor that allows to enter a search term. - */ - void setSearchModeEnabled(bool enabled); + + /** Returns true if the search mode is enabled. */ bool isSearchModeEnabled() const; /** @@ -160,11 +157,21 @@ public slots: */ void setFilterBarVisible(bool visible); + /** + * Enables the search mode, if \p enabled is true. In the search mode the URL navigator + * will be hidden and replaced by a line editor that allows to enter a search term. + */ + void setSearchModeEnabled(bool enabled); + signals: /** * 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 |
