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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Jan 22 14:06:27 UTC 2007


Revision: 1191
          http://svn.sourceforge.net/rkward/?rev=1191&view=rev
Author:   tfry
Date:     2007-01-22 06:06:27 -0800 (Mon, 22 Jan 2007)

Log Message:
-----------
Provide help links in Settings->Configure RKWard (if available).
Link to help for console settings from console settings page

Modified Paths:
--------------
    trunk/rkward/rkward/settings/rksettings.cpp
    trunk/rkward/rkward/settings/rksettings.h
    trunk/rkward/rkward/settings/rksettingsmodule.h
    trunk/rkward/rkward/settings/rksettingsmoduleconsole.h

Modified: trunk/rkward/rkward/settings/rksettings.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettings.cpp	2007-01-22 14:03:58 UTC (rev 1190)
+++ trunk/rkward/rkward/settings/rksettings.cpp	2007-01-22 14:06:27 UTC (rev 1191)
@@ -2,7 +2,7 @@
                           rksettings  -  description
                              -------------------
     begin                : Wed Jul 28 2004
-    copyright            : (C) 2004 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2007 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -21,6 +21,8 @@
 #include <klocale.h>
 #include <kapplication.h>
 
+#include "../windows/rkworkplace.h"
+
 // modules
 #include "rksettingsmoduleplugins.h"
 #include "rksettingsmoduler.h"
@@ -58,18 +60,20 @@
 	settings_dialog = 0;
 }
 
-RKSettings::RKSettings (QWidget *parent, const char *name) : KDialogBase (KDialogBase::Tabbed, i18n ("Settings"), KDialogBase::Ok | KDialogBase::Apply | KDialogBase::Cancel, KDialogBase::Ok, parent, name, false) {
+RKSettings::RKSettings (QWidget *parent, const char *name) : KDialogBase (KDialogBase::Tabbed, i18n ("Settings"), KDialogBase::Ok | KDialogBase::Apply | KDialogBase::Cancel | KDialogBase::Help, KDialogBase::Ok, parent, name, false) {
 	RK_TRACE (SETTINGS);
 	setWFlags (getWFlags () | QWidget::WDestructiveClose);
 
 	initModules ();
+
+	connect (this, SIGNAL (aboutToShowPage (QWidget *)), this, SLOT (pageAboutToBeShown (QWidget *)));
 }
 
 RKSettings::~RKSettings() {
 	RK_TRACE (SETTINGS);
 
-	ModuleList::iterator it;
-	for (it = modules.begin (); it != modules.end (); ++it) {
+	ModuleList::const_iterator it;
+	for (it = modules.constBegin (); it != modules.constEnd (); ++it) {
 		delete *it;
 	}
 	modules.clear ();
@@ -90,10 +94,10 @@
 	modules.append (new RKSettingsModuleConsole (this, this));
 	modules.append (new RKSettingsModuleObjectBrowser (this, this));
 	
-	ModuleList::iterator it;
+	ModuleList::const_iterator it;
 	QFrame *page;
 	QVBoxLayout *layout;
-	for (it = modules.begin (); it != modules.end (); ++it) {
+	for (it = modules.constBegin (); it != modules.constEnd (); ++it) {
 		page = addPage ((*it)->caption ());
 		layout = new QVBoxLayout (page, 0, KDialog::spacingHint ());
 // this is somewhat ugly, but works fine
@@ -110,11 +114,38 @@
 	}
 }
 
+void RKSettings::pageAboutToBeShown (QWidget *page) {
+	RK_TRACE (SETTINGS);
+
+	// which module is it?
+	RKSettingsModule *new_module = 0;
+	for (ModuleList::const_iterator it = modules.constBegin (); it != modules.constEnd (); ++it) {
+		QWidget *pwidget = *it;
+		while (pwidget) {
+			if (pwidget == page) {
+				new_module = *it;
+				break;
+			}
+			pwidget = pwidget->parentWidget ();
+		}
+		if (new_module) break;
+	}
+
+	bool has_help;
+	if (!new_module) {
+		RK_ASSERT (false);
+		has_help = false;
+	} else {
+		has_help = !(new_module->helpURL ().isEmpty ());
+	}
+	enableButton (KDialogBase::Help, has_help);
+}
+
 void RKSettings::slotApply () {
 	RK_TRACE (SETTINGS);
 
-	ModuleList::iterator it;
-	for (it = modules.begin (); it != modules.end (); ++it) {
+	ModuleList::const_iterator it;
+	for (it = modules.constBegin (); it != modules.constEnd (); ++it) {
 		if ((*it)->hasChanges ()) {
 			(*it)->applyChanges ();
 			(*it)->save (kapp->config ());
@@ -136,6 +167,16 @@
 	QDialog::reject ();
 }
 
+void RKSettings::slotHelp () {
+	RK_TRACE (SETTINGS);
+
+	// which page are we on?
+	RKSettingsModule *current_module = modules[activePageIndex ()];
+	RK_ASSERT (current_module);
+
+	RKWorkplace::mainWorkplace ()->openHelpWindow (current_module->helpURL ());
+}
+
 void RKSettings::enableApply () {
 	RK_TRACE (SETTINGS);
 	enableButtonApply (true);

Modified: trunk/rkward/rkward/settings/rksettings.h
===================================================================
--- trunk/rkward/rkward/settings/rksettings.h	2007-01-22 14:03:58 UTC (rev 1190)
+++ trunk/rkward/rkward/settings/rksettings.h	2007-01-22 14:06:27 UTC (rev 1191)
@@ -2,7 +2,7 @@
                           rksettings  -  description
                              -------------------
     begin                : Wed Jul 28 2004
-    copyright            : (C) 2004 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2007 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -22,8 +22,6 @@
 #include <qvaluelist.h>
 
 class RKSettingsModule;
-class QTabWidget;
-class QPushButton;
 class KConfig;
 class RKWardMainWindow;
 class RKSettingsTracker;
@@ -35,6 +33,7 @@
 @author Thomas Friedrichsmeier
 */
 class RKSettings : public KDialogBase {
+	Q_OBJECT
 public:
 	enum SettingsPage { NoPage=0, Plugins=1, R=2, RPackages=3, PHP=4, General=5, Output=6, Watch=7, Console=8, ObjectBrowser=9 };
 
@@ -46,10 +45,13 @@
 	void enableApply ();
 	
 	static RKSettingsTracker* tracker () { return settings_tracker; };
+public slots:
+	void pageAboutToBeShown (QWidget *page);
 protected:
 	void slotApply ();
 	void slotOk ();
 	void slotCancel ();
+	void slotHelp ();
 protected:
 	RKSettings (QWidget *parent = 0, const char *name = 0);
 	~RKSettings ();

Modified: trunk/rkward/rkward/settings/rksettingsmodule.h
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmodule.h	2007-01-22 14:03:58 UTC (rev 1190)
+++ trunk/rkward/rkward/settings/rksettingsmodule.h	2007-01-22 14:06:27 UTC (rev 1191)
@@ -2,7 +2,7 @@
                           rksettingsmodule  -  description
                              -------------------
     begin                : Wed Jul 28 2004
-    copyright            : (C) 2004 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2007 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -43,6 +43,8 @@
 /** Some settings modules execute R commands on "apply". If an RCommandChain is specified for the RKSettings-dialog, those commands should
 be inserted into this chain. It's safe to use this unconditionally, as if there is no chain, this will return 0, which corresponds to using the top-level chain */
 	RCommandChain *commandChain () { return chain; };
+
+	virtual QString helpURL () { return QString (); };
 protected:
 	void change ();
 

Modified: trunk/rkward/rkward/settings/rksettingsmoduleconsole.h
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmoduleconsole.h	2007-01-22 14:03:58 UTC (rev 1190)
+++ trunk/rkward/rkward/settings/rksettingsmoduleconsole.h	2007-01-22 14:06:27 UTC (rev 1191)
@@ -57,6 +57,8 @@
 	static void saveCommandHistory (const QStringList &list);
 
 	QString caption ();
+
+	QString helpURL () { return ("rkward://page/rkward_console#settings"); };
 public slots:
 	void changedSetting (int);
 private:


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