]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinviewactionhandler.cpp
Make "Show hidden files" action follow HIG
[dolphin.git] / src / views / dolphinviewactionhandler.cpp
index ef9f317ee16d20e3399d6e46b41d1bd33d0ef4b2..a63263bf5822dcbbebb65e8e0c0b3c07775b7b34 100644 (file)
@@ -1,22 +1,9 @@
-/***************************************************************************
- *   Copyright (C) 2008 by David Faure <faure@kde.org>                     *
- *   Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2008 David Faure <faure@kde.org>
+ * SPDX-FileCopyrightText: 2012 Peter Penz <peter.penz19@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #include "dolphinviewactionhandler.h"
 
@@ -34,7 +21,6 @@
 #include <KNewFileMenu>
 #include <KPropertiesDialog>
 #include <KProtocolManager>
-
 #include <QMenu>
 #include <QPointer>
 
@@ -136,6 +122,13 @@ 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") );
@@ -149,6 +142,17 @@ void DolphinViewActionHandler::createActions()
     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();
@@ -268,15 +272,15 @@ void DolphinViewActionHandler::createActions()
     connect(showInGroups, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleGroupedSorting);
 
     KToggleAction* showHiddenFiles = m_actionCollection->add<KToggleAction>(QStringLiteral("show_hidden_files"));
+    showHiddenFiles->setIcon(QIcon::fromTheme(QStringLiteral("view-visible")));
     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 "
         "are visible. They will be displayed semi-transparent.</para>"
         "<para>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.</para>"));
-    m_actionCollection->setDefaultShortcuts(showHiddenFiles, {Qt::ALT + Qt::Key_Period, Qt::CTRL + Qt::Key_H, Qt::Key_F8});
+    m_actionCollection->setDefaultShortcuts(showHiddenFiles, KStandardShortcut::showHideHiddenFiles());
     connect(showHiddenFiles, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleShowHiddenFiles);
 
     QAction* adjustViewProps = m_actionCollection->addAction(QStringLiteral("view_properties"));
@@ -548,14 +552,6 @@ void DolphinViewActionHandler::slotHiddenFilesShownChanged(bool shown)
 {
     QAction* showHiddenFilesAction = m_actionCollection->action(QStringLiteral("show_hidden_files"));
     showHiddenFilesAction->setChecked(shown);
-
-    // #374508: don't overwrite custom icons.
-    const QString iconName = showHiddenFilesAction->icon().name();
-    if (!iconName.isEmpty() && iconName != QLatin1String("view-visible") && iconName != QLatin1String("view-hidden")) {
-        return;
-    }
-
-    showHiddenFilesAction->setIcon(QIcon::fromTheme(shown ? QStringLiteral("view-visible") : QStringLiteral("view-hidden")));
 }
 
 void DolphinViewActionHandler::slotWriteStateChanged(bool isFolderWritable)
@@ -616,14 +612,14 @@ void DolphinViewActionHandler::slotSortRoleChanged(const QByteArray& role)
         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"));
+        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"));
+        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"));
+        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"));
@@ -680,6 +676,12 @@ void DolphinViewActionHandler::slotAdjustViewProperties()
     delete dialog;
 }
 
+void DolphinViewActionHandler::slotDuplicate()
+{
+    emit actionBeingHandled();
+    m_currentView->duplicateSelectedItems();
+}
+
 void DolphinViewActionHandler::slotProperties()
 {
     KPropertiesDialog* dialog = nullptr;
@@ -696,3 +698,8 @@ void DolphinViewActionHandler::slotProperties()
     dialog->raise();
     dialog->activateWindow();
 }
+
+void DolphinViewActionHandler::slotCopyPath()
+{
+    m_currentView->copyPathToClipboard();
+}