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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Fri Apr 22 12:24:59 UTC 2011


Revision: 3520
          http://rkward.svn.sourceforge.net/rkward/?rev=3520&view=rev
Author:   tfry
Date:     2011-04-22 12:24:58 +0000 (Fri, 22 Apr 2011)

Log Message:
-----------
Add option to cd to loaded workspace (on by default)

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/agents/rkloadagent.cpp
    trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp
    trunk/rkward/rkward/settings/rksettingsmodulegeneral.h

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2011-04-22 11:28:08 UTC (rev 3519)
+++ trunk/rkward/ChangeLog	2011-04-22 12:24:58 UTC (rev 3520)
@@ -1,3 +1,4 @@
+- When loading a (local) workspace, change the working directory to the directory of the workspace (configurable)
 - Include the sidebar position of tool windows when saving / restoring the workplace layout
 - "Pending jobs" tool window is not longer shown in the bottom sidebar by default
 - Support removing individual tool windows from the sidebars, completely

Modified: trunk/rkward/rkward/agents/rkloadagent.cpp
===================================================================
--- trunk/rkward/rkward/agents/rkloadagent.cpp	2011-04-22 11:28:08 UTC (rev 3519)
+++ trunk/rkward/rkward/agents/rkloadagent.cpp	2011-04-22 12:24:58 UTC (rev 3520)
@@ -28,6 +28,7 @@
 #include "../rbackend/rinterface.h"
 #include "../rkward.h"
 #include "../windows/rkworkplace.h"
+#include "../settings/rksettingsmodulegeneral.h"
 
 #include "../debug.h"
 
@@ -74,6 +75,11 @@
 			RObjectList::getObjectList ()->setWorkspaceURL (KUrl());
 		} else {
 			RKWorkplace::mainWorkplace ()->restoreWorkplace ();
+			if (RKSettingsModuleGeneral::cdToWorkspaceOnLoad ()) {
+				if (RObjectList::getObjectList ()->getWorkspaceURL ().isLocalFile ()) {
+					RKGlobals::rInterface ()->issueCommand ("setwd (" + RObject::rQuote (RObjectList::getObjectList ()->getWorkspaceURL ().directory ()) + ")", RCommand::App);
+				}
+			}
 		}
 		RKWardMainWindow::getMain ()->slotSetStatusReady ();
 		RKWardMainWindow::getMain ()->setCaption (QString::null);	// trigger update of caption

Modified: trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp	2011-04-22 11:28:08 UTC (rev 3519)
+++ trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp	2011-04-22 12:24:58 UTC (rev 3520)
@@ -41,6 +41,7 @@
 QString RKSettingsModuleGeneral::new_files_path;
 StartupDialog::Result RKSettingsModuleGeneral::startup_action;
 RKSettingsModuleGeneral::WorkplaceSaveMode RKSettingsModuleGeneral::workplace_save_mode;
+bool RKSettingsModuleGeneral::cd_to_workspace_dir_on_load;
 bool RKSettingsModuleGeneral::show_help_on_startup;
 int RKSettingsModuleGeneral::warn_size_object_edit;
 RKSettingsModuleGeneral::RKMDIFocusPolicy RKSettingsModuleGeneral::mdi_focus_policy;
@@ -104,6 +105,13 @@
 
 	main_vbox->addSpacing (2*RKGlobals::spacingHint ());
 
+	cd_to_workspace_dir_on_load_box = new QCheckBox (i18n ("When loading a workspace, change to the corresponding directory."), this);
+	cd_to_workspace_dir_on_load_box->setChecked (cd_to_workspace_dir_on_load);
+	connect (cd_to_workspace_dir_on_load_box, SIGNAL (stateChanged (int)), this, SLOT (boxChanged (int)));
+	main_vbox->addWidget (cd_to_workspace_dir_on_load_box);
+
+	main_vbox->addSpacing (2*RKGlobals::spacingHint ());
+
 	label = new QLabel (i18n ("Warn when editing objects with more than this number of fields (0 for no limit):"), this);
 	warn_size_object_edit_box = new RKSpinBox (this);
 	warn_size_object_edit_box->setIntMode (0, INT_MAX, warn_size_object_edit);
@@ -157,6 +165,7 @@
 	startup_action = static_cast<StartupDialog::Result> (startup_action_choser->itemData (startup_action_choser->currentIndex ()).toInt ());
 	show_help_on_startup = show_help_on_startup_box->isChecked ();
 	workplace_save_mode = static_cast<WorkplaceSaveMode> (workplace_save_chooser->checkedId ());
+	cd_to_workspace_dir_on_load = cd_to_workspace_dir_on_load_box->isChecked ();
 	warn_size_object_edit = warn_size_object_edit_box->intValue ();
 	mdi_focus_policy = static_cast<RKMDIFocusPolicy> (mdi_focus_policy_chooser->currentIndex ());
 }
@@ -179,6 +188,7 @@
 
 	cg = config->group ("Workplace");
 	cg.writeEntry ("save mode", (int) workplace_save_mode);
+	cg.writeEntry ("cd to workspace on load", cd_to_workspace_dir_on_load);
 
 	cg = config->group ("Editor");
 	cg.writeEntry ("large object warning limit", warn_size_object_edit);
@@ -200,6 +210,7 @@
 
 	cg = config->group ("Workplace");
 	workplace_save_mode = (WorkplaceSaveMode) cg.readEntry ("save mode", (int) SaveWorkplaceWithWorkspace);
+	cd_to_workspace_dir_on_load = cg.readEntry ("cd to workspace on load", true);
 
 	cg = config->group ("Editor");
 	warn_size_object_edit = cg.readEntry ("large object warning limit", 250000);

Modified: trunk/rkward/rkward/settings/rksettingsmodulegeneral.h
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmodulegeneral.h	2011-04-22 11:28:08 UTC (rev 3519)
+++ trunk/rkward/rkward/settings/rksettingsmodulegeneral.h	2011-04-22 12:24:58 UTC (rev 3520)
@@ -2,7 +2,7 @@
                           rksettingsmodulegeneral  -  description
                              -------------------
     begin                : Fri Jul 30 2004
-    copyright            : (C) 2004, 2007, 2008 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2007, 2008, 2011 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -66,6 +66,7 @@
 	static QString getSavedWorkplace (KConfig *config);
 /** set the saved workplace description. Meaningful only is workplaceSaveMode () == SaveWorkplaceWithSession */
 	static void setSavedWorkplace (const QString &description, KConfig *config);
+	static bool cdToWorkspaceOnLoad () { return cd_to_workspace_dir_on_load; };
 	static unsigned long warnLargeObjectThreshold () { return warn_size_object_edit; };
 	static RKMDIFocusPolicy mdiFocusPolicy () { return mdi_focus_policy; }
 public slots:
@@ -75,6 +76,7 @@
 	GetFileNameWidget *files_choser;
 	QComboBox *startup_action_choser;
 	QButtonGroup *workplace_save_chooser;
+	QCheckBox *cd_to_workspace_dir_on_load_box;
 	QCheckBox *show_help_on_startup_box;
 	RKSpinBox *warn_size_object_edit_box;
 	QComboBox *mdi_focus_policy_chooser;
@@ -84,6 +86,7 @@
 /** since changing the files_path can not easily be done while in an active session, the setting should only take effect on the next start. This string stores a changed setting, while keeping the old one intact as long as RKWard is running */
 	static QString new_files_path;
 	static WorkplaceSaveMode workplace_save_mode;
+	static bool cd_to_workspace_dir_on_load;
 	static bool show_help_on_startup;
 	static int warn_size_object_edit;
 	static RKMDIFocusPolicy mdi_focus_policy;


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