[rkward-cvs] SF.net SVN: rkward-code:[4694] trunk/rkward

tfry at users.sf.net tfry at users.sf.net
Fri Apr 12 11:11:54 UTC 2013


Revision: 4694
          http://sourceforge.net/p/rkward/code/4694
Author:   tfry
Date:     2013-04-12 11:11:53 +0000 (Fri, 12 Apr 2013)
Log Message:
-----------
Merge Run line and Run selection, and re-assign shortcuts.
See http://www.mail-archive.com/rkward-devel@lists.sourceforge.net/msg02048.html

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/misc/rkstandardactions.cpp
    trunk/rkward/rkward/misc/rkstandardactions.h
    trunk/rkward/rkward/rkconsole.cpp
    trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
    trunk/rkward/rkward/windows/rkcommandeditorwindow.h
    trunk/rkward/rkward/windows/rkcommandlog.cpp
    trunk/rkward/rkward/windows/rkhtmlwindow.cpp
    trunk/rkward/rkward/windows/rkstandardactions.rc

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2013-04-11 17:56:27 UTC (rev 4693)
+++ trunk/rkward/ChangeLog	2013-04-12 11:11:53 UTC (rev 4694)
@@ -1,3 +1,5 @@
+- Shortcuts for the "Run ..." actions have been changed for better cross-platform compatibility
+- The script editor's "Run line" and "Run selection" actions have been merged
 - New (experimental) RKWard native on-screen device (RK())
         TODO: Finish it, then provide UI option to select on-screen device
 - New R function rk.without.plot.history() for turning off plot history, temporarily

Modified: trunk/rkward/rkward/misc/rkstandardactions.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkstandardactions.cpp	2013-04-11 17:56:27 UTC (rev 4693)
+++ trunk/rkward/rkward/misc/rkstandardactions.cpp	2013-04-12 11:11:53 UTC (rev 4694)
@@ -2,7 +2,7 @@
                           rkstandardactions  -  description
                              -------------------
     begin                : Sun Nov 18 2007
-    copyright            : (C) 2007, 2009, 2010, 2011 by Thomas Friedrichsmeier
+    copyright            : (C) 2007-2013 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -45,33 +45,29 @@
 	return ret;
 }
 
-KAction* RKStandardActions::runLine (RKMDIWindow *window, const QObject *receiver, const char *member) {
+KAction* RKStandardActions::runCurrent (RKMDIWindow *window, const QObject *receiver, const char *member, bool current_or_line) {
 	RK_TRACE (MISC);
 
-	KAction* ret = window->standardActionCollection ()->addAction ("run_line", receiver, member);
-	ret->setText (i18n ("Run current line"));
+	KAction* ret = window->standardActionCollection ()->addAction ("run_current", receiver, member);
+	if (current_or_line) {
+		ret->setText (i18n ("Run line / selection"));
+		ret->setStatusTip (i18n ("Runs the current selection (if any) or the current line (if there is no selection)"));
+		ret->setToolTip (ret->statusTip ());
+	} else {
+		ret->setText (i18n ("Run selection"));
+	}
 	ret->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionRunLine));
-	ret->setShortcut (Qt::ShiftModifier + Qt::Key_F7);
+	ret->setShortcut (KShortcut (Qt::ControlModifier + Qt::Key_Return, Qt::ControlModifier + Qt::Key_Enter));
 	return ret;
 }
 
-KAction* RKStandardActions::runSelection (RKMDIWindow *window, const QObject *receiver, const char *member) {
-	RK_TRACE (MISC);
-
-	KAction* ret = window->standardActionCollection ()->addAction ("run_selection", receiver, member);
-	ret->setText (i18n ("Run selection"));
-	ret->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionRunSelection));
-	ret->setShortcut (Qt::ShiftModifier + Qt::Key_F8);
-	return ret;
-}
-
 KAction* RKStandardActions::runAll (RKMDIWindow *window, const QObject *receiver, const char *member) {
 	RK_TRACE (MISC);
 
 	KAction* ret = window->standardActionCollection ()->addAction ("run_all", receiver, member);
 	ret->setText (i18n ("Run all"));
 	ret->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionRunAll));
-	ret->setShortcut (Qt::ShiftModifier + Qt::Key_F9);
+	ret->setShortcut (KShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Return, Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Enter));
 	return ret;
 }
 

Modified: trunk/rkward/rkward/misc/rkstandardactions.h
===================================================================
--- trunk/rkward/rkward/misc/rkstandardactions.h	2013-04-11 17:56:27 UTC (rev 4693)
+++ trunk/rkward/rkward/misc/rkstandardactions.h	2013-04-12 11:11:53 UTC (rev 4694)
@@ -2,7 +2,7 @@
                           rkstandardactions  -  description
                              -------------------
     begin                : Sun Nov 18 2007
-    copyright            : (C) 2007, 2009, 2010, 2011 by Thomas Friedrichsmeier
+    copyright            : (C) 2007-2013 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -32,8 +32,7 @@
 @param member needs to have the signature void fun (const QString&). */
 	KAction* pasteSpecial (RKMDIWindow *window, const QObject *receiver=0, const char *member=0);
 
-	KAction* runLine (RKMDIWindow *window, const QObject *receiver=0, const char *member=0);
-	KAction* runSelection (RKMDIWindow *window, const QObject *receiver=0, const char *member=0);
+	KAction* runCurrent (RKMDIWindow *window, const QObject *receiver=0, const char *member=0, bool current_or_line=false);
 	KAction* runAll (RKMDIWindow *window, const QObject *receiver=0, const char *member=0);
 
 	KAction* functionHelp (RKMDIWindow *window, const QObject *receiver=0, const char *member=0);

Modified: trunk/rkward/rkward/rkconsole.cpp
===================================================================
--- trunk/rkward/rkward/rkconsole.cpp	2013-04-11 17:56:27 UTC (rev 4693)
+++ trunk/rkward/rkward/rkconsole.cpp	2013-04-12 11:11:53 UTC (rev 4694)
@@ -889,7 +889,7 @@
 #endif
 	RKStandardActions::copyLinesToOutput (this, this, SLOT (copyLinesToOutput()));
 	context_help_action = RKStandardActions::functionHelp (this, this, SLOT(showContextHelp()));
-	run_selection_action = RKStandardActions::runSelection (this, this, SLOT (runSelection()));
+	run_selection_action = RKStandardActions::runCurrent (this, this, SLOT (runSelection()));
 
 	interrupt_command_action = ac->addAction ("interrupt", this, SLOT (resetConsole()));
 	interrupt_command_action->setText (i18n ("Interrupt running command"));

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2013-04-11 17:56:27 UTC (rev 4693)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2013-04-12 11:11:53 UTC (rev 4694)
@@ -2,7 +2,7 @@
                           rkcommandeditorwindow  -  description
                              -------------------
     begin                : Mon Aug 30 2004
-    copyright            : (C) 2004, 2006, 2007, 2009, 2010, 2011, 2012 by Thomas Friedrichsmeier
+    copyright            : (C) 2004-2013 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -212,13 +212,11 @@
 	RKStandardActions::pasteSpecial (this, this, SLOT (paste(const QString&)));
 
 	action_run_all = RKStandardActions::runAll (this, this, SLOT (runAll()));
-	action_run_selection = RKStandardActions::runSelection (this, this, SLOT (runSelection()));
-	action_run_selection->setEnabled (false);
-	action_run_line = RKStandardActions::runLine (this, this, SLOT (runLine()));
+	action_run_current = RKStandardActions::runCurrent (this, this, SLOT (runCurrent()), true);
 	// NOTE: enter_and_submit is not currently added to the menu
 	KAction *action = ac->addAction ("enter_and_submit", this, SLOT (enterAndSubmit()));
 	action->setText (i18n ("Insert line break and run"));
-	action->setShortcuts (KShortcut (Qt::ControlModifier + Qt::Key_Return, Qt::ControlModifier + Qt::Key_Enter));
+	action->setShortcuts (KShortcut (Qt::AltModifier + Qt::Key_Return, Qt::AltModifier + Qt::Key_Enter));
 
 	action_help_function = RKStandardActions::functionHelp (this, this, SLOT (showHelp()));
 
@@ -690,27 +688,22 @@
 	RKConsole::pipeUserCommand ("setwd (\"" + dir + "\")");
 }
 
-void RKCommandEditorWindow::runSelection() {
+void RKCommandEditorWindow::runCurrent () {
 	RK_TRACE (COMMANDEDITOR);
 
-	QString command = m_view->selectionText ();
-	if (command.isEmpty ()) return;
+	if (m_view->selection ()) {
+		RKConsole::pipeUserCommand (m_view->selectionText ());
+	} else {
+		KTextEditor::Cursor c = m_view->cursorPosition();
+		QString command = m_doc->line (c.line());
+		if (!command.isEmpty ()) RKConsole::pipeUserCommand (command + '\n');
 
-	RKConsole::pipeUserCommand (command);
+		// advance to next line (NOTE: m_view->down () won't work on auto-wrapped lines)
+		c.setLine(c.line() + 1);
+		m_view->setCursorPosition (c);
+	}
 }
 
-void RKCommandEditorWindow::runLine() {
-	RK_TRACE (COMMANDEDITOR);
-
-	KTextEditor::Cursor c = m_view->cursorPosition();
-	QString command = m_doc->line (c.line());
-	if (!command.isEmpty ()) RKConsole::pipeUserCommand (command + '\n');
-
-	// advance to next line (NOTE: m_view->down () won't work on auto-wrapped lines)
-	c.setLine(c.line() + 1);
-	m_view->setCursorPosition (c);
-}
-
 void RKCommandEditorWindow::enterAndSubmit () {
 	RK_TRACE (COMMANDEDITOR);
 
@@ -863,10 +856,8 @@
 	RK_ASSERT (view == m_view);
 
 	if (view->selection ()) {
-		action_run_selection->setEnabled (true);
 		actionmenu_mark_block->setEnabled (true);
 	} else {
-		action_run_selection->setEnabled (false);
 		actionmenu_mark_block->setEnabled (false);
 	}
 }

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2013-04-11 17:56:27 UTC (rev 4693)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2013-04-12 11:11:53 UTC (rev 4694)
@@ -2,7 +2,7 @@
                           rkcommandeditorwindow  -  description
                              -------------------
     begin                : Mon Aug 30 2004
-    copyright            : (C) 2004, 2006, 2007, 2009, 2010, 2011, 2012 by Thomas Friedrichsmeier
+    copyright            : (C) 2004-2013 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -205,10 +205,8 @@
 	void focusIn (KTextEditor::View *);
 /** Show help about the current word. */
 	void showHelp ();
-/** run the currently selected command(s) */
-	void runSelection ();
-/** run the current line */
-	void runLine ();
+/** run the currently selected command(s) or line */
+	void runCurrent ();
 /** run the entire script */
 	void runAll ();
 /** insert line break and run the (previous) line */
@@ -287,8 +285,7 @@
 	KActionMenu* actionmenu_run_block;
 
 	KAction* action_run_all;
-	KAction* action_run_selection;
-	KAction* action_run_line;
+	KAction* action_run_current;
 
 	KAction* action_setwd_to_script;
 

Modified: trunk/rkward/rkward/windows/rkcommandlog.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandlog.cpp	2013-04-11 17:56:27 UTC (rev 4693)
+++ trunk/rkward/rkward/windows/rkcommandlog.cpp	2013-04-12 11:11:53 UTC (rev 4694)
@@ -287,7 +287,7 @@
 	QAction *configure = actionCollection ()->addAction ("log_configure", log, SLOT(configureLog()));
 	configure->setText (i18n ("Configure"));
 
-	run_selection = RKStandardActions::runSelection (log, log, SLOT(runSelection()));
+	run_selection = RKStandardActions::runCurrent (log, log, SLOT(runSelection()));
 
 	connect (log->getView (), SIGNAL (popupMenuRequest (const QPoint &)), this, SLOT (doPopupMenu (const QPoint &)));
 }

Modified: trunk/rkward/rkward/windows/rkhtmlwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.cpp	2013-04-11 17:56:27 UTC (rev 4693)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.cpp	2013-04-12 11:11:53 UTC (rev 4694)
@@ -135,7 +135,7 @@
 
 	print = actionCollection ()->addAction (KStandardAction::Print, "print_html", this, SLOT (slotPrint()));
 
-	run_selection = RKStandardActions::runSelection (this, this, SLOT (runSelection()));
+	run_selection = RKStandardActions::runCurrent (this, this, SLOT (runSelection()));
 
 		// needed to enable / disable the run selection action
 	connect (khtmlpart, SIGNAL (selectionChanged()), this, SLOT (selectionChanged()));

Modified: trunk/rkward/rkward/windows/rkstandardactions.rc
===================================================================
--- trunk/rkward/rkward/windows/rkstandardactions.rc	2013-04-11 17:56:27 UTC (rev 4693)
+++ trunk/rkward/rkward/windows/rkstandardactions.rc	2013-04-12 11:11:53 UTC (rev 4694)
@@ -1,5 +1,5 @@
 <!DOCTYPE kpartgui>
-<kpartgui name="rkward_standardactions" version="560">
+<kpartgui name="rkward_standardactions" version="620">
 <!-- What is this for, wouldn't it be easier to just inline these actions in the parts where they
      end up? Yes, but then they would be separate actions, internally, and each could be assigned
      a shortcut of its own. This is needed to tie them all together. -->
@@ -11,8 +11,7 @@
 			<Action name="paste_special" group="after_edit_paste_merge"/>
 		</Menu>
 		<Menu name="run">
-			<Action name="run_line" group="run_actions_merge"/>
-			<Action name="run_selection" group="run_actions_merge"/>
+			<Action name="run_current" group="run_actions_merge"/>
 			<Action name="run_all" group="run_actions_merge"/>
 			<WeakSeparator group="postrun_actions_merge"/>
 			<Action name="interrupt" group="postrun_actions_merge"/>
@@ -37,8 +36,7 @@
 	<Menu name="ktexteditor_popup">
 		<Action name="paste_special" group="edit_paste_merge"/>
 		<Menu name="run">
-			<Action name="run_line" group="run_actions_merge"/>
-			<Action name="run_selection" group="run_actions_merge"/>
+			<Action name="run_current" group="run_actions_merge"/>
 			<Action name="run_all" group="run_actions_merge"/>
 		</Menu>
 		<Action name="function_reference" group="ktexteditor_popup_merge2"/>
@@ -48,12 +46,12 @@
 	<Menu name="rkconsole_context_menu">
 		<Action name="copy_lines_to_output" group="rkconsole_context_merge_copy"/>
 		<Action name="paste_special" group="rkconsole_context_merge_paste"/>
-		<Action name="run_selection" group="rkconsole_context_merge1"/>
+		<Action name="run_current" group="rkconsole_context_merge1"/>
 		<Action name="function_reference" group="rkconsole_context_merge2"/>
 		<Separator/>
 		<Action name="window_configure"/>
 	</Menu>
 	<Menu name="rkcommandlog_context_menu">
-		<Action name="run_selection" group="rkcommandlog_context_merge1"/>
+		<Action name="run_current" group="rkcommandlog_context_merge1"/>
 	</Menu>
 </kpartgui>
\ No newline at end of file





More information about the rkward-tracker mailing list