1 /***************************************************************************
2 * Copyright (C) 2008 by David Faure <faure@kde.org> *
3 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
21 #include "dolphinviewactionhandler.h"
23 #include "dolphindebug.h"
24 #include "kitemviews/kfileitemmodel.h"
25 #include "settings/viewpropertiesdialog.h"
26 #include "views/zoomlevelinfo.h"
29 #include <Baloo/IndexerConfig>
31 #include <KActionCollection>
32 #include <KActionMenu>
33 #include <KLocalizedString>
34 #include <KNewFileMenu>
35 #include <KPropertiesDialog>
36 #include <KProtocolManager>
41 DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection
* collection
, QObject
* parent
) :
43 m_actionCollection(collection
),
44 m_currentView(nullptr),
48 Q_ASSERT(m_actionCollection
);
52 void DolphinViewActionHandler::setCurrentView(DolphinView
* view
)
57 disconnect(m_currentView
, nullptr, this, nullptr);
62 connect(view
, &DolphinView::modeChanged
,
63 this, &DolphinViewActionHandler::updateViewActions
);
64 connect(view
, &DolphinView::previewsShownChanged
,
65 this, &DolphinViewActionHandler::slotPreviewsShownChanged
);
66 connect(view
, &DolphinView::sortOrderChanged
,
67 this, &DolphinViewActionHandler::slotSortOrderChanged
);
68 connect(view
, &DolphinView::sortFoldersFirstChanged
,
69 this, &DolphinViewActionHandler::slotSortFoldersFirstChanged
);
70 connect(view
, &DolphinView::visibleRolesChanged
,
71 this, &DolphinViewActionHandler::slotVisibleRolesChanged
);
72 connect(view
, &DolphinView::groupedSortingChanged
,
73 this, &DolphinViewActionHandler::slotGroupedSortingChanged
);
74 connect(view
, &DolphinView::hiddenFilesShownChanged
,
75 this, &DolphinViewActionHandler::slotHiddenFilesShownChanged
);
76 connect(view
, &DolphinView::sortRoleChanged
,
77 this, &DolphinViewActionHandler::slotSortRoleChanged
);
78 connect(view
, &DolphinView::zoomLevelChanged
,
79 this, &DolphinViewActionHandler::slotZoomLevelChanged
);
80 connect(view
, &DolphinView::writeStateChanged
,
81 this, &DolphinViewActionHandler::slotWriteStateChanged
);
84 DolphinView
* DolphinViewActionHandler::currentView()
89 void DolphinViewActionHandler::createActions()
91 // This action doesn't appear in the GUI, it's for the shortcut only.
92 // KNewFileMenu takes care of the GUI stuff.
93 QAction
* newDirAction
= m_actionCollection
->addAction(QStringLiteral("create_dir"));
94 newDirAction
->setText(i18nc("@action", "Create Folder..."));
95 m_actionCollection
->setDefaultShortcut(newDirAction
, Qt::Key_F10
);
96 newDirAction
->setIcon(QIcon::fromTheme(QStringLiteral("folder-new")));
97 newDirAction
->setEnabled(false); // Will be enabled in slotWriteStateChanged(bool) if the current URL is writable
98 connect(newDirAction
, &QAction::triggered
, this, &DolphinViewActionHandler::createDirectory
);
102 KStandardAction::renameFile(this, &DolphinViewActionHandler::slotRename
, m_actionCollection
);
104 auto trashAction
= KStandardAction::moveToTrash(this, &DolphinViewActionHandler::slotTrashActivated
, m_actionCollection
);
105 auto trashShortcuts
= trashAction
->shortcuts();
106 if (!trashShortcuts
.contains(QKeySequence::Delete
)) {
107 trashShortcuts
.append(QKeySequence::Delete
);
108 m_actionCollection
->setDefaultShortcuts(trashAction
, trashShortcuts
);
111 auto deleteAction
= KStandardAction::deleteFile(this, &DolphinViewActionHandler::slotDeleteItems
, m_actionCollection
);
112 auto deleteShortcuts
= deleteAction
->shortcuts();
113 if (!deleteShortcuts
.contains(Qt::SHIFT
| Qt::Key_Delete
)) {
114 deleteShortcuts
.append(Qt::SHIFT
| Qt::Key_Delete
);
115 m_actionCollection
->setDefaultShortcuts(deleteAction
, deleteShortcuts
);
118 // This action is useful for being enabled when KStandardAction::MoveToTrash should be
119 // disabled and KStandardAction::DeleteFile is enabled (e.g. non-local files), so that Key_Del
120 // can be used for deleting the file (#76016). It needs to be a separate action
121 // so that the Edit menu isn't affected.
122 QAction
* deleteWithTrashShortcut
= m_actionCollection
->addAction(QStringLiteral("delete_shortcut"));
123 // The descriptive text is just for the shortcuts editor.
124 deleteWithTrashShortcut
->setText(i18nc("@action \"Move to Trash\" for non-local files, etc.", "Delete (using shortcut for Trash)"));
125 m_actionCollection
->setDefaultShortcut(deleteWithTrashShortcut
, QKeySequence::Delete
);
126 deleteWithTrashShortcut
->setEnabled(false);
127 connect(deleteWithTrashShortcut
, &QAction::triggered
, this, &DolphinViewActionHandler::slotDeleteItems
);
129 QAction
*propertiesAction
= m_actionCollection
->addAction( QStringLiteral("properties") );
130 // Well, it's the File menu in dolphinmainwindow and the Edit menu in dolphinpart... :)
131 propertiesAction
->setText( i18nc("@action:inmenu File", "Properties") );
132 propertiesAction
->setIcon(QIcon::fromTheme(QStringLiteral("document-properties")));
133 m_actionCollection
->setDefaultShortcuts(propertiesAction
, {Qt::ALT
+ Qt::Key_Return
, Qt::ALT
+ Qt::Key_Enter
});
134 connect(propertiesAction
, &QAction::triggered
, this, &DolphinViewActionHandler::slotProperties
);
137 KToggleAction
* iconsAction
= iconsModeAction();
138 KToggleAction
* compactAction
= compactModeAction();
139 KToggleAction
* detailsAction
= detailsModeAction();
141 KSelectAction
* viewModeActions
= m_actionCollection
->add
<KSelectAction
>(QStringLiteral("view_mode"));
142 viewModeActions
->setText(i18nc("@action:intoolbar", "View Mode"));
143 viewModeActions
->addAction(iconsAction
);
144 viewModeActions
->addAction(compactAction
);
145 viewModeActions
->addAction(detailsAction
);
146 viewModeActions
->setToolBarMode(KSelectAction::MenuMode
);
147 connect(viewModeActions
, static_cast<void(KSelectAction::*)(QAction
*)>(&KSelectAction::triggered
), this, &DolphinViewActionHandler::slotViewModeActionTriggered
);
149 KStandardAction::zoomIn(this,
150 &DolphinViewActionHandler::zoomIn
,
153 KStandardAction::zoomOut(this,
154 &DolphinViewActionHandler::zoomOut
,
157 KToggleAction
* showPreview
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("show_preview"));
158 showPreview
->setText(i18nc("@action:intoolbar", "Preview"));
159 showPreview
->setToolTip(i18nc("@info", "Show preview of files and folders"));
160 showPreview
->setIcon(QIcon::fromTheme(QStringLiteral("view-preview")));
161 connect(showPreview
, &KToggleAction::triggered
, this, &DolphinViewActionHandler::togglePreview
);
163 KToggleAction
* sortDescending
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("descending"));
164 sortDescending
->setText(i18nc("@action:inmenu Sort", "Descending"));
165 connect(sortDescending
, &KToggleAction::triggered
, this, &DolphinViewActionHandler::toggleSortOrder
);
167 KToggleAction
* sortFoldersFirst
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("folders_first"));
168 sortFoldersFirst
->setText(i18nc("@action:inmenu Sort", "Folders First"));
169 connect(sortFoldersFirst
, &KToggleAction::triggered
, this, &DolphinViewActionHandler::toggleSortFoldersFirst
);
172 QActionGroup
* sortByActionGroup
= createFileItemRolesActionGroup(QStringLiteral("sort_by_"));
174 KActionMenu
* sortByActionMenu
= m_actionCollection
->add
<KActionMenu
>(QStringLiteral("sort"));
175 sortByActionMenu
->setText(i18nc("@action:inmenu View", "Sort By"));
176 sortByActionMenu
->setDelayed(false);
178 foreach (QAction
* action
, sortByActionGroup
->actions()) {
179 sortByActionMenu
->addAction(action
);
181 sortByActionMenu
->addSeparator();
182 sortByActionMenu
->addAction(sortDescending
);
183 sortByActionMenu
->addAction(sortFoldersFirst
);
185 // View -> Additional Information
186 QActionGroup
* visibleRolesGroup
= createFileItemRolesActionGroup(QStringLiteral("show_"));
188 KActionMenu
* visibleRolesMenu
= m_actionCollection
->add
<KActionMenu
>(QStringLiteral("additional_info"));
189 visibleRolesMenu
->setText(i18nc("@action:inmenu View", "Additional Information"));
190 visibleRolesMenu
->setDelayed(false);
192 foreach (QAction
* action
, visibleRolesGroup
->actions()) {
193 visibleRolesMenu
->addAction(action
);
196 KToggleAction
* showInGroups
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("show_in_groups"));
197 showInGroups
->setIcon(QIcon::fromTheme(QStringLiteral("view-group")));
198 showInGroups
->setText(i18nc("@action:inmenu View", "Show in Groups"));
199 connect(showInGroups
, &KToggleAction::triggered
, this, &DolphinViewActionHandler::toggleGroupedSorting
);
201 KToggleAction
* showHiddenFiles
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("show_hidden_files"));
202 showHiddenFiles
->setText(i18nc("@action:inmenu View", "Hidden Files"));
203 showHiddenFiles
->setToolTip(i18nc("@info", "Visibility of hidden files and folders"));
204 m_actionCollection
->setDefaultShortcuts(showHiddenFiles
, {Qt::ALT
+ Qt::Key_Period
, Qt::CTRL
+ Qt::Key_H
, Qt::Key_F8
});
205 connect(showHiddenFiles
, &KToggleAction::triggered
, this, &DolphinViewActionHandler::toggleShowHiddenFiles
);
207 QAction
* adjustViewProps
= m_actionCollection
->addAction(QStringLiteral("view_properties"));
208 adjustViewProps
->setText(i18nc("@action:inmenu View", "Adjust View Properties..."));
209 connect(adjustViewProps
, &QAction::triggered
, this, &DolphinViewActionHandler::slotAdjustViewProperties
);
212 QActionGroup
* DolphinViewActionHandler::createFileItemRolesActionGroup(const QString
& groupPrefix
)
214 const bool isSortGroup
= (groupPrefix
== QLatin1String("sort_by_"));
215 Q_ASSERT(isSortGroup
|| (!isSortGroup
&& groupPrefix
== QLatin1String("show_")));
217 QActionGroup
* rolesActionGroup
= new QActionGroup(m_actionCollection
);
218 rolesActionGroup
->setExclusive(isSortGroup
);
220 connect(rolesActionGroup
, &QActionGroup::triggered
,
221 this, &DolphinViewActionHandler::slotSortTriggered
);
223 connect(rolesActionGroup
, &QActionGroup::triggered
,
224 this, &DolphinViewActionHandler::toggleVisibleRole
);
228 KActionMenu
* groupMenu
= nullptr;
229 QActionGroup
* groupMenuGroup
= nullptr;
231 bool indexingEnabled
= false;
233 Baloo::IndexerConfig config
;
234 indexingEnabled
= config
.fileIndexingEnabled();
237 const QList
<KFileItemModel::RoleInfo
> rolesInfo
= KFileItemModel::rolesInformation();
238 foreach (const KFileItemModel::RoleInfo
& info
, rolesInfo
) {
239 if (!isSortGroup
&& info
.role
== "text") {
240 // It should not be possible to hide the "text" role
244 KToggleAction
* action
= nullptr;
245 const QString name
= groupPrefix
+ info
.role
;
246 if (info
.group
.isEmpty()) {
247 action
= m_actionCollection
->add
<KToggleAction
>(name
);
248 action
->setActionGroup(rolesActionGroup
);
250 if (!groupMenu
|| info
.group
!= groupName
) {
251 groupName
= info
.group
;
252 groupMenu
= m_actionCollection
->add
<KActionMenu
>(groupName
);
253 groupMenu
->setText(groupName
);
254 groupMenu
->setActionGroup(rolesActionGroup
);
256 groupMenuGroup
= new QActionGroup(groupMenu
);
257 groupMenuGroup
->setExclusive(isSortGroup
);
259 connect(groupMenuGroup
, &QActionGroup::triggered
,
260 this, &DolphinViewActionHandler::slotSortTriggered
);
262 connect(groupMenuGroup
, &QActionGroup::triggered
,
263 this, &DolphinViewActionHandler::toggleVisibleRole
);
267 action
= new KToggleAction(groupMenu
);
268 action
->setActionGroup(groupMenuGroup
);
269 groupMenu
->addAction(action
);
271 action
->setText(info
.translation
);
272 action
->setData(info
.role
);
274 const bool enable
= (!info
.requiresBaloo
&& !info
.requiresIndexer
) ||
275 (info
.requiresBaloo
) ||
276 (info
.requiresIndexer
&& indexingEnabled
);
277 action
->setEnabled(enable
);
280 m_sortByActions
.insert(info
.role
, action
);
282 m_visibleRoles
.insert(info
.role
, action
);
286 return rolesActionGroup
;
289 void DolphinViewActionHandler::slotViewModeActionTriggered(QAction
* action
)
291 const DolphinView::Mode mode
= action
->data().value
<DolphinView::Mode
>();
292 m_currentView
->setMode(mode
);
294 QAction
* viewModeMenu
= m_actionCollection
->action(QStringLiteral("view_mode"));
295 viewModeMenu
->setIcon(action
->icon());
298 void DolphinViewActionHandler::slotRename()
300 emit
actionBeingHandled();
301 m_currentView
->renameSelectedItems();
304 void DolphinViewActionHandler::slotTrashActivated()
306 emit
actionBeingHandled();
307 m_currentView
->trashSelectedItems();
310 void DolphinViewActionHandler::slotDeleteItems()
312 emit
actionBeingHandled();
313 m_currentView
->deleteSelectedItems();
316 void DolphinViewActionHandler::togglePreview(bool show
)
318 emit
actionBeingHandled();
319 m_currentView
->setPreviewsShown(show
);
322 void DolphinViewActionHandler::slotPreviewsShownChanged(bool shown
)
325 // It is not enough to update the 'Show Preview' action, also
326 // the 'Zoom In' and 'Zoom Out' actions must be adapted.
330 QString
DolphinViewActionHandler::currentViewModeActionName() const
332 switch (m_currentView
->mode()) {
333 case DolphinView::IconsView
:
334 return QStringLiteral("icons");
335 case DolphinView::DetailsView
:
336 return QStringLiteral("details");
337 case DolphinView::CompactView
:
338 return QStringLiteral("compact");
343 return QString(); // can't happen
346 KActionCollection
* DolphinViewActionHandler::actionCollection()
348 return m_actionCollection
;
351 void DolphinViewActionHandler::updateViewActions()
353 QAction
* viewModeAction
= m_actionCollection
->action(currentViewModeActionName());
354 if (viewModeAction
) {
355 viewModeAction
->setChecked(true);
357 QAction
* viewModeMenu
= m_actionCollection
->action(QStringLiteral("view_mode"));
358 viewModeMenu
->setIcon(viewModeAction
->icon());
361 QAction
* showPreviewAction
= m_actionCollection
->action(QStringLiteral("show_preview"));
362 showPreviewAction
->setChecked(m_currentView
->previewsShown());
364 slotSortOrderChanged(m_currentView
->sortOrder());
365 slotSortFoldersFirstChanged(m_currentView
->sortFoldersFirst());
366 slotVisibleRolesChanged(m_currentView
->visibleRoles(), QList
<QByteArray
>());
367 slotGroupedSortingChanged(m_currentView
->groupedSorting());
368 slotSortRoleChanged(m_currentView
->sortRole());
369 slotZoomLevelChanged(m_currentView
->zoomLevel(), -1);
371 // Updates the "show_hidden_files" action state and icon
372 slotHiddenFilesShownChanged(m_currentView
->hiddenFilesShown());
375 void DolphinViewActionHandler::zoomIn()
377 const int level
= m_currentView
->zoomLevel();
378 m_currentView
->setZoomLevel(level
+ 1);
382 void DolphinViewActionHandler::zoomOut()
384 const int level
= m_currentView
->zoomLevel();
385 m_currentView
->setZoomLevel(level
- 1);
389 void DolphinViewActionHandler::toggleSortOrder()
391 const Qt::SortOrder order
= (m_currentView
->sortOrder() == Qt::AscendingOrder
) ?
392 Qt::DescendingOrder
:
394 m_currentView
->setSortOrder(order
);
397 void DolphinViewActionHandler::toggleSortFoldersFirst()
399 const bool sortFirst
= m_currentView
->sortFoldersFirst();
400 m_currentView
->setSortFoldersFirst(!sortFirst
);
403 void DolphinViewActionHandler::slotSortOrderChanged(Qt::SortOrder order
)
405 QAction
* descending
= m_actionCollection
->action(QStringLiteral("descending"));
406 const bool sortDescending
= (order
== Qt::DescendingOrder
);
407 descending
->setChecked(sortDescending
);
410 void DolphinViewActionHandler::slotSortFoldersFirstChanged(bool foldersFirst
)
412 m_actionCollection
->action(QStringLiteral("folders_first"))->setChecked(foldersFirst
);
415 void DolphinViewActionHandler::toggleVisibleRole(QAction
* action
)
417 emit
actionBeingHandled();
419 const QByteArray toggledRole
= action
->data().toByteArray();
421 QList
<QByteArray
> roles
= m_currentView
->visibleRoles();
423 const bool show
= action
->isChecked();
425 const int index
= roles
.indexOf(toggledRole
);
426 const bool containsInfo
= (index
>= 0);
427 if (show
&& !containsInfo
) {
428 roles
.append(toggledRole
);
429 m_currentView
->setVisibleRoles(roles
);
430 } else if (!show
&& containsInfo
) {
431 roles
.removeAt(index
);
432 m_currentView
->setVisibleRoles(roles
);
433 Q_ASSERT(roles
.indexOf(toggledRole
) < 0);
437 void DolphinViewActionHandler::slotVisibleRolesChanged(const QList
<QByteArray
>& current
,
438 const QList
<QByteArray
>& previous
)
442 const QSet
<QByteArray
> checkedRoles
= current
.toSet();
443 QHashIterator
<QByteArray
, KToggleAction
*> it(m_visibleRoles
);
444 while (it
.hasNext()) {
446 const QByteArray
& role
= it
.key();
447 KToggleAction
* action
= it
.value();
448 action
->setChecked(checkedRoles
.contains(role
));
452 void DolphinViewActionHandler::toggleGroupedSorting(bool grouped
)
454 m_currentView
->setGroupedSorting(grouped
);
457 void DolphinViewActionHandler::slotGroupedSortingChanged(bool groupedSorting
)
459 QAction
* showInGroupsAction
= m_actionCollection
->action(QStringLiteral("show_in_groups"));
460 showInGroupsAction
->setChecked(groupedSorting
);
463 void DolphinViewActionHandler::toggleShowHiddenFiles(bool show
)
465 emit
actionBeingHandled();
466 m_currentView
->setHiddenFilesShown(show
);
469 void DolphinViewActionHandler::slotHiddenFilesShownChanged(bool shown
)
471 QAction
* showHiddenFilesAction
= m_actionCollection
->action(QStringLiteral("show_hidden_files"));
472 showHiddenFilesAction
->setChecked(shown
);
474 // #374508: don't overwrite custom icons.
475 const QString iconName
= showHiddenFilesAction
->icon().name();
476 if (!iconName
.isEmpty() && iconName
!= QLatin1String("visibility") && iconName
!= QLatin1String("hint")) {
480 showHiddenFilesAction
->setIcon(QIcon::fromTheme(shown
? QStringLiteral("visibility") : QStringLiteral("hint")));
483 void DolphinViewActionHandler::slotWriteStateChanged(bool isFolderWritable
)
485 m_actionCollection
->action(QStringLiteral("create_dir"))->setEnabled(isFolderWritable
&&
486 KProtocolManager::supportsMakeDir(currentView()->url()));
489 KToggleAction
* DolphinViewActionHandler::iconsModeAction()
491 KToggleAction
* iconsView
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("icons"));
492 iconsView
->setText(i18nc("@action:inmenu View Mode", "Icons"));
493 iconsView
->setToolTip(i18nc("@info", "Icons view mode"));
494 m_actionCollection
->setDefaultShortcut(iconsView
, Qt::CTRL
+ Qt::Key_1
);
495 iconsView
->setIcon(QIcon::fromTheme(QStringLiteral("view-list-icons")));
496 iconsView
->setData(QVariant::fromValue(DolphinView::IconsView
));
500 KToggleAction
* DolphinViewActionHandler::compactModeAction()
502 KToggleAction
* iconsView
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("compact"));
503 iconsView
->setText(i18nc("@action:inmenu View Mode", "Compact"));
504 iconsView
->setToolTip(i18nc("@info", "Compact view mode"));
505 m_actionCollection
->setDefaultShortcut(iconsView
, Qt::CTRL
+ Qt::Key_2
);
506 iconsView
->setIcon(QIcon::fromTheme(QStringLiteral("view-list-details"))); // TODO: discuss with Oxygen-team the wrong (?) name
507 iconsView
->setData(QVariant::fromValue(DolphinView::CompactView
));
511 KToggleAction
* DolphinViewActionHandler::detailsModeAction()
513 KToggleAction
* detailsView
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("details"));
514 detailsView
->setText(i18nc("@action:inmenu View Mode", "Details"));
515 detailsView
->setToolTip(i18nc("@info", "Details view mode"));
516 m_actionCollection
->setDefaultShortcut(detailsView
, Qt::CTRL
+ Qt::Key_3
);
517 detailsView
->setIcon(QIcon::fromTheme(QStringLiteral("view-list-tree")));
518 detailsView
->setData(QVariant::fromValue(DolphinView::DetailsView
));
522 void DolphinViewActionHandler::slotSortRoleChanged(const QByteArray
& role
)
524 KToggleAction
* action
= m_sortByActions
.value(role
);
526 action
->setChecked(true);
528 if (!action
->icon().isNull()) {
529 QAction
* sortByMenu
= m_actionCollection
->action(QStringLiteral("sort"));
530 sortByMenu
->setIcon(action
->icon());
535 void DolphinViewActionHandler::slotZoomLevelChanged(int current
, int previous
)
539 QAction
* zoomInAction
= m_actionCollection
->action(KStandardAction::name(KStandardAction::ZoomIn
));
541 zoomInAction
->setEnabled(current
< ZoomLevelInfo::maximumLevel());
544 QAction
* zoomOutAction
= m_actionCollection
->action(KStandardAction::name(KStandardAction::ZoomOut
));
546 zoomOutAction
->setEnabled(current
> ZoomLevelInfo::minimumLevel());
550 void DolphinViewActionHandler::slotSortTriggered(QAction
* action
)
552 // The radiobuttons of the "Sort By"-menu are split between the main-menu
553 // and several sub-menus. Because of this they don't have a common
554 // action-group that assures an exclusive toggle-state between the main-menu
555 // actions and the sub-menu-actions. If an action gets checked, it must
556 // be assured that all other actions get unchecked.
557 QAction
* sortByMenu
= m_actionCollection
->action(QStringLiteral("sort"));
558 foreach (QAction
* groupAction
, sortByMenu
->menu()->actions()) {
559 KActionMenu
* actionMenu
= qobject_cast
<KActionMenu
*>(groupAction
);
561 foreach (QAction
* subAction
, actionMenu
->menu()->actions()) {
562 subAction
->setChecked(false);
564 } else if (groupAction
->actionGroup()) {
565 groupAction
->setChecked(false);
568 action
->setChecked(true);
570 // Apply the activated sort-role to the view
571 const QByteArray role
= action
->data().toByteArray();
572 m_currentView
->setSortRole(role
);
575 void DolphinViewActionHandler::slotAdjustViewProperties()
577 emit
actionBeingHandled();
578 QPointer
<ViewPropertiesDialog
> dialog
= new ViewPropertiesDialog(m_currentView
);
583 void DolphinViewActionHandler::slotProperties()
585 KPropertiesDialog
* dialog
= nullptr;
586 const KFileItemList list
= m_currentView
->selectedItems();
587 if (list
.isEmpty()) {
588 const QUrl url
= m_currentView
->url();
589 dialog
= new KPropertiesDialog(url
, m_currentView
);
591 dialog
= new KPropertiesDialog(list
, m_currentView
);
594 dialog
->setAttribute(Qt::WA_DeleteOnClose
);
597 dialog
->activateWindow();