X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/f7c2bd34104c592e4111255821432ef83ed4242c..86e3b82efbbcdb287773cdaf6a5f4c1c22bb9fc6:/src/views/dolphinviewactionhandler.cpp diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp index 5697c7f41..29bd530b4 100644 --- a/src/views/dolphinviewactionhandler.cpp +++ b/src/views/dolphinviewactionhandler.cpp @@ -34,7 +34,6 @@ #include #include #include - #include #include @@ -99,7 +98,10 @@ void DolphinViewActionHandler::createActions() // File menu - KStandardAction::renameFile(this, &DolphinViewActionHandler::slotRename, m_actionCollection); + auto renameAction = KStandardAction::renameFile(this, &DolphinViewActionHandler::slotRename, m_actionCollection); + renameAction->setWhatsThis(xi18nc("@info:whatsthis", "This renames the " + "items in your current selection.Renaming multiple items " + "at once amounts to their new names differing only in a number.")); auto trashAction = KStandardAction::moveToTrash(this, &DolphinViewActionHandler::slotTrashActivated, m_actionCollection); auto trashShortcuts = trashAction->shortcuts(); @@ -107,6 +109,10 @@ void DolphinViewActionHandler::createActions() trashShortcuts.append(QKeySequence::Delete); m_actionCollection->setDefaultShortcuts(trashAction, trashShortcuts); } + trashAction->setWhatsThis(xi18nc("@info:whatsthis", "This moves the " + "items in your current selection to the Trash" + ".The trash is a temporary storage where " + "items can be deleted from if disk space is needed.")); auto deleteAction = KStandardAction::deleteFile(this, &DolphinViewActionHandler::slotDeleteItems, m_actionCollection); auto deleteShortcuts = deleteAction->shortcuts(); @@ -114,6 +120,9 @@ void DolphinViewActionHandler::createActions() deleteShortcuts.append(Qt::SHIFT | Qt::Key_Delete); m_actionCollection->setDefaultShortcuts(deleteAction, deleteShortcuts); } + deleteAction->setWhatsThis(xi18nc("@info:whatsthis", "This deletes " + "the items in your current selection completely. They can " + "not be recovered by normal means.")); // This action is useful for being enabled when KStandardAction::MoveToTrash should be // disabled and KStandardAction::DeleteFile is enabled (e.g. non-local files), so that Key_Del @@ -126,44 +135,99 @@ void DolphinViewActionHandler::createActions() deleteWithTrashShortcut->setEnabled(false); connect(deleteWithTrashShortcut, &QAction::triggered, this, &DolphinViewActionHandler::slotDeleteItems); + QAction* duplicateAction = m_actionCollection->addAction(QStringLiteral("duplicate")); + duplicateAction->setText(i18nc("@action:inmenu File", "Duplicate Here")); + duplicateAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-duplicate"))); + m_actionCollection->setDefaultShortcut(duplicateAction, Qt::CTRL | Qt::Key_D); + duplicateAction->setEnabled(false); + connect(duplicateAction, &QAction::triggered, this, &DolphinViewActionHandler::slotDuplicate); + QAction *propertiesAction = m_actionCollection->addAction( QStringLiteral("properties") ); // Well, it's the File menu in dolphinmainwindow and the Edit menu in dolphinpart... :) propertiesAction->setText( i18nc("@action:inmenu File", "Properties") ); + propertiesAction->setWhatsThis(xi18nc("@info:whatsthis properties", + "This shows a complete list of properties of the currently " + "selected items in a new window.If nothing is selected the " + "window will be about the currently viewed folder instead." + "You can configure advanced options there like managing " + "read- and write-permissions.")); propertiesAction->setIcon(QIcon::fromTheme(QStringLiteral("document-properties"))); m_actionCollection->setDefaultShortcuts(propertiesAction, {Qt::ALT + Qt::Key_Return, Qt::ALT + Qt::Key_Enter}); connect(propertiesAction, &QAction::triggered, this, &DolphinViewActionHandler::slotProperties); + QAction *copyPathAction = m_actionCollection->addAction( QStringLiteral("copy_location") ); + copyPathAction->setText(i18nc("@action:incontextmenu", "Copy location")); + copyPathAction->setWhatsThis(i18nc("@info:whatsthis copy_location", + "This will copy the path of the first selected item into the clipboard." + )); + + copyPathAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy"))); + m_actionCollection->setDefaultShortcuts(copyPathAction, {Qt::CTRL + Qt::SHIFT + Qt::Key_C}); + connect(copyPathAction, &QAction::triggered, this, &DolphinViewActionHandler::slotCopyPath); + + // View menu KToggleAction* iconsAction = iconsModeAction(); KToggleAction* compactAction = compactModeAction(); KToggleAction* detailsAction = detailsModeAction(); + iconsAction->setWhatsThis(xi18nc("@info:whatsthis Icons view mode", + "This switches to a view mode that focuses on the folder " + "and file icons. This mode makes it easy to distinguish folders " + "from files and to detect items with distinctive " + "file types. This mode is handy to " + "browse through pictures when the Preview" + " option is enabled.")); + compactAction->setWhatsThis(xi18nc("@info:whatsthis Compact view mode", + "This switches to a compact view mode that lists the folders " + "and files in columns with the names beside the icons." + "This helps to keep the overview in folders with many items.")); + detailsAction->setWhatsThis(xi18nc("@info:whatsthis Details view mode", + "This switches to a list view mode that focuses on folder " + "and file details.Click on a detail in the column " + "header to sort the items by it. Click again to sort the other " + "way around. To select which details should be displayed click " + "the header with the right mouse button.You can " + "view the contents of a folder without leaving the current " + "location by clicking to the left of it. This way you can view " + "the contents of multiple folders in the same list.")); + KSelectAction* viewModeActions = m_actionCollection->add(QStringLiteral("view_mode")); viewModeActions->setText(i18nc("@action:intoolbar", "View Mode")); viewModeActions->addAction(iconsAction); viewModeActions->addAction(compactAction); viewModeActions->addAction(detailsAction); viewModeActions->setToolBarMode(KSelectAction::MenuMode); - connect(viewModeActions, static_cast(&KSelectAction::triggered), this, &DolphinViewActionHandler::slotViewModeActionTriggered); + connect(viewModeActions, QOverload::of(&KSelectAction::triggered), this, &DolphinViewActionHandler::slotViewModeActionTriggered); - KStandardAction::zoomIn(this, + QAction* zoomInAction = KStandardAction::zoomIn(this, &DolphinViewActionHandler::zoomIn, m_actionCollection); + zoomInAction->setWhatsThis(i18nc("@info:whatsthis zoom in", "This increases the icon size.")); + + QAction* zoomResetAction = m_actionCollection->addAction(QStringLiteral("view_zoom_reset")); + zoomResetAction->setText(i18nc("@action:inmenu View", "Reset Zoom Level")); + zoomResetAction->setToolTip(i18n("Zoom To Default")); + zoomResetAction->setWhatsThis(i18nc("@info:whatsthis zoom reset", "This resets the icon size to default.")); + zoomResetAction->setIcon(QIcon::fromTheme(QStringLiteral("zoom-original"))); + m_actionCollection->setDefaultShortcuts(zoomResetAction, {Qt::CTRL + Qt::Key_0}); + connect(zoomResetAction, &QAction::triggered, this, &DolphinViewActionHandler::zoomReset); - KStandardAction::zoomOut(this, + QAction* zoomOutAction = KStandardAction::zoomOut(this, &DolphinViewActionHandler::zoomOut, m_actionCollection); + zoomOutAction->setWhatsThis(i18nc("@info:whatsthis zoom out", "This reduces the icon size.")); KToggleAction* showPreview = m_actionCollection->add(QStringLiteral("show_preview")); - showPreview->setText(i18nc("@action:intoolbar", "Preview")); + showPreview->setText(i18nc("@action:intoolbar", "Show Previews")); showPreview->setToolTip(i18nc("@info", "Show preview of files and folders")); + showPreview->setWhatsThis(xi18nc("@info:whatsthis", "When this is " + "enabled, the icons are based on the actual file or folder " + "contents.For example the icons of images become scaled " + "down versions of the images.")); showPreview->setIcon(QIcon::fromTheme(QStringLiteral("view-preview"))); connect(showPreview, &KToggleAction::triggered, this, &DolphinViewActionHandler::togglePreview); - KToggleAction* sortDescending = m_actionCollection->add(QStringLiteral("descending")); - sortDescending->setText(i18nc("@action:inmenu Sort", "Descending")); - connect(sortDescending, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleSortOrder); - KToggleAction* sortFoldersFirst = m_actionCollection->add(QStringLiteral("folders_first")); sortFoldersFirst->setText(i18nc("@action:inmenu Sort", "Folders First")); connect(sortFoldersFirst, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleSortFoldersFirst); @@ -172,21 +236,42 @@ void DolphinViewActionHandler::createActions() QActionGroup* sortByActionGroup = createFileItemRolesActionGroup(QStringLiteral("sort_by_")); KActionMenu* sortByActionMenu = m_actionCollection->add(QStringLiteral("sort")); + sortByActionMenu->setIcon(QIcon::fromTheme(QStringLiteral("view-sort"))); sortByActionMenu->setText(i18nc("@action:inmenu View", "Sort By")); sortByActionMenu->setDelayed(false); foreach (QAction* action, sortByActionGroup->actions()) { sortByActionMenu->addAction(action); } + + sortByActionMenu->addSeparator(); + + QActionGroup* group = new QActionGroup(sortByActionMenu); + group->setExclusive(true); + + KToggleAction* ascendingAction = m_actionCollection->add(QStringLiteral("ascending")); + ascendingAction->setActionGroup(group); + connect(ascendingAction, &QAction::triggered, this, [this] { + m_currentView->setSortOrder(Qt::AscendingOrder); + }); + + KToggleAction* descendingAction = m_actionCollection->add(QStringLiteral("descending")); + descendingAction->setActionGroup(group); + connect(descendingAction, &QAction::triggered, this, [this] { + m_currentView->setSortOrder(Qt::DescendingOrder); + }); + + sortByActionMenu->addAction(ascendingAction); + sortByActionMenu->addAction(descendingAction); sortByActionMenu->addSeparator(); - sortByActionMenu->addAction(sortDescending); sortByActionMenu->addAction(sortFoldersFirst); // View -> Additional Information QActionGroup* visibleRolesGroup = createFileItemRolesActionGroup(QStringLiteral("show_")); KActionMenu* visibleRolesMenu = m_actionCollection->add(QStringLiteral("additional_info")); - visibleRolesMenu->setText(i18nc("@action:inmenu View", "Additional Information")); + visibleRolesMenu->setText(i18nc("@action:inmenu View", "Show Additional Information")); + visibleRolesMenu->setIcon(QIcon::fromTheme(QStringLiteral("documentinfo"))); visibleRolesMenu->setDelayed(false); foreach (QAction* action, visibleRolesGroup->actions()) { @@ -196,23 +281,33 @@ void DolphinViewActionHandler::createActions() KToggleAction* showInGroups = m_actionCollection->add(QStringLiteral("show_in_groups")); showInGroups->setIcon(QIcon::fromTheme(QStringLiteral("view-group"))); showInGroups->setText(i18nc("@action:inmenu View", "Show in Groups")); + showInGroups->setWhatsThis(i18nc("@info:whatsthis", "This groups files and folders by their first letter.")); connect(showInGroups, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleGroupedSorting); KToggleAction* showHiddenFiles = m_actionCollection->add(QStringLiteral("show_hidden_files")); - showHiddenFiles->setText(i18nc("@action:inmenu View", "Hidden Files")); + showHiddenFiles->setText(i18nc("@action:inmenu View", "Show Hidden Files")); showHiddenFiles->setToolTip(i18nc("@info", "Visibility of hidden files and folders")); - m_actionCollection->setDefaultShortcuts(showHiddenFiles, {Qt::ALT + Qt::Key_Period, Qt::CTRL + Qt::Key_H, Qt::Key_F8}); + showHiddenFiles->setWhatsThis(xi18nc("@info:whatsthis", "When " + "this is enabled hidden files and folders " + "are visible. They will be displayed semi-transparent." + "Hidden items only differ from other ones in that their " + "name starts with a \".\". In general there is no need for " + "users to access them which is why they are hidden.")); + m_actionCollection->setDefaultShortcuts(showHiddenFiles, KStandardShortcut::showHideHiddenFiles()); connect(showHiddenFiles, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleShowHiddenFiles); QAction* adjustViewProps = m_actionCollection->addAction(QStringLiteral("view_properties")); - adjustViewProps->setText(i18nc("@action:inmenu View", "Adjust View Properties...")); + adjustViewProps->setText(i18nc("@action:inmenu View", "Adjust View Display Style...")); + adjustViewProps->setIcon(QIcon::fromTheme(QStringLiteral("view-choose"))); + adjustViewProps->setWhatsThis(i18nc("@info:whatsthis", "This opens a window " + "in which all folder view properties can be adjusted.")); connect(adjustViewProps, &QAction::triggered, this, &DolphinViewActionHandler::slotAdjustViewProperties); } QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QString& groupPrefix) { const bool isSortGroup = (groupPrefix == QLatin1String("sort_by_")); - Q_ASSERT(isSortGroup || (!isSortGroup && groupPrefix == QLatin1String("show_"))); + Q_ASSERT(isSortGroup || groupPrefix == QLatin1String("show_")); QActionGroup* rolesActionGroup = new QActionGroup(m_actionCollection); rolesActionGroup->setExclusive(isSortGroup); @@ -321,9 +416,9 @@ void DolphinViewActionHandler::togglePreview(bool show) void DolphinViewActionHandler::slotPreviewsShownChanged(bool shown) { - Q_UNUSED(shown); + Q_UNUSED(shown) // It is not enough to update the 'Show Preview' action, also - // the 'Zoom In' and 'Zoom Out' actions must be adapted. + // the 'Zoom In', 'Zoom Out' and 'Zoom Reset' actions must be adapted. updateViewActions(); } @@ -386,12 +481,10 @@ void DolphinViewActionHandler::zoomOut() updateViewActions(); } -void DolphinViewActionHandler::toggleSortOrder() +void DolphinViewActionHandler::zoomReset() { - const Qt::SortOrder order = (m_currentView->sortOrder() == Qt::AscendingOrder) ? - Qt::DescendingOrder : - Qt::AscendingOrder; - m_currentView->setSortOrder(order); + m_currentView->resetZoomLevel(); + updateViewActions(); } void DolphinViewActionHandler::toggleSortFoldersFirst() @@ -403,8 +496,10 @@ void DolphinViewActionHandler::toggleSortFoldersFirst() void DolphinViewActionHandler::slotSortOrderChanged(Qt::SortOrder order) { QAction* descending = m_actionCollection->action(QStringLiteral("descending")); + QAction* ascending = m_actionCollection->action(QStringLiteral("ascending")); const bool sortDescending = (order == Qt::DescendingOrder); descending->setChecked(sortDescending); + ascending->setChecked(!sortDescending); } void DolphinViewActionHandler::slotSortFoldersFirstChanged(bool foldersFirst) @@ -437,7 +532,7 @@ void DolphinViewActionHandler::toggleVisibleRole(QAction* action) void DolphinViewActionHandler::slotVisibleRolesChanged(const QList& current, const QList& previous) { - Q_UNUSED(previous); + Q_UNUSED(previous) const QSet checkedRoles = current.toSet(); QHashIterator it(m_visibleRoles); @@ -473,11 +568,11 @@ void DolphinViewActionHandler::slotHiddenFilesShownChanged(bool shown) // #374508: don't overwrite custom icons. const QString iconName = showHiddenFilesAction->icon().name(); - if (!iconName.isEmpty() && iconName != QLatin1String("visibility") && iconName != QLatin1String("hint")) { + if (!iconName.isEmpty() && iconName != QLatin1String("view-visible") && iconName != QLatin1String("view-hidden")) { return; } - showHiddenFilesAction->setIcon(QIcon::fromTheme(shown ? QStringLiteral("visibility") : QStringLiteral("hint"))); + showHiddenFilesAction->setIcon(QIcon::fromTheme(shown ? QStringLiteral("view-visible") : QStringLiteral("view-hidden"))); } void DolphinViewActionHandler::slotWriteStateChanged(bool isFolderWritable) @@ -530,11 +625,33 @@ void DolphinViewActionHandler::slotSortRoleChanged(const QByteArray& role) sortByMenu->setIcon(action->icon()); } } + + QAction* descending = m_actionCollection->action(QStringLiteral("descending")); + QAction* ascending = m_actionCollection->action(QStringLiteral("ascending")); + + if (role == "text" || role == "type" || role == "tags" || role == "comment") { + descending->setText(i18nc("Sort descending", "Z-A")); + ascending->setText(i18nc("Sort ascending", "A-Z")); + } else if (role == "size") { + descending->setText(i18nc("Sort descending", "Largest first")); + ascending->setText(i18nc("Sort ascending", "Smallest first")); + } else if (role == "modificationtime" || role == "creationtime" || role == "accesstime") { + descending->setText(i18nc("Sort descending", "Newest first")); + ascending->setText(i18nc("Sort ascending", "Oldest first")); + } else if (role == "rating") { + descending->setText(i18nc("Sort descending", "Highest first")); + ascending->setText(i18nc("Sort ascending", "Lowest first")); + } else { + descending->setText(i18nc("Sort descending", "Descending")); + ascending->setText(i18nc("Sort ascending", "Ascending")); + } + + slotSortOrderChanged(m_currentView->sortOrder()); } void DolphinViewActionHandler::slotZoomLevelChanged(int current, int previous) { - Q_UNUSED(previous); + Q_UNUSED(previous) QAction* zoomInAction = m_actionCollection->action(KStandardAction::name(KStandardAction::ZoomIn)); if (zoomInAction) { @@ -553,9 +670,9 @@ void DolphinViewActionHandler::slotSortTriggered(QAction* action) // and several sub-menus. Because of this they don't have a common // action-group that assures an exclusive toggle-state between the main-menu // actions and the sub-menu-actions. If an action gets checked, it must - // be assured that all other actions get unchecked. - QAction* sortByMenu = m_actionCollection->action(QStringLiteral("sort")); - foreach (QAction* groupAction, sortByMenu->menu()->actions()) { + // be assured that all other actions get unchecked, except the ascending/ + // descending actions + for (QAction *groupAction : qAsConst(m_sortByActions)) { KActionMenu* actionMenu = qobject_cast(groupAction); if (actionMenu) { foreach (QAction* subAction, actionMenu->menu()->actions()) { @@ -580,6 +697,12 @@ void DolphinViewActionHandler::slotAdjustViewProperties() delete dialog; } +void DolphinViewActionHandler::slotDuplicate() +{ + emit actionBeingHandled(); + m_currentView->duplicateSelectedItems(); +} + void DolphinViewActionHandler::slotProperties() { KPropertiesDialog* dialog = nullptr; @@ -596,3 +719,8 @@ void DolphinViewActionHandler::slotProperties() dialog->raise(); dialog->activateWindow(); } + +void DolphinViewActionHandler::slotCopyPath() +{ + m_currentView->copyPathToClipboard(); +}