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()
const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
const int index = urlNavigator->historyIndex();
QAction* backAction = actionCollection()->action(QStringLiteral("go_back"));
QAction* backAction = actionCollection()->action(KStandardAction::name(KStandardAction::Back));
if (backAction) {
backAction->setToolTip(i18nc("@info", "Go back"));
backAction->setEnabled(index < urlNavigator->historySize() - 1);
}
QAction* forwardAction = actionCollection()->action(QStringLiteral("go_forward"));
QAction* forwardAction = actionCollection()->action(KStandardAction::name(KStandardAction::Forward));
if (forwardAction) {
forwardAction->setToolTip(i18nc("@info", "Go forward"));
forwardAction->setEnabled(index > 0);
......@@ -536,9 +536,9 @@ void DolphinMainWindow::slotDirectoryLoadingCompleted()
void DolphinMainWindow::slotToolBarActionMiddleClicked(QAction *action)
{
if (action == actionCollection()->action(QStringLiteral("go_back"))) {
if (action == actionCollection()->action(KStandardAction::name(KStandardAction::Back))) {
goBackInNewTab();
} else if (action == actionCollection()->action(QStringLiteral("go_forward"))) {
} else if (action == actionCollection()->action(KStandardAction::name(KStandardAction::Forward))) {
goForwardInNewTab();
} else if (action == actionCollection()->action(QStringLiteral("go_up"))) {
goUpInNewTab();
......@@ -858,7 +858,7 @@ void DolphinMainWindow::updateControlMenu()
// Add "Edit" actions
bool added = addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Undo)), 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);
if (added) {
......@@ -884,7 +884,7 @@ void DolphinMainWindow::updateControlMenu()
}
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);
if (added) {
menu->addSeparator();
......@@ -991,7 +991,7 @@ void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer)
void DolphinMainWindow::tabCountChanged(int count)
{
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_prev_tab"))->setEnabled(enableTabActions);
}
......@@ -1068,24 +1068,19 @@ void DolphinMainWindow::setupActions()
connect(menu, &QMenu::aboutToShow,
this, &DolphinMainWindow::updateNewMenu);
QAction* newWindow = actionCollection()->addAction(QStringLiteral("new_window"));
newWindow->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
QAction* newWindow = KStandardAction::openNew(this, &DolphinMainWindow::openNewMainWindow, actionCollection());
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"));
newTab->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
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));
QAction* closeTab = actionCollection()->addAction(QStringLiteral("close_tab"));
closeTab->setIcon(QIcon::fromTheme(QStringLiteral("tab-close")));
QAction* closeTab = KStandardAction::close(
m_tabWidget, static_cast<void(DolphinTabWidget::*)()>(&DolphinTabWidget::closeTab), actionCollection());
closeTab->setText(i18nc("@action:inmenu File", "Close Tab"));
actionCollection()->setDefaultShortcut(closeTab, Qt::CTRL + Qt::Key_W);
closeTab->setEnabled(false);
connect(closeTab, &QAction::triggered, m_tabWidget, static_cast<void(DolphinTabWidget::*)()>(&DolphinTabWidget::closeTab));
KStandardAction::quit(this, &DolphinMainWindow::quit, actionCollection());
......@@ -1105,11 +1100,7 @@ void DolphinMainWindow::setupActions()
KStandardAction::find(this, &DolphinMainWindow::find, actionCollection());
QAction* selectAll = actionCollection()->addAction(QStringLiteral("select_all"));
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);
KStandardAction::selectAll(this, &DolphinMainWindow::selectAll, actionCollection());
QAction* invertSelection = actionCollection()->addAction(QStringLiteral("invert_selection"));
invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
......@@ -1133,11 +1124,7 @@ void DolphinMainWindow::setupActions()
stashSplit->setVisible(KProtocolInfo::isKnownProtocol("stash"));
connect(stashSplit, &QAction::triggered, this, &DolphinMainWindow::toggleSplitStash);
QAction* reload = actionCollection()->addAction(QStringLiteral("reload"));
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);
KStandardAction::redisplay(this, &DolphinMainWindow::reloadView, actionCollection());
QAction* stop = actionCollection()->addAction(QStringLiteral("stop"));
stop->setText(i18nc("@action:inmenu View", "Stop"));
......
......@@ -180,7 +180,7 @@ void DolphinPart::createActions()
unselectItemsMatching->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching..."));
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"));
unselectAll->setText(i18nc("@action:inmenu Edit", "Unselect All"));
......@@ -216,11 +216,8 @@ void DolphinPart::createActions()
goActionGroup);
// 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..."));
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
if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="dolphin" version="19">
<kpartgui name="dolphin" version="20">
<MenuBar>
<Menu name="file">
<Action name="new_menu" />
<Action name="new_window" />
<Action name="file_new" />
<Action name="new_tab" />
<Action name="close_tab" />
<Action name="file_close" />
<Action name="undo_close_tab" />
<Separator/>
<Action name="renamefile" />
......@@ -17,7 +17,7 @@
<Action name="properties" />
</Menu>
<Menu name="edit">
<Action name="select_all" />
<Action name="edit_select_all" />
<Action name="invert_selection" />
</Menu>
<Menu name="view">
......@@ -30,7 +30,7 @@
<Separator/>
<Action name="split_view" />
<Action name="split_stash" />
<Action name="reload" />
<Action name="redisplay" />
<Action name="stop" />
<Separator/>
<Action name="panels" />
......
......@@ -122,7 +122,7 @@ void DolphinViewActionHandler::createActions()
QAction* deleteWithTrashShortcut = m_actionCollection->addAction(QStringLiteral("delete_shortcut"));
// 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)"));
m_actionCollection->setDefaultShortcut(deleteWithTrashShortcut, QKeySequence::Delete);
m_actionCollection->setDefaultShortcuts(deleteWithTrashShortcut, KStandardShortcut::moveToTrash());
deleteWithTrashShortcut->setEnabled(false);
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