summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElvis Angelaccio <[email protected]>2017-07-19 00:00:37 +0200
committerElvis Angelaccio <[email protected]>2017-07-27 16:15:03 +0200
commit4b5ea05b6760e9020ab87f1d90071e1a2a8f9e99 (patch)
treed1c87653f2ebaecdf0cb5b110b24a7242f4cc3d6
parent82b2dbd3ec568a6e6fe01a8e75739b25cae25f15 (diff)
Port to KStandardAction::MoveToTrash
It was introduced in kconfig(widgets) 5.25. Using the standard action results in less code and no need to hardcode the Del shortcut. Test Plan: - Change shortcut in System Settings -> Shortcuts -> Standard Shortcuts - Make sure the new shortcut is used by dolphin. Differential Revision: https://phabricator.kde.org/D6778
-rw-r--r--src/dolphincontextmenu.cpp2
-rw-r--r--src/dolphinmainwindow.cpp2
-rw-r--r--src/dolphinpart.cpp4
-rw-r--r--src/dolphinpart.rc8
-rw-r--r--src/dolphinremoveaction.cpp2
-rw-r--r--src/dolphinremoveaction.h2
-rw-r--r--src/dolphinui.rc10
-rw-r--r--src/views/dolphinviewactionhandler.cpp10
8 files changed, 17 insertions, 23 deletions
diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp
index 05082df..7ee9562 100644
--- a/src/dolphincontextmenu.cpp
+++ b/src/dolphincontextmenu.cpp
@@ -405,7 +405,7 @@ void DolphinContextMenu::insertDefaultItemActions(const KFileItemListProperties&
if (showDeleteAction && showMoveToTrashAction) {
delete m_removeAction;
m_removeAction = 0;
- addAction(m_mainWindow->actionCollection()->action(QStringLiteral("move_to_trash")));
+ addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash)));
addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
} else if (showDeleteAction && !showMoveToTrashAction) {
addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index 3d6f848..194666b 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -1317,7 +1317,7 @@ void DolphinMainWindow::updateEditActions()
KActionCollection* col = actionCollection();
QAction* renameAction = col->action(QStringLiteral("rename"));
- QAction* moveToTrashAction = col->action(QStringLiteral("move_to_trash"));
+ QAction* moveToTrashAction = col->action(KStandardAction::name(KStandardAction::MoveToTrash));
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
diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp
index ef9b300..0e771ac 100644
--- a/src/dolphinpart.cpp
+++ b/src/dolphinpart.cpp
@@ -254,7 +254,7 @@ void DolphinPart::slotSelectionChanged(const KFileItemList& selection)
const bool hasSelection = !selection.isEmpty();
QAction* renameAction = actionCollection()->action(QStringLiteral("rename"));
- QAction* moveToTrashAction = actionCollection()->action(QStringLiteral("move_to_trash"));
+ QAction* moveToTrashAction = actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash));
QAction* deleteAction = actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile));
QAction* editMimeTypeAction = actionCollection()->action(QStringLiteral("editMimeType"));
QAction* propertiesAction = actionCollection()->action(QStringLiteral("properties"));
@@ -432,7 +432,7 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
if (showDeleteAction && showMoveToTrashAction) {
delete m_removeAction;
m_removeAction = 0;
- editActions.append(actionCollection()->action(QStringLiteral("move_to_trash")));
+ editActions.append(actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash)));
editActions.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
} else if (showDeleteAction && !showMoveToTrashAction) {
editActions.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
diff --git a/src/dolphinpart.rc b/src/dolphinpart.rc
index 01bd600..6d38cc3 100644
--- a/src/dolphinpart.rc
+++ b/src/dolphinpart.rc
@@ -1,11 +1,11 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui name="dolphinpart" version="12" translationDomain="dolphin">
+<kpartgui name="dolphinpart" version="13" translationDomain="dolphin">
<MenuBar>
<Menu name="edit"><text>&amp;Edit</text>
<Action name="new_menu"/>
<Separator/>
<Action name="rename"/>
- <Action name="move_to_trash" />
+ <Action name="movetotrash" />
<Action name="deletefile"/>
<Action name="editMimeType"/>
<Action name="properties"/>
@@ -52,14 +52,14 @@
</ToolBar>
<State name="has_selection" >
<enable>
- <Action name="move_to_trash" />
+ <Action name="movetotrash" />
<Action name="deletefile" />
</enable>
</State>
<State name="has_no_selection" >
<disable>
<Action name="rename" />
- <Action name="move_to_trash" />
+ <Action name="movetotrash" />
<Action name="deletefile" />
</disable>
</State>
diff --git a/src/dolphinremoveaction.cpp b/src/dolphinremoveaction.cpp
index ad00f62..7e8a353 100644
--- a/src/dolphinremoveaction.cpp
+++ b/src/dolphinremoveaction.cpp
@@ -49,7 +49,7 @@ void DolphinRemoveAction::update()
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;
+ m_action = m_collection ? m_collection->action(KStandardAction::name(KStandardAction::MoveToTrash)) : 0;
setText(i18nc("@action:inmenu", "&Move to Trash"));
}
diff --git a/src/dolphinremoveaction.h b/src/dolphinremoveaction.h
index fd8fc35..f9a1b98 100644
--- a/src/dolphinremoveaction.h
+++ b/src/dolphinremoveaction.h
@@ -31,7 +31,7 @@
* 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
+ * This class expects the presence of both the KStandardAction::MoveToTrash and
* KStandardAction::DeleteFile actions in @ref collection.
*/
class DOLPHIN_EXPORT DolphinRemoveAction : public QAction
diff --git a/src/dolphinui.rc b/src/dolphinui.rc
index 9354882..a8e6436 100644
--- a/src/dolphinui.rc
+++ b/src/dolphinui.rc
@@ -1,5 +1,5 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui name="dolphin" version="15">
+<kpartgui name="dolphin" version="16">
<MenuBar>
<Menu name="file">
<Action name="new_menu" />
@@ -9,7 +9,7 @@
<Action name="undo_close_tab" />
<Separator/>
<Action name="rename" />
- <Action name="move_to_trash" />
+ <Action name="movetotrash" />
<Action name="deletefile" />
<Separator/>
<Action name="properties" />
@@ -57,7 +57,7 @@
<Action name="edit_cut" />
<Action name="edit_copy" />
<Action name="rename" />
- <Action name="move_to_trash" />
+ <Action name="movetotrash" />
<Action name="deletefile" />
<Action name="invert_selection" />
<Separator/>
@@ -70,7 +70,7 @@
<Action name="edit_cut" />
<Action name="edit_copy" />
<Action name="rename" />
- <Action name="move_to_trash" />
+ <Action name="movetotrash" />
<Action name="deletefile" />
<Action name="invert_selection" />
</enable>
@@ -80,7 +80,7 @@
<Action name="edit_cut" />
<Action name="edit_copy" />
<Action name="rename" />
- <Action name="move_to_trash" />
+ <Action name="movetotrash" />
<Action name="deletefile" />
<Action name="delete_shortcut" />
<Action name="invert_selection" />
diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp
index 7e52d5b..5f98577 100644
--- a/src/views/dolphinviewactionhandler.cpp
+++ b/src/views/dolphinviewactionhandler.cpp
@@ -113,16 +113,10 @@ void DolphinViewActionHandler::createActions()
rename->setIcon(QIcon::fromTheme(QStringLiteral("edit-rename")));
connect(rename, &QAction::triggered, this, &DolphinViewActionHandler::slotRename);
- QAction* moveToTrash = m_actionCollection->addAction(QStringLiteral("move_to_trash"));
- moveToTrash->setText(i18nc("@action:inmenu File", "Move to Trash"));
- moveToTrash->setIcon(QIcon::fromTheme(QStringLiteral("user-trash")));
- m_actionCollection->setDefaultShortcut(moveToTrash, QKeySequence::Delete);
- connect(moveToTrash, &QAction::triggered,
- this, &DolphinViewActionHandler::slotTrashActivated);
-
+ KStandardAction::moveToTrash(this, &DolphinViewActionHandler::slotTrashActivated, m_actionCollection);
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 KStandardAction::MoveToTrash should be
// 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.