+
+void DolphinViewActionHandler::slotCopyPath()
+{
+ if (m_currentView->selectedItemsCount() == 0) {
+ Q_EMIT selectionModeChangeTriggered(true, SelectionMode::BottomBar::Contents::CopyLocationContents);
+ } else {
+ m_currentView->copyPathToClipboard();
+ Q_EMIT selectionModeChangeTriggered(false);
+ }
+}
+
+void DolphinViewActionHandler::slotSelectionChanged(const KFileItemList &selection)
+{
+ QString basicActionsMenuText;
+ if (selection.isEmpty()) {
+ basicActionsMenuText = i18nc("@action:inmenu menu with actions like copy, paste, rename. The user's selection is empty when this text is shown.",
+ "Actions for Current View");
+ } else {
+ // clang-format off
+ QFontMetrics fontMetrics = QMenu().fontMetrics();
+ // i18n: @action:inmenu menu with actions like copy, paste, rename.
+ // %1 is a textual representation of the currently selected files or folders. This can be the name of
+ // the file/files like "file1" or "file1, file2 and file3" or an aggregate like "8 Selected Folders".
+ // If this sort of word puzzle can not be correctly translated in your language, translate it as "NULL" (without the quotes)
+ // and a fallback will be used.
+ basicActionsMenuText = i18n("Actions for %1", fileItemListToString(selection, fontMetrics.averageCharWidth() * 40, fontMetrics, ItemsState::Selected));
+ // clang-format on
+ }
+
+ if (basicActionsMenuText == QStringLiteral("NULL")) {
+ const KFileItemListProperties properties(selection);
+ basicActionsMenuText = i18ncp("@action:inmenu menu with actions like copy, paste, rename. %1 is the amount of selected files/folders.",
+ "Actions for One Selected Item",
+ "Actions for %1 Selected Items",
+ selection.count());
+ }
+
+ QAction *basicActionsMenu = m_actionCollection->action(QStringLiteral("basic_actions"));
+ basicActionsMenu->setText(basicActionsMenuText);
+
+ // Add or remove contextual actions
+ while (!basicActionsMenu->menu()->actions().constLast()->isSeparator()) {
+ basicActionsMenu->menu()->removeAction(basicActionsMenu->menu()->actions().last());
+ }
+ if (selection.count() == 1) {
+ if (selection.first().isLink()) {
+ basicActionsMenu->menu()->addAction(m_actionCollection->action(QStringLiteral("show_target")));
+ }
+ if (selection.first().isDir()) {
+ basicActionsMenu->menu()->addAction(m_actionCollection->action(QStringLiteral("add_to_places")));
+ }
+ }
+}
+
+#include "moc_dolphinviewactionhandler.cpp"