Git commit 60b9eaa4c1c4d3057934d2cefbbe986553090ab3 by Méven Car. Committed on 02/12/2020 at 07:07. Pushed by meven into branch 'master'.
Toolbar: move and rename filter to edit menu above Search This is to expose more filter. Also rename "Show Filter Bar" to simply "Filter", keep "Show Filter Bar" as tooltip Adds a toggle filter bar action. M +33 -33 doc/index.docbook M +38 -16 src/dolphinmainwindow.cpp M +1 -0 src/dolphinmainwindow.h M +3 -1 src/dolphinui.rc https://invent.kde.org/system/dolphin/commit/60b9eaa4c1c4d3057934d2cefbbe986553090ab3 diff --git a/doc/index.docbook b/doc/index.docbook index 50fc37d91..589e09e1b 100644 --- a/doc/index.docbook +++ b/doc/index.docbook @@ -775,6 +775,26 @@ current folder, &RMB; click in the work space and click </sect2> +<sect2 id="filter-files"> +<title>Filtering Files</title> + +<para> +&dolphin; is capable of filtering files, &ie; showing only those items in the +view whose name contains a given text. For example, if you wish to show +only the <acronym>MP3</acronym> files within a folder, you could filter for <quote>.mp3</quote>. +This would then filter out all files whose name does not contain <quote>.mp3</quote>. +</para> + +<para> +To filter files, first enable the filter bar, either by pressing <keycombo action="simul">&Ctrl;<keycap>I</keycap></keycombo> +or via the menu: <menuchoice> <guimenu>Edit</guimenu> <guimenuitem>Filter...</guimenuitem> </menuchoice>. +You can then enter the text to be filtered for in the filter bar. The filter bar can +be disabled either by pressing &Esc;, or with a &LMB; click on the +<guiicon>Hide Filter Bar</guiicon> icon. +</para> + +</sect2> + <sect2 id="finding-searching-in-file"> <title>Finding Files and Searching in Files</title> <!-- FIXME search in hidden files + folders View -> Show Hidden Files has to be enabled ? --> @@ -912,26 +932,6 @@ via the Tools menu: <menuchoice> <guimenu>Tools</guimenu> <guimenuitem>Compare F </sect2> -<sect2 id="filter-files"> -<title>Filtering Files</title> - -<para> -&dolphin; is capable of filtering files, &ie; showing only those items in the -view whose name contains a given text. For example, if you wish to show -only the <acronym>MP3</acronym> files within a folder, you could filter for <quote>.mp3</quote>. -This would then filter out all files whose name does not contain <quote>.mp3</quote>. -</para> - -<para> -To filter files, first enable the filter bar, either by pressing <keycombo action="simul">&Ctrl;<keycap>I</keycap></keycombo> -or via the menu: <menuchoice> <guimenu>Tools</guimenu> <guimenuitem>Show Filter Bar</guimenuitem> </menuchoice>. -You can then enter the text to be filtered for in the filter bar. The filter bar can -be disabled either by pressing &Esc;, or with a &LMB; click on the -<guiicon>Hide Filter Bar</guiicon> icon. -</para> - -</sect2> - </sect1> </chapter> @@ -1752,6 +1752,19 @@ The name of this file has to be entered in a dialog. Is disabled if the current user does not have write permission on the selected item(s).</action></para></listitem> </varlistentry> +<varlistentry> +<term><menuchoice> +<shortcut> +<keycombo action="simul">&Ctrl;<keycap>I</keycap></keycombo> +</shortcut> +<guimenu>Edit</guimenu> +<guimenuitem>Filter...</guimenuitem> +</menuchoice></term> +<listitem><para><action>Enables and disables the <link linkend="filter-files">filter bar</link>.</action> +You can also use the alternate shortcut <keycombo action="simul">&Shift;<keycap>/</keycap></keycombo> +for this action.</para></listitem> +</varlistentry> + <varlistentry> <term><menuchoice> <shortcut> @@ -2052,19 +2065,6 @@ be reopened.</action></para></listitem> <para> <variablelist> -<varlistentry> -<term><menuchoice> -<shortcut> -<keycombo action="simul">&Ctrl;<keycap>I</keycap></keycombo> -</shortcut> -<guimenu>Tools</guimenu> -<guimenuitem>Show Filter Bar</guimenuitem> -</menuchoice></term> -<listitem><para><action>Enables and disables the <link linkend="filter-files">filter bar</link>.</action> -You can also use the alternate shortcut <keycombo action="simul">&Shift;<keycap>/</keycap></keycombo> -for this action.</para></listitem> -</varlistentry> - <varlistentry> <term><menuchoice> <shortcut> diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 64268542d..fb6da0b4a 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -173,8 +173,8 @@ DolphinMainWindow::DolphinMainWindow() : connect(clipboard, &QClipboard::dataChanged, this, &DolphinMainWindow::updatePasteAction); - QAction* showFilterBarAction = actionCollection()->action(QStringLiteral("show_filter_bar")); - showFilterBarAction->setChecked(generalSettings->filterBar()); + QAction* toggleFilterBarAction = actionCollection()->action(QStringLiteral("toggle_filter")); + toggleFilterBarAction->setChecked(generalSettings->filterBar()); if (firstRun) { menuBar()->setVisible(false); @@ -383,8 +383,8 @@ void DolphinMainWindow::updateHistory() void DolphinMainWindow::updateFilterBarAction(bool show) { - QAction* showFilterBarAction = actionCollection()->action(QStringLiteral("show_filter_bar")); - showFilterBarAction->setChecked(show); + QAction* toggleFilterBarAction = actionCollection()->action(QStringLiteral("toggle_filter")); + toggleFilterBarAction->setChecked(show); } void DolphinMainWindow::openNewMainWindow() @@ -847,6 +847,15 @@ void DolphinMainWindow::showFilterBar() m_activeViewContainer->setFilterBarVisible(true); } +void DolphinMainWindow::toggleFilterBar() +{ + bool checked = !m_activeViewContainer->isFilterBarVisible(); + m_activeViewContainer->setFilterBarVisible(checked); + + QAction* toggleFilterBarAction = actionCollection()->action(QStringLiteral("toggle_filter")); + toggleFilterBarAction->setChecked(checked); +} + void DolphinMainWindow::toggleEditLocation() { clearStatusBar(); @@ -1442,6 +1451,29 @@ void DolphinMainWindow::setupActions() actionCollection()->setDefaultShortcut(moveToOtherViewAction, Qt::SHIFT + Qt::Key_F6 ); connect(moveToOtherViewAction, &QAction::triggered, m_tabWidget, &DolphinTabWidget::moveToInactiveSplitView); + QAction* showFilterBar = actionCollection()->addAction(QStringLiteral("show_filter_bar")); + showFilterBar->setText(i18nc("@action:inmenu Tools", "Filter...")); + showFilterBar->setToolTip(i18nc("@info:tooltip", "Toggle Filter Bar")); + showFilterBar->setWhatsThis(xi18nc("@info:whatsthis", "This opens the " + "<emphasis>Filter Bar</emphasis> at the bottom of the window.<nl/> " + "There you can enter a text to filter the files and folders currently displayed. " + "Only those that contain the text in their name will be kept in view.")); + showFilterBar->setIcon(QIcon::fromTheme(QStringLiteral("view-filter"))); + actionCollection()->setDefaultShortcuts(showFilterBar, {Qt::CTRL + Qt::Key_I, Qt::Key_Slash}); + connect(showFilterBar, &QAction::triggered, this, &DolphinMainWindow::showFilterBar); + + // toggle_filter acts as a copy of the main showFilterBar to be used mainly + // in the toolbar, with no default shortcut attached, to avoid messing with + // existing workflows (filter bar always open and Ctrl-I to focus) + QAction *toggleFilter = actionCollection()->addAction(QStringLiteral("toggle_filter")); + toggleFilter->setText(i18nc("@action:inmenu", "Toggle Filter Bar")); + toggleFilter->setIconText(i18nc("@action:intoolbar", "Filter")); + toggleFilter->setIcon(showFilterBar->icon()); + toggleFilter->setToolTip(showFilterBar->toolTip()); + toggleFilter->setWhatsThis(showFilterBar->whatsThis()); + toggleFilter->setCheckable(true); + connect(toggleFilter, &QAction::triggered, this, &DolphinMainWindow::toggleFilterBar); + QAction *searchAction = KStandardAction::find(this, &DolphinMainWindow::find, actionCollection()); searchAction->setText(i18n("Search...")); searchAction->setToolTip(i18nc("@info:tooltip", "Search for files and folders")); @@ -1597,16 +1629,6 @@ void DolphinMainWindow::setupActions() "including folders that contain personal application data.")); // setup 'Tools' menu - QAction* showFilterBar = actionCollection()->addAction(QStringLiteral("show_filter_bar")); - showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar")); - showFilterBar->setWhatsThis(xi18nc("@info:whatsthis", "This opens the " - "<emphasis>Filter Bar</emphasis> at the bottom of the window.<nl/> " - "There you can enter a text to filter the files and folders currently displayed. " - "Only those that contain the text in their name will be kept in view.")); - showFilterBar->setIcon(QIcon::fromTheme(QStringLiteral("view-filter"))); - actionCollection()->setDefaultShortcuts(showFilterBar, {Qt::CTRL + Qt::Key_I, Qt::Key_Slash}); - connect(showFilterBar, &QAction::triggered, this, &DolphinMainWindow::showFilterBar); - QAction* compareFiles = actionCollection()->addAction(QStringLiteral("compare_files")); compareFiles->setText(i18nc("@action:inmenu Tools", "Compare Files")); compareFiles->setIcon(QIcon::fromTheme(QStringLiteral("kompare"))); @@ -2032,8 +2054,8 @@ void DolphinMainWindow::updateViewActions() { m_actionHandler->updateViewActions(); - QAction* showFilterBarAction = actionCollection()->action(QStringLiteral("show_filter_bar")); - showFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible()); + QAction* toggleFilterBarAction = actionCollection()->action(QStringLiteral("toggle_filter")); + toggleFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible()); updateSplitAction(); } diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index 8d5eae344..8e031fd03 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -312,6 +312,7 @@ private slots: void disableStopAction(); void showFilterBar(); + void toggleFilterBar(); /** * Toggles between edit and browse mode of the navigation bar. diff --git a/src/dolphinui.rc b/src/dolphinui.rc index 01458f2c6..e749abae0 100644 --- a/src/dolphinui.rc +++ b/src/dolphinui.rc @@ -28,6 +28,7 @@ <Action name="copy_location" /> <Action name="edit_paste" /> <Separator /> + <Action name="show_filter_bar" /> <Action name="edit_find" /> <Separator /> <Action name="copy_to_inactive_split_view" /> @@ -66,7 +67,6 @@ <Action name="closed_tabs" /> </Menu> <Menu name="tools"> - <Action name="show_filter_bar" /> <Action name="open_preferred_search_tool" /> <Action name="open_terminal" /> <Action name="focus_terminal_panel"/> @@ -124,6 +124,7 @@ <Action name="split_view" /> <Action name="split_stash" /> <Action name="toggle_search" /> + <Action name="toggle_filter" /> </ToolBar> <ActionProperties scheme="Default"> <Action priority="0" name="go_back"/> @@ -141,5 +142,6 @@ <Action priority="0" name="edit_copy"/> <Action priority="0" name="edit_paste"/> <Action priority="0" name="toggle_search"/> + <Action priority="0" name="toggle_filter"/> </ActionProperties> </gui>