2 * SPDX-FileCopyrightText: 2008 David Faure <faure@kde.org>
3 * SPDX-FileCopyrightText: 2012 Peter Penz <peter.penz19@gmail.com>
5 * SPDX-License-Identifier: GPL-2.0-or-later
8 #include "dolphinviewactionhandler.h"
10 #include "kitemviews/kfileitemlisttostring.h"
11 #include "kitemviews/kfileitemmodel.h"
12 #include "selectionmode/actiontexthelper.h"
13 #include "settings/viewpropertiesdialog.h"
14 #include "views/zoomlevelinfo.h"
15 #include "views/zoomwidgetaction.h"
18 #include <Baloo/IndexerConfig>
20 #include <KActionCollection>
21 #include <KActionMenu>
22 #include <KFileItemListProperties>
23 #include <KLocalizedString>
24 #include <KNewFileMenu>
25 #include <KPropertiesDialog>
26 #include <KProtocolManager>
28 #include <QActionGroup>
32 DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection
*collection
, SelectionMode::ActionTextHelper
*actionTextHelper
, QObject
*parent
)
34 , m_actionCollection(collection
)
35 , m_currentView(nullptr)
40 Q_ASSERT(m_actionCollection
);
41 createActions(actionTextHelper
);
44 void DolphinViewActionHandler::setCurrentView(DolphinView
*view
)
49 disconnect(m_currentView
, nullptr, this, nullptr);
54 connect(view
, &DolphinView::modeChanged
, this, &DolphinViewActionHandler::updateViewActions
);
55 connect(view
, &DolphinView::previewsShownChanged
, this, &DolphinViewActionHandler::slotPreviewsShownChanged
);
56 connect(view
, &DolphinView::sortOrderChanged
, this, &DolphinViewActionHandler::slotSortOrderChanged
);
57 connect(view
, &DolphinView::sortFoldersFirstChanged
, this, &DolphinViewActionHandler::slotSortFoldersFirstChanged
);
58 connect(view
, &DolphinView::sortHiddenLastChanged
, this, &DolphinViewActionHandler::slotSortHiddenLastChanged
);
59 connect(view
, &DolphinView::visibleRolesChanged
, this, &DolphinViewActionHandler::slotVisibleRolesChanged
);
60 connect(view
, &DolphinView::groupedSortingChanged
, this, &DolphinViewActionHandler::slotGroupedSortingChanged
);
61 connect(view
, &DolphinView::hiddenFilesShownChanged
, this, &DolphinViewActionHandler::slotHiddenFilesShownChanged
);
62 connect(view
, &DolphinView::sortRoleChanged
, this, &DolphinViewActionHandler::slotSortRoleChanged
);
63 connect(view
, &DolphinView::groupRoleChanged
, this, &DolphinViewActionHandler::slotGroupRoleChanged
);
64 connect(view
, &DolphinView::groupOrderChanged
, this, &DolphinViewActionHandler::slotGroupOrderChanged
);
65 connect(view
, &DolphinView::zoomLevelChanged
, this, &DolphinViewActionHandler::slotZoomLevelChanged
);
66 connect(view
, &DolphinView::writeStateChanged
, this, &DolphinViewActionHandler::slotWriteStateChanged
);
67 slotWriteStateChanged(view
->isFolderWritable());
68 connect(view
, &DolphinView::selectionModeChangeRequested
, this, [this](bool enabled
) {
69 Q_EMIT
selectionModeChangeTriggered(enabled
);
71 connect(view
, &DolphinView::selectionChanged
, this, &DolphinViewActionHandler::slotSelectionChanged
);
72 slotSelectionChanged(m_currentView
->selectedItems());
75 DolphinView
*DolphinViewActionHandler::currentView()
80 void DolphinViewActionHandler::createActions(SelectionMode::ActionTextHelper
*actionTextHelper
)
82 // This action doesn't appear in the GUI, it's for the shortcut only.
83 // KNewFileMenu takes care of the GUI stuff.
84 QAction
*newDirAction
= m_actionCollection
->addAction(QStringLiteral("create_dir"));
85 newDirAction
->setText(i18nc("@action", "Create Folder…"));
86 m_actionCollection
->setDefaultShortcuts(newDirAction
, KStandardShortcut::createFolder());
87 newDirAction
->setIcon(QIcon::fromTheme(QStringLiteral("folder-new")));
88 newDirAction
->setEnabled(false); // Will be enabled in slotWriteStateChanged(bool) if the current URL is writable
89 connect(newDirAction
, &QAction::triggered
, this, &DolphinViewActionHandler::createDirectoryTriggered
);
91 QAction
*newFileAction
= m_actionCollection
->addAction(QStringLiteral("create_file"));
92 newFileAction
->setText(i18nc("@action", "Create File…"));
93 newFileAction
->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
94 newFileAction
->setEnabled(false); // Will be enabled in slotWriteStateChanged(bool) if the current URL is writable
95 connect(newFileAction
, &QAction::triggered
, this, &DolphinViewActionHandler::createFileTriggered
);
99 auto renameAction
= KStandardAction::renameFile(this, &DolphinViewActionHandler::slotRename
, m_actionCollection
);
100 renameAction
->setWhatsThis(xi18nc("@info:whatsthis",
102 "items in your current selection.<nl/>Renaming multiple items "
103 "at once results in their new names differing only in a number."));
105 auto trashAction
= KStandardAction::moveToTrash(this, &DolphinViewActionHandler::slotTrashActivated
, m_actionCollection
);
106 auto trashShortcuts
= trashAction
->shortcuts();
107 trashAction
->setAutoRepeat(false);
108 if (!trashShortcuts
.contains(QKeySequence::Delete
)) {
109 trashShortcuts
.append(QKeySequence::Delete
);
110 m_actionCollection
->setDefaultShortcuts(trashAction
, trashShortcuts
);
112 trashAction
->setWhatsThis(xi18nc("@info:whatsthis",
114 "items in your current selection to the <filename>Trash"
115 "</filename>.<nl/>The trash is a temporary storage location where "
116 "items can be deleted later if disk space is needed."));
118 auto deleteAction
= KStandardAction::deleteFile(this, &DolphinViewActionHandler::slotDeleteItems
, m_actionCollection
);
119 auto deleteShortcuts
= deleteAction
->shortcuts();
120 deleteAction
->setAutoRepeat(false);
121 if (!deleteShortcuts
.contains(Qt::SHIFT
| Qt::Key_Delete
)) {
122 deleteShortcuts
.append(Qt::SHIFT
| Qt::Key_Delete
);
123 m_actionCollection
->setDefaultShortcuts(deleteAction
, deleteShortcuts
);
125 deleteAction
->setWhatsThis(xi18nc("@info:whatsthis",
127 "the items in your current selection permanently. They "
128 "cannot be recovered by normal means."));
130 // This action is useful for being enabled when KStandardAction::MoveToTrash should be
131 // disabled and KStandardAction::DeleteFile is enabled (e.g. non-local files), so that Key_Del
132 // can be used for deleting the file (#76016). It needs to be a separate action
133 // so that the Edit menu isn't affected.
134 QAction
*deleteWithTrashShortcut
= m_actionCollection
->addAction(QStringLiteral("delete_shortcut"));
135 // The descriptive text is just for the shortcuts editor.
136 deleteWithTrashShortcut
->setText(i18nc("@action \"Move to Trash\" for non-local files, etc.", "Delete (using shortcut for Trash)"));
137 m_actionCollection
->setDefaultShortcuts(deleteWithTrashShortcut
, KStandardShortcut::moveToTrash());
138 deleteWithTrashShortcut
->setEnabled(false);
139 connect(deleteWithTrashShortcut
, &QAction::triggered
, this, &DolphinViewActionHandler::slotDeleteItems
);
141 QAction
*duplicateAction
= m_actionCollection
->addAction(QStringLiteral("duplicate"));
142 duplicateAction
->setText(i18nc("@action:inmenu File", "Duplicate Here"));
143 duplicateAction
->setIcon(QIcon::fromTheme(QStringLiteral("edit-duplicate")));
144 m_actionCollection
->setDefaultShortcut(duplicateAction
, Qt::CTRL
| Qt::Key_D
);
145 duplicateAction
->setEnabled(false);
146 connect(duplicateAction
, &QAction::triggered
, this, &DolphinViewActionHandler::slotDuplicate
);
148 QAction
*propertiesAction
= m_actionCollection
->addAction(QStringLiteral("properties"));
149 // Well, it's the File menu in dolphinmainwindow and the Edit menu in dolphinpart... :)
150 propertiesAction
->setText(i18nc("@action:inmenu File", "Properties"));
151 propertiesAction
->setWhatsThis(xi18nc("@info:whatsthis properties",
152 "This shows a complete list of properties of the currently "
153 "selected items in a new window.<nl/>If nothing is selected the "
154 "window will be about the currently viewed folder instead.<nl/>"
155 "You can configure advanced options there like managing "
156 "read- and write-permissions."));
157 propertiesAction
->setIcon(QIcon::fromTheme(QStringLiteral("document-properties")));
158 m_actionCollection
->setDefaultShortcuts(propertiesAction
, {Qt::ALT
| Qt::Key_Return
, Qt::ALT
| Qt::Key_Enter
});
159 connect(propertiesAction
, &QAction::triggered
, this, &DolphinViewActionHandler::slotProperties
);
161 QAction
*copyPathAction
= m_actionCollection
->addAction(QStringLiteral("copy_location"));
162 copyPathAction
->setText(i18nc("@action:incontextmenu", "Copy Location"));
163 copyPathAction
->setWhatsThis(i18nc("@info:whatsthis copy_location", "This will copy the path of the first selected item into the clipboard."));
165 copyPathAction
->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy-path")));
166 m_actionCollection
->setDefaultShortcuts(copyPathAction
, {Qt::CTRL
| Qt::ALT
| Qt::Key_C
});
167 connect(copyPathAction
, &QAction::triggered
, this, &DolphinViewActionHandler::slotCopyPath
);
169 if (actionTextHelper
) {
170 // The "…" at the end make clear that they won't trigger their respective actions directly.
171 actionTextHelper
->registerTextWhenNothingIsSelected(trashAction
, i18nc("@action:inmenu File", "Move to Trash…"));
172 actionTextHelper
->registerTextWhenNothingIsSelected(deleteAction
, i18nc("@action:inmenu File", "Delete…"));
173 actionTextHelper
->registerTextWhenNothingIsSelected(duplicateAction
, i18nc("@action:inmenu File", "Duplicate Here…"));
174 actionTextHelper
->registerTextWhenNothingIsSelected(copyPathAction
, i18nc("@action:incontextmenu", "Copy Location…"));
177 // This menu makes sure that users who don't know how to open a context menu and haven't
178 // figured out how to enable the menu bar can still perform basic file manipulation.
179 // This only works if they know how to select a file.
180 // The text when nothing is selected at least implies that a selection can /somehow/ be made.
181 // This menu is by default only used in the hamburger menu but created here so users can put
182 // it on their toolbar.
183 KActionMenu
*basicActionsMenu
= m_actionCollection
->add
<KActionMenu
>(QStringLiteral("basic_actions"), this);
184 // The text is set later depending on the selection in the currently active view.
185 basicActionsMenu
->setPopupMode(QToolButton::InstantPopup
);
186 basicActionsMenu
->addAction(m_actionCollection
->action(KStandardAction::name(KStandardAction::Cut
)));
187 basicActionsMenu
->addAction(m_actionCollection
->action(KStandardAction::name(KStandardAction::Copy
)));
188 basicActionsMenu
->addAction(m_actionCollection
->action(KStandardAction::name(KStandardAction::Paste
)));
189 basicActionsMenu
->addSeparator();
190 basicActionsMenu
->addAction(m_actionCollection
->action(KStandardAction::name(KStandardAction::RenameFile
)));
191 basicActionsMenu
->addAction(m_actionCollection
->action(KStandardAction::name(KStandardAction::MoveToTrash
)));
192 basicActionsMenu
->addSeparator();
193 basicActionsMenu
->addAction(m_actionCollection
->action(QStringLiteral("properties")));
194 basicActionsMenu
->addSeparator(); // We add one more separator because we sometimes add contextual
195 // actions in slotSelectionChanged() after the static ones above.
198 KToggleAction
*iconsAction
= iconsModeAction();
199 KToggleAction
*compactAction
= compactModeAction();
200 KToggleAction
*detailsAction
= detailsModeAction();
202 iconsAction
->setWhatsThis(xi18nc("@info:whatsthis Icons view mode",
203 "<para>This switches to a view mode that focuses on the folder "
204 "and file icons. This mode makes it easy to distinguish folders "
205 "from files and to detect items with distinctive <emphasis>"
206 "file types</emphasis>.</para><para> This mode is handy to "
207 "browse through pictures when the <interface>Preview"
208 "</interface> option is enabled.</para>"));
209 compactAction
->setWhatsThis(xi18nc("@info:whatsthis Compact view mode",
210 "<para>This switches to a compact view mode that lists the folders "
211 "and files in columns with the names beside the icons.</para><para>"
212 "This helps to give you an overview in folders with many items.</para>"));
213 detailsAction
->setWhatsThis(xi18nc("@info:whatsthis Details view mode",
214 "<para>This switches to a list view mode that focuses on folder "
215 "and file details.</para><para>Click on a detail in the column "
216 "header to sort the items by it. Click again to sort the other "
217 "way around. To select which details should be displayed click "
218 "the header with the right mouse button.</para><para>You can "
219 "view the contents of a folder without leaving the current "
220 "location by clicking the region to the left of it. This way you can "
221 "view the contents of multiple folders in the same list.</para>"));
223 KSelectAction
*viewModeActions
= m_actionCollection
->add
<KSelectAction
>(QStringLiteral("view_mode"));
224 viewModeActions
->setText(i18nc("@action:intoolbar", "Change View Mode"));
225 viewModeActions
->setWhatsThis(xi18nc("@info:whatsthis View Mode Toolbutton", "This cycles through all view modes."));
226 viewModeActions
->addAction(iconsAction
);
227 viewModeActions
->addAction(compactAction
);
228 viewModeActions
->addAction(detailsAction
);
229 viewModeActions
->setToolBarMode(KSelectAction::MenuMode
);
230 viewModeActions
->setToolButtonPopupMode(QToolButton::ToolButtonPopupMode::MenuButtonPopup
);
231 connect(viewModeActions
, &KSelectAction::actionTriggered
, this, &DolphinViewActionHandler::slotViewModeActionTriggered
);
232 connect(viewModeActions
, &KSelectAction::triggered
, this, [this, viewModeActions
, iconsAction
, compactAction
, detailsAction
]() {
233 // Loop through the actions when button is clicked
234 const auto currentAction
= viewModeActions
->currentAction();
235 if (currentAction
== iconsAction
) {
236 slotViewModeActionTriggered(compactAction
);
237 } else if (currentAction
== compactAction
) {
238 slotViewModeActionTriggered(detailsAction
);
239 } else if (currentAction
== detailsAction
) {
240 slotViewModeActionTriggered(iconsAction
);
244 QAction
*zoomInAction
= KStandardAction::zoomIn(this, &DolphinViewActionHandler::zoomIn
, m_actionCollection
);
245 zoomInAction
->setWhatsThis(i18nc("@info:whatsthis zoom in", "This increases the icon size."));
247 QAction
*zoomResetAction
= m_actionCollection
->addAction(QStringLiteral("view_zoom_reset"));
248 zoomResetAction
->setText(i18nc("@action:inmenu View", "Reset Zoom Level"));
249 zoomResetAction
->setToolTip(i18n("Zoom To Default"));
250 zoomResetAction
->setWhatsThis(i18nc("@info:whatsthis zoom reset", "This resets the icon size to default."));
251 zoomResetAction
->setIcon(QIcon::fromTheme(QStringLiteral("zoom-original")));
252 m_actionCollection
->setDefaultShortcuts(zoomResetAction
, {Qt::CTRL
| Qt::Key_0
});
253 connect(zoomResetAction
, &QAction::triggered
, this, &DolphinViewActionHandler::zoomReset
);
255 QAction
*zoomOutAction
= KStandardAction::zoomOut(this, &DolphinViewActionHandler::zoomOut
, m_actionCollection
);
256 zoomOutAction
->setWhatsThis(i18nc("@info:whatsthis zoom out", "This reduces the icon size."));
258 ZoomWidgetAction
*zoomWidgetAction
= new ZoomWidgetAction(zoomInAction
, zoomResetAction
, zoomOutAction
, m_actionCollection
);
259 m_actionCollection
->addAction(QStringLiteral("zoom"), zoomWidgetAction
);
261 KToggleAction
*showPreview
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("show_preview"));
262 showPreview
->setText(i18nc("@action:intoolbar", "Show Previews"));
263 showPreview
->setToolTip(i18nc("@info", "Show preview of files and folders"));
264 showPreview
->setWhatsThis(xi18nc("@info:whatsthis",
266 "enabled, the icons are based on the actual file or folder "
267 "contents.<nl/>For example the icons of images become scaled "
268 "down versions of the images."));
269 showPreview
->setIcon(QIcon::fromTheme(QStringLiteral("view-preview")));
270 m_actionCollection
->setDefaultShortcut(showPreview
, QKeySequence(Qt::Key_F12
));
271 connect(showPreview
, &KToggleAction::triggered
, this, &DolphinViewActionHandler::togglePreview
);
273 KToggleAction
*sortFoldersFirst
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("folders_first"));
274 sortFoldersFirst
->setText(i18nc("@action:inmenu Sort", "Folders First"));
275 connect(sortFoldersFirst
, &KToggleAction::triggered
, this, &DolphinViewActionHandler::toggleSortFoldersFirst
);
277 KToggleAction
*sortHiddenLast
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("hidden_last"));
278 sortHiddenLast
->setText(i18nc("@action:inmenu Sort", "Hidden Files Last"));
279 connect(sortHiddenLast
, &KToggleAction::triggered
, this, &DolphinViewActionHandler::toggleSortHiddenLast
);
282 QActionGroup
*sortByActionGroup
= createFileItemRolesActionGroup(QStringLiteral("sort_by_"));
284 KActionMenu
*sortByActionMenu
= m_actionCollection
->add
<KActionMenu
>(QStringLiteral("sort"));
285 sortByActionMenu
->setIcon(QIcon::fromTheme(QStringLiteral("view-sort")));
286 sortByActionMenu
->setText(i18nc("@action:inmenu View", "Sort By"));
287 sortByActionMenu
->setPopupMode(QToolButton::InstantPopup
);
289 const auto sortByActionGroupActions
= sortByActionGroup
->actions();
290 for (QAction
*action
: sortByActionGroupActions
) {
291 sortByActionMenu
->addAction(action
);
294 sortByActionMenu
->addSeparator();
296 QActionGroup
*groupForSort
= new QActionGroup(sortByActionMenu
);
297 groupForSort
->setExclusive(true);
299 KToggleAction
*sortAscendingAction
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("sort_ascending"));
300 sortAscendingAction
->setActionGroup(groupForSort
);
301 connect(sortAscendingAction
, &QAction::triggered
, this, [this] {
302 m_currentView
->setSortOrder(Qt::AscendingOrder
);
305 KToggleAction
*sortDescendingAction
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("sort_descending"));
306 sortDescendingAction
->setActionGroup(groupForSort
);
307 connect(sortDescendingAction
, &QAction::triggered
, this, [this] {
308 m_currentView
->setSortOrder(Qt::DescendingOrder
);
311 sortByActionMenu
->addAction(sortAscendingAction
);
312 sortByActionMenu
->addAction(sortDescendingAction
);
313 sortByActionMenu
->addSeparator();
314 sortByActionMenu
->addAction(sortFoldersFirst
);
315 sortByActionMenu
->addAction(sortHiddenLast
);
318 QActionGroup
*groupByActionGroup
= createFileItemRolesActionGroup(QStringLiteral("group_by_"));
320 KActionMenu
*groupByActionMenu
= m_actionCollection
->add
<KActionMenu
>(QStringLiteral("group"));
321 groupByActionMenu
->setIcon(QIcon::fromTheme(QStringLiteral("view-group")));
322 groupByActionMenu
->setText(i18nc("@action:inmenu View", "Group By"));
323 groupByActionMenu
->setPopupMode(QToolButton::InstantPopup
);
325 const auto groupByActionGroupActions
= groupByActionGroup
->actions();
326 for (QAction
*action
: groupByActionGroupActions
) {
327 groupByActionMenu
->addAction(action
);
330 groupByActionMenu
->addSeparator();
332 QActionGroup
*groupForGroup
= new QActionGroup(groupByActionMenu
);
333 groupForGroup
->setExclusive(true);
335 KToggleAction
*groupAscendingAction
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("group_ascending"));
336 groupAscendingAction
->setActionGroup(groupForGroup
);
337 connect(groupAscendingAction
, &QAction::triggered
, this, [this] {
338 m_currentView
->setGroupOrder(Qt::AscendingOrder
);
341 KToggleAction
*groupDescendingAction
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("group_descending"));
342 groupDescendingAction
->setActionGroup(groupForGroup
);
343 connect(groupDescendingAction
, &QAction::triggered
, this, [this] {
344 m_currentView
->setGroupOrder(Qt::DescendingOrder
);
347 groupByActionMenu
->addAction(groupAscendingAction
);
348 groupByActionMenu
->addAction(groupDescendingAction
);
350 // View -> Additional Information
351 QActionGroup
*visibleRolesGroup
= createFileItemRolesActionGroup(QStringLiteral("show_"));
353 KActionMenu
*visibleRolesMenu
= m_actionCollection
->add
<KActionMenu
>(QStringLiteral("additional_info"));
354 visibleRolesMenu
->setText(i18nc("@action:inmenu View", "Show Additional Information"));
355 visibleRolesMenu
->setIcon(QIcon::fromTheme(QStringLiteral("documentinfo")));
356 visibleRolesMenu
->setPopupMode(QToolButton::InstantPopup
);
358 const auto visibleRolesGroupActions
= visibleRolesGroup
->actions();
359 for (QAction
*action
: visibleRolesGroupActions
) {
360 visibleRolesMenu
->addAction(action
);
363 KToggleAction
*showInGroups
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("show_in_groups"));
364 showInGroups
->setIcon(QIcon::fromTheme(QStringLiteral("view-group")));
365 showInGroups
->setText(i18nc("@action:inmenu View", "Show in Groups"));
366 showInGroups
->setWhatsThis(i18nc("@info:whatsthis", "This groups files and folders by their first letter."));
367 connect(showInGroups
, &KToggleAction::triggered
, this, &DolphinViewActionHandler::toggleGroupedSorting
);
369 KToggleAction
*showHiddenFiles
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("show_hidden_files"));
370 showHiddenFiles
->setIcon(QIcon::fromTheme(QStringLiteral("view-visible")));
371 showHiddenFiles
->setText(i18nc("@action:inmenu View", "Show Hidden Files"));
372 showHiddenFiles
->setWhatsThis(xi18nc("@info:whatsthis",
374 "this is enabled, <emphasis>hidden</emphasis> files and folders "
375 "are visible. They will be displayed semi-transparent.</para>"
376 "<para>Hidden items only differ from normal ones in that their "
377 "name starts with a dot (\".\"). Typically, there is no need for "
378 "users to access them, which is why they are hidden.</para>"
379 "<para>Items can also be hidden if their names are listed in a text file "
380 "named \".hidden\". Files with the \"application/x-trash\" MIME type, "
381 "such as backup files, can also be hidden by enabling that setting in "
382 "Configure Dolphin > View > General.</para>"));
383 m_actionCollection
->setDefaultShortcuts(showHiddenFiles
, KStandardShortcut::showHideHiddenFiles());
384 connect(showHiddenFiles
, &KToggleAction::triggered
, this, &DolphinViewActionHandler::toggleShowHiddenFiles
);
386 QAction
*adjustViewProps
= m_actionCollection
->addAction(QStringLiteral("view_properties"));
387 adjustViewProps
->setText(i18nc("@action:inmenu View", "Adjust View Display Style…"));
388 adjustViewProps
->setIcon(QIcon::fromTheme(QStringLiteral("view-choose")));
389 adjustViewProps
->setWhatsThis(i18nc("@info:whatsthis",
390 "This opens a window "
391 "in which all folder view properties can be adjusted."));
392 connect(adjustViewProps
, &QAction::triggered
, this, &DolphinViewActionHandler::slotAdjustViewProperties
);
394 // View settings: the dropdown menu contains various view-related actions
395 KActionMenu
*viewSettings
= m_actionCollection
->add
<KActionMenu
>(QStringLiteral("view_settings"));
396 viewSettings
->setText(i18nc("@action:intoolbar", "View Settings"));
397 viewSettings
->setWhatsThis(
398 xi18nc("@info:whatsthis View Settings Toolbutton", "This cycles through all view modes. The dropdown menu contains various view-related actions."));
399 const auto actions
= viewModeActions
->actions();
400 for (QAction
*action
: actions
) {
401 viewSettings
->addAction(action
);
403 viewSettings
->addSeparator();
404 viewSettings
->addAction(zoomWidgetAction
);
405 viewSettings
->addAction(sortByActionMenu
);
406 viewSettings
->addAction(visibleRolesMenu
);
407 viewSettings
->addAction(showPreview
);
408 viewSettings
->addAction(showInGroups
);
409 viewSettings
->addAction(showHiddenFiles
);
410 viewSettings
->addAction(adjustViewProps
);
411 viewSettings
->setPopupMode(QToolButton::ToolButtonPopupMode::MenuButtonPopup
);
412 connect(viewSettings
, &KActionMenu::triggered
, viewModeActions
, &KSelectAction::triggered
);
415 QActionGroup
*DolphinViewActionHandler::createFileItemRolesActionGroup(const QString
&groupPrefix
)
417 const bool isSortGroup
= (groupPrefix
== QLatin1String("sort_by_"));
418 const bool isGroupGroup
= (groupPrefix
== QLatin1String("group_by_"));
419 Q_ASSERT(isSortGroup
|| isGroupGroup
|| groupPrefix
== QLatin1String("show_"));
421 QActionGroup
*rolesActionGroup
= new QActionGroup(m_actionCollection
);
422 rolesActionGroup
->setExclusive(isSortGroup
|| isGroupGroup
);
424 connect(rolesActionGroup
, &QActionGroup::triggered
, this, &DolphinViewActionHandler::slotSortTriggered
);
425 } else if (isGroupGroup
) {
426 connect(rolesActionGroup
, &QActionGroup::triggered
, this, &DolphinViewActionHandler::slotGroupTriggered
);
428 connect(rolesActionGroup
, &QActionGroup::triggered
, this, &DolphinViewActionHandler::toggleVisibleRole
);
432 KActionMenu
*groupMenu
= nullptr;
433 QActionGroup
*groupMenuGroup
= nullptr;
435 bool indexingEnabled
= false;
437 Baloo::IndexerConfig config
;
438 indexingEnabled
= config
.fileIndexingEnabled();
441 QList
<KFileItemModel::RoleInfo
> rolesInfo
= KFileItemModel::rolesInformation();
443 rolesInfo
+= KFileItemModel::extraGroupingInformation();
446 for (const KFileItemModel::RoleInfo
&info
: rolesInfo
) {
447 if (!isSortGroup
&& !isGroupGroup
&& info
.role
== "text") {
448 // It should not be possible to hide the "text" role
452 KToggleAction
*action
= nullptr;
453 const QString name
= groupPrefix
+ info
.role
;
454 if (info
.group
.isEmpty()) {
455 action
= m_actionCollection
->add
<KToggleAction
>(name
);
456 action
->setActionGroup(rolesActionGroup
);
458 if (!groupMenu
|| info
.group
!= groupName
) {
459 groupName
= info
.group
;
460 groupMenu
= m_actionCollection
->add
<KActionMenu
>(groupName
);
461 groupMenu
->setText(groupName
);
462 groupMenu
->setActionGroup(rolesActionGroup
);
464 groupMenuGroup
= new QActionGroup(groupMenu
);
465 groupMenuGroup
->setExclusive(isSortGroup
|| isGroupGroup
);
467 connect(groupMenuGroup
, &QActionGroup::triggered
, this, &DolphinViewActionHandler::slotSortTriggered
);
468 } else if (isGroupGroup
) {
469 connect(groupMenuGroup
, &QActionGroup::triggered
, this, &DolphinViewActionHandler::slotGroupTriggered
);
471 connect(groupMenuGroup
, &QActionGroup::triggered
, this, &DolphinViewActionHandler::toggleVisibleRole
);
475 action
= new KToggleAction(groupMenu
);
476 action
->setActionGroup(groupMenuGroup
);
477 groupMenu
->addAction(action
);
479 action
->setText(info
.translation
);
480 action
->setData(info
.role
);
482 const bool enable
= (!info
.requiresBaloo
&& !info
.requiresIndexer
) || (info
.requiresBaloo
) || (info
.requiresIndexer
&& indexingEnabled
);
483 action
->setEnabled(enable
);
486 m_sortByActions
.insert(info
.role
, action
);
487 } else if (isGroupGroup
) {
488 m_groupByActions
.insert(info
.role
, action
);
490 m_visibleRoles
.insert(info
.role
, action
);
494 return rolesActionGroup
;
497 void DolphinViewActionHandler::slotViewModeActionTriggered(QAction
*action
)
499 const DolphinView::Mode mode
= action
->data().value
<DolphinView::Mode
>();
500 m_currentView
->setViewMode(mode
);
502 QAction
*viewModeMenu
= m_actionCollection
->action(QStringLiteral("view_mode"));
503 viewModeMenu
->setIcon(action
->icon());
505 QAction
*viewSettingsAction
= m_actionCollection
->action(QStringLiteral("view_settings"));
506 viewSettingsAction
->setIcon(action
->icon());
509 void DolphinViewActionHandler::slotRename()
511 if (m_currentView
->selectedItemsCount() == 0) {
512 Q_EMIT
selectionModeChangeTriggered(true, SelectionMode::BottomBar::Contents::RenameContents
);
514 Q_EMIT
actionBeingHandled();
515 m_currentView
->renameSelectedItems();
516 // We don't exit selectionMode here because users might want to rename more items.
520 void DolphinViewActionHandler::slotTrashActivated()
522 if (m_currentView
->selectedItemsCount() == 0) {
523 Q_EMIT
selectionModeChangeTriggered(true, SelectionMode::BottomBar::Contents::MoveToTrashContents
);
525 Q_EMIT
actionBeingHandled();
526 m_currentView
->trashSelectedItems();
527 Q_EMIT
selectionModeChangeTriggered(false);
531 void DolphinViewActionHandler::slotDeleteItems()
533 if (m_currentView
->selectedItemsCount() == 0) {
534 Q_EMIT
selectionModeChangeTriggered(true, SelectionMode::BottomBar::Contents::DeleteContents
);
536 Q_EMIT
actionBeingHandled();
537 m_currentView
->deleteSelectedItems();
538 Q_EMIT
selectionModeChangeTriggered(false);
542 void DolphinViewActionHandler::togglePreview(bool show
)
544 Q_EMIT
actionBeingHandled();
545 m_currentView
->setPreviewsShown(show
);
548 void DolphinViewActionHandler::slotPreviewsShownChanged(bool shown
)
551 // It is not enough to update the 'Show Preview' action, also
552 // the 'Zoom In', 'Zoom Out' and 'Zoom Reset' actions must be adapted.
556 QString
DolphinViewActionHandler::currentViewModeActionName() const
558 switch (m_currentView
->viewMode()) {
559 case DolphinView::IconsView
:
560 return QStringLiteral("icons");
561 case DolphinView::DetailsView
:
562 return QStringLiteral("details");
563 case DolphinView::CompactView
:
564 return QStringLiteral("compact");
569 return QString(); // can't happen
572 KActionCollection
*DolphinViewActionHandler::actionCollection()
574 return m_actionCollection
;
577 void DolphinViewActionHandler::updateViewActions()
579 QAction
*viewModeAction
= m_actionCollection
->action(currentViewModeActionName());
580 if (viewModeAction
) {
581 viewModeAction
->setChecked(true);
583 QAction
*viewModeMenu
= m_actionCollection
->action(QStringLiteral("view_mode"));
584 viewModeMenu
->setIcon(viewModeAction
->icon());
586 QAction
*viewSettingsAction
= m_actionCollection
->action(QStringLiteral("view_settings"));
587 viewSettingsAction
->setIcon(viewModeAction
->icon());
590 QAction
*showPreviewAction
= m_actionCollection
->action(QStringLiteral("show_preview"));
591 showPreviewAction
->setChecked(m_currentView
->previewsShown());
593 slotSortOrderChanged(m_currentView
->sortOrder());
594 slotSortFoldersFirstChanged(m_currentView
->sortFoldersFirst());
595 slotSortHiddenLastChanged(m_currentView
->sortHiddenLast());
596 slotVisibleRolesChanged(m_currentView
->visibleRoles(), QList
<QByteArray
>());
597 slotGroupedSortingChanged(m_currentView
->groupedSorting());
598 slotSortRoleChanged(m_currentView
->sortRole());
599 slotGroupRoleChanged(m_currentView
->groupRole());
600 slotGroupOrderChanged(m_currentView
->groupOrder());
601 slotZoomLevelChanged(m_currentView
->zoomLevel(), -1);
603 // Updates the "show_hidden_files" action state and icon
604 slotHiddenFilesShownChanged(m_currentView
->hiddenFilesShown());
607 void DolphinViewActionHandler::zoomIn()
609 const int level
= m_currentView
->zoomLevel();
610 m_currentView
->setZoomLevel(level
+ 1);
614 void DolphinViewActionHandler::zoomOut()
616 const int level
= m_currentView
->zoomLevel();
617 m_currentView
->setZoomLevel(level
- 1);
621 void DolphinViewActionHandler::zoomReset()
623 m_currentView
->resetZoomLevel();
627 void DolphinViewActionHandler::toggleSortFoldersFirst()
629 const bool sortFirst
= m_currentView
->sortFoldersFirst();
630 m_currentView
->setSortFoldersFirst(!sortFirst
);
633 void DolphinViewActionHandler::toggleSortHiddenLast()
635 const bool sortHiddenLast
= m_currentView
->sortHiddenLast();
636 m_currentView
->setSortHiddenLast(!sortHiddenLast
);
639 void DolphinViewActionHandler::slotSortOrderChanged(Qt::SortOrder order
)
641 QAction
*descending
= m_actionCollection
->action(QStringLiteral("sort_descending"));
642 QAction
*ascending
= m_actionCollection
->action(QStringLiteral("sort_ascending"));
643 const bool sortDescending
= (order
== Qt::DescendingOrder
);
644 descending
->setChecked(sortDescending
);
645 ascending
->setChecked(!sortDescending
);
648 void DolphinViewActionHandler::slotGroupOrderChanged(Qt::SortOrder order
)
650 QAction
*descending
= m_actionCollection
->action(QStringLiteral("group_descending"));
651 QAction
*ascending
= m_actionCollection
->action(QStringLiteral("group_ascending"));
652 const bool groupDescending
= (order
== Qt::DescendingOrder
);
653 descending
->setChecked(groupDescending
);
654 ascending
->setChecked(!groupDescending
);
657 void DolphinViewActionHandler::slotSortFoldersFirstChanged(bool foldersFirst
)
659 m_actionCollection
->action(QStringLiteral("folders_first"))->setChecked(foldersFirst
);
662 void DolphinViewActionHandler::slotSortHiddenLastChanged(bool hiddenLast
)
664 m_actionCollection
->action(QStringLiteral("hidden_last"))->setChecked(hiddenLast
);
667 void DolphinViewActionHandler::toggleVisibleRole(QAction
*action
)
669 Q_EMIT
actionBeingHandled();
671 const QByteArray toggledRole
= action
->data().toByteArray();
673 QList
<QByteArray
> roles
= m_currentView
->visibleRoles();
675 const bool show
= action
->isChecked();
677 const int index
= roles
.indexOf(toggledRole
);
678 const bool containsInfo
= (index
>= 0);
679 if (show
&& !containsInfo
) {
680 roles
.append(toggledRole
);
681 m_currentView
->setVisibleRoles(roles
);
682 } else if (!show
&& containsInfo
) {
683 roles
.removeAt(index
);
684 m_currentView
->setVisibleRoles(roles
);
685 Q_ASSERT(roles
.indexOf(toggledRole
) < 0);
689 void DolphinViewActionHandler::slotVisibleRolesChanged(const QList
<QByteArray
> ¤t
, const QList
<QByteArray
> &previous
)
693 const auto checkedRoles
= QSet
<QByteArray
>(current
.constBegin(), current
.constEnd());
694 QHashIterator
<QByteArray
, KToggleAction
*> it(m_visibleRoles
);
695 while (it
.hasNext()) {
697 const QByteArray
&role
= it
.key();
698 KToggleAction
*action
= it
.value();
699 action
->setChecked(checkedRoles
.contains(role
));
703 void DolphinViewActionHandler::toggleGroupedSorting(bool grouped
)
705 m_currentView
->setGroupedSorting(grouped
);
708 void DolphinViewActionHandler::slotGroupedSortingChanged(bool groupedSorting
)
710 QAction
*showInGroupsAction
= m_actionCollection
->action(QStringLiteral("show_in_groups"));
711 showInGroupsAction
->setChecked(groupedSorting
);
714 void DolphinViewActionHandler::toggleShowHiddenFiles(bool show
)
716 Q_EMIT
actionBeingHandled();
717 m_currentView
->setHiddenFilesShown(show
);
720 void DolphinViewActionHandler::slotHiddenFilesShownChanged(bool shown
)
722 QAction
*showHiddenFilesAction
= m_actionCollection
->action(QStringLiteral("show_hidden_files"));
723 showHiddenFilesAction
->setChecked(shown
);
726 void DolphinViewActionHandler::slotWriteStateChanged(bool isFolderWritable
)
728 const bool supportsMakeDir
= KProtocolManager::supportsMakeDir(currentView()->url());
729 m_actionCollection
->action(QStringLiteral("create_dir"))->setEnabled(isFolderWritable
&& supportsMakeDir
);
730 m_actionCollection
->action(QStringLiteral("create_file"))->setEnabled(isFolderWritable
);
733 KToggleAction
*DolphinViewActionHandler::iconsModeAction()
735 KToggleAction
*iconsView
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("icons"));
736 iconsView
->setText(i18nc("@action:inmenu View Mode", "Icons"));
737 iconsView
->setToolTip(i18nc("@info", "Icons view mode"));
738 m_actionCollection
->setDefaultShortcut(iconsView
, Qt::CTRL
| Qt::Key_1
);
739 iconsView
->setIcon(QIcon::fromTheme(QStringLiteral("view-list-icons")));
740 iconsView
->setData(QVariant::fromValue(DolphinView::IconsView
));
744 KToggleAction
*DolphinViewActionHandler::compactModeAction()
746 KToggleAction
*iconsView
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("compact"));
747 iconsView
->setText(i18nc("@action:inmenu View Mode", "Compact"));
748 iconsView
->setToolTip(i18nc("@info", "Compact view mode"));
749 m_actionCollection
->setDefaultShortcut(iconsView
, Qt::CTRL
| Qt::Key_2
);
750 iconsView
->setIcon(QIcon::fromTheme(QStringLiteral("view-list-details"))); // TODO: discuss with Oxygen-team the wrong (?) name
751 iconsView
->setData(QVariant::fromValue(DolphinView::CompactView
));
755 KToggleAction
*DolphinViewActionHandler::detailsModeAction()
757 KToggleAction
*detailsView
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("details"));
758 detailsView
->setText(i18nc("@action:inmenu View Mode", "Details"));
759 detailsView
->setToolTip(i18nc("@info", "Details view mode"));
760 m_actionCollection
->setDefaultShortcut(detailsView
, Qt::CTRL
| Qt::Key_3
);
761 detailsView
->setIcon(QIcon::fromTheme(QStringLiteral("view-list-tree")));
762 detailsView
->setData(QVariant::fromValue(DolphinView::DetailsView
));
766 void DolphinViewActionHandler::slotSortRoleChanged(const QByteArray
&role
)
768 KToggleAction
*action
= m_sortByActions
.value(role
);
770 action
->setChecked(true);
772 if (!action
->icon().isNull()) {
773 QAction
*sortByMenu
= m_actionCollection
->action(QStringLiteral("sort"));
774 sortByMenu
->setIcon(action
->icon());
778 QAction
*descending
= m_actionCollection
->action(QStringLiteral("sort_descending"));
779 QAction
*ascending
= m_actionCollection
->action(QStringLiteral("sort_ascending"));
781 if (role
== "text" || role
== "type" || role
== "extension" || role
== "tags" || role
== "comment") {
782 descending
->setText(i18nc("Sort descending", "Z-A"));
783 ascending
->setText(i18nc("Sort ascending", "A-Z"));
784 } else if (role
== "size") {
785 descending
->setText(i18nc("Sort descending", "Largest First"));
786 ascending
->setText(i18nc("Sort ascending", "Smallest First"));
787 } else if (role
== "modificationtime" || role
== "creationtime" || role
== "accesstime") {
788 descending
->setText(i18nc("Sort descending", "Newest First"));
789 ascending
->setText(i18nc("Sort ascending", "Oldest First"));
790 } else if (role
== "rating") {
791 descending
->setText(i18nc("Sort descending", "Highest First"));
792 ascending
->setText(i18nc("Sort ascending", "Lowest First"));
794 descending
->setText(i18nc("Sort descending", "Descending"));
795 ascending
->setText(i18nc("Sort ascending", "Ascending"));
798 slotSortOrderChanged(m_currentView
->sortOrder());
801 void DolphinViewActionHandler::slotGroupRoleChanged(const QByteArray
&role
)
803 KToggleAction
*action
= m_groupByActions
.value(role
);
805 action
->setChecked(true);
807 if (!action
->icon().isNull()) {
808 QAction
*groupByMenu
= m_actionCollection
->action(QStringLiteral("group"));
809 groupByMenu
->setIcon(action
->icon());
813 QAction
*descending
= m_actionCollection
->action(QStringLiteral("group_descending"));
814 QAction
*ascending
= m_actionCollection
->action(QStringLiteral("group_ascending"));
816 if (role
== "text" || role
== "type" || role
== "extension" || role
== "tags" || role
== "comment") {
817 descending
->setText(i18nc("Group descending", "Z-A"));
818 ascending
->setText(i18nc("Group ascending", "A-Z"));
819 } else if (role
== "size") {
820 descending
->setText(i18nc("Group descending", "Largest First"));
821 ascending
->setText(i18nc("Group ascending", "Smallest First"));
822 } else if (role
== "modificationtime" || role
== "creationtime" || role
== "accesstime") {
823 descending
->setText(i18nc("Group descending", "Newest First"));
824 ascending
->setText(i18nc("Group ascending", "Oldest First"));
825 } else if (role
== "rating") {
826 descending
->setText(i18nc("Group descending", "Highest First"));
827 ascending
->setText(i18nc("Group ascending", "Lowest First"));
829 descending
->setText(i18nc("Group descending", "Descending"));
830 ascending
->setText(i18nc("Group ascending", "Ascending"));
833 // Disable group order selector if grouping behavior does not support it
834 if (role
== "none" || role
== "followSort") {
835 descending
->setEnabled(false);
836 ascending
->setEnabled(false);
838 descending
->setEnabled(true);
839 ascending
->setEnabled(true);
842 slotGroupOrderChanged(m_currentView
->groupOrder());
845 void DolphinViewActionHandler::slotZoomLevelChanged(int current
, int previous
)
849 QAction
*zoomInAction
= m_actionCollection
->action(KStandardAction::name(KStandardAction::ZoomIn
));
851 zoomInAction
->setEnabled(current
< ZoomLevelInfo::maximumLevel());
854 QAction
*zoomOutAction
= m_actionCollection
->action(KStandardAction::name(KStandardAction::ZoomOut
));
856 zoomOutAction
->setEnabled(current
> ZoomLevelInfo::minimumLevel());
860 void DolphinViewActionHandler::slotSortTriggered(QAction
*action
)
862 // The radiobuttons of the "Sort By"-menu are split between the main-menu
863 // and several sub-menus. Because of this they don't have a common
864 // action-group that assures an exclusive toggle-state between the main-menu
865 // actions and the sub-menu-actions. If an action gets checked, it must
866 // be assured that all other actions get unchecked, except the ascending/
867 // descending actions
868 for (QAction
*groupAction
: std::as_const(m_sortByActions
)) {
869 KActionMenu
*actionMenu
= qobject_cast
<KActionMenu
*>(groupAction
);
871 const auto actions
= actionMenu
->menu()->actions();
872 for (QAction
*subAction
: actions
) {
873 subAction
->setChecked(false);
875 } else if (groupAction
->actionGroup()) {
876 groupAction
->setChecked(false);
879 action
->setChecked(true);
881 // Apply the activated sort-role to the view
882 const QByteArray role
= action
->data().toByteArray();
883 m_currentView
->setSortRole(role
);
886 void DolphinViewActionHandler::slotGroupTriggered(QAction
*action
)
888 // The radiobuttons of the "Group By"-menu are split between the main-menu
889 // and several sub-menus. Because of this they don't have a common
890 // action-group that assures an exclusive toggle-state between the main-menu
891 // actions and the sub-menu-actions. If an action gets checked, it must
892 // be assured that all other actions get unchecked, except the ascending/
893 // descending actions
894 for (QAction
*groupAction
: std::as_const(m_groupByActions
)) {
895 KActionMenu
*actionMenu
= qobject_cast
<KActionMenu
*>(groupAction
);
897 const auto actions
= actionMenu
->menu()->actions();
898 for (QAction
*subAction
: actions
) {
899 subAction
->setChecked(false);
901 } else if (groupAction
->actionGroup()) {
902 groupAction
->setChecked(false);
905 action
->setChecked(true);
907 // Apply the activated sort-role to the view
908 const QByteArray role
= action
->data().toByteArray();
909 m_currentView
->setGroupRole(role
);
912 void DolphinViewActionHandler::slotAdjustViewProperties()
914 Q_EMIT
actionBeingHandled();
915 QPointer
<ViewPropertiesDialog
> dialog
= new ViewPropertiesDialog(m_currentView
);
920 void DolphinViewActionHandler::slotDuplicate()
922 if (m_currentView
->selectedItemsCount() == 0) {
923 Q_EMIT
selectionModeChangeTriggered(true, SelectionMode::BottomBar::Contents::DuplicateContents
);
925 Q_EMIT
actionBeingHandled();
926 m_currentView
->duplicateSelectedItems();
927 Q_EMIT
selectionModeChangeTriggered(false);
931 void DolphinViewActionHandler::slotProperties()
933 KPropertiesDialog
*dialog
= nullptr;
934 const KFileItemList list
= m_currentView
->selectedItems();
935 if (list
.isEmpty()) {
936 const QUrl url
= m_currentView
->url();
937 dialog
= new KPropertiesDialog(url
, m_currentView
);
939 dialog
= new KPropertiesDialog(list
, m_currentView
);
942 dialog
->setAttribute(Qt::WA_DeleteOnClose
);
945 dialog
->activateWindow();
948 void DolphinViewActionHandler::slotCopyPath()
950 if (m_currentView
->selectedItemsCount() == 0) {
951 Q_EMIT
selectionModeChangeTriggered(true, SelectionMode::BottomBar::Contents::CopyLocationContents
);
953 m_currentView
->copyPathToClipboard();
954 Q_EMIT
selectionModeChangeTriggered(false);
958 void DolphinViewActionHandler::slotSelectionChanged(const KFileItemList
&selection
)
960 QString basicActionsMenuText
;
961 if (selection
.isEmpty()) {
962 basicActionsMenuText
= i18nc("@action:inmenu menu with actions like copy, paste, rename. The user's selection is empty when this text is shown.",
963 "Actions for Current View");
966 QFontMetrics fontMetrics
= QMenu().fontMetrics();
967 // i18n: @action:inmenu menu with actions like copy, paste, rename.
968 // %1 is a textual representation of the currently selected files or folders. This can be the name of
969 // the file/files like "file1" or "file1, file2 and file3" or an aggregate like "8 Selected Folders".
970 // If this sort of word puzzle can not be correctly translated in your language, translate it as "NULL" (without the quotes)
971 // and a fallback will be used.
972 basicActionsMenuText
= i18n("Actions for %1", fileItemListToString(selection
, fontMetrics
.averageCharWidth() * 40, fontMetrics
, ItemsState::Selected
));
976 if (basicActionsMenuText
== QStringLiteral("NULL")) {
977 const KFileItemListProperties
properties(selection
);
978 basicActionsMenuText
= i18ncp("@action:inmenu menu with actions like copy, paste, rename. %1 is the amount of selected files/folders.",
979 "Actions for One Selected Item",
980 "Actions for %1 Selected Items",
984 QAction
*basicActionsMenu
= m_actionCollection
->action(QStringLiteral("basic_actions"));
985 basicActionsMenu
->setText(basicActionsMenuText
);
987 // Add or remove contextual actions
988 while (!basicActionsMenu
->menu()->actions().constLast()->isSeparator()) {
989 basicActionsMenu
->menu()->removeAction(basicActionsMenu
->menu()->actions().last());
991 if (selection
.count() == 1) {
992 if (selection
.first().isLink()) {
993 basicActionsMenu
->menu()->addAction(m_actionCollection
->action(QStringLiteral("show_target")));
995 if (selection
.first().isDir()) {
996 basicActionsMenu
->menu()->addAction(m_actionCollection
->action(QStringLiteral("add_to_places")));
1001 #include "moc_dolphinviewactionhandler.cpp"