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