On Friday 29 November 2002 8:44 am, [EMAIL PROTECTED] wrote:
> http://bugzilla.lyx.org/show_bug.cgi?id=749
>
>            Summary: xforms gui prefs not saved
>            Product: LyX
>            Version: 1.3.0cvs
>           Platform: Other
>         OS/Version: All
>             Status: NEW
>           Severity: normal
>           Priority: P2
>          Component: frontend-xforms
>         AssignedTo: [EMAIL PROTECTED]
>         ReportedBy: [EMAIL PROTECTED]
>          QAContact: [EMAIL PROTECTED]
>
>
> see FIXME in FormPreferences.C

Ok, John. I believe that the attached patch fixes this in the correct manner. 
I'll commit this, but I've attached it also so that you can see how to do the 
same sort of thing for Qt.

Angus
Index: src/frontends/controllers/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ChangeLog,v
retrieving revision 1.266
diff -u -p -r1.266 ChangeLog
--- src/frontends/controllers/ChangeLog	28 Nov 2002 16:15:45 -0000	1.266
+++ src/frontends/controllers/ChangeLog	29 Nov 2002 09:53:03 -0000
@@ -1,3 +1,15 @@
+2002-11-29  Angus Leeming  <[EMAIL PROTECTED]>
+
+	* ControlButtons.h (isClosing): make it public, so that the view can
+	see it too.
+	(OKButton): no longer virtual. ControlPrefs should use isClosing() from
+	within apply.
+
+	* ControlPrefs.[Ch] (OKButton): removed.
+
+	* ControlPrefs.C (apply): dispatch a LFUN_SAVEPREFERENCES if the
+	dialog isClosing(). (Ie, if the "save" button has been pressed.)
+
 2002-11-28  John Levon  <[EMAIL PROTECTED]>
  
         * ControlSpellchecker.C: fix Lars' broken cleanup
Index: src/frontends/controllers/ControlButtons.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlButtons.h,v
retrieving revision 1.16
diff -u -p -r1.16 ControlButtons.h
--- src/frontends/controllers/ControlButtons.h	15 Nov 2002 02:41:54 -0000	1.16
+++ src/frontends/controllers/ControlButtons.h	29 Nov 2002 09:53:03 -0000
@@ -49,8 +49,8 @@ public:
 	 */
 	///
 	void ApplyButton();
-	/// virtual for ControlPrefs
-	virtual void OKButton();
+	///
+	void OKButton();
 	///
 	void CancelButton();
 	///
@@ -66,13 +66,13 @@ public:
 	void setView(ViewBase &);
 	///
 	void setButtonController(ButtonControllerBase &);
-protected:
-	///
-	ViewBase & view();
-
 	/** When Applying it's useful to know whether the dialog is about
 	    to close or not (no point refreshing the display for example). */
 	bool isClosing() const { return is_closing_; }
+
+protected:
+	///
+	ViewBase & view();
 
 	/// Get changed parameters and Dispatch them to the kernel.
 	virtual void apply() = 0;
Index: src/frontends/controllers/ControlPrefs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlPrefs.C,v
retrieving revision 1.5
diff -u -p -r1.5 ControlPrefs.C
--- src/frontends/controllers/ControlPrefs.C	27 Nov 2002 10:30:22 -0000	1.5
+++ src/frontends/controllers/ControlPrefs.C	29 Nov 2002 09:53:03 -0000
@@ -48,13 +48,11 @@ void ControlPrefs::apply()
 {
 	view().apply();
 	lyxrc = rc_;
-}
 
-
-void ControlPrefs::OKButton()
-{
-	ControlDialogBI::OKButton();
-	lv_.dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
+	// The Save button has been pressed
+	if (isClosing()) {
+		lv_.dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
+	}
 }
 
 
Index: src/frontends/controllers/ControlPrefs.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlPrefs.h,v
retrieving revision 1.3
diff -u -p -r1.3 ControlPrefs.h
--- src/frontends/controllers/ControlPrefs.h	15 Nov 2002 02:53:47 -0000	1.3
+++ src/frontends/controllers/ControlPrefs.h	29 Nov 2002 09:53:03 -0000
@@ -39,9 +39,6 @@ public:
 
 	LyXRC const & rc() const { return rc_; }
  
-	/// make OK do the save
-	virtual void OKButton();
- 
 	/// various file pickers
 	string const browsebind(string const & file);
 	string const browseUI(string const & file);
Index: src/frontends/xforms/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/ChangeLog,v
retrieving revision 1.620
diff -u -p -r1.620 ChangeLog
--- src/frontends/xforms/ChangeLog	29 Nov 2002 09:26:53 -0000	1.620
+++ src/frontends/xforms/ChangeLog	29 Nov 2002 09:53:06 -0000
@@ -1,5 +1,10 @@
 2002-11-29  Angus Leeming  <[EMAIL PROTECTED]>
 
+	* FormPreferences.C (apply): if controller().isClosing() (ie, if the
+	"save" button has been pressed), then save any modified gui colors.
+
+2002-11-29  Angus Leeming  <[EMAIL PROTECTED]>
+
 	* forms_gettext.[Ch] (scex, idex): re-written to receive and return
 	string not char *. The old idex function was new-ing memory and nothing
 	that used it was ensuring that this memory didn't leak. Now safe.
Index: src/frontends/xforms/FormPreferences.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormPreferences.C,v
retrieving revision 1.143
diff -u -p -r1.143 FormPreferences.C
--- src/frontends/xforms/FormPreferences.C	29 Nov 2002 09:26:53 -0000	1.143
+++ src/frontends/xforms/FormPreferences.C	29 Nov 2002 09:53:08 -0000
@@ -135,24 +135,6 @@ void FormPreferences::redraw()
 }
 
 
-#if 0
-void FormPreferences::ok()
-{
-	FormBaseDeprecated::ok();
-
-// FIXME !!
-	if (colors_.modifiedXformsPrefs) {
-		string const filename =
-			AddName(user_lyxdir, "preferences.xform");
-		colors_.modifiedXformsPrefs = !XformsColor::write(filename);
-	}
-
-	lv_.dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
-}
-#endif
-
-
-
 void FormPreferences::hide()
 {
 	// We need to hide the active tabfolder otherwise we get a
@@ -302,6 +284,13 @@ void FormPreferences::apply()
 	printer_.apply(rc);
 	screen_fonts_.apply(rc);
 	spelloptions_.apply(rc);
+
+	// The "Save" button has been pressed.
+	if (controller().isClosing() && colors_.modifiedXformsPrefs) {
+		string const filename =
+			AddName(user_lyxdir, "preferences.xform");
+		colors_.modifiedXformsPrefs = !XformsColor::write(filename);
+	}
 }
 
 

Reply via email to