]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Make sure we always have the Del shortcut
authorElvis Angelaccio <elvis.angelaccio@kde.org>
Mon, 16 Oct 2017 17:56:31 +0000 (19:56 +0200)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Mon, 16 Oct 2017 17:56:37 +0000 (19:56 +0200)
Same fix as in D7655, but this time for the MoveToTrash standard action.

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

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

index ab1117770f2b76537d675b325cb3bcc60ad4dcfd..ea7efe6c86730c66476df6d6747c4d522937baf2 100644 (file)
@@ -61,10 +61,15 @@ void DolphinRemoveAction::update(ShiftState shiftState)
         m_collection->setDefaultShortcuts(this, deleteShortcuts);
         break;
     }
-    case ShiftState::Released:
+    case ShiftState::Released: {
         m_action = m_collection->action(KStandardAction::name(KStandardAction::MoveToTrash));
-        m_collection->setDefaultShortcuts(this, m_action->shortcuts());
+        // Make sure we show Del in the context menu.
+        auto trashShortcuts = m_action->shortcuts();
+        trashShortcuts.removeAll(QKeySequence::Delete);
+        trashShortcuts.prepend(QKeySequence::Delete);
+        m_collection->setDefaultShortcuts(this, trashShortcuts);
         break;
+    }
     case ShiftState::Unknown:
         Q_UNREACHABLE();
         break;
index d0b9e7dc1ea6eb0e3505f87d1c5b87ee9195d7c1..10aae11ce6f30d6630cfe116614905184d3bc9f5 100644 (file)
@@ -109,7 +109,13 @@ void DolphinViewActionHandler::createActions()
 
     KStandardAction::renameFile(this, &DolphinViewActionHandler::slotRename, m_actionCollection);
 
-    KStandardAction::moveToTrash(this, &DolphinViewActionHandler::slotTrashActivated, m_actionCollection);
+    auto trashAction = KStandardAction::moveToTrash(this, &DolphinViewActionHandler::slotTrashActivated, m_actionCollection);
+    auto trashShortcuts = trashAction->shortcuts();
+    if (!trashShortcuts.contains(QKeySequence::Delete)) {
+        trashShortcuts.append(QKeySequence::Delete);
+        m_actionCollection->setDefaultShortcuts(trashAction, trashShortcuts);
+    }
+
     auto deleteAction = KStandardAction::deleteFile(this, &DolphinViewActionHandler::slotDeleteItems, m_actionCollection);
     auto deleteShortcuts = deleteAction->shortcuts();
     if (!deleteShortcuts.contains(Qt::SHIFT | Qt::Key_Delete)) {