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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Jan 7 14:28:56 UTC 2008


Revision: 2304
          http://rkward.svn.sourceforge.net/rkward/?rev=2304&view=rev
Author:   tfry
Date:     2008-01-07 06:28:56 -0800 (Mon, 07 Jan 2008)

Log Message:
-----------
Add simple support for focus follows mouse-style MDI window focus

Modified Paths:
--------------
    trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp
    trunk/rkward/rkward/settings/rksettingsmodulegeneral.h
    trunk/rkward/rkward/windows/rkmdiwindow.cpp
    trunk/rkward/rkward/windows/rkmdiwindow.h

Modified: trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp	2008-01-07 14:25:08 UTC (rev 2303)
+++ trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp	2008-01-07 14:28:56 UTC (rev 2304)
@@ -2,7 +2,7 @@
                           rksettingsmodulegeneral  -  description
                              -------------------
     begin                : Fri Jul 30 2004
-    copyright            : (C) 2004, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2007, 2008 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -43,6 +43,7 @@
 RKSettingsModuleGeneral::WorkplaceSaveMode RKSettingsModuleGeneral::workplace_save_mode;
 bool RKSettingsModuleGeneral::show_help_on_startup;
 int RKSettingsModuleGeneral::warn_size_object_edit;
+RKSettingsModuleGeneral::RKMDIFocusPolicy RKSettingsModuleGeneral::mdi_focus_policy;
 
 RKSettingsModuleGeneral::RKSettingsModuleGeneral (RKSettings *gui, QWidget *parent) : RKSettingsModule (gui, parent) {
 	RK_TRACE (SETTINGS);
@@ -110,6 +111,18 @@
 	main_vbox->addWidget (label);
 	main_vbox->addWidget (warn_size_object_edit_box);
 
+	main_vbox->addSpacing (2*RKGlobals::spacingHint ());
+
+	label = new QLabel (i18n ("MDI window focus behavior"), this);
+	mdi_focus_policy_chooser = new QComboBox (this);
+	mdi_focus_policy_chooser->setEditable (false);
+	mdi_focus_policy_chooser->insertItem (RKMDIClickFocus, i18n ("Click to focus"));
+	mdi_focus_policy_chooser->insertItem (RKMDIFocusFollowsMouse, i18n ("Focus follows mouse"));
+	mdi_focus_policy_chooser->setCurrentIndex (mdi_focus_policy);
+	connect (mdi_focus_policy_chooser, SIGNAL (activated (int)), this, SLOT (boxChanged (int)));
+	main_vbox->addWidget (label);
+	main_vbox->addWidget (mdi_focus_policy_chooser);
+
 	main_vbox->addStretch ();
 }
 
@@ -144,6 +157,7 @@
 	show_help_on_startup = show_help_on_startup_box->isChecked ();
 	workplace_save_mode = static_cast<WorkplaceSaveMode> (workplace_save_chooser->checkedId ());
 	warn_size_object_edit = warn_size_object_edit_box->intValue ();
+	mdi_focus_policy = static_cast<RKMDIFocusPolicy> (mdi_focus_policy_chooser->currentIndex ());
 }
 
 void RKSettingsModuleGeneral::save (KConfig *config) {
@@ -167,6 +181,9 @@
 
 	cg = config->group ("Editor");
 	cg.writeEntry ("large object warning limit", warn_size_object_edit);
+
+	cg = config->group ("MDI");
+	cg.writeEntry ("focus policy", (int) mdi_focus_policy);
 }
 
 void RKSettingsModuleGeneral::loadSettings (KConfig *config) {
@@ -185,6 +202,9 @@
 
 	cg = config->group ("Editor");
 	warn_size_object_edit = cg.readEntry ("large object warning limit", 250000);
+
+	cg = config->group ("MDI");
+	mdi_focus_policy = (RKMDIFocusPolicy) cg.readEntry ("focus policy", (int) RKMDIClickFocus);
 }
 
 QString RKSettingsModuleGeneral::getSavedWorkplace (KConfig *config) {

Modified: trunk/rkward/rkward/settings/rksettingsmodulegeneral.h
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmodulegeneral.h	2008-01-07 14:25:08 UTC (rev 2303)
+++ trunk/rkward/rkward/settings/rksettingsmodulegeneral.h	2008-01-07 14:28:56 UTC (rev 2304)
@@ -2,7 +2,7 @@
                           rksettingsmodulegeneral  -  description
                              -------------------
     begin                : Fri Jul 30 2004
-    copyright            : (C) 2004, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2007, 2008 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -42,6 +42,11 @@
 		DontSaveWorkplace=2
 	};
 
+	enum RKMDIFocusPolicy {		// don't change the int values of this enum, or you'll ruin users saved settings. Append new values at the end
+		RKMDIClickFocus=0,
+		RKMDIFocusFollowsMouse=1
+	};
+
 	bool hasChanges ();
 	void applyChanges ();
 	void save (KConfig *config);
@@ -62,6 +67,7 @@
 /** set the saved workplace description. Meaningful only is workplaceSaveMode () == SaveWorkplaceWithSession */
 	static void setSavedWorkplace (const QString &description, KConfig *config);
 	static unsigned long warnLargeObjectThreshold () { return warn_size_object_edit; };
+	static RKMDIFocusPolicy mdiFocusPolicy () { return mdi_focus_policy; }
 public slots:
 	void pathChanged ();
 	void boxChanged (int);
@@ -71,6 +77,7 @@
 	QButtonGroup *workplace_save_chooser;
 	QCheckBox *show_help_on_startup_box;
 	RKSpinBox *warn_size_object_edit_box;
+	QComboBox *mdi_focus_policy_chooser;
 
 	static StartupDialog::Result startup_action;
 	static QString files_path;
@@ -79,6 +86,7 @@
 	static WorkplaceSaveMode workplace_save_mode;
 	static bool show_help_on_startup;
 	static int warn_size_object_edit;
+	static RKMDIFocusPolicy mdi_focus_policy;
 };
 
 #endif

Modified: trunk/rkward/rkward/windows/rkmdiwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkmdiwindow.cpp	2008-01-07 14:25:08 UTC (rev 2303)
+++ trunk/rkward/rkward/windows/rkmdiwindow.cpp	2008-01-07 14:28:56 UTC (rev 2304)
@@ -2,7 +2,7 @@
                           rkmdiwindow  -  description
                              -------------------
     begin                : Tue Sep 26 2006
-    copyright            : (C) 2006, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2006, 2007, 2008 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -29,6 +29,7 @@
 #include "rkworkplace.h"
 #include "rkworkplaceview.h"
 #include "rktoolwindowbar.h"
+#include "../settings/rksettingsmodulegeneral.h"
 #include "../misc/rkstandardicons.h"
 
 #include "../debug.h"
@@ -205,4 +206,16 @@
 	if (active || (!isAttached ())) update ();
 }
 
+void RKMDIWindow::enterEvent (QEvent *event) {
+	RK_TRACE (APP);
+
+	if (!isActive ()) {
+		if (RKSettingsModuleGeneral::mdiFocusPolicy () == RKSettingsModuleGeneral::RKMDIFocusFollowsMouse) {
+			activate (true);
+		}
+	}
+
+	QFrame::enterEvent (event);
+}
+
 #include "rkmdiwindow.moc"

Modified: trunk/rkward/rkward/windows/rkmdiwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkmdiwindow.h	2008-01-07 14:25:08 UTC (rev 2303)
+++ trunk/rkward/rkward/windows/rkmdiwindow.h	2008-01-07 14:28:56 UTC (rev 2304)
@@ -2,7 +2,7 @@
                           rkmdiwindow  -  description
                              -------------------
     begin                : Tue Sep 26 2006
-    copyright            : (C) 2006, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2006, 2007, 2008 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -108,6 +108,9 @@
 	void initializeActivationSignals ();
 	void paintEvent (QPaintEvent *e);
 	void windowActivationChange (bool);
+
+/** reimplemented from QWidget to emulate focus-follows-mouse behavior */
+	void enterEvent (QEvent *event);
 friend class RKWorkplace;
 /** type of this window */
 	int type;


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