[rkward/frameworks] rkward: Use KActionCollection::setDefaultShortcut(), where appropriate.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Tue Feb 16 19:57:31 UTC 2016


Git commit deebf44b9b40036301fb6ea864832f4d41fdd5ed by Thomas Friedrichsmeier.
Committed on 16/02/2016 at 19:57.
Pushed by tfry into branch 'frameworks'.

Use KActionCollection::setDefaultShortcut(), where appropriate.

M  +2    -4    rkward/misc/rkstandardactions.cpp
M  +2    -2    rkward/rkconsole.cpp
M  +2    -4    rkward/rkward.cpp
M  +2    -2    rkward/windows/rkcommandeditorwindow.cpp
M  +1    -1    rkward/windows/rkhtmlwindow.cpp
M  +4    -4    rkward/windows/rktoplevelwindowgui.cpp
M  +0    -2    rkward/windows/rkworkplaceview.cpp

http://commits.kde.org/rkward/deebf44b9b40036301fb6ea864832f4d41fdd5ed

diff --git a/rkward/misc/rkstandardactions.cpp b/rkward/misc/rkstandardactions.cpp
index 3646157..879f105 100644
--- a/rkward/misc/rkstandardactions.cpp
+++ b/rkward/misc/rkstandardactions.cpp
@@ -41,7 +41,7 @@ QAction* RKStandardActions::pasteSpecial (RKMDIWindow *window, const QObject *re
 	QAction* ret = new RKPasteSpecialAction (window->standardActionCollection ());
 	window->standardActionCollection ()->addAction ("paste_special", ret);
 	ret->connect (ret, SIGNAL (pasteText(QString)), receiver, member);
-	ret->setShortcut (Qt::ShiftModifier + Qt::ControlModifier + Qt::Key_V);
+	window->standardActionCollection ()->setDefaultShortcut (ret, Qt::ShiftModifier + Qt::ControlModifier + Qt::Key_V);
 	return ret;
 }
 
@@ -58,7 +58,6 @@ QAction* RKStandardActions::runCurrent (RKMDIWindow *window, const QObject *rece
 	}
 	ret->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionRunLine));
 	window->standardActionCollection ()->setDefaultShortcuts (ret, QList<QKeySequence>() << Qt::ControlModifier + Qt::Key_Return << Qt::ControlModifier + Qt::Key_Enter);
-	ret->setShortcut (Qt::ControlModifier + Qt::Key_Return);  // KF5 TODO: Not needed for KF5 >= 5.2
 
 	return ret;
 }
@@ -70,7 +69,6 @@ QAction* RKStandardActions::runAll (RKMDIWindow *window, const QObject *receiver
 	ret->setText (i18n ("Run all"));
 	ret->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionRunAll));
 	window->standardActionCollection ()->setDefaultShortcuts (ret, QList<QKeySequence>() << Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Return << Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Enter);
-	ret->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Return);  // KF5 TODO: Not needed for KF5 >= 5.2
 
 	return ret;
 }
@@ -80,6 +78,6 @@ QAction* RKStandardActions::functionHelp (RKMDIWindow *window, const QObject *re
 
 	QAction* ret = window->standardActionCollection ()->addAction ("function_reference", receiver, member);
 	ret->setText (i18n ("&Function reference"));
-	ret->setShortcut (Qt::Key_F2);
+	window->standardActionCollection ()->setDefaultShortcut (ret, Qt::Key_F2);
 	return ret;
 }
diff --git a/rkward/rkconsole.cpp b/rkward/rkconsole.cpp
index 9a6fcd3..f438208 100644
--- a/rkward/rkconsole.cpp
+++ b/rkward/rkconsole.cpp
@@ -968,12 +968,12 @@ void RKConsole::initializeActions (KActionCollection *ac) {
 
 	interrupt_command_action = ac->addAction ("interrupt", this, SLOT (resetConsole()));
 	interrupt_command_action->setText (i18n ("Interrupt running command"));
-	interrupt_command_action->setShortcut (REAL_CTRL_KEY + Qt::Key_C);
+	ac->setDefaultShortcut (interrupt_command_action, REAL_CTRL_KEY + Qt::Key_C);
 	interrupt_command_action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionInterrupt));
 	interrupt_command_action->setEnabled (false);
 
 	copy_literal_action = ac->addAction ("rkconsole_copy_literal", this, SLOT (literalCopy()));
-	copy_literal_action->setShortcut (REAL_CMD_KEY + Qt::Key_C);
+	ac->setDefaultShortcut (copy_literal_action, REAL_CMD_KEY + Qt::Key_C);
 	copy_literal_action->setText (i18n ("Copy selection literally"));
 
 	copy_commands_action = ac->addAction ("rkconsole_copy_commands", this, SLOT (copyCommands()));
diff --git a/rkward/rkward.cpp b/rkward/rkward.cpp
index f401b79..a60fd57 100644
--- a/rkward/rkward.cpp
+++ b/rkward/rkward.cpp
@@ -482,7 +482,7 @@ void RKWardMainWindow::initActions() {
 
 	fileOpenWorkspace = actionCollection ()->addAction (KStandardAction::Open, "file_openx", this, SLOT(slotFileOpenWorkspace()));
 	fileOpenWorkspace->setText (i18n ("Open Workspace..."));
-	fileOpenWorkspace->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_O);
+	actionCollection ()->setDefaultShortcut (fileOpenWorkspace, Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_O);
 	fileOpenWorkspace->setStatusTip (i18n ("Opens an existing document"));
 
 	fileOpenRecentWorkspace = static_cast<KRecentFilesAction*> (actionCollection ()->addAction (KStandardAction::OpenRecent, "file_open_recentx", this, SLOT(askOpenWorkspace(QUrl))));
@@ -492,12 +492,10 @@ void RKWardMainWindow::initActions() {
 	fileSaveWorkspace = actionCollection ()->addAction (KStandardAction::Save, "file_savex", this, SLOT(slotFileSaveWorkspace()));
 	fileSaveWorkspace->setText (i18n ("Save Workspace"));
 	actionCollection ()->setDefaultShortcut (fileSaveWorkspace, Qt::ControlModifier + Qt::AltModifier + Qt::Key_S);
-	fileSaveWorkspace->setShortcut (Qt::ControlModifier + Qt::AltModifier + Qt::Key_S); // KF5 TODO: Not needed for KF5 >= 5.2
 	fileSaveWorkspace->setStatusTip (i18n ("Saves the actual document"));
 
 	fileSaveWorkspaceAs = actionCollection ()->addAction (KStandardAction::SaveAs, "file_save_asx", this, SLOT(slotFileSaveWorkspaceAs()));
 	actionCollection ()->setDefaultShortcut (fileSaveWorkspaceAs, Qt::ControlModifier + Qt::AltModifier + Qt::ShiftModifier + Qt::Key_S);
-	fileSaveWorkspaceAs->setShortcut (Qt::ControlModifier + Qt::AltModifier + Qt::ShiftModifier + Qt::Key_S); // KF5 TODO: Not needed for KF5 >= 5.2
 	fileSaveWorkspaceAs->setText (i18n ("Save Workspace As"));
 	fileSaveWorkspaceAs->setStatusTip (i18n ("Saves the actual document as..."));
 
@@ -506,7 +504,7 @@ void RKWardMainWindow::initActions() {
 
 	interrupt_all_commands = actionCollection ()->addAction ("cancel_all_commands", this, SLOT (slotCancelAllCommands()));
 	interrupt_all_commands->setText (i18n ("Interrupt all commands"));
-	interrupt_all_commands->setShortcut (Qt::ShiftModifier + Qt::Key_Escape);
+	actionCollection ()->setDefaultShortcut (interrupt_all_commands, Qt::ShiftModifier + Qt::Key_Escape);
 	interrupt_all_commands->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionInterrupt));
 	interrupt_all_commands->setEnabled (false);		// enabled from within setRStatus()
 
diff --git a/rkward/windows/rkcommandeditorwindow.cpp b/rkward/windows/rkcommandeditorwindow.cpp
index ae4c2ec..552b22e 100644
--- a/rkward/windows/rkcommandeditorwindow.cpp
+++ b/rkward/windows/rkcommandeditorwindow.cpp
@@ -203,7 +203,7 @@ void RKCommandEditorWindow::initializeActions (KActionCollection* ac) {
 	QAction *action = ac->addAction ("enter_and_submit", this, SLOT (enterAndSubmit()));
 	action->setText (i18n ("Insert line break and run"));
 	ac->setDefaultShortcuts (action, QList<QKeySequence>() << Qt::AltModifier + Qt::Key_Return << Qt::AltModifier + Qt::Key_Enter);
-	action->setShortcut (Qt::AltModifier + Qt::Key_Return); // KF5 TODO: This line needed only for KF5 < 5.2, according to documentation
+	ac->setDefaultShortcut (action, Qt::AltModifier + Qt::Key_Return); // KF5 TODO: This line needed only for KF5 < 5.2, according to documentation
 
 	action_help_function = RKStandardActions::functionHelp (this, this, SLOT (showHelp()));
 
@@ -280,7 +280,7 @@ void RKCommandEditorWindow::initBlocks () {
 		record.unmark->setData (i);
 		actionmenu_unmark_block->addAction (record.unmark);
 		record.run = ac->addAction ("runblock" + QString::number (i), this, SLOT (runBlock()));
-		record.run->setShortcut (shortcuts[i]);
+		ac->setDefaultShortcut (record.run, shortcuts[i]);
 		record.run->setIcon (icon);
 		record.run->setData (i);
 		actionmenu_run_block->addAction (record.run);
diff --git a/rkward/windows/rkhtmlwindow.cpp b/rkward/windows/rkhtmlwindow.cpp
index 5d8aa95..6c7e8d2 100644
--- a/rkward/windows/rkhtmlwindow.cpp
+++ b/rkward/windows/rkhtmlwindow.cpp
@@ -647,7 +647,7 @@ void RKHTMLWindowPart::initActions () {
 
 	actionCollection ()->addAction (KStandardAction::Find, "find", window->findbar, SLOT (activate()));
 	QAction* findAhead = actionCollection ()->addAction ("find_ahead", new QAction (i18n ("Find as you type"), this));
-	findAhead->setShortcut ('/');
+	actionCollection ()->setDefaultShortcut (findAhead, '/');
 	connect (findAhead, &QAction::triggered, window->findbar, &RKFindBar::activate);
 	actionCollection ()->addAction (KStandardAction::FindNext, "find_next", window->findbar, SLOT (forward()));;
 	actionCollection ()->addAction (KStandardAction::FindPrev, "find_previous", window->findbar, SLOT (backward()));;;
diff --git a/rkward/windows/rktoplevelwindowgui.cpp b/rkward/windows/rktoplevelwindowgui.cpp
index 33b3672..b389209 100644
--- a/rkward/windows/rktoplevelwindowgui.cpp
+++ b/rkward/windows/rktoplevelwindowgui.cpp
@@ -76,23 +76,23 @@ RKTopLevelWindowGUI::RKTopLevelWindowGUI (KXmlGuiWindow *for_window) : QObject (
 	prev_action = actionCollection ()->addAction ("prev_window", this, SLOT (previousWindow()));
 	prev_action->setText (i18n ("Previous Window"));
 	prev_action->setIcon (QIcon (RKCommonFunctions::getRKWardDataDir () + "icons/window_back.png"));
-	prev_action->setShortcut (Qt::ControlModifier + Qt::Key_Tab);
+	actionCollection ()->setDefaultShortcut (prev_action, Qt::ControlModifier + Qt::Key_Tab);
 	next_action = actionCollection ()->addAction ("next_window", this, SLOT (nextWindow()));
 	next_action->setText (i18n ("Next Window"));
 	next_action->setIcon (QIcon (RKCommonFunctions::getRKWardDataDir () + "icons/window_forward.png"));
-	next_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Tab);
+	actionCollection ()->setDefaultShortcut (next_action, Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Tab);
 
 	QAction *action;
 	foreach (const RKToolWindowList::ToolWindowRepresentation& rep, RKToolWindowList::registeredToolWindows ()) {
 		action = actionCollection ()->addAction ("window_show_" + rep.id, this, SLOT (toggleToolView()));
 		action->setText (i18n ("Show/Hide %1", rep.window->shortCaption ()));
 		action->setIcon (rep.window->windowIcon ());
-		action->setShortcut (rep.default_shortcut);
+		actionCollection ()->setDefaultShortcut (action, rep.default_shortcut);
 		action->setProperty ("rk_toolwindow_id", rep.id);
 	}
 	action = actionCollection ()->addAction ("window_activate_docview", this, SLOT(activateDocumentView()));
 	action->setText (i18n ("Activate Document view"));
-	action->setShortcut (Qt::AltModifier + Qt::Key_0);
+	actionCollection ()->setDefaultShortcut (action, Qt::AltModifier + Qt::Key_0);
 
 	action = actionCollection ()->addAction ("output_show", this, SLOT (slotOutputShow()));
 	action->setText (i18n ("Show &Output"));
diff --git a/rkward/windows/rkworkplaceview.cpp b/rkward/windows/rkworkplaceview.cpp
index 3f1dc8c..0f93a7b 100644
--- a/rkward/windows/rkworkplaceview.cpp
+++ b/rkward/windows/rkworkplaceview.cpp
@@ -72,12 +72,10 @@ void RKWorkplaceView::initActions (KActionCollection *ac, const char *id_left, c
 	action_page_left = (QAction *) ac->addAction (id_left, this, SLOT (pageLeft()));
 	action_page_left->setText (i18n ("Window Left"));
 	ac->setDefaultShortcuts (action_page_left, QList<QKeySequence>() << Qt::ControlModifier + Qt::Key_Less << Qt::ControlModifier + Qt::Key_Comma);
-	action_page_left->setShortcut (Qt::ControlModifier + Qt::Key_Less); // KF5 TODO: not needed for KF5 >= 5.2
 
 	action_page_right = (QAction *) ac->addAction (id_right, this, SLOT (pageRight()));
 	action_page_right->setText (i18n ("Window Right"));
 	ac->setDefaultShortcuts (action_page_right, QList<QKeySequence>() << Qt::ControlModifier + Qt::Key_Greater << Qt::ControlModifier + Qt::Key_Period);
-	action_page_right->setShortcut (Qt::ControlModifier + Qt::Key_Greater); // KF5 TODO: not needed for KF5 >= 5.2
 
 	updateActions ();
 }



More information about the rkward-tracker mailing list