Summary:
It was introduced in kconfig 5.25 and it properly handles the shift+del
shortcut (together with kxmlgui >= 5.30). This allows us to drop the
custom delete shortcut as well as the shift+del workaround in
DolphinMainWindow.
Test Plan: Shift+Del still deletes files, without the 'ambiguous shortcut' warning dialog.
Reviewers: emmanuelp
Differential Revision: https://phabricator.kde.org/D5010
QAction* restoreAction = new QAction(i18nc("@action:inmenu", "Restore"), m_mainWindow);
addAction(restoreAction);
QAction* restoreAction = new QAction(i18nc("@action:inmenu", "Restore"), m_mainWindow);
addAction(restoreAction);
- QAction* deleteAction = m_mainWindow->actionCollection()->action(QStringLiteral("delete"));
+ QAction* deleteAction = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile));
addAction(deleteAction);
QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties"));
addAction(deleteAction);
QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties"));
delete m_removeAction;
m_removeAction = 0;
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("move_to_trash")));
delete m_removeAction;
m_removeAction = 0;
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("move_to_trash")));
- addAction(m_mainWindow->actionCollection()->action(QStringLiteral("delete")));
+ addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
} else if (showDeleteAction && !showMoveToTrashAction) {
} else if (showDeleteAction && !showMoveToTrashAction) {
- addAction(m_mainWindow->actionCollection()->action(QStringLiteral("delete")));
+ addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
} else {
if (!m_removeAction) {
m_removeAction = new DolphinRemoveAction(this, m_mainWindow->actionCollection());
} else {
if (!m_removeAction) {
m_removeAction = new DolphinRemoveAction(this, m_mainWindow->actionCollection());
SLOT(undo()),
actionCollection());
SLOT(undo()),
actionCollection());
- // need to remove shift+del from cut action, else the shortcut for deletejob
- // doesn't work
- QAction* cut = KStandardAction::cut(this, SLOT(cut()), actionCollection());
- auto cutShortcuts = cut->shortcuts();
- cutShortcuts.removeAll(QKeySequence(Qt::SHIFT | Qt::Key_Delete));
- actionCollection()->setDefaultShortcuts(cut, cutShortcuts);
+
+ KStandardAction::cut(this, SLOT(cut()), actionCollection());
KStandardAction::copy(this, SLOT(copy()), actionCollection());
QAction* paste = KStandardAction::paste(this, SLOT(paste()), actionCollection());
// The text of the paste-action is modified dynamically by Dolphin
KStandardAction::copy(this, SLOT(copy()), actionCollection());
QAction* paste = KStandardAction::paste(this, SLOT(paste()), actionCollection());
// The text of the paste-action is modified dynamically by Dolphin
KActionCollection* col = actionCollection();
QAction* renameAction = col->action(QStringLiteral("rename"));
QAction* moveToTrashAction = col->action(QStringLiteral("move_to_trash"));
KActionCollection* col = actionCollection();
QAction* renameAction = col->action(QStringLiteral("rename"));
QAction* moveToTrashAction = col->action(QStringLiteral("move_to_trash"));
- QAction* deleteAction = col->action(QStringLiteral("delete"));
+ QAction* deleteAction = col->action(KStandardAction::name(KStandardAction::DeleteFile));
QAction* cutAction = col->action(KStandardAction::name(KStandardAction::Cut));
QAction* deleteWithTrashShortcut = col->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
QAction* cutAction = col->action(KStandardAction::name(KStandardAction::Cut));
QAction* deleteWithTrashShortcut = col->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
QAction* renameAction = actionCollection()->action(QStringLiteral("rename"));
QAction* moveToTrashAction = actionCollection()->action(QStringLiteral("move_to_trash"));
QAction* renameAction = actionCollection()->action(QStringLiteral("rename"));
QAction* moveToTrashAction = actionCollection()->action(QStringLiteral("move_to_trash"));
- QAction* deleteAction = actionCollection()->action(QStringLiteral("delete"));
+ QAction* deleteAction = actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile));
QAction* editMimeTypeAction = actionCollection()->action(QStringLiteral("editMimeType"));
QAction* propertiesAction = actionCollection()->action(QStringLiteral("properties"));
QAction* deleteWithTrashShortcut = actionCollection()->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
QAction* editMimeTypeAction = actionCollection()->action(QStringLiteral("editMimeType"));
QAction* propertiesAction = actionCollection()->action(QStringLiteral("properties"));
QAction* deleteWithTrashShortcut = actionCollection()->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
delete m_removeAction;
m_removeAction = 0;
editActions.append(actionCollection()->action(QStringLiteral("move_to_trash")));
delete m_removeAction;
m_removeAction = 0;
editActions.append(actionCollection()->action(QStringLiteral("move_to_trash")));
- editActions.append(actionCollection()->action(QStringLiteral("delete")));
+ editActions.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
} else if (showDeleteAction && !showMoveToTrashAction) {
} else if (showDeleteAction && !showMoveToTrashAction) {
- editActions.append(actionCollection()->action(QStringLiteral("delete")));
+ editActions.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
} else {
if (!m_removeAction)
m_removeAction = new DolphinRemoveAction(this, actionCollection());
} else {
if (!m_removeAction)
m_removeAction = new DolphinRemoveAction(this, actionCollection());
// This is only done until the original action has been shown at least once. To
// bypass this issue, the text and &-shortcut is applied manually.
if (qApp->queryKeyboardModifiers() & Qt::ShiftModifier) {
// This is only done until the original action has been shown at least once. To
// bypass this issue, the text and &-shortcut is applied manually.
if (qApp->queryKeyboardModifiers() & Qt::ShiftModifier) {
- m_action = m_collection ? m_collection->action(QStringLiteral("delete")) : 0;
+ m_action = m_collection ? m_collection->action(KStandardAction::name(KStandardAction::DeleteFile)) : 0;
setText(i18nc("@action:inmenu", "&Delete"));
} else {
m_action = m_collection ? m_collection->action(QStringLiteral("move_to_trash")) : 0;
setText(i18nc("@action:inmenu", "&Delete"));
} else {
m_action = m_collection ? m_collection->action(QStringLiteral("move_to_trash")) : 0;
* A QAction that manages the delete based on the current state of
* the Shift key or the parameter passed to update.
*
* A QAction that manages the delete based on the current state of
* the Shift key or the parameter passed to update.
*
- * This class expects the presence of both the "move_to_trash" and "delete"
- * actions in @ref collection.
+ * This class expects the presence of both the "move_to_trash" and
+ * KStandardAction::DeleteFile actions in @ref collection.
*/
class DOLPHIN_EXPORT DolphinRemoveAction : public QAction
{
*/
class DOLPHIN_EXPORT DolphinRemoveAction : public QAction
{
connect(moveToTrash, &QAction::triggered,
this, &DolphinViewActionHandler::slotTrashActivated);
connect(moveToTrash, &QAction::triggered,
this, &DolphinViewActionHandler::slotTrashActivated);
- QAction* deleteAction = m_actionCollection->addAction(QStringLiteral("delete"));
- deleteAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete")));
- deleteAction->setText(i18nc("@action:inmenu File", "Delete"));
- m_actionCollection->setDefaultShortcut(deleteAction, Qt::SHIFT | Qt::Key_Delete);
- connect(deleteAction, &QAction::triggered, this, &DolphinViewActionHandler::slotDeleteItems);
+ KStandardAction::deleteFile(this, &DolphinViewActionHandler::slotDeleteItems, m_actionCollection);
// This action is useful for being enabled when "move_to_trash" should be
// This action is useful for being enabled when "move_to_trash" should be
- // disabled and "delete" is enabled (e.g. non-local files), so that Key_Del
+ // disabled and KStandardAction::DeleteFile is enabled (e.g. non-local files), so that Key_Del
// can be used for deleting the file (#76016). It needs to be a separate action
// so that the Edit menu isn't affected.
QAction* deleteWithTrashShortcut = m_actionCollection->addAction(QStringLiteral("delete_shortcut"));
// can be used for deleting the file (#76016). It needs to be a separate action
// so that the Edit menu isn't affected.
QAction* deleteWithTrashShortcut = m_actionCollection->addAction(QStringLiteral("delete_shortcut"));