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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Thu Feb 17 11:54:57 UTC 2011


Revision: 3444
          http://rkward.svn.sourceforge.net/rkward/?rev=3444&view=rev
Author:   tfry
Date:     2011-02-17 11:54:57 +0000 (Thu, 17 Feb 2011)

Log Message:
-----------
Re-label the command editor's save and save as actions, and add them to the main window's toolbar.

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/rkward.cpp
    trunk/rkward/rkward/rkward.h
    trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
    trunk/rkward/rkward/windows/rkcommandeditorwindow.h

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2011-02-16 13:34:53 UTC (rev 3443)
+++ trunk/rkward/ChangeLog	2011-02-17 11:54:57 UTC (rev 3444)
@@ -1,4 +1,5 @@
 --- Version 0.5.5 - XXX-XX-2011
+- Re-organize the default toolbar actions of the main window
 - Detached windows are now restored in detached state when restoring the workplace layout
 - Workplace layout is now saved in a separate file, instead of in a hidden object inside the .RData file
 - Added R functions rk.save.workplace() and rk.restore.workplace() to save / restore a set of document windows

Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp	2011-02-16 13:34:53 UTC (rev 3443)
+++ trunk/rkward/rkward/rkward.cpp	2011-02-17 11:54:57 UTC (rev 3444)
@@ -418,15 +418,16 @@
 	new_any_action->addAction (new_data_frame);
 	new_any_action->addAction (new_command_editor);
 
-	KActionMenu* save_any_action = new KActionMenu (KIcon ("document-save"), i18n ("Save..."), this);
+	save_any_action = new KActionMenu (KIcon ("document-save"), i18n ("Save..."), this);
 	save_any_action->setDelayed (false);
 	actionCollection ()->addAction ("save_any", save_any_action);
 
 	proxy_export = new KAction (i18n ("Export"), this);
 	save_any_action->addAction (fileSaveWorkspace);
 	save_any_action->addAction (fileSaveWorkspaceAs);
+	save_any_action->addSeparator ();
 // TODO: A way to add R-script-save actions, dynamically, would be nice
-	save_any_action->addSeparator ();
+	save_actions_plug_point = save_any_action->addSeparator ();
 	save_any_action->addAction (proxy_export);
 }
 
@@ -475,6 +476,24 @@
 	updateEmptyMenuIndicator (view_menu_dummy, dynamic_cast<QMenu*>(guiFactory ()->container ("view", this)));
 	updateEmptyMenuIndicator (run_menu_dummy, dynamic_cast<QMenu*>(guiFactory ()->container ("run", this)));
 
+	// plug save file actions into the toolbar collections
+	RK_ASSERT (save_any_action);
+	for (int i = 0; i < plugged_save_actions.size (); ++i) {
+		QAction* a = plugged_save_actions[i].data ();
+		if (a) save_any_action->removeAction (a);
+	}
+	plugged_save_actions.clear ();
+
+	RKMDIWindow *w = RKWorkplace::mainWorkplace ()->activeWindow (RKMDIWindow::Attached);
+	if (w && (w->isType (RKMDIWindow::CommandEditorWindow))) {
+		QAction *a = static_cast<RKCommandEditorWindow*>(w)->fileSaveAction ();
+		if (a) plugged_save_actions.append (a);
+		a = static_cast<RKCommandEditorWindow*>(w)->fileSaveAsAction ();
+		if (a) plugged_save_actions.append (a);
+	}
+	for (int i = 0; i < plugged_save_actions.size (); ++i) {
+		save_any_action->insertAction (save_actions_plug_point, plugged_save_actions[i]);
+	}
 /*
 	// debug code: prints out all current actions
 	foreach (QAction *action, menuBar ()->actions ()) printActionsRecursive (action, QString ());

Modified: trunk/rkward/rkward/rkward.h
===================================================================
--- trunk/rkward/rkward/rkward.h	2011-02-16 13:34:53 UTC (rev 3443)
+++ trunk/rkward/rkward/rkward.h	2011-02-17 11:54:57 UTC (rev 3444)
@@ -25,6 +25,7 @@
 
 class QLabel;
 class QCloseEvent;
+class KActionMenu;
 // forward declaration of the RKward classes
 class RSettings;
 class RKMenu;
@@ -40,6 +41,7 @@
 class RKTopLevelWindowGUI;
 class KRecentFilesAction;
 class KSqueezedTextLabel;
+class QAction;
 
 struct RKWardStartupOptions {
 	KUrl initial_url;	/**< The workspace file to load on startup. If empty, show a dialog asking what to do. **/
@@ -176,6 +178,9 @@
 	KAction* run_menu_dummy;
 
 	KAction* proxy_export, *proxy_import;
+	KActionMenu* save_any_action;
+	QAction* save_actions_plug_point;
+	QList<QPointer <QAction> > plugged_save_actions;
 
 	friend class RKSettingsModule;
 	friend class RKSettingsModulePlugins;

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2011-02-16 13:34:53 UTC (rev 3443)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2011-02-17 11:54:57 UTC (rev 3444)
@@ -2,7 +2,7 @@
                           rkcommandeditorwindow  -  description
                              -------------------
     begin                : Mon Aug 30 2004
-    copyright            : (C) 2004, 2006, 2007, 2009, 2010 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2009, 2010, 2011 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -169,6 +169,17 @@
 	RKCommonFunctions::moveContainer (m_view, "Menu", "tools", "edit", true);
 }
 
+QAction *findAction (KTextEditor::View* view, const QString &actionName) {
+	// katepart has more than one actionCollection
+	QList<KActionCollection*> acs = view->findChildren<KActionCollection*>();
+	acs.append (view->actionCollection ());
+
+	foreach (KActionCollection* ac, acs) {
+		QAction* found = ac->action (actionName);
+		if (found) return found;
+	}
+}
+
 void RKCommandEditorWindow::initializeActions (KActionCollection* ac) {
 	RK_TRACE (COMMANDEDITOR);
 
@@ -198,6 +209,11 @@
 	action_setwd_to_script->setHelpText (i18n ("Change the working directory to the directory of this script"));
 #endif
 	action_setwd_to_script->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionCDToScript));
+
+	file_save = findAction (m_view, "file_save");
+	if (file_save) file_save->setText (i18n ("Save Script..."));
+	file_save_as = findAction (m_view, "file_save_as");
+	if (file_save_as) file_save_as->setText (i18n ("Save Script As..."));
 }
 
 void RKCommandEditorWindow::initBlocks () {

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2011-02-16 13:34:53 UTC (rev 3443)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2011-02-17 11:54:57 UTC (rev 3444)
@@ -2,7 +2,7 @@
                           rkcommandeditorwindow  -  description
                              -------------------
     begin                : Mon Aug 30 2004
-    copyright            : (C) 2004, 2006, 2007, 2009, 2010 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2009, 2010, 2011 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -43,6 +43,7 @@
 class QFrame;
 class QLabel;
 class KAction;
+class QAction;
 class KActionMenu;
 class RKCommandEditorWindow;
 class KActionCollection;
@@ -191,6 +192,9 @@
 
 /** apply our customizations to the katepart GUI */
 	void fixupPartGUI ();
+
+	QAction* fileSaveAction () { return file_save; };
+	QAction* fileSaveAsAction () { return file_save_as; };
 protected:
 /** reimplemented from RKMDIWindow: give the editor window a chance to object to being closed (if unsaved) */
 	void closeEvent (QCloseEvent *e);
@@ -245,6 +249,8 @@
 	void addBlock (int index, const KTextEditor::Range& range);
 	void removeBlock (int index, bool was_deleted=false);
 
+	QAction *file_save, *file_save_as;
+
 	KActionMenu* actionmenu_mark_block;
 	KActionMenu* actionmenu_unmark_block;
 	KActionMenu* actionmenu_run_block;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list