changeset 27562:d7876110e854

use symbolic preference keys if available * gui-preferences-ve.h (ve_font_size): Rename from ve_font. * file-editor-tab.cc, main-window.cc, octave-dock-widget.cc, settings-dialog.cc, variable-editor.cc: If available, use symbolic names for gui preference keys instead of literal strings. For example, ed_default_enc.key instead of "editor/default_encoding". * variable-editor.cc: Fix mixup with font name and size settings.
author John W. Eaton <jwe@octave.org>
date Fri, 25 Oct 2019 01:30:03 -0400
parents 78b28d0af037
children 3490ea06aba1
files libgui/src/gui-preferences-ve.h libgui/src/m-editor/file-editor-tab.cc libgui/src/main-window.cc libgui/src/octave-dock-widget.cc libgui/src/settings-dialog.cc libgui/src/variable-editor.cc
diffstat 6 files changed, 13 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/gui-preferences-ve.h	Fri Oct 25 00:41:16 2019 -0400
+++ b/libgui/src/gui-preferences-ve.h	Fri Oct 25 01:30:03 2019 -0400
@@ -28,6 +28,6 @@
 // Variable Editor preferences
 
 const gui_pref
-ve_font ("variable_editor/font_size", QVariant ());
+ve_font_size ("variable_editor/font_size", QVariant ());
 
 #endif
--- a/libgui/src/m-editor/file-editor-tab.cc	Fri Oct 25 00:41:16 2019 -0400
+++ b/libgui/src/m-editor/file-editor-tab.cc	Fri Oct 25 01:30:03 2019 -0400
@@ -263,7 +263,7 @@
     // encoding, not updated with the settings
     QString locale_enc_name =
       QTextCodec::codecForLocale ()->name ().toUpper ().prepend ("SYSTEM (").append (")");
-    m_encoding = settings->value ("editor/default_encoding", locale_enc_name)
+    m_encoding = settings->value (ed_default_enc.key, locale_enc_name)
                 .toString ();
     m_enc_indicator->setText (m_encoding);
     // no changes in encoding yet
--- a/libgui/src/main-window.cc	Fri Oct 25 00:41:16 2019 -0400
+++ b/libgui/src/main-window.cc	Fri Oct 25 01:30:03 2019 -0400
@@ -1528,8 +1528,8 @@
         return;
       }
 
-    settings->setValue ("MainWindow/geometry", saveGeometry ());
-    settings->setValue ("MainWindow/windowState", saveState ());
+    settings->setValue (mw_geometry.key, saveGeometry ());
+    settings->setValue (mw_state.key, saveState ());
     // write the list of recent used directories
     QStringList curr_dirs;
     for (int i=0; i<m_current_directory_combo_box->count (); i++)
--- a/libgui/src/octave-dock-widget.cc	Fri Oct 25 00:41:16 2019 -0400
+++ b/libgui/src/octave-dock-widget.cc	Fri Oct 25 01:30:03 2019 -0400
@@ -36,6 +36,7 @@
 #include <QMenuBar>
 
 #include "gui-preferences-global.h"
+#include "gui-preferences-mw.h"
 #include "octave-dock-widget.h"
 #include "resource-manager.h"
 
@@ -326,13 +327,13 @@
     // Since floating widget has no parent, we have to read it
     QSettings *settings = resource_manager::get_settings ();
 
-    settings->setValue ("MainWindow/windowState", m_parent->saveState ());
+    settings->setValue (mw_state.key, m_parent->saveState ());
     // Stay window, otherwise will bounce back to window by default because
     // there is no layout information for this widget in the saved settings.
     setParent (m_parent, Qt::Window);
     m_parent->addDockWidget (Qt::BottomDockWidgetArea, this);
     // recover old window states, hide and re-show new added widget
-    m_parent->restoreState (settings->value ("MainWindow/windowState").toByteArray ());
+    m_parent->restoreState (settings->value (mw_state.key).toByteArray ());
     setFloating (false);
 
     // adjust the (un)dock icon
--- a/libgui/src/settings-dialog.cc	Fri Oct 25 00:41:16 2019 -0400
+++ b/libgui/src/settings-dialog.cc	Fri Oct 25 01:30:03 2019 -0400
@@ -427,7 +427,7 @@
     varedit_rowAutofit->setChecked (settings->value ("variable_editor/autofit_row_height", true).toBool ());
 
     varedit_font->setCurrentFont (QFont (settings->value ("variable_editor/font_name", settings->value (cs_font.key, default_font)).toString ()));
-    varedit_fontSize->setValue (settings->value ("variable_editor/font_size", QVariant (10)).toInt ());
+    varedit_fontSize->setValue (settings->value (ve_font_size.key, ve_font_size.def).toInt ());
     connect (varedit_useTerminalFont, SIGNAL (toggled (bool)),
              varedit_font, SLOT (setDisabled (bool)));
     connect (varedit_useTerminalFont, SIGNAL (toggled (bool)),
@@ -911,7 +911,7 @@
       }
     settings->setValue (ed_uncomment_str.key, rb_uncomment);
 
-    settings->setValue ("editor/default_encoding", editor_combo_encoding->currentText ());
+    settings->setValue (ed_default_enc.key, editor_combo_encoding->currentText ());
     settings->setValue ("editor/auto_indent", editor_auto_ind_checkbox->isChecked ());
     settings->setValue ("editor/tab_indents_line", editor_tab_ind_checkbox->isChecked ());
     settings->setValue ("editor/backspace_unindents_line", editor_bs_unind_checkbox->isChecked ());
@@ -929,7 +929,7 @@
     settings->setValue (ed_show_dbg_file.key, editor_show_dbg_file->isChecked ());
 
     settings->setValue ("terminal/fontSize", terminal_fontSize->value ());
-    settings->setValue ("terminal/fontName", terminal_fontName->currentFont ().family ());
+    settings->setValue (cs_font.key, terminal_fontName->currentFont ().family ());
 
     // file browser
     settings->setValue (fb_sync_octdir.key, sync_octave_directory->isChecked ());
@@ -1018,7 +1018,7 @@
     settings->setValue ("variable_editor/use_terminal_font", varedit_useTerminalFont->isChecked ());
     settings->setValue ("variable_editor/alternate_rows", varedit_alternate->isChecked ());
     settings->setValue ("variable_editor/font_name", varedit_font->currentFont ().family ());
-    settings->setValue ("variable_editor/font_size", varedit_fontSize->value ());
+    settings->setValue (ve_font_size.key, varedit_fontSize->value ());
     write_varedit_colors (settings);
 
     // shortcuts
--- a/libgui/src/variable-editor.cc	Fri Oct 25 00:41:16 2019 -0400
+++ b/libgui/src/variable-editor.cc	Fri Oct 25 01:30:03 2019 -0400
@@ -1390,8 +1390,8 @@
       }
     else
       {
-        font_name = settings->value (ve_font.key, default_font).toString ();
-        font_size = settings->value ("variable_editor/font_size", 10).toInt ();
+        font_name = settings->value ("variable_editor/font_name", default_font).toString ();
+        font_size = settings->value (ve_font_size.key, ve_font_size.def).toInt ();
       }
 
     m_font = QFont (font_name, font_size);