mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-21 09:20:13 +00:00
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
This commit is contained in:
parent
82b2dbd3ec
commit
4b5ea05b67
|
@ -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)));
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)));
|
||||
|
|
|
@ -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>&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>
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue