Commit ec12391a authored by Roman Inflianskas's avatar Roman Inflianskas
Browse files

Convert hard coded shortcuts to standard keys

Test Plan: Check all changed shortcuts on all platforms.

Reviewers: #dolphin, rizzitello, elvisangelaccio

Reviewed By: #dolphin, rizzitello, elvisangelaccio

Subscribers: anthonyfieroni, ngraham, elvisangelaccio, rizzitello, #dolphin

Differential Revision: https://phabricator.kde.org/D11048
parent a4f16761
...@@ -288,13 +288,13 @@ void DolphinMainWindow::updateHistory() ...@@ -288,13 +288,13 @@ void DolphinMainWindow::updateHistory()
const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator(); const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
const int index = urlNavigator->historyIndex(); const int index = urlNavigator->historyIndex();
QAction* backAction = actionCollection()->action(QStringLiteral("go_back")); QAction* backAction = actionCollection()->action(KStandardAction::name(KStandardAction::Back));
if (backAction) { if (backAction) {
backAction->setToolTip(i18nc("@info", "Go back")); backAction->setToolTip(i18nc("@info", "Go back"));
backAction->setEnabled(index < urlNavigator->historySize() - 1); backAction->setEnabled(index < urlNavigator->historySize() - 1);
} }
QAction* forwardAction = actionCollection()->action(QStringLiteral("go_forward")); QAction* forwardAction = actionCollection()->action(KStandardAction::name(KStandardAction::Forward));
if (forwardAction) { if (forwardAction) {
forwardAction->setToolTip(i18nc("@info", "Go forward")); forwardAction->setToolTip(i18nc("@info", "Go forward"));
forwardAction->setEnabled(index > 0); forwardAction->setEnabled(index > 0);
...@@ -536,9 +536,9 @@ void DolphinMainWindow::slotDirectoryLoadingCompleted() ...@@ -536,9 +536,9 @@ void DolphinMainWindow::slotDirectoryLoadingCompleted()
void DolphinMainWindow::slotToolBarActionMiddleClicked(QAction *action) void DolphinMainWindow::slotToolBarActionMiddleClicked(QAction *action)
{ {
if (action == actionCollection()->action(QStringLiteral("go_back"))) { if (action == actionCollection()->action(KStandardAction::name(KStandardAction::Back))) {
goBackInNewTab(); goBackInNewTab();
} else if (action == actionCollection()->action(QStringLiteral("go_forward"))) { } else if (action == actionCollection()->action(KStandardAction::name(KStandardAction::Forward))) {
goForwardInNewTab(); goForwardInNewTab();
} else if (action == actionCollection()->action(QStringLiteral("go_up"))) { } else if (action == actionCollection()->action(QStringLiteral("go_up"))) {
goUpInNewTab(); goUpInNewTab();
...@@ -858,7 +858,7 @@ void DolphinMainWindow::updateControlMenu() ...@@ -858,7 +858,7 @@ void DolphinMainWindow::updateControlMenu()
// Add "Edit" actions // Add "Edit" actions
bool added = addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Undo)), menu) | bool added = addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Undo)), menu) |
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Find)), menu) | addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Find)), menu) |
addActionToMenu(ac->action(QStringLiteral("select_all")), menu) | addActionToMenu(ac->action(KStandardAction::name(KStandardAction::SelectAll)), menu) |
addActionToMenu(ac->action(QStringLiteral("invert_selection")), menu); addActionToMenu(ac->action(QStringLiteral("invert_selection")), menu);
if (added) { if (added) {
...@@ -884,7 +884,7 @@ void DolphinMainWindow::updateControlMenu() ...@@ -884,7 +884,7 @@ void DolphinMainWindow::updateControlMenu()
} }
added = addActionToMenu(ac->action(QStringLiteral("split_view")), menu) | added = addActionToMenu(ac->action(QStringLiteral("split_view")), menu) |
addActionToMenu(ac->action(QStringLiteral("reload")), menu) | addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Redisplay)), menu) |
addActionToMenu(ac->action(QStringLiteral("view_properties")), menu); addActionToMenu(ac->action(QStringLiteral("view_properties")), menu);
if (added) { if (added) {
menu->addSeparator(); menu->addSeparator();
...@@ -991,7 +991,7 @@ void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer) ...@@ -991,7 +991,7 @@ void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer)
void DolphinMainWindow::tabCountChanged(int count) void DolphinMainWindow::tabCountChanged(int count)
{ {
const bool enableTabActions = (count > 1); const bool enableTabActions = (count > 1);
actionCollection()->action(QStringLiteral("close_tab"))->setEnabled(enableTabActions); actionCollection()->action(KStandardAction::name(KStandardAction::Close))->setEnabled(enableTabActions);
actionCollection()->action(QStringLiteral("activate_next_tab"))->setEnabled(enableTabActions); actionCollection()->action(QStringLiteral("activate_next_tab"))->setEnabled(enableTabActions);
actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions); actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions);
} }
...@@ -1068,24 +1068,19 @@ void DolphinMainWindow::setupActions() ...@@ -1068,24 +1068,19 @@ void DolphinMainWindow::setupActions()
connect(menu, &QMenu::aboutToShow, connect(menu, &QMenu::aboutToShow,
this, &DolphinMainWindow::updateNewMenu); this, &DolphinMainWindow::updateNewMenu);
QAction* newWindow = actionCollection()->addAction(QStringLiteral("new_window")); QAction* newWindow = KStandardAction::openNew(this, &DolphinMainWindow::openNewMainWindow, actionCollection());
newWindow->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
newWindow->setText(i18nc("@action:inmenu File", "New &Window")); newWindow->setText(i18nc("@action:inmenu File", "New &Window"));
actionCollection()->setDefaultShortcut(newWindow, Qt::CTRL + Qt::Key_N);
connect(newWindow, &QAction::triggered, this, &DolphinMainWindow::openNewMainWindow);
QAction* newTab = actionCollection()->addAction(QStringLiteral("new_tab")); QAction* newTab = actionCollection()->addAction(QStringLiteral("new_tab"));
newTab->setIcon(QIcon::fromTheme(QStringLiteral("tab-new"))); newTab->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
newTab->setText(i18nc("@action:inmenu File", "New Tab")); newTab->setText(i18nc("@action:inmenu File", "New Tab"));
actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL + Qt::Key_T, Qt::CTRL + Qt::SHIFT + Qt::Key_N}); actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL + Qt::Key_T, QKeySequence::AddTab});
connect(newTab, &QAction::triggered, this, static_cast<void(DolphinMainWindow::*)()>(&DolphinMainWindow::openNewActivatedTab)); connect(newTab, &QAction::triggered, this, static_cast<void(DolphinMainWindow::*)()>(&DolphinMainWindow::openNewActivatedTab));
QAction* closeTab = actionCollection()->addAction(QStringLiteral("close_tab")); QAction* closeTab = KStandardAction::close(
closeTab->setIcon(QIcon::fromTheme(QStringLiteral("tab-close"))); m_tabWidget, static_cast<void(DolphinTabWidget::*)()>(&DolphinTabWidget::closeTab), actionCollection());
closeTab->setText(i18nc("@action:inmenu File", "Close Tab")); closeTab->setText(i18nc("@action:inmenu File", "Close Tab"));
actionCollection()->setDefaultShortcut(closeTab, Qt::CTRL + Qt::Key_W);
closeTab->setEnabled(false); closeTab->setEnabled(false);
connect(closeTab, &QAction::triggered, m_tabWidget, static_cast<void(DolphinTabWidget::*)()>(&DolphinTabWidget::closeTab));
KStandardAction::quit(this, &DolphinMainWindow::quit, actionCollection()); KStandardAction::quit(this, &DolphinMainWindow::quit, actionCollection());
...@@ -1105,11 +1100,7 @@ void DolphinMainWindow::setupActions() ...@@ -1105,11 +1100,7 @@ void DolphinMainWindow::setupActions()
KStandardAction::find(this, &DolphinMainWindow::find, actionCollection()); KStandardAction::find(this, &DolphinMainWindow::find, actionCollection());
QAction* selectAll = actionCollection()->addAction(QStringLiteral("select_all")); KStandardAction::selectAll(this, &DolphinMainWindow::selectAll, actionCollection());
selectAll->setText(i18nc("@action:inmenu Edit", "Select All"));
selectAll->setIcon(QIcon::fromTheme(QStringLiteral("edit-select-all")));
actionCollection()->setDefaultShortcut(selectAll, Qt::CTRL + Qt::Key_A);
connect(selectAll, &QAction::triggered, this, &DolphinMainWindow::selectAll);
QAction* invertSelection = actionCollection()->addAction(QStringLiteral("invert_selection")); QAction* invertSelection = actionCollection()->addAction(QStringLiteral("invert_selection"));
invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection")); invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
...@@ -1133,11 +1124,7 @@ void DolphinMainWindow::setupActions() ...@@ -1133,11 +1124,7 @@ void DolphinMainWindow::setupActions()
stashSplit->setVisible(KProtocolInfo::isKnownProtocol("stash")); stashSplit->setVisible(KProtocolInfo::isKnownProtocol("stash"));
connect(stashSplit, &QAction::triggered, this, &DolphinMainWindow::toggleSplitStash); connect(stashSplit, &QAction::triggered, this, &DolphinMainWindow::toggleSplitStash);
QAction* reload = actionCollection()->addAction(QStringLiteral("reload")); KStandardAction::redisplay(this, &DolphinMainWindow::reloadView, actionCollection());
reload->setText(i18nc("@action:inmenu View", "Reload"));
actionCollection()->setDefaultShortcut(reload, Qt::Key_F5);
reload->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh")));
connect(reload, &QAction::triggered, this, &DolphinMainWindow::reloadView);
QAction* stop = actionCollection()->addAction(QStringLiteral("stop")); QAction* stop = actionCollection()->addAction(QStringLiteral("stop"));
stop->setText(i18nc("@action:inmenu View", "Stop")); stop->setText(i18nc("@action:inmenu View", "Stop"));
......
...@@ -180,7 +180,7 @@ void DolphinPart::createActions() ...@@ -180,7 +180,7 @@ void DolphinPart::createActions()
unselectItemsMatching->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching...")); unselectItemsMatching->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching..."));
connect(unselectItemsMatching, &QAction::triggered, this, &DolphinPart::slotUnselectItemsMatchingPattern); connect(unselectItemsMatching, &QAction::triggered, this, &DolphinPart::slotUnselectItemsMatchingPattern);
actionCollection()->addAction(KStandardAction::SelectAll, QStringLiteral("select_all"), m_view, SLOT(selectAll())); KStandardAction::selectAll(m_view, &DolphinView::selectAll, actionCollection());
QAction* unselectAll = actionCollection()->addAction(QStringLiteral("unselect_all")); QAction* unselectAll = actionCollection()->addAction(QStringLiteral("unselect_all"));
unselectAll->setText(i18nc("@action:inmenu Edit", "Unselect All")); unselectAll->setText(i18nc("@action:inmenu Edit", "Unselect All"));
...@@ -216,11 +216,8 @@ void DolphinPart::createActions() ...@@ -216,11 +216,8 @@ void DolphinPart::createActions()
goActionGroup); goActionGroup);
// Tools menu // Tools menu
m_findFileAction = actionCollection()->addAction(QStringLiteral("find_file")); m_findFileAction = KStandardAction::find(this, &DolphinPart::slotFindFile, actionCollection());
m_findFileAction->setText(i18nc("@action:inmenu Tools", "Find File...")); m_findFileAction->setText(i18nc("@action:inmenu Tools", "Find File..."));
actionCollection()->setDefaultShortcut(m_findFileAction, Qt::CTRL + Qt::Key_F);
m_findFileAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-find")));
connect(m_findFileAction, &QAction::triggered, this, &DolphinPart::slotFindFile);
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
if (KAuthorized::authorize(QStringLiteral("shell_access"))) { if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="dolphin" version="19"> <kpartgui name="dolphin" version="20">
<MenuBar> <MenuBar>
<Menu name="file"> <Menu name="file">
<Action name="new_menu" /> <Action name="new_menu" />
<Action name="new_window" /> <Action name="file_new" />
<Action name="new_tab" /> <Action name="new_tab" />
<Action name="close_tab" /> <Action name="file_close" />
<Action name="undo_close_tab" /> <Action name="undo_close_tab" />
<Separator/> <Separator/>
<Action name="renamefile" /> <Action name="renamefile" />
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<Action name="properties" /> <Action name="properties" />
</Menu> </Menu>
<Menu name="edit"> <Menu name="edit">
<Action name="select_all" /> <Action name="edit_select_all" />
<Action name="invert_selection" /> <Action name="invert_selection" />
</Menu> </Menu>
<Menu name="view"> <Menu name="view">
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
<Separator/> <Separator/>
<Action name="split_view" /> <Action name="split_view" />
<Action name="split_stash" /> <Action name="split_stash" />
<Action name="reload" /> <Action name="redisplay" />
<Action name="stop" /> <Action name="stop" />
<Separator/> <Separator/>
<Action name="panels" /> <Action name="panels" />
......
...@@ -122,7 +122,7 @@ void DolphinViewActionHandler::createActions() ...@@ -122,7 +122,7 @@ void DolphinViewActionHandler::createActions()
QAction* deleteWithTrashShortcut = m_actionCollection->addAction(QStringLiteral("delete_shortcut")); QAction* deleteWithTrashShortcut = m_actionCollection->addAction(QStringLiteral("delete_shortcut"));
// The descriptive text is just for the shortcuts editor. // The descriptive text is just for the shortcuts editor.
deleteWithTrashShortcut->setText(i18nc("@action \"Move to Trash\" for non-local files, etc.", "Delete (using shortcut for Trash)")); deleteWithTrashShortcut->setText(i18nc("@action \"Move to Trash\" for non-local files, etc.", "Delete (using shortcut for Trash)"));
m_actionCollection->setDefaultShortcut(deleteWithTrashShortcut, QKeySequence::Delete); m_actionCollection->setDefaultShortcuts(deleteWithTrashShortcut, KStandardShortcut::moveToTrash());
deleteWithTrashShortcut->setEnabled(false); deleteWithTrashShortcut->setEnabled(false);
connect(deleteWithTrashShortcut, &QAction::triggered, this, &DolphinViewActionHandler::slotDeleteItems); connect(deleteWithTrashShortcut, &QAction::triggered, this, &DolphinViewActionHandler::slotDeleteItems);
......
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