+ KStandardAction::undo(this, &DolphinMainWindow::undo, actionCollection());
+
+ // i18n: This will be the last paragraph for the whatsthis for all three:
+ // Cut, Copy and Paste
+ const QString cutCopyPastePara = xi18nc("@info:whatsthis",
+ "<para><emphasis>Cut, "
+ "Copy</emphasis> and <emphasis>Paste</emphasis> work between many "
+ "applications and are among the most used commands. That's why their "
+ "<emphasis>keyboard shortcuts</emphasis> are prominently placed right "
+ "next to each other on the keyboard: <shortcut>Ctrl+X</shortcut>, "
+ "<shortcut>Ctrl+C</shortcut> and <shortcut>Ctrl+V</shortcut>.</para>");
+ QAction *cutAction = KStandardAction::cut(this, &DolphinMainWindow::cut, actionCollection());
+ m_actionTextHelper->registerTextWhenNothingIsSelected(cutAction, i18nc("@action", "Cut…"));
+ cutAction->setWhatsThis(xi18nc("@info:whatsthis cut",
+ "This copies the items "
+ "in your current selection to the <emphasis>clipboard</emphasis>.<nl/>"
+ "Use the <emphasis>Paste</emphasis> action afterwards to copy them from "
+ "the clipboard to a new location. The items will be removed from their "
+ "initial location.")
+ + cutCopyPastePara);
+ QAction *copyAction = KStandardAction::copy(this, &DolphinMainWindow::copy, actionCollection());
+ m_actionTextHelper->registerTextWhenNothingIsSelected(copyAction, i18nc("@action", "Copy…"));
+ copyAction->setWhatsThis(xi18nc("@info:whatsthis copy",
+ "This copies the "
+ "items in your current selection to the <emphasis>clipboard</emphasis>."
+ "<nl/>Use the <emphasis>Paste</emphasis> action afterwards to copy them "
+ "from the clipboard to a new location.")
+ + cutCopyPastePara);
+ QAction *paste = KStandardAction::paste(this, &DolphinMainWindow::paste, actionCollection());
+ // The text of the paste-action is modified dynamically by Dolphin
+ // (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes
+ // due to the long text, the text "Paste" is used:
+ paste->setIconText(i18nc("@action:inmenu Edit", "Paste"));
+ paste->setWhatsThis(xi18nc("@info:whatsthis paste",
+ "This copies the items from "
+ "your <emphasis>clipboard</emphasis> to the currently viewed folder.<nl/>"
+ "If the items were added to the clipboard by the <emphasis>Cut</emphasis> "
+ "action they are removed from their old location.")
+ + cutCopyPastePara);
+
+ QAction *copyToOtherViewAction = actionCollection()->addAction(QStringLiteral("copy_to_inactive_split_view"));
+ copyToOtherViewAction->setText(i18nc("@action:inmenu", "Copy to Other View"));
+ m_actionTextHelper->registerTextWhenNothingIsSelected(copyToOtherViewAction, i18nc("@action:inmenu", "Copy to Other View…"));
+ copyToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Copy",
+ "This copies the selected items from "
+ "the view in focus to the other view. "
+ "(Only available while in Split View mode.)"));
+ copyToOtherViewAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy")));
+ copyToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Copy to Other View"));
+ actionCollection()->setDefaultShortcut(copyToOtherViewAction, Qt::SHIFT | Qt::Key_F5);
+ connect(copyToOtherViewAction, &QAction::triggered, this, &DolphinMainWindow::copyToInactiveSplitView);
+
+ QAction *moveToOtherViewAction = actionCollection()->addAction(QStringLiteral("move_to_inactive_split_view"));
+ moveToOtherViewAction->setText(i18nc("@action:inmenu", "Move to Other View"));
+ m_actionTextHelper->registerTextWhenNothingIsSelected(moveToOtherViewAction, i18nc("@action:inmenu", "Move to Other View…"));
+ moveToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Move",
+ "This moves the selected items from "
+ "the view in focus to the other view. "
+ "(Only available while in Split View mode.)"));
+ moveToOtherViewAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut")));
+ moveToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Move to Other View"));
+ actionCollection()->setDefaultShortcut(moveToOtherViewAction, Qt::SHIFT | Qt::Key_F6);
+ connect(moveToOtherViewAction, &QAction::triggered, this, &DolphinMainWindow::moveToInactiveSplitView);
+
+ QAction *showFilterBar = actionCollection()->addAction(QStringLiteral("show_filter_bar"));
+ showFilterBar->setText(i18nc("@action:inmenu Tools", "Filter…"));
+ showFilterBar->setToolTip(i18nc("@info:tooltip", "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 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"));
+ searchAction->setWhatsThis(xi18nc("@info:whatsthis find",
+ "<para>This helps you "
+ "find files and folders by opening a <emphasis>search bar</emphasis>. "
+ "There you can enter search terms and specify settings to find the "
+ "items you are looking for.</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);
+ connect(toggleSearchAction, &QAction::triggered, this, [this](bool checked) {
+ if (checked) {
+ find();
+ } else {
+ m_activeViewContainer->setSearchBarVisible(false);
+ }
+ });
+
+ QAction *toggleSelectionModeAction = actionCollection()->addAction(QStringLiteral("toggle_selection_mode"));
+ // i18n: This action toggles a selection mode.
+ toggleSelectionModeAction->setText(i18nc("@action:inmenu", "Select Files and Folders"));
+ // i18n: Opens a selection mode for selecting files/folders.
+ // The text is kept so unspecific because it will be shown on the toolbar where space is at a premium.
+ toggleSelectionModeAction->setIconText(i18nc("@action:intoolbar", "Select"));
+ toggleSelectionModeAction->setWhatsThis(xi18nc(
+ "@info:whatsthis",
+ "<para>This application only knows which files or folders should be acted on if they are"
+ " <emphasis>selected</emphasis> first. Press this to toggle a <emphasis>Selection Mode</emphasis> which makes selecting and deselecting as easy as "
+ "pressing an item once.</para><para>While in this mode, a quick access bar at the bottom shows available actions for the currently selected items."
+ "</para>"));
+ toggleSelectionModeAction->setIcon(QIcon::fromTheme(QStringLiteral("quickwizard")));
+ toggleSelectionModeAction->setCheckable(true);
+ actionCollection()->setDefaultShortcut(toggleSelectionModeAction, Qt::Key_Space);
+ connect(toggleSelectionModeAction, &QAction::triggered, this, &DolphinMainWindow::toggleSelectionMode);
+
+ // A special version of the toggleSelectionModeAction for the toolbar that also contains a menu
+ // with the selectAllAction and invertSelectionAction.
+ auto *toggleSelectionModeToolBarAction =
+ new KToolBarPopupAction(toggleSelectionModeAction->icon(), toggleSelectionModeAction->iconText(), actionCollection());
+ toggleSelectionModeToolBarAction->setToolTip(toggleSelectionModeAction->text());
+ toggleSelectionModeToolBarAction->setWhatsThis(toggleSelectionModeAction->whatsThis());
+ actionCollection()->addAction(QStringLiteral("toggle_selection_mode_tool_bar"), toggleSelectionModeToolBarAction);
+ toggleSelectionModeToolBarAction->setCheckable(true);
+ toggleSelectionModeToolBarAction->setPopupMode(KToolBarPopupAction::DelayedPopup);
+ connect(toggleSelectionModeToolBarAction, &QAction::triggered, toggleSelectionModeAction, &QAction::trigger);
+ connect(toggleSelectionModeAction, &QAction::toggled, toggleSelectionModeToolBarAction, &QAction::setChecked);
+
+ QAction *selectAllAction = KStandardAction::selectAll(this, &DolphinMainWindow::selectAll, actionCollection());
+ selectAllAction->setWhatsThis(xi18nc("@info:whatsthis",
+ "This selects all "
+ "files and folders in the current location."));
+
+ QAction *invertSelection = actionCollection()->addAction(QStringLiteral("invert_selection"));
+ invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
+ invertSelection->setWhatsThis(xi18nc("@info:whatsthis invert",
+ "This selects all "
+ "items that you have currently <emphasis>not</emphasis> selected instead."));
+ invertSelection->setIcon(QIcon::fromTheme(QStringLiteral("edit-select-invert")));
+ actionCollection()->setDefaultShortcut(invertSelection, Qt::CTRL | Qt::SHIFT | Qt::Key_A);
+ connect(invertSelection, &QAction::triggered, this, &DolphinMainWindow::invertSelection);
+
+ QMenu *toggleSelectionModeActionMenu = new QMenu(this);
+ toggleSelectionModeActionMenu->addAction(selectAllAction);
+ toggleSelectionModeActionMenu->addAction(invertSelection);
+ toggleSelectionModeToolBarAction->setMenu(toggleSelectionModeActionMenu);