Commit 54817090 authored by Elvis Angelaccio's avatar Elvis Angelaccio

Port to KStandardAction::RenameFile

It was introduced in kconfig(widgets) 5.25. Using the standard action
results in less code and no need to hardcode the F2 shortcut.

Differential Revision: https://phabricator.kde.org/D6777
parent f38960e0
......@@ -392,8 +392,7 @@ void DolphinContextMenu::insertDefaultItemActions(const KFileItemListProperties&
addSeparator();
// Insert 'Rename'
QAction* renameAction = collection->action(QStringLiteral("rename"));
addAction(renameAction);
addAction(collection->action(KStandardAction::name(KStandardAction::RenameFile)));
// Insert 'Move to Trash' and/or 'Delete'
if (properties.supportsDeleting()) {
......
......@@ -1308,7 +1308,7 @@ void DolphinMainWindow::updateEditActions()
stateChanged(QStringLiteral("has_selection"));
KActionCollection* col = actionCollection();
QAction* renameAction = col->action(QStringLiteral("rename"));
QAction* renameAction = col->action(KStandardAction::name(KStandardAction::RenameFile));
QAction* moveToTrashAction = col->action(KStandardAction::name(KStandardAction::MoveToTrash));
QAction* deleteAction = col->action(KStandardAction::name(KStandardAction::DeleteFile));
QAction* cutAction = col->action(KStandardAction::name(KStandardAction::Cut));
......
......@@ -253,7 +253,7 @@ void DolphinPart::slotSelectionChanged(const KFileItemList& selection)
{
const bool hasSelection = !selection.isEmpty();
QAction* renameAction = actionCollection()->action(QStringLiteral("rename"));
QAction* renameAction = actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile));
QAction* moveToTrashAction = actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash));
QAction* deleteAction = actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile));
QAction* editMimeTypeAction = actionCollection()->action(QStringLiteral("editMimeType"));
......@@ -447,7 +447,7 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
}
if (supportsMoving) {
editActions.append(actionCollection()->action(QStringLiteral("rename")));
editActions.append(actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile)));
}
// Normally KonqPopupMenu only shows the "Create new" submenu in the current view
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="dolphinpart" version="13" translationDomain="dolphin">
<kpartgui name="dolphinpart" version="14" translationDomain="dolphin">
<MenuBar>
<Menu name="edit"><text>&amp;Edit</text>
<Action name="new_menu"/>
<Separator/>
<Action name="rename"/>
<Action name="renamefile"/>
<Action name="movetotrash" />
<Action name="deletefile"/>
<Action name="editMimeType"/>
......@@ -58,7 +58,7 @@
</State>
<State name="has_no_selection" >
<disable>
<Action name="rename" />
<Action name="renamefile" />
<Action name="movetotrash" />
<Action name="deletefile" />
</disable>
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="dolphin" version="16">
<kpartgui name="dolphin" version="17">
<MenuBar>
<Menu name="file">
<Action name="new_menu" />
......@@ -8,7 +8,7 @@
<Action name="close_tab" />
<Action name="undo_close_tab" />
<Separator/>
<Action name="rename" />
<Action name="renamefile" />
<Action name="movetotrash" />
<Action name="deletefile" />
<Separator/>
......@@ -56,7 +56,7 @@
<Action name="edit_redo" />
<Action name="edit_cut" />
<Action name="edit_copy" />
<Action name="rename" />
<Action name="renamefile" />
<Action name="movetotrash" />
<Action name="deletefile" />
<Action name="invert_selection" />
......@@ -69,7 +69,7 @@
<enable>
<Action name="edit_cut" />
<Action name="edit_copy" />
<Action name="rename" />
<Action name="renamefile" />
<Action name="movetotrash" />
<Action name="deletefile" />
<Action name="invert_selection" />
......@@ -79,7 +79,7 @@
<disable>
<Action name="edit_cut" />
<Action name="edit_copy" />
<Action name="rename" />
<Action name="renamefile" />
<Action name="movetotrash" />
<Action name="deletefile" />
<Action name="delete_shortcut" />
......
......@@ -107,11 +107,7 @@ void DolphinViewActionHandler::createActions()
// File menu
QAction* rename = m_actionCollection->addAction(QStringLiteral("rename"));
rename->setText(i18nc("@action:inmenu File", "Rename..."));
m_actionCollection->setDefaultShortcut(rename, Qt::Key_F2);
rename->setIcon(QIcon::fromTheme(QStringLiteral("edit-rename")));
connect(rename, &QAction::triggered, this, &DolphinViewActionHandler::slotRename);
KStandardAction::renameFile(this, &DolphinViewActionHandler::slotRename, m_actionCollection);
KStandardAction::moveToTrash(this, &DolphinViewActionHandler::slotTrashActivated, m_actionCollection);
KStandardAction::deleteFile(this, &DolphinViewActionHandler::slotDeleteItems, m_actionCollection);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment