]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Make sure we always have Shift+Del as shortcut
authorElvis Angelaccio <elvis.angelaccio@kde.org>
Sat, 2 Sep 2017 14:28:49 +0000 (16:28 +0200)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Sun, 17 Sep 2017 09:06:32 +0000 (11:06 +0200)
After commit 68bb0ec22a the shortcut for the Delete action is not
necessarily Shift+Del, but whatever the user set in System Setting.
However DolphinRemoveAction assumes/hardcodes Shift+Del, so we should
always make sure we have this shortcut around, for consistency.

We just need to add it (if necessary) to the list of shortcuts of the
action. However:

* for the actual Delete action, we need to append it (if we'd prepend it,
  it would override a custom primary shortcut in the 'Configure Shortcuts' dialog).
* for DolphinRemoveAction, we need to prepend it in order to have
  Shift+Del (rather than the custom primary shortcut) in the context menu.

Differential Revision: https://phabricator.kde.org/D7655

src/dolphinremoveaction.cpp
src/views/dolphinviewactionhandler.cpp

index ad00f6286ef5843a8a1562315212479e1433c940..79d6bed6021bee4dec7ba231cdcea1438de93073 100644 (file)
@@ -48,14 +48,19 @@ void DolphinRemoveAction::update()
     if (qApp->queryKeyboardModifiers() & Qt::ShiftModifier) {
         m_action = m_collection ? m_collection->action(KStandardAction::name(KStandardAction::DeleteFile)) : 0;
         setText(i18nc("@action:inmenu", "&Delete"));
+        // Make sure we show Shift+Del in the context menu.
+        auto deleteShortcuts = m_action->shortcuts();
+        deleteShortcuts.removeAll(Qt::SHIFT | Qt::Key_Delete);
+        deleteShortcuts.prepend(Qt::SHIFT | Qt::Key_Delete);
+        m_collection->setDefaultShortcuts(this, deleteShortcuts);
     } else {
         m_action = m_collection ? m_collection->action(QStringLiteral("move_to_trash")) : 0;
         setText(i18nc("@action:inmenu", "&Move to Trash"));
+        m_collection->setDefaultShortcuts(this, m_action->shortcuts());
     }
 
     if (m_action) {
         setIcon(m_action->icon());
-        m_collection->setDefaultShortcuts(this, m_action->shortcuts());
         setEnabled(m_action->isEnabled());
     }
 }
index 7e52d5b284b76f90ae1ab8944e7f2895e45b3f4c..f4104d9cfeef21e166f989cc7d67457c67e00bae 100644 (file)
@@ -120,7 +120,12 @@ void DolphinViewActionHandler::createActions()
     connect(moveToTrash, &QAction::triggered,
             this, &DolphinViewActionHandler::slotTrashActivated);
 
-    KStandardAction::deleteFile(this, &DolphinViewActionHandler::slotDeleteItems, m_actionCollection);
+    auto deleteAction = KStandardAction::deleteFile(this, &DolphinViewActionHandler::slotDeleteItems, m_actionCollection);
+    auto deleteShortcuts = deleteAction->shortcuts();
+    if (!deleteShortcuts.contains(Qt::SHIFT | Qt::Key_Delete)) {
+        deleteShortcuts.append(Qt::SHIFT | Qt::Key_Delete);
+        m_actionCollection->setDefaultShortcuts(deleteAction, deleteShortcuts);
+    }
 
     // This action is useful for being enabled when "move_to_trash" should be
     // disabled and KStandardAction::DeleteFile is enabled (e.g. non-local files), so that Key_Del