]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinviewactionhandler.cpp
Don't overload the word "Properties" to mean multiple things
[dolphin.git] / src / views / dolphinviewactionhandler.cpp
index 18b1c2d97096bc960057fe6ce47ccda1907a1257..ef9f317ee16d20e3399d6e46b41d1bd33d0ef4b2 100644 (file)
@@ -188,13 +188,21 @@ void DolphinViewActionHandler::createActions()
                             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);
+
     QAction* zoomOutAction = KStandardAction::zoomOut(this,
                              &DolphinViewActionHandler::zoomOut,
                              m_actionCollection);
-    zoomOutAction->setWhatsThis(i18nc("@info:whatsthis zoom in", "This reduces the icon size."));
+    zoomOutAction->setWhatsThis(i18nc("@info:whatsthis zoom out", "This reduces the icon size."));
 
     KToggleAction* showPreview = m_actionCollection->add<KToggleAction>(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 "
@@ -245,7 +253,8 @@ void DolphinViewActionHandler::createActions()
     QActionGroup* visibleRolesGroup = createFileItemRolesActionGroup(QStringLiteral("show_"));
 
     KActionMenu* visibleRolesMenu = m_actionCollection->add<KActionMenu>(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()) {
@@ -259,7 +268,7 @@ void DolphinViewActionHandler::createActions()
     connect(showInGroups, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleGroupedSorting);
 
     KToggleAction* showHiddenFiles = m_actionCollection->add<KToggleAction>(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"));
     showHiddenFiles->setWhatsThis(xi18nc("@info:whatsthis", "<para>When "
         "this is enabled <emphasis>hidden</emphasis> files and folders "
@@ -271,7 +280,8 @@ void DolphinViewActionHandler::createActions()
     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);
@@ -280,7 +290,7 @@ void DolphinViewActionHandler::createActions()
 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);
@@ -389,9 +399,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();
 }
 
@@ -454,6 +464,12 @@ void DolphinViewActionHandler::zoomOut()
     updateViewActions();
 }
 
+void DolphinViewActionHandler::zoomReset()
+{
+    m_currentView->resetZoomLevel();
+    updateViewActions();
+}
+
 void DolphinViewActionHandler::toggleSortFoldersFirst()
 {
     const bool sortFirst = m_currentView->sortFoldersFirst();
@@ -499,7 +515,7 @@ void DolphinViewActionHandler::toggleVisibleRole(QAction* action)
 void DolphinViewActionHandler::slotVisibleRolesChanged(const QList<QByteArray>& current,
                                                        const QList<QByteArray>& previous)
 {
-    Q_UNUSED(previous);
+    Q_UNUSED(previous)
 
     const QSet<QByteArray> checkedRoles = current.toSet();
     QHashIterator<QByteArray, KToggleAction*> it(m_visibleRoles);
@@ -535,11 +551,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)
@@ -618,7 +634,7 @@ void DolphinViewActionHandler::slotSortRoleChanged(const QByteArray& role)
 
 void DolphinViewActionHandler::slotZoomLevelChanged(int current, int previous)
 {
-    Q_UNUSED(previous);
+    Q_UNUSED(previous)
 
     QAction* zoomInAction = m_actionCollection->action(KStandardAction::name(KStandardAction::ZoomIn));
     if (zoomInAction) {
@@ -637,9 +653,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<KActionMenu*>(groupAction);
         if (actionMenu) {
             foreach (QAction* subAction, actionMenu->menu()->actions()) {