mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 11:25:14 +00:00
[dolphin] Add an action to toggle the searchbar
Summary: Make search action toggle the searchbar instead of just launching it. The search action in dolphin did only bring up the search bar, but to close it again you had to go to the closing button on the same searchbar. This behavior in inconsistent with other dolphin actions which toggle panels or tools. BEFORE: {F7256652} AFTER: {F7256862} BUG: 344617 FIXED-IN: 19.12.0 Closes T8473 Depends on D23075 Test Plan: - Enable the search mode: the searchbar appears and the toolbar button gets checked - Press the search button again, and it goes back to normal mode. - The search button state is coherent with the searchbox - Coherence is kept when changing to a split view or different tab - Shorcut <Ctrl-F> does not close the searchbar, but moves the focus to it. Reviewers: #dolphin, ngraham, #vdg, elvisangelaccio Reviewed By: ngraham, #vdg Subscribers: ndavis, felixernst, elvisangelaccio, kfm-devel Tags: #dolphin Maniphest Tasks: T8473 Differential Revision: https://phabricator.kde.org/D23232
This commit is contained in:
parent
7f6d49377b
commit
3a7586907e
|
@ -617,6 +617,12 @@ void DolphinMainWindow::find()
|
||||||
m_activeViewContainer->setSearchModeEnabled(true);
|
m_activeViewContainer->setSearchModeEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DolphinMainWindow::updateSearchAction()
|
||||||
|
{
|
||||||
|
QAction* toggleSearchAction = actionCollection()->action(QStringLiteral("toggle_search"));
|
||||||
|
toggleSearchAction->setChecked(m_activeViewContainer->isSearchModeEnabled());
|
||||||
|
}
|
||||||
|
|
||||||
void DolphinMainWindow::updatePasteAction()
|
void DolphinMainWindow::updatePasteAction()
|
||||||
{
|
{
|
||||||
QAction* pasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
|
QAction* pasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
|
||||||
|
@ -1084,6 +1090,9 @@ void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer)
|
||||||
m_activeViewContainer = viewContainer;
|
m_activeViewContainer = viewContainer;
|
||||||
|
|
||||||
if (oldViewContainer) {
|
if (oldViewContainer) {
|
||||||
|
const QAction* toggleSearchAction = actionCollection()->action(QStringLiteral("toggle_search"));
|
||||||
|
toggleSearchAction->disconnect(oldViewContainer);
|
||||||
|
|
||||||
// Disconnect all signals between the old view container (container,
|
// Disconnect all signals between the old view container (container,
|
||||||
// view and url navigator) and main window.
|
// view and url navigator) and main window.
|
||||||
oldViewContainer->disconnect(this);
|
oldViewContainer->disconnect(this);
|
||||||
|
@ -1104,6 +1113,7 @@ void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer)
|
||||||
updatePasteAction();
|
updatePasteAction();
|
||||||
updateViewActions();
|
updateViewActions();
|
||||||
updateGoActions();
|
updateGoActions();
|
||||||
|
updateSearchAction();
|
||||||
|
|
||||||
const QUrl url = viewContainer->url();
|
const QUrl url = viewContainer->url();
|
||||||
emit urlChanged(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 "
|
"the find bar so we can have a look at it while the settings are "
|
||||||
"explained.</para>"));
|
"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());
|
QAction* selectAllAction = KStandardAction::selectAll(this, &DolphinMainWindow::selectAll, actionCollection());
|
||||||
selectAllAction->setWhatsThis(xi18nc("@info:whatsthis", "This selects all "
|
selectAllAction->setWhatsThis(xi18nc("@info:whatsthis", "This selects all "
|
||||||
"files and folders in the current location."));
|
"files and folders in the current location."));
|
||||||
|
@ -1803,6 +1824,11 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
|
||||||
this, &DolphinMainWindow::updateFilterBarAction);
|
this, &DolphinMainWindow::updateFilterBarAction);
|
||||||
connect(container, &DolphinViewContainer::writeStateChanged,
|
connect(container, &DolphinViewContainer::writeStateChanged,
|
||||||
this, &DolphinMainWindow::slotWriteStateChanged);
|
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();
|
const DolphinView* view = container->view();
|
||||||
connect(view, &DolphinView::selectionChanged,
|
connect(view, &DolphinView::selectionChanged,
|
||||||
|
|
|
@ -255,6 +255,9 @@ private slots:
|
||||||
/** Replaces the URL navigator by a search box to find files. */
|
/** Replaces the URL navigator by a search box to find files. */
|
||||||
void find();
|
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
|
* Updates the text of the paste action dependent on
|
||||||
* the number of items which are in the clipboard.
|
* the number of items which are in the clipboard.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
||||||
<kpartgui name="dolphin" version="23">
|
<kpartgui name="dolphin" version="24">
|
||||||
<MenuBar>
|
<MenuBar>
|
||||||
<Menu name="file">
|
<Menu name="file">
|
||||||
<Action name="new_menu" />
|
<Action name="new_menu" />
|
||||||
|
@ -102,7 +102,7 @@
|
||||||
<Spacer name="spacer_0" />
|
<Spacer name="spacer_0" />
|
||||||
<Action name="split_view" />
|
<Action name="split_view" />
|
||||||
<Action name="split_stash" />
|
<Action name="split_stash" />
|
||||||
<Action name="edit_find" />
|
<Action name="toggle_search" />
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
<ActionProperties scheme="Default">
|
<ActionProperties scheme="Default">
|
||||||
<Action priority="0" name="go_back"/>
|
<Action priority="0" name="go_back"/>
|
||||||
|
@ -118,6 +118,6 @@
|
||||||
<Action priority="0" name="edit_cut"/>
|
<Action priority="0" name="edit_cut"/>
|
||||||
<Action priority="0" name="edit_copy"/>
|
<Action priority="0" name="edit_copy"/>
|
||||||
<Action priority="0" name="edit_paste"/>
|
<Action priority="0" name="edit_paste"/>
|
||||||
<Action priority="0" name="edit_find"/>
|
<Action priority="0" name="toggle_search"/>
|
||||||
</ActionProperties>
|
</ActionProperties>
|
||||||
</kpartgui>
|
</kpartgui>
|
||||||
|
|
|
@ -412,6 +412,8 @@ void DolphinViewContainer::setSearchModeEnabled(bool enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_searchModeEnabled = enabled;
|
m_searchModeEnabled = enabled;
|
||||||
|
|
||||||
|
emit searchModeEnabledChanged(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DolphinViewContainer::isSearchModeEnabled() const
|
bool DolphinViewContainer::isSearchModeEnabled() const
|
||||||
|
|
|
@ -118,11 +118,8 @@ public:
|
||||||
/** Returns true, if the filter bar is visible. */
|
/** Returns true, if the filter bar is visible. */
|
||||||
bool isFilterBarVisible() const;
|
bool isFilterBarVisible() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables the search mode, if \p enabled is true. In the search mode the URL navigator
|
/** Returns true if the search mode is enabled. */
|
||||||
* will be hidden and replaced by a line editor that allows to enter a search term.
|
|
||||||
*/
|
|
||||||
void setSearchModeEnabled(bool enabled);
|
|
||||||
bool isSearchModeEnabled() const;
|
bool isSearchModeEnabled() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,11 +157,21 @@ public slots:
|
||||||
*/
|
*/
|
||||||
void setFilterBarVisible(bool visible);
|
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:
|
signals:
|
||||||
/**
|
/**
|
||||||
* Is emitted whenever the filter bar has changed its visibility state.
|
* Is emitted whenever the filter bar has changed its visibility state.
|
||||||
*/
|
*/
|
||||||
void showFilterBarChanged(bool shown);
|
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
|
* Is emitted when the write state of the folder has been changed. The application
|
||||||
|
|
Loading…
Reference in a new issue