]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/dolphinviewactionhandler.cpp
Add some missing includes.
[dolphin.git] / src / views / dolphinviewactionhandler.cpp
1 /***************************************************************************
2 * Copyright (C) 2008 by David Faure <faure@kde.org> *
3 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
4 * *
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. *
9 * *
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. *
14 * *
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 ***************************************************************************/
20
21 #include "dolphinviewactionhandler.h"
22
23 #include <config-nepomuk.h>
24
25 #include "settings/viewpropertiesdialog.h"
26 #include "views/dolphinview.h"
27 #include "views/zoomlevelinfo.h"
28 #include <konq_operations.h>
29
30 #include <KAction>
31 #include <KActionCollection>
32 #include <KActionMenu>
33 #include <kitemviews/kfileitemmodel.h>
34 #include <KLocale>
35 #include <KMenu>
36 #include <KNewFileMenu>
37 #include <KSelectAction>
38 #include <KToggleAction>
39 #include <KRun>
40 #include <KPropertiesDialog>
41 #include <KIcon>
42
43 #ifdef HAVE_NEPOMUK
44 #include <Nepomuk/ResourceManager>
45 #endif
46
47 #include <KDebug>
48
49 DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection* collection, QObject* parent) :
50 QObject(parent),
51 m_actionCollection(collection),
52 m_currentView(0),
53 m_sortByActions(),
54 m_visibleRoles()
55 {
56 Q_ASSERT(m_actionCollection);
57 createActions();
58 }
59
60 void DolphinViewActionHandler::setCurrentView(DolphinView* view)
61 {
62 Q_ASSERT(view);
63
64 if (m_currentView) {
65 disconnect(m_currentView, 0, this, 0);
66 }
67
68 m_currentView = view;
69
70 connect(view, SIGNAL(modeChanged(DolphinView::Mode,DolphinView::Mode)),
71 this, SLOT(updateViewActions()));
72 connect(view, SIGNAL(previewsShownChanged(bool)),
73 this, SLOT(slotPreviewsShownChanged(bool)));
74 connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)),
75 this, SLOT(slotSortOrderChanged(Qt::SortOrder)));
76 connect(view, SIGNAL(sortFoldersFirstChanged(bool)),
77 this, SLOT(slotSortFoldersFirstChanged(bool)));
78 connect(view, SIGNAL(visibleRolesChanged(QList<QByteArray>,QList<QByteArray>)),
79 this, SLOT(slotVisibleRolesChanged(QList<QByteArray>,QList<QByteArray>)));
80 connect(view, SIGNAL(groupedSortingChanged(bool)),
81 this, SLOT(slotGroupedSortingChanged(bool)));
82 connect(view, SIGNAL(hiddenFilesShownChanged(bool)),
83 this, SLOT(slotHiddenFilesShownChanged(bool)));
84 connect(view, SIGNAL(sortRoleChanged(QByteArray)),
85 this, SLOT(slotSortRoleChanged(QByteArray)));
86 connect(view, SIGNAL(zoomLevelChanged(int,int)),
87 this, SLOT(slotZoomLevelChanged(int,int)));
88 }
89
90 DolphinView* DolphinViewActionHandler::currentView()
91 {
92 return m_currentView;
93 }
94
95 void DolphinViewActionHandler::createActions()
96 {
97 // This action doesn't appear in the GUI, it's for the shortcut only.
98 // KNewFileMenu takes care of the GUI stuff.
99 KAction* newDirAction = m_actionCollection->addAction("create_dir");
100 newDirAction->setText(i18nc("@action", "Create Folder..."));
101 newDirAction->setShortcut(Qt::Key_F10);
102 newDirAction->setIcon(KIcon("folder-new"));
103 connect(newDirAction, SIGNAL(triggered()), this, SIGNAL(createDirectory()));
104
105 // File menu
106
107 KAction* rename = m_actionCollection->addAction("rename");
108 rename->setText(i18nc("@action:inmenu File", "Rename..."));
109 rename->setShortcut(Qt::Key_F2);
110 rename->setIcon(KIcon("edit-rename"));
111 connect(rename, SIGNAL(triggered()), this, SLOT(slotRename()));
112
113 KAction* moveToTrash = m_actionCollection->addAction("move_to_trash");
114 moveToTrash->setText(i18nc("@action:inmenu File", "Move to Trash"));
115 moveToTrash->setIcon(KIcon("user-trash"));
116 moveToTrash->setShortcut(QKeySequence::Delete);
117 connect(moveToTrash, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)),
118 this, SLOT(slotTrashActivated(Qt::MouseButtons,Qt::KeyboardModifiers)));
119
120 KAction* deleteAction = m_actionCollection->addAction("delete");
121 deleteAction->setIcon(KIcon("edit-delete"));
122 deleteAction->setText(i18nc("@action:inmenu File", "Delete"));
123 deleteAction->setShortcut(Qt::SHIFT | Qt::Key_Delete);
124 connect(deleteAction, SIGNAL(triggered()), this, SLOT(slotDeleteItems()));
125
126 // This action is useful for being enabled when "move_to_trash" should be
127 // disabled and "delete" is enabled (e.g. non-local files), so that Key_Del
128 // can be used for deleting the file (#76016). It needs to be a separate action
129 // so that the Edit menu isn't affected.
130 KAction* deleteWithTrashShortcut = m_actionCollection->addAction("delete_shortcut");
131 // The descriptive text is just for the shortcuts editor.
132 deleteWithTrashShortcut->setText(i18nc("@action \"Move to Trash\" for non-local files, etc.", "Delete (using shortcut for Trash)"));
133 deleteWithTrashShortcut->setShortcut(QKeySequence::Delete);
134 deleteWithTrashShortcut->setEnabled(false);
135 connect(deleteWithTrashShortcut, SIGNAL(triggered()), this, SLOT(slotDeleteItems()));
136
137 KAction *propertiesAction = m_actionCollection->addAction( "properties" );
138 // Well, it's the File menu in dolphinmainwindow and the Edit menu in dolphinpart... :)
139 propertiesAction->setText( i18nc("@action:inmenu File", "Properties") );
140 propertiesAction->setIcon(KIcon("document-properties"));
141 propertiesAction->setShortcut(Qt::ALT | Qt::Key_Return);
142 connect(propertiesAction, SIGNAL(triggered()), SLOT(slotProperties()));
143
144 // View menu
145 KToggleAction* iconsAction = iconsModeAction();
146 KToggleAction* compactAction = compactModeAction();
147 KToggleAction* detailsAction = detailsModeAction();
148
149 KSelectAction* viewModeActions = m_actionCollection->add<KSelectAction>("view_mode");
150 viewModeActions->setText(i18nc("@action:intoolbar", "View Mode"));
151 viewModeActions->addAction(iconsAction);
152 viewModeActions->addAction(compactAction);
153 viewModeActions->addAction(detailsAction);
154 viewModeActions->setToolBarMode(KSelectAction::MenuMode);
155 connect(viewModeActions, SIGNAL(triggered(QAction*)), this, SLOT(slotViewModeActionTriggered(QAction*)));
156
157 KStandardAction::zoomIn(this,
158 SLOT(zoomIn()),
159 m_actionCollection);
160
161 KStandardAction::zoomOut(this,
162 SLOT(zoomOut()),
163 m_actionCollection);
164
165 KToggleAction* showPreview = m_actionCollection->add<KToggleAction>("show_preview");
166 showPreview->setText(i18nc("@action:intoolbar", "Preview"));
167 showPreview->setToolTip(i18nc("@info", "Show preview of files and folders"));
168 showPreview->setIcon(KIcon("view-preview"));
169 connect(showPreview, SIGNAL(triggered(bool)), this, SLOT(togglePreview(bool)));
170
171 KToggleAction* sortDescending = m_actionCollection->add<KToggleAction>("descending");
172 sortDescending->setText(i18nc("@action:inmenu Sort", "Descending"));
173 connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
174
175 KToggleAction* sortFoldersFirst = m_actionCollection->add<KToggleAction>("folders_first");
176 sortFoldersFirst->setText(i18nc("@action:inmenu Sort", "Folders First"));
177 connect(sortFoldersFirst, SIGNAL(triggered()), this, SLOT(toggleSortFoldersFirst()));
178
179 // View -> Sort By
180 QActionGroup* sortByActionGroup = createFileItemRolesActionGroup("sort_by_");
181
182 KActionMenu* sortByActionMenu = m_actionCollection->add<KActionMenu>("sort");
183 sortByActionMenu->setText(i18nc("@action:inmenu View", "Sort By"));
184 sortByActionMenu->setDelayed(false);
185
186 foreach (QAction* action, sortByActionGroup->actions()) {
187 sortByActionMenu->addAction(action);
188 }
189 sortByActionMenu->addSeparator();
190 sortByActionMenu->addAction(sortDescending);
191 sortByActionMenu->addAction(sortFoldersFirst);
192
193 // View -> Additional Information
194 QActionGroup* visibleRolesGroup = createFileItemRolesActionGroup("show_");
195
196 KActionMenu* visibleRolesMenu = m_actionCollection->add<KActionMenu>("additional_info");
197 visibleRolesMenu->setText(i18nc("@action:inmenu View", "Additional Information"));
198 visibleRolesMenu->setDelayed(false);
199
200 foreach (QAction* action, visibleRolesGroup->actions()) {
201 visibleRolesMenu->addAction(action);
202 }
203
204 KToggleAction* showInGroups = m_actionCollection->add<KToggleAction>("show_in_groups");
205 showInGroups->setIcon(KIcon("view-group"));
206 showInGroups->setText(i18nc("@action:inmenu View", "Show in Groups"));
207 connect(showInGroups, SIGNAL(triggered(bool)), this, SLOT(toggleGroupedSorting(bool)));
208
209 KToggleAction* showHiddenFiles = m_actionCollection->add<KToggleAction>("show_hidden_files");
210 showHiddenFiles->setText(i18nc("@action:inmenu View", "Show Hidden Files"));
211 showHiddenFiles->setShortcuts(QList<QKeySequence>() << Qt::ALT + Qt::Key_Period << Qt::Key_F8);
212 connect(showHiddenFiles, SIGNAL(triggered(bool)), this, SLOT(toggleShowHiddenFiles(bool)));
213
214 KAction* adjustViewProps = m_actionCollection->addAction("view_properties");
215 adjustViewProps->setText(i18nc("@action:inmenu View", "Adjust View Properties..."));
216 connect(adjustViewProps, SIGNAL(triggered()), this, SLOT(slotAdjustViewProperties()));
217 }
218
219 QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QString& groupPrefix)
220 {
221 const bool isSortGroup = (groupPrefix == QLatin1String("sort_by_"));
222 Q_ASSERT(isSortGroup || (!isSortGroup && groupPrefix == QLatin1String("show_")));
223
224 QActionGroup* rolesActionGroup = new QActionGroup(m_actionCollection);
225 rolesActionGroup->setExclusive(isSortGroup);
226 if (isSortGroup) {
227 connect(rolesActionGroup, SIGNAL(triggered(QAction*)),
228 this, SLOT(slotSortTriggered(QAction*)));
229 } else {
230 connect(rolesActionGroup, SIGNAL(triggered(QAction*)),
231 this, SLOT(toggleVisibleRole(QAction*)));
232 }
233
234 QString groupName;
235 KActionMenu* groupMenu = 0;
236 QActionGroup* groupMenuGroup = 0;
237
238 bool nepomukRunning = false;
239 bool indexingEnabled = false;
240 #ifdef HAVE_NEPOMUK
241 nepomukRunning = (Nepomuk::ResourceManager::instance()->init() == 0);
242 if (nepomukRunning) {
243 KConfig config("nepomukserverrc");
244 indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", false);
245 }
246 #endif
247
248 const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
249 foreach (const KFileItemModel::RoleInfo& info, rolesInfo) {
250 if (!isSortGroup && info.role == "name") {
251 // It should not be possible to hide the "name" role
252 continue;
253 }
254
255 KToggleAction* action = 0;
256 const QString name = groupPrefix + info.role;
257 if (info.group.isEmpty()) {
258 action = m_actionCollection->add<KToggleAction>(name);
259 action->setActionGroup(rolesActionGroup);
260 } else {
261 if (!groupMenu || info.group != groupName) {
262 groupName = info.group;
263 groupMenu = m_actionCollection->add<KActionMenu>(groupName);
264 groupMenu->setText(groupName);
265 groupMenu->setActionGroup(rolesActionGroup);
266
267 groupMenuGroup = new QActionGroup(groupMenu);
268 groupMenuGroup->setExclusive(isSortGroup);
269 if (isSortGroup) {
270 connect(groupMenuGroup, SIGNAL(triggered(QAction*)),
271 this, SLOT(slotSortTriggered(QAction*)));
272 } else {
273 connect(groupMenuGroup, SIGNAL(triggered(QAction*)),
274 this, SLOT(toggleVisibleRole(QAction*)));
275 }
276 }
277
278 action = new KToggleAction(groupMenu);
279 action->setActionGroup(groupMenuGroup);
280 groupMenu->addAction(action);
281 }
282 action->setText(info.translation);
283 action->setData(info.role);
284
285 const bool enable = (!info.requiresNepomuk && !info.requiresIndexer) ||
286 (info.requiresNepomuk && nepomukRunning) ||
287 (info.requiresIndexer && indexingEnabled);
288 action->setEnabled(enable);
289
290 if (isSortGroup) {
291 m_sortByActions.insert(info.role, action);
292 } else {
293 m_visibleRoles.insert(info.role, action);
294 }
295 }
296
297 return rolesActionGroup;
298 }
299
300 void DolphinViewActionHandler::slotViewModeActionTriggered(QAction* action)
301 {
302 const DolphinView::Mode mode = action->data().value<DolphinView::Mode>();
303 m_currentView->setMode(mode);
304
305 QAction* viewModeMenu = m_actionCollection->action("view_mode");
306 viewModeMenu->setIcon(KIcon(action->icon()));
307 }
308
309 void DolphinViewActionHandler::slotRename()
310 {
311 emit actionBeingHandled();
312 m_currentView->renameSelectedItems();
313 }
314
315 void DolphinViewActionHandler::slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers modifiers)
316 {
317 emit actionBeingHandled();
318 // Note: kde3's konq_mainwindow.cpp used to check
319 // reason == KAction::PopupMenuActivation && ...
320 // but this isn't supported anymore
321 if (modifiers & Qt::ShiftModifier) {
322 m_currentView->deleteSelectedItems();
323 } else {
324 m_currentView->trashSelectedItems();
325 }
326 }
327
328 void DolphinViewActionHandler::slotDeleteItems()
329 {
330 emit actionBeingHandled();
331 m_currentView->deleteSelectedItems();
332 }
333
334 void DolphinViewActionHandler::togglePreview(bool show)
335 {
336 emit actionBeingHandled();
337 m_currentView->setPreviewsShown(show);
338 }
339
340 void DolphinViewActionHandler::slotPreviewsShownChanged(bool shown)
341 {
342 Q_UNUSED(shown);
343 // It is not enough to update the 'Show Preview' action, also
344 // the 'Zoom In' and 'Zoom Out' actions must be adapted.
345 updateViewActions();
346 }
347
348 QString DolphinViewActionHandler::currentViewModeActionName() const
349 {
350 switch (m_currentView->mode()) {
351 case DolphinView::IconsView:
352 return "icons";
353 case DolphinView::DetailsView:
354 return "details";
355 case DolphinView::CompactView:
356 return "compact";
357 default:
358 Q_ASSERT(false);
359 break;
360 }
361 return QString(); // can't happen
362 }
363
364 KActionCollection* DolphinViewActionHandler::actionCollection()
365 {
366 return m_actionCollection;
367 }
368
369 void DolphinViewActionHandler::updateViewActions()
370 {
371 QAction* viewModeAction = m_actionCollection->action(currentViewModeActionName());
372 if (viewModeAction) {
373 viewModeAction->setChecked(true);
374
375 QAction* viewModeMenu = m_actionCollection->action("view_mode");
376 viewModeMenu->setIcon(KIcon(viewModeAction->icon()));
377 }
378
379 QAction* showPreviewAction = m_actionCollection->action("show_preview");
380 showPreviewAction->setChecked(m_currentView->previewsShown());
381
382 slotSortOrderChanged(m_currentView->sortOrder());
383 slotSortFoldersFirstChanged(m_currentView->sortFoldersFirst());
384 slotVisibleRolesChanged(m_currentView->visibleRoles(), QList<QByteArray>());
385 slotGroupedSortingChanged(m_currentView->groupedSorting());
386 slotSortRoleChanged(m_currentView->sortRole());
387 slotZoomLevelChanged(m_currentView->zoomLevel(), -1);
388
389 QAction* showHiddenFilesAction = m_actionCollection->action("show_hidden_files");
390 showHiddenFilesAction->setChecked(m_currentView->hiddenFilesShown());
391 }
392
393 void DolphinViewActionHandler::zoomIn()
394 {
395 const int level = m_currentView->zoomLevel();
396 m_currentView->setZoomLevel(level + 1);
397 updateViewActions();
398 }
399
400 void DolphinViewActionHandler::zoomOut()
401 {
402 const int level = m_currentView->zoomLevel();
403 m_currentView->setZoomLevel(level - 1);
404 updateViewActions();
405 }
406
407 void DolphinViewActionHandler::toggleSortOrder()
408 {
409 const Qt::SortOrder order = (m_currentView->sortOrder() == Qt::AscendingOrder) ?
410 Qt::DescendingOrder :
411 Qt::AscendingOrder;
412 m_currentView->setSortOrder(order);
413 }
414
415 void DolphinViewActionHandler::toggleSortFoldersFirst()
416 {
417 const bool sortFirst = m_currentView->sortFoldersFirst();
418 m_currentView->setSortFoldersFirst(!sortFirst);
419 }
420
421 void DolphinViewActionHandler::slotSortOrderChanged(Qt::SortOrder order)
422 {
423 QAction* descending = m_actionCollection->action("descending");
424 const bool sortDescending = (order == Qt::DescendingOrder);
425 descending->setChecked(sortDescending);
426 }
427
428 void DolphinViewActionHandler::slotSortFoldersFirstChanged(bool foldersFirst)
429 {
430 m_actionCollection->action("folders_first")->setChecked(foldersFirst);
431 }
432
433 void DolphinViewActionHandler::toggleVisibleRole(QAction* action)
434 {
435 emit actionBeingHandled();
436
437 const QByteArray toggledRole = action->data().toByteArray();
438
439 QList<QByteArray> roles = m_currentView->visibleRoles();
440
441 const bool show = action->isChecked();
442
443 const int index = roles.indexOf(toggledRole);
444 const bool containsInfo = (index >= 0);
445 if (show && !containsInfo) {
446 roles.append(toggledRole);
447 m_currentView->setVisibleRoles(roles);
448 } else if (!show && containsInfo) {
449 roles.removeAt(index);
450 m_currentView->setVisibleRoles(roles);
451 Q_ASSERT(roles.indexOf(toggledRole) < 0);
452 }
453 }
454
455 void DolphinViewActionHandler::slotVisibleRolesChanged(const QList<QByteArray>& current,
456 const QList<QByteArray>& previous)
457 {
458 Q_UNUSED(previous);
459
460 const QSet<QByteArray> checkedRoles = current.toSet();
461 QHashIterator<QByteArray, KToggleAction*> it(m_visibleRoles);
462 while (it.hasNext()) {
463 it.next();
464 const QByteArray& role = it.key();
465 KToggleAction* action = it.value();
466 action->setChecked(checkedRoles.contains(role));
467 }
468 }
469
470 void DolphinViewActionHandler::toggleGroupedSorting(bool grouped)
471 {
472 m_currentView->setGroupedSorting(grouped);
473 }
474
475 void DolphinViewActionHandler::slotGroupedSortingChanged(bool groupedSorting)
476 {
477 QAction* showInGroupsAction = m_actionCollection->action("show_in_groups");
478 showInGroupsAction->setChecked(groupedSorting);
479 }
480
481 void DolphinViewActionHandler::toggleShowHiddenFiles(bool show)
482 {
483 emit actionBeingHandled();
484 m_currentView->setHiddenFilesShown(show);
485 }
486
487 void DolphinViewActionHandler::slotHiddenFilesShownChanged(bool shown)
488 {
489 QAction* showHiddenFilesAction = m_actionCollection->action("show_hidden_files");
490 showHiddenFilesAction->setChecked(shown);
491 }
492
493 KToggleAction* DolphinViewActionHandler::iconsModeAction()
494 {
495 KToggleAction* iconsView = m_actionCollection->add<KToggleAction>("icons");
496 iconsView->setText(i18nc("@action:inmenu View Mode", "Icons"));
497 iconsView->setToolTip(i18nc("@info", "Icons view mode"));
498 iconsView->setShortcut(Qt::CTRL | Qt::Key_1);
499 iconsView->setIcon(KIcon("view-list-icons"));
500 iconsView->setData(QVariant::fromValue(DolphinView::IconsView));
501 return iconsView;
502 }
503
504 KToggleAction* DolphinViewActionHandler::compactModeAction()
505 {
506 KToggleAction* iconsView = m_actionCollection->add<KToggleAction>("compact");
507 iconsView->setText(i18nc("@action:inmenu View Mode", "Compact"));
508 iconsView->setToolTip(i18nc("@info", "Compact view mode"));
509 iconsView->setShortcut(Qt::CTRL | Qt::Key_2);
510 iconsView->setIcon(KIcon("view-list-details")); // TODO: discuss with Oxygen-team the wrong (?) name
511 iconsView->setData(QVariant::fromValue(DolphinView::CompactView));
512 return iconsView;
513 }
514
515 KToggleAction* DolphinViewActionHandler::detailsModeAction()
516 {
517 KToggleAction* detailsView = m_actionCollection->add<KToggleAction>("details");
518 detailsView->setText(i18nc("@action:inmenu View Mode", "Details"));
519 detailsView->setToolTip(i18nc("@info", "Details view mode"));
520 detailsView->setShortcut(Qt::CTRL | Qt::Key_3);
521 detailsView->setIcon(KIcon("view-list-tree"));
522 detailsView->setData(QVariant::fromValue(DolphinView::DetailsView));
523 return detailsView;
524 }
525
526 void DolphinViewActionHandler::slotSortRoleChanged(const QByteArray& role)
527 {
528 KToggleAction* action = m_sortByActions.value(role);
529 if (action) {
530 action->setChecked(true);
531
532 QAction* sortByMenu = m_actionCollection->action("sort");
533 sortByMenu->setIcon(KIcon(action->icon()));
534 }
535 }
536
537 void DolphinViewActionHandler::slotZoomLevelChanged(int current, int previous)
538 {
539 Q_UNUSED(previous);
540
541 QAction* zoomInAction = m_actionCollection->action(KStandardAction::name(KStandardAction::ZoomIn));
542 if (zoomInAction) {
543 zoomInAction->setEnabled(current < ZoomLevelInfo::maximumLevel());
544 }
545
546 QAction* zoomOutAction = m_actionCollection->action(KStandardAction::name(KStandardAction::ZoomOut));
547 if (zoomOutAction) {
548 zoomOutAction->setEnabled(current > ZoomLevelInfo::minimumLevel());
549 }
550 }
551
552 void DolphinViewActionHandler::slotSortTriggered(QAction* action)
553 {
554 // The radiobuttons of the "Sort By"-menu are split between the main-menu
555 // and several sub-menus. Because of this they don't have a common
556 // action-group that assures an exclusive toggle-state between the main-menu
557 // actions and the sub-menu-actions. If an action gets checked, it must
558 // be assured that all other actions get unchecked.
559 QAction* sortByMenu = m_actionCollection->action("sort");
560 foreach (QAction* groupAction, sortByMenu->menu()->actions()) {
561 KActionMenu* actionMenu = qobject_cast<KActionMenu*>(groupAction);
562 if (actionMenu) {
563 foreach (QAction* subAction, actionMenu->menu()->actions()) {
564 subAction->setChecked(false);
565 }
566 } else if (groupAction->actionGroup()) {
567 groupAction->setChecked(false);
568 }
569 }
570 action->setChecked(true);
571
572 // Apply the activated sort-role to the view
573 const QByteArray role = action->data().toByteArray();
574 m_currentView->setSortRole(role);
575 }
576
577 void DolphinViewActionHandler::slotAdjustViewProperties()
578 {
579 emit actionBeingHandled();
580 QPointer<ViewPropertiesDialog> dialog = new ViewPropertiesDialog(m_currentView);
581 dialog->exec();
582 delete dialog;
583 }
584
585 void DolphinViewActionHandler::slotProperties()
586 {
587 KPropertiesDialog* dialog = 0;
588 const KFileItemList list = m_currentView->selectedItems();
589 if (list.isEmpty()) {
590 const KUrl url = m_currentView->url();
591 dialog = new KPropertiesDialog(url, m_currentView);
592 } else {
593 dialog = new KPropertiesDialog(list, m_currentView);
594 }
595
596 dialog->setAttribute(Qt::WA_DeleteOnClose);
597 dialog->show();
598 dialog->raise();
599 dialog->activateWindow();
600 }