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 <config-baloo.h>
25 #include "settings/viewpropertiesdialog.h"
26 #include "views/dolphinview.h"
27 #include "views/zoomlevelinfo.h"
32 #include <KActionCollection>
33 #include <KActionMenu>
34 #include <kitemviews/kfileitemmodel.h>
35 #include <KLocalizedString>
36 #include <KNewFileMenu>
37 #include <KSelectAction>
38 #include <KToggleAction>
39 #include <KPropertiesDialog>
42 #include "dolphindebug.h"
45 #include <Baloo/IndexerConfig>
48 DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection
* collection
, QObject
* parent
) :
50 m_actionCollection(collection
),
55 Q_ASSERT(m_actionCollection
);
59 void DolphinViewActionHandler::setCurrentView(DolphinView
* view
)
64 disconnect(m_currentView
, 0, this, 0);
69 connect(view
, &DolphinView::modeChanged
,
70 this, &DolphinViewActionHandler::updateViewActions
);
71 connect(view
, &DolphinView::previewsShownChanged
,
72 this, &DolphinViewActionHandler::slotPreviewsShownChanged
);
73 connect(view
, &DolphinView::sortOrderChanged
,
74 this, &DolphinViewActionHandler::slotSortOrderChanged
);
75 connect(view
, &DolphinView::sortFoldersFirstChanged
,
76 this, &DolphinViewActionHandler::slotSortFoldersFirstChanged
);
77 connect(view
, &DolphinView::visibleRolesChanged
,
78 this, &DolphinViewActionHandler::slotVisibleRolesChanged
);
79 connect(view
, &DolphinView::groupedSortingChanged
,
80 this, &DolphinViewActionHandler::slotGroupedSortingChanged
);
81 connect(view
, &DolphinView::hiddenFilesShownChanged
,
82 this, &DolphinViewActionHandler::slotHiddenFilesShownChanged
);
83 connect(view
, &DolphinView::sortRoleChanged
,
84 this, &DolphinViewActionHandler::slotSortRoleChanged
);
85 connect(view
, &DolphinView::zoomLevelChanged
,
86 this, &DolphinViewActionHandler::slotZoomLevelChanged
);
87 connect(view
, &DolphinView::writeStateChanged
,
88 this, &DolphinViewActionHandler::slotWriteStateChanged
);
91 DolphinView
* DolphinViewActionHandler::currentView()
96 void DolphinViewActionHandler::createActions()
98 // This action doesn't appear in the GUI, it's for the shortcut only.
99 // KNewFileMenu takes care of the GUI stuff.
100 QAction
* newDirAction
= m_actionCollection
->addAction(QStringLiteral("create_dir"));
101 newDirAction
->setText(i18nc("@action", "Create Folder..."));
102 m_actionCollection
->setDefaultShortcut(newDirAction
, Qt::Key_F10
);
103 newDirAction
->setIcon(QIcon::fromTheme(QStringLiteral("folder-new")));
104 newDirAction
->setEnabled(false); // Will be enabled in slotWriteStateChanged(bool) if the current URL is writable
105 connect(newDirAction
, &QAction::triggered
, this, &DolphinViewActionHandler::createDirectory
);
109 QAction
* rename
= m_actionCollection
->addAction(QStringLiteral("rename"));
110 rename
->setText(i18nc("@action:inmenu File", "Rename..."));
111 m_actionCollection
->setDefaultShortcut(rename
, Qt::Key_F2
);
112 rename
->setIcon(QIcon::fromTheme(QStringLiteral("edit-rename")));
113 connect(rename
, &QAction::triggered
, this, &DolphinViewActionHandler::slotRename
);
115 QAction
* moveToTrash
= m_actionCollection
->addAction(QStringLiteral("move_to_trash"));
116 moveToTrash
->setText(i18nc("@action:inmenu File", "Move to Trash"));
117 moveToTrash
->setIcon(QIcon::fromTheme(QStringLiteral("user-trash")));
118 m_actionCollection
->setDefaultShortcut(moveToTrash
, QKeySequence::Delete
);
119 connect(moveToTrash
, &QAction::triggered
,
120 this, &DolphinViewActionHandler::slotTrashActivated
);
122 QAction
* deleteAction
= m_actionCollection
->addAction(QStringLiteral("delete"));
123 deleteAction
->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete")));
124 deleteAction
->setText(i18nc("@action:inmenu File", "Delete"));
125 m_actionCollection
->setDefaultShortcut(deleteAction
, Qt::SHIFT
| Qt::Key_Delete
);
126 connect(deleteAction
, &QAction::triggered
, this, &DolphinViewActionHandler::slotDeleteItems
);
128 // This action is useful for being enabled when "move_to_trash" should be
129 // disabled and "delete" is enabled (e.g. non-local files), so that Key_Del
130 // can be used for deleting the file (#76016). It needs to be a separate action
131 // so that the Edit menu isn't affected.
132 QAction
* deleteWithTrashShortcut
= m_actionCollection
->addAction(QStringLiteral("delete_shortcut"));
133 // The descriptive text is just for the shortcuts editor.
134 deleteWithTrashShortcut
->setText(i18nc("@action \"Move to Trash\" for non-local files, etc.", "Delete (using shortcut for Trash)"));
135 m_actionCollection
->setDefaultShortcut(deleteWithTrashShortcut
, QKeySequence::Delete
);
136 deleteWithTrashShortcut
->setEnabled(false);
137 connect(deleteWithTrashShortcut
, &QAction::triggered
, this, &DolphinViewActionHandler::slotDeleteItems
);
139 QAction
*propertiesAction
= m_actionCollection
->addAction( QStringLiteral("properties") );
140 // Well, it's the File menu in dolphinmainwindow and the Edit menu in dolphinpart... :)
141 propertiesAction
->setText( i18nc("@action:inmenu File", "Properties") );
142 propertiesAction
->setIcon(QIcon::fromTheme(QStringLiteral("document-properties")));
143 m_actionCollection
->setDefaultShortcuts(propertiesAction
, {Qt::ALT
+ Qt::Key_Return
, Qt::ALT
+ Qt::Key_Enter
});
144 connect(propertiesAction
, &QAction::triggered
, this, &DolphinViewActionHandler::slotProperties
);
147 KToggleAction
* iconsAction
= iconsModeAction();
148 KToggleAction
* compactAction
= compactModeAction();
149 KToggleAction
* detailsAction
= detailsModeAction();
151 KSelectAction
* viewModeActions
= m_actionCollection
->add
<KSelectAction
>(QStringLiteral("view_mode"));
152 viewModeActions
->setText(i18nc("@action:intoolbar", "View Mode"));
153 viewModeActions
->addAction(iconsAction
);
154 viewModeActions
->addAction(compactAction
);
155 viewModeActions
->addAction(detailsAction
);
156 viewModeActions
->setToolBarMode(KSelectAction::MenuMode
);
157 connect(viewModeActions
, static_cast<void(KSelectAction::*)(QAction
*)>(&KSelectAction::triggered
), this, &DolphinViewActionHandler::slotViewModeActionTriggered
);
159 KStandardAction::zoomIn(this,
163 KStandardAction::zoomOut(this,
167 KToggleAction
* showPreview
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("show_preview"));
168 showPreview
->setText(i18nc("@action:intoolbar", "Preview"));
169 showPreview
->setToolTip(i18nc("@info", "Show preview of files and folders"));
170 showPreview
->setIcon(QIcon::fromTheme(QStringLiteral("view-preview")));
171 connect(showPreview
, &KToggleAction::triggered
, this, &DolphinViewActionHandler::togglePreview
);
173 KToggleAction
* sortDescending
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("descending"));
174 sortDescending
->setText(i18nc("@action:inmenu Sort", "Descending"));
175 connect(sortDescending
, &KToggleAction::triggered
, this, &DolphinViewActionHandler::toggleSortOrder
);
177 KToggleAction
* sortFoldersFirst
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("folders_first"));
178 sortFoldersFirst
->setText(i18nc("@action:inmenu Sort", "Folders First"));
179 connect(sortFoldersFirst
, &KToggleAction::triggered
, this, &DolphinViewActionHandler::toggleSortFoldersFirst
);
182 QActionGroup
* sortByActionGroup
= createFileItemRolesActionGroup(QStringLiteral("sort_by_"));
184 KActionMenu
* sortByActionMenu
= m_actionCollection
->add
<KActionMenu
>(QStringLiteral("sort"));
185 sortByActionMenu
->setText(i18nc("@action:inmenu View", "Sort By"));
186 sortByActionMenu
->setDelayed(false);
188 foreach (QAction
* action
, sortByActionGroup
->actions()) {
189 sortByActionMenu
->addAction(action
);
191 sortByActionMenu
->addSeparator();
192 sortByActionMenu
->addAction(sortDescending
);
193 sortByActionMenu
->addAction(sortFoldersFirst
);
195 // View -> Additional Information
196 QActionGroup
* visibleRolesGroup
= createFileItemRolesActionGroup(QStringLiteral("show_"));
198 KActionMenu
* visibleRolesMenu
= m_actionCollection
->add
<KActionMenu
>(QStringLiteral("additional_info"));
199 visibleRolesMenu
->setText(i18nc("@action:inmenu View", "Additional Information"));
200 visibleRolesMenu
->setDelayed(false);
202 foreach (QAction
* action
, visibleRolesGroup
->actions()) {
203 visibleRolesMenu
->addAction(action
);
206 KToggleAction
* showInGroups
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("show_in_groups"));
207 showInGroups
->setIcon(QIcon::fromTheme(QStringLiteral("view-group")));
208 showInGroups
->setText(i18nc("@action:inmenu View", "Show in Groups"));
209 connect(showInGroups
, &KToggleAction::triggered
, this, &DolphinViewActionHandler::toggleGroupedSorting
);
211 KToggleAction
* showHiddenFiles
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("show_hidden_files"));
212 showHiddenFiles
->setText(i18nc("@action:inmenu View", "Hidden Files"));
213 showHiddenFiles
->setToolTip(i18nc("@info", "Visibility of hidden files and folders"));
214 m_actionCollection
->setDefaultShortcuts(showHiddenFiles
, {Qt::ALT
+ Qt::Key_Period
, Qt::Key_F8
});
215 connect(showHiddenFiles
, &KToggleAction::triggered
, this, &DolphinViewActionHandler::toggleShowHiddenFiles
);
217 QAction
* adjustViewProps
= m_actionCollection
->addAction(QStringLiteral("view_properties"));
218 adjustViewProps
->setText(i18nc("@action:inmenu View", "Adjust View Properties..."));
219 connect(adjustViewProps
, &QAction::triggered
, this, &DolphinViewActionHandler::slotAdjustViewProperties
);
222 QActionGroup
* DolphinViewActionHandler::createFileItemRolesActionGroup(const QString
& groupPrefix
)
224 const bool isSortGroup
= (groupPrefix
== QLatin1String("sort_by_"));
225 Q_ASSERT(isSortGroup
|| (!isSortGroup
&& groupPrefix
== QLatin1String("show_")));
227 QActionGroup
* rolesActionGroup
= new QActionGroup(m_actionCollection
);
228 rolesActionGroup
->setExclusive(isSortGroup
);
230 connect(rolesActionGroup
, &QActionGroup::triggered
,
231 this, &DolphinViewActionHandler::slotSortTriggered
);
233 connect(rolesActionGroup
, &QActionGroup::triggered
,
234 this, &DolphinViewActionHandler::toggleVisibleRole
);
238 KActionMenu
* groupMenu
= 0;
239 QActionGroup
* groupMenuGroup
= 0;
241 bool indexingEnabled
= false;
243 Baloo::IndexerConfig config
;
244 indexingEnabled
= config
.fileIndexingEnabled();
247 const QList
<KFileItemModel::RoleInfo
> rolesInfo
= KFileItemModel::rolesInformation();
248 foreach (const KFileItemModel::RoleInfo
& info
, rolesInfo
) {
249 if (!isSortGroup
&& info
.role
== "text") {
250 // It should not be possible to hide the "text" role
254 KToggleAction
* action
= 0;
255 const QString name
= groupPrefix
+ info
.role
;
256 if (info
.group
.isEmpty()) {
257 action
= m_actionCollection
->add
<KToggleAction
>(name
);
258 action
->setActionGroup(rolesActionGroup
);
260 if (!groupMenu
|| info
.group
!= groupName
) {
261 groupName
= info
.group
;
262 groupMenu
= m_actionCollection
->add
<KActionMenu
>(groupName
);
263 groupMenu
->setText(groupName
);
264 groupMenu
->setActionGroup(rolesActionGroup
);
266 groupMenuGroup
= new QActionGroup(groupMenu
);
267 groupMenuGroup
->setExclusive(isSortGroup
);
269 connect(groupMenuGroup
, &QActionGroup::triggered
,
270 this, &DolphinViewActionHandler::slotSortTriggered
);
272 connect(groupMenuGroup
, &QActionGroup::triggered
,
273 this, &DolphinViewActionHandler::toggleVisibleRole
);
277 action
= new KToggleAction(groupMenu
);
278 action
->setActionGroup(groupMenuGroup
);
279 groupMenu
->addAction(action
);
281 action
->setText(info
.translation
);
282 action
->setData(info
.role
);
284 const bool enable
= (!info
.requiresBaloo
&& !info
.requiresIndexer
) ||
285 (info
.requiresBaloo
) ||
286 (info
.requiresIndexer
&& indexingEnabled
);
287 action
->setEnabled(enable
);
290 m_sortByActions
.insert(info
.role
, action
);
292 m_visibleRoles
.insert(info
.role
, action
);
296 return rolesActionGroup
;
299 void DolphinViewActionHandler::slotViewModeActionTriggered(QAction
* action
)
301 const DolphinView::Mode mode
= action
->data().value
<DolphinView::Mode
>();
302 m_currentView
->setMode(mode
);
304 QAction
* viewModeMenu
= m_actionCollection
->action(QStringLiteral("view_mode"));
305 viewModeMenu
->setIcon(action
->icon());
308 void DolphinViewActionHandler::slotRename()
310 emit
actionBeingHandled();
311 m_currentView
->renameSelectedItems();
314 void DolphinViewActionHandler::slotTrashActivated()
316 emit
actionBeingHandled();
317 m_currentView
->trashSelectedItems();
320 void DolphinViewActionHandler::slotDeleteItems()
322 emit
actionBeingHandled();
323 m_currentView
->deleteSelectedItems();
326 void DolphinViewActionHandler::togglePreview(bool show
)
328 emit
actionBeingHandled();
329 m_currentView
->setPreviewsShown(show
);
332 void DolphinViewActionHandler::slotPreviewsShownChanged(bool shown
)
335 // It is not enough to update the 'Show Preview' action, also
336 // the 'Zoom In' and 'Zoom Out' actions must be adapted.
340 QString
DolphinViewActionHandler::currentViewModeActionName() const
342 switch (m_currentView
->mode()) {
343 case DolphinView::IconsView
:
344 return QStringLiteral("icons");
345 case DolphinView::DetailsView
:
346 return QStringLiteral("details");
347 case DolphinView::CompactView
:
348 return QStringLiteral("compact");
353 return QString(); // can't happen
356 KActionCollection
* DolphinViewActionHandler::actionCollection()
358 return m_actionCollection
;
361 void DolphinViewActionHandler::updateViewActions()
363 QAction
* viewModeAction
= m_actionCollection
->action(currentViewModeActionName());
364 if (viewModeAction
) {
365 viewModeAction
->setChecked(true);
367 QAction
* viewModeMenu
= m_actionCollection
->action(QStringLiteral("view_mode"));
368 viewModeMenu
->setIcon(viewModeAction
->icon());
371 QAction
* showPreviewAction
= m_actionCollection
->action(QStringLiteral("show_preview"));
372 showPreviewAction
->setChecked(m_currentView
->previewsShown());
374 slotSortOrderChanged(m_currentView
->sortOrder());
375 slotSortFoldersFirstChanged(m_currentView
->sortFoldersFirst());
376 slotVisibleRolesChanged(m_currentView
->visibleRoles(), QList
<QByteArray
>());
377 slotGroupedSortingChanged(m_currentView
->groupedSorting());
378 slotSortRoleChanged(m_currentView
->sortRole());
379 slotZoomLevelChanged(m_currentView
->zoomLevel(), -1);
381 // Updates the "show_hidden_files" action state and icon
382 slotHiddenFilesShownChanged(m_currentView
->hiddenFilesShown());
385 void DolphinViewActionHandler::zoomIn()
387 const int level
= m_currentView
->zoomLevel();
388 m_currentView
->setZoomLevel(level
+ 1);
392 void DolphinViewActionHandler::zoomOut()
394 const int level
= m_currentView
->zoomLevel();
395 m_currentView
->setZoomLevel(level
- 1);
399 void DolphinViewActionHandler::toggleSortOrder()
401 const Qt::SortOrder order
= (m_currentView
->sortOrder() == Qt::AscendingOrder
) ?
402 Qt::DescendingOrder
:
404 m_currentView
->setSortOrder(order
);
407 void DolphinViewActionHandler::toggleSortFoldersFirst()
409 const bool sortFirst
= m_currentView
->sortFoldersFirst();
410 m_currentView
->setSortFoldersFirst(!sortFirst
);
413 void DolphinViewActionHandler::slotSortOrderChanged(Qt::SortOrder order
)
415 QAction
* descending
= m_actionCollection
->action(QStringLiteral("descending"));
416 const bool sortDescending
= (order
== Qt::DescendingOrder
);
417 descending
->setChecked(sortDescending
);
420 void DolphinViewActionHandler::slotSortFoldersFirstChanged(bool foldersFirst
)
422 m_actionCollection
->action(QStringLiteral("folders_first"))->setChecked(foldersFirst
);
425 void DolphinViewActionHandler::toggleVisibleRole(QAction
* action
)
427 emit
actionBeingHandled();
429 const QByteArray toggledRole
= action
->data().toByteArray();
431 QList
<QByteArray
> roles
= m_currentView
->visibleRoles();
433 const bool show
= action
->isChecked();
435 const int index
= roles
.indexOf(toggledRole
);
436 const bool containsInfo
= (index
>= 0);
437 if (show
&& !containsInfo
) {
438 roles
.append(toggledRole
);
439 m_currentView
->setVisibleRoles(roles
);
440 } else if (!show
&& containsInfo
) {
441 roles
.removeAt(index
);
442 m_currentView
->setVisibleRoles(roles
);
443 Q_ASSERT(roles
.indexOf(toggledRole
) < 0);
447 void DolphinViewActionHandler::slotVisibleRolesChanged(const QList
<QByteArray
>& current
,
448 const QList
<QByteArray
>& previous
)
452 const QSet
<QByteArray
> checkedRoles
= current
.toSet();
453 QHashIterator
<QByteArray
, KToggleAction
*> it(m_visibleRoles
);
454 while (it
.hasNext()) {
456 const QByteArray
& role
= it
.key();
457 KToggleAction
* action
= it
.value();
458 action
->setChecked(checkedRoles
.contains(role
));
462 void DolphinViewActionHandler::toggleGroupedSorting(bool grouped
)
464 m_currentView
->setGroupedSorting(grouped
);
467 void DolphinViewActionHandler::slotGroupedSortingChanged(bool groupedSorting
)
469 QAction
* showInGroupsAction
= m_actionCollection
->action(QStringLiteral("show_in_groups"));
470 showInGroupsAction
->setChecked(groupedSorting
);
473 void DolphinViewActionHandler::toggleShowHiddenFiles(bool show
)
475 emit
actionBeingHandled();
476 m_currentView
->setHiddenFilesShown(show
);
479 void DolphinViewActionHandler::slotHiddenFilesShownChanged(bool shown
)
481 QAction
* showHiddenFilesAction
= m_actionCollection
->action(QStringLiteral("show_hidden_files"));
482 showHiddenFilesAction
->setChecked(shown
);
484 showHiddenFilesAction
->setIcon(QIcon::fromTheme(shown
? QStringLiteral("visibility") : QStringLiteral("hint")));
487 void DolphinViewActionHandler::slotWriteStateChanged(bool isFolderWritable
)
489 m_actionCollection
->action(QStringLiteral("create_dir"))->setEnabled(isFolderWritable
);
492 KToggleAction
* DolphinViewActionHandler::iconsModeAction()
494 KToggleAction
* iconsView
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("icons"));
495 iconsView
->setText(i18nc("@action:inmenu View Mode", "Icons"));
496 iconsView
->setToolTip(i18nc("@info", "Icons view mode"));
497 m_actionCollection
->setDefaultShortcut(iconsView
, Qt::CTRL
| Qt::Key_1
);
498 iconsView
->setIcon(QIcon::fromTheme(QStringLiteral("view-list-icons")));
499 iconsView
->setData(QVariant::fromValue(DolphinView::IconsView
));
503 KToggleAction
* DolphinViewActionHandler::compactModeAction()
505 KToggleAction
* iconsView
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("compact"));
506 iconsView
->setText(i18nc("@action:inmenu View Mode", "Compact"));
507 iconsView
->setToolTip(i18nc("@info", "Compact view mode"));
508 m_actionCollection
->setDefaultShortcut(iconsView
, Qt::CTRL
| Qt::Key_2
);
509 iconsView
->setIcon(QIcon::fromTheme(QStringLiteral("view-list-details"))); // TODO: discuss with Oxygen-team the wrong (?) name
510 iconsView
->setData(QVariant::fromValue(DolphinView::CompactView
));
514 KToggleAction
* DolphinViewActionHandler::detailsModeAction()
516 KToggleAction
* detailsView
= m_actionCollection
->add
<KToggleAction
>(QStringLiteral("details"));
517 detailsView
->setText(i18nc("@action:inmenu View Mode", "Details"));
518 detailsView
->setToolTip(i18nc("@info", "Details view mode"));
519 m_actionCollection
->setDefaultShortcut(detailsView
, Qt::CTRL
| Qt::Key_3
);
520 detailsView
->setIcon(QIcon::fromTheme(QStringLiteral("view-list-tree")));
521 detailsView
->setData(QVariant::fromValue(DolphinView::DetailsView
));
525 void DolphinViewActionHandler::slotSortRoleChanged(const QByteArray
& role
)
527 KToggleAction
* action
= m_sortByActions
.value(role
);
529 action
->setChecked(true);
531 if (!action
->icon().isNull()) {
532 QAction
* sortByMenu
= m_actionCollection
->action(QStringLiteral("sort"));
533 sortByMenu
->setIcon(action
->icon());
538 void DolphinViewActionHandler::slotZoomLevelChanged(int current
, int previous
)
542 QAction
* zoomInAction
= m_actionCollection
->action(KStandardAction::name(KStandardAction::ZoomIn
));
544 zoomInAction
->setEnabled(current
< ZoomLevelInfo::maximumLevel());
547 QAction
* zoomOutAction
= m_actionCollection
->action(KStandardAction::name(KStandardAction::ZoomOut
));
549 zoomOutAction
->setEnabled(current
> ZoomLevelInfo::minimumLevel());
553 void DolphinViewActionHandler::slotSortTriggered(QAction
* action
)
555 // The radiobuttons of the "Sort By"-menu are split between the main-menu
556 // and several sub-menus. Because of this they don't have a common
557 // action-group that assures an exclusive toggle-state between the main-menu
558 // actions and the sub-menu-actions. If an action gets checked, it must
559 // be assured that all other actions get unchecked.
560 QAction
* sortByMenu
= m_actionCollection
->action(QStringLiteral("sort"));
561 foreach (QAction
* groupAction
, sortByMenu
->menu()->actions()) {
562 KActionMenu
* actionMenu
= qobject_cast
<KActionMenu
*>(groupAction
);
564 foreach (QAction
* subAction
, actionMenu
->menu()->actions()) {
565 subAction
->setChecked(false);
567 } else if (groupAction
->actionGroup()) {
568 groupAction
->setChecked(false);
571 action
->setChecked(true);
573 // Apply the activated sort-role to the view
574 const QByteArray role
= action
->data().toByteArray();
575 m_currentView
->setSortRole(role
);
578 void DolphinViewActionHandler::slotAdjustViewProperties()
580 emit
actionBeingHandled();
581 QPointer
<ViewPropertiesDialog
> dialog
= new ViewPropertiesDialog(m_currentView
);
586 void DolphinViewActionHandler::slotProperties()
588 KPropertiesDialog
* dialog
= 0;
589 const KFileItemList list
= m_currentView
->selectedItems();
590 if (list
.isEmpty()) {
591 const QUrl url
= m_currentView
->url();
592 dialog
= new KPropertiesDialog(url
, m_currentView
);
594 dialog
= new KPropertiesDialog(list
, m_currentView
);
597 dialog
->setAttribute(Qt::WA_DeleteOnClose
);
600 dialog
->activateWindow();