changeset 27866:b134fc61d89e

use symbolic constants for prefs of graphics utlilities * annotation-dialog.cc: include gui-preferences-gp.h; (init, button_clicked): replace literals by symbolic constants * gui-preferences-all.h: add gui-preferences-gp.h * gui-preferences-gp.h: new include file with symbilic constants for prefs
author Torsten Lilge <ttl-octave@mailbox.org>
date Sun, 22 Dec 2019 17:40:15 +0100
parents b62ca41f355b
children 99371079780f
files libgui/graphics/annotation-dialog.cc libgui/src/gui-preferences-all.h libgui/src/gui-preferences-gp.h
diffstat 3 files changed, 38 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/graphics/annotation-dialog.cc	Mon Dec 23 08:01:12 2019 -0800
+++ b/libgui/graphics/annotation-dialog.cc	Sun Dec 22 17:40:15 2019 +0100
@@ -29,6 +29,7 @@
 #include <QPalette>
 
 #include "gui-settings.h"
+#include "gui-preferences-gp.h"
 #include "octave-qobject.h"
 
 #include "QtHandlesUtils.h"
@@ -56,8 +57,8 @@
   octave::gui_settings *settings = rmgr.get_settings ();
 
   // restore last geometry
-  if (settings)
-    restoreGeometry (settings->value ("annotation/geometry").toByteArray ());
+  if (settings && settings->contains (gp_annotation_geometry.key))
+    restoreGeometry (settings->value (gp_annotation_geometry).toByteArray ());
 
   // connect signals
   connect (ui->button_box, SIGNAL (clicked (QAbstractButton *)),
@@ -103,7 +104,7 @@
 
   // save position
   if (settings)
-    settings->setValue ("annotation/geometry",saveGeometry ());
+    settings->setValue (gp_annotation_geometry.key, saveGeometry ());
 
   if (button_role == QDialogButtonBox::ApplyRole
       || button_role == QDialogButtonBox::AcceptRole)
--- a/libgui/src/gui-preferences-all.h	Mon Dec 23 08:01:12 2019 -0800
+++ b/libgui/src/gui-preferences-all.h	Sun Dec 22 17:40:15 2019 +0100
@@ -29,6 +29,7 @@
 #include "gui-preferences-fb.h"
 #include "gui-preferences-ff.h"
 #include "gui-preferences-global.h"
+#include "gui-preferences-gp.h"
 #include "gui-preferences-hw.h"
 #include "gui-preferences-mw.h"
 #include "gui-preferences-nr.h"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgui/src/gui-preferences-gp.h	Sun Dec 22 17:40:15 2019 +0100
@@ -0,0 +1,33 @@
+/*
+
+Copyright (C) 2017-2019 Torsten <ttl-octave@mailbox.org>
+
+This file is part of Octave.
+
+Octave is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+Octave is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<https://www.gnu.org/licenses/>.
+
+*/
+
+#if ! defined (octave_gui_preferences_gp_h)
+#define octave_gui_preferences_gp_h 1
+
+#include "gui-preferences.h"
+
+// Graphics utilities
+
+const gui_pref
+gp_annotation_geometry ("annotation/geometry", QVariant ());
+
+#endif