changeset 27861:3fada47cc58a

replacing literals for editor prefs by symbolic constants * gui-preferences-ed.h: Add symbolic constant for all editor preferences * m-editor/file-editor-tab.cc (update_lexer_settings, detect_eol_mode, new_file, notice_settings): replace literals by symbolic constants * file-editor.cc (restore_session, notice_settings, closeEvent, construct, mru_menu_update): replace literals by symbolic constants; (show_line_numbers, show_white_space, show_eol_chars, show_indent_guides, show_long_line, show_toolbar, show_statusbar, show_hscrollbar): replace literals by constants and use new form of toggle_preference; (toggle_preference): only gui_pref as argument, including the default value * file-editor.h: new arguments for toggle_preferences * settings-dialog.cc (settings_dialog, write_changed_settings): replace literals by symbolic constants;
author Torsten Lilge <ttl-octave@mailbox.org>
date Sat, 21 Dec 2019 20:23:51 +0100
parents cbd4d97100b3
children 813f76932ab6
files libgui/src/gui-preferences-ed.h libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor.cc libgui/src/m-editor/file-editor.h libgui/src/settings-dialog.cc
diffstat 5 files changed, 312 insertions(+), 177 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/gui-preferences-ed.h	Sat Dec 21 20:23:50 2019 +0100
+++ b/libgui/src/gui-preferences-ed.h	Sat Dec 21 20:23:51 2019 +0100
@@ -23,10 +23,130 @@
 #if ! defined (octave_gui_preferences_ed_h)
 #define octave_gui_preferences_ed_h 1
 
+#if defined (HAVE_QSCINTILLA)
+#include <Qsci/qsciscintilla.h>
+#endif
+
 #include "gui-preferences.h"
 
 // Editor preferences
 
+// Code completion
+
+const gui_pref
+ed_code_completion_octave_builtins ("editor/codeCompletion_octave_builtins", QVariant (true));
+
+const gui_pref
+ed_code_completion_octave_functions ("editor/codeCompletion_octave_functions", QVariant (true));
+
+const gui_pref
+ed_code_completion_keywords ("editor/codeCompletion_keywords", QVariant (true));
+
+const gui_pref
+ed_code_completion_document ("editor/codeCompletion_document", QVariant (true));
+
+const gui_pref
+ed_code_completion_replace ("editor/codeCompletion_replace", QVariant (false));
+
+const gui_pref
+ed_code_completion_case ("editor/codeCompletion_case", QVariant (true));
+
+const gui_pref
+ed_code_completion ("editor/codeCompletion", QVariant (true));
+
+const gui_pref
+ed_code_completion_threshold ("editor/codeCompletion_threshold", QVariant (2));
+
+// Code formatting
+
+const gui_pref
+ed_code_folding ("editor/code_folding", QVariant (true));
+
+const gui_pref
+ed_auto_indent ("editor/auto_indent", QVariant (true));
+
+const gui_pref
+ed_tab_indents_line ("editor/tab_indents_line", QVariant (false));
+
+const gui_pref
+ed_backspace_unindents_line ("editor/backspace_unindents_line", QVariant (false));
+
+const gui_pref
+ed_show_indent_guides ("editor/show_indent_guides", QVariant (false));
+
+const gui_pref
+ed_indent_uses_tabs ("editor/indent_uses_tabs", QVariant (false));
+
+const gui_pref
+ed_indent_width ("editor/indent_width", QVariant (2));
+
+const gui_pref
+ed_tab_width ("editor/tab_width", QVariant (2));
+
+const gui_pref
+ed_auto_endif ("editor/auto_endif", QVariant (1));
+
+// Long line handling
+
+const gui_pref
+ed_long_line_column ("editor/long_line_column", QVariant (80));
+
+const gui_pref
+ed_long_line_marker ("editor/long_line_marker", QVariant (true));
+
+const gui_pref
+ed_long_line_marker_line ("editor/long_line_marker_line", QVariant (true));
+
+const gui_pref
+ed_long_line_marker_background ("editor/long_line_marker_background", QVariant (false));
+
+const gui_pref
+ed_wrap_lines ("editor/wrap_lines", QVariant (false));
+
+const gui_pref
+ed_break_lines ("editor/break_lines", QVariant (false));
+
+const gui_pref
+ed_break_lines_comments ("editor/break_lines_comments", QVariant (false));
+
+const gui_pref
+ed_highlight_all_occurrences ("editor/highlight_all_occurrences", QVariant (true));
+
+const gui_pref
+ed_show_Line_numbers ("editor/showLineNumbers", QVariant (true));
+
+const gui_pref
+ed_line_numbers_size ("editor/line_numbers_size", QVariant ( 0));
+
+const gui_pref
+ed_show_edit_status_bar ("editor/show_edit_status_bar", QVariant (true));
+
+const gui_pref
+ed_highlight_current_line ("editor/highlightCurrentLine", QVariant (true));
+
+const gui_pref
+ed_highlight_current_line_color ("editor/highlight_current_line_color", QVariant (QColor (240, 240, 240)));
+
+const gui_pref
+ed_show_white_space ("editor/show_white_space", QVariant (false));
+
+const gui_pref
+ed_show_white_space_indent ("editor/show_white_space_indent", QVariant (false));
+
+const gui_pref
+ed_show_line_numbers ("editor/showLineNumbers", QVariant (true));
+
+const gui_pref
+ed_show_eol_chars ("editor/show_eol_chars", QVariant (false));
+
+const gui_pref
+ed_show_toolbar ("editor/show_toolbar", QVariant (true));
+
+const gui_pref
+ed_show_hscroll_bar ("editor/show_hscroll_bar", QVariant (true));
+
+
+
 // Octave comment strings
 
 const gui_pref
@@ -49,6 +169,9 @@
 // Session data
 
 const gui_pref
+ed_restore_session ("editor/restoreSession", QVariant (true));
+
+const gui_pref
 ed_session_names ("editor/savedSessionTabs", QVariant (QStringList ()));
 
 const gui_pref
@@ -74,6 +197,28 @@
 // File handling
 
 const gui_pref
+ed_long_window_title ("editor/longWindowTitle", QVariant (false));
+
+const gui_pref
+ed_notebook_tab_width_min ("editor/notebook_tab_width_min", QVariant (160));
+
+const gui_pref
+ed_notebook_tab_width_max ("editor/notebook_tab_width_max", QVariant (300));
+
+#if defined (HAVE_QSCINTILLA)
+#if defined (Q_OS_WIN32)
+const int os_eol_mode = QsciScintilla::EolWindows;
+#else
+const int os_eol_mode = QsciScintilla::EolUnix;
+#endif
+#else
+const int os_eol_mode = 2;
+#endif
+
+const gui_pref
+ed_default_eol_mode ("editor/default_eol_mode", QVariant (os_eol_mode));
+
+const gui_pref
 ed_show_dbg_file ("editor/show_dbg_file", QVariant (true));
 
 const gui_pref
@@ -83,6 +228,18 @@
 const gui_pref
 ed_create_new_file ("editor/create_new_file", QVariant (false));
 
+const gui_pref
+ed_hiding_closes_files ("editor/hiding_closes_files", QVariant (false));
+
+const gui_pref
+ed_always_reload_changed_files ("editor/always_reload_changed_files", QVariant (false));
+
+const gui_pref
+ed_mru_file_list ("editor/mru_file_list", QVariant ());
+
+const gui_pref
+ed_mru_file_encodings ("editor/mru_file_encodings", QVariant ());
+
 // The find dialog
 
 enum find_dialog_options
--- a/libgui/src/m-editor/file-editor-tab.cc	Sat Dec 21 20:23:50 2019 +0100
+++ b/libgui/src/m-editor/file-editor-tab.cc	Sat Dec 21 20:23:51 2019 +0100
@@ -716,9 +716,9 @@
 
         // get settings which infos are used for octave
         bool octave_builtins
-          = settings->value ("editor/codeCompletion_octave_builtins", true).toBool ();
+          = settings->value (ed_code_completion_octave_builtins).toBool ();
         bool octave_functions
-          = settings->value ("editor/codeCompletion_octave_functions", true).toBool ();
+          = settings->value (ed_code_completion_octave_functions).toBool ();
 
         QCoreApplication::setApplicationName (tmp_app_name);  // Restore name
 
@@ -888,7 +888,7 @@
 
     // fix line number width with respect to the font size of the lexer and
     // set the line numbers font depending on the lexers font
-    if (settings->value ("editor/showLineNumbers", true).toBool ())
+    if (settings->value (ed_show_line_numbers).toBool ())
       {
         // Line numbers width
         auto_margin_width ();
@@ -897,7 +897,7 @@
         QFont line_numbers_font = lexer->defaultFont ();
         int font_size = line_numbers_font.pointSize ();
         font_size = font_size
-                    + settings->value ("editor/line_numbers_size", 0).toInt ();
+                    + settings->value (ed_line_numbers_size).toInt ();
         if (font_size < 4)
           font_size = 4;
         line_numbers_font.setPointSize (font_size);
@@ -1974,16 +1974,10 @@
     int count_lf = text.count (eol_lf) - count_crlf;  // isolated lf
     int count_cr = text.count (eol_cr) - count_crlf;  // isolated cr;
 
-    // get default from OS or from settings
-#if defined (Q_OS_WIN32)
-    int os_eol_mode = QsciScintilla::EolWindows;
-#else
-    int os_eol_mode = QsciScintilla::EolUnix;
-#endif
     resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
     gui_settings *settings = rmgr.get_settings ();
     QsciScintilla::EolMode eol_mode
-      = static_cast<QsciScintilla::EolMode> (settings->value ("editor/default_eol_mode",os_eol_mode).toInt ());
+      = static_cast<QsciScintilla::EolMode> (settings->value (ed_default_eol_mode).toInt ());
 
     int count_max = 0;
 
@@ -2069,12 +2063,7 @@
 
     // set the eol mode from the settings or depending on the OS if the entry is
     // missing in the settings
-#if defined (Q_OS_WIN32)
-    int eol_mode = QsciScintilla::EolWindows;
-#else
-    int eol_mode = QsciScintilla::EolUnix;
-#endif
-    m_edit_area->setEolMode (static_cast<QsciScintilla::EolMode> (settings->value ("editor/default_eol_mode",eol_mode).toInt ()));
+    m_edit_area->setEolMode (static_cast<QsciScintilla::EolMode> (settings->value (ed_default_eol_mode).toInt ()));
 
     update_eol_indicator ();
 
@@ -2642,7 +2631,7 @@
       update_lexer_settings ();
 
     // code folding
-    if (settings->value ("editor/code_folding",true).toBool ())
+    if (settings->value (ed_code_folding).toBool ())
       {
         m_edit_area->setMarginType (3, QsciScintilla::SymbolMargin);
         m_edit_area->setFolding (QsciScintilla::BoxedTreeFoldStyle , 3);
@@ -2653,23 +2642,21 @@
       }
 
     // status bar
-    if (settings->value ("editor/show_edit_status_bar",true).toBool ())
+    if (settings->value (ed_show_edit_status_bar).toBool ())
       m_status_bar->show ();
     else
       m_status_bar->hide ();
 
     //highlight current line color
-    QVariant default_var = QColor (240, 240, 240);
-    QColor setting_color = settings->value ("editor/highlight_current_line_color",
-                                            default_var).value<QColor> ();
+    QColor setting_color = settings->value (ed_highlight_current_line_color).value<QColor> ();
     m_edit_area->setCaretLineBackgroundColor (setting_color);
     m_edit_area->setCaretLineVisible
-      (settings->value ("editor/highlightCurrentLine", true).toBool ());
+      (settings->value (ed_highlight_current_line).toBool ());
 
     bool match_keywords = settings->value
-                          ("editor/codeCompletion_keywords",true).toBool ();
+                          (ed_code_completion_keywords).toBool ();
     bool match_document = settings->value
-                          ("editor/codeCompletion_document",true).toBool ();
+                          (ed_code_completion_document).toBool ();
 
     QsciScintilla::AutoCompletionSource source = QsciScintilla::AcsNone;
     if (match_keywords)
@@ -2682,27 +2669,27 @@
     m_edit_area->setAutoCompletionSource (source);
 
     m_edit_area->setAutoCompletionReplaceWord
-      (settings->value ("editor/codeCompletion_replace",false).toBool ());
+      (settings->value (ed_code_completion_replace).toBool ());
     m_edit_area->setAutoCompletionCaseSensitivity
-      (settings->value ("editor/codeCompletion_case",true).toBool ());
-
-    if (settings->value ("editor/codeCompletion", true).toBool ())
+      (settings->value (ed_code_completion_case).toBool ());
+
+    if (settings->value (ed_code_completion).toBool ())
       m_edit_area->setAutoCompletionThreshold
-        (settings->value ("editor/codeCompletion_threshold",2).toInt ());
+        (settings->value (ed_code_completion_threshold).toInt ());
     else
       m_edit_area->setAutoCompletionThreshold (-1);
 
-    if (settings->value ("editor/show_white_space",false).toBool ())
-      if (settings->value ("editor/show_white_space_indent",false).toBool ())
+    if (settings->value (ed_show_white_space).toBool ())
+      if (settings->value (ed_show_white_space_indent).toBool ())
         m_edit_area->setWhitespaceVisibility (QsciScintilla::WsVisibleAfterIndent);
       else
         m_edit_area->setWhitespaceVisibility (QsciScintilla::WsVisible);
     else
       m_edit_area->setWhitespaceVisibility (QsciScintilla::WsInvisible);
 
-    m_edit_area->setEolVisibility (settings->value ("editor/show_eol_chars",false).toBool ());
-
-    if (settings->value ("editor/showLineNumbers", true).toBool ())
+    m_edit_area->setEolVisibility (settings->value (ed_show_eol_chars).toBool ());
+
+    if (settings->value (ed_show_line_numbers).toBool ())
       {
         m_edit_area->setMarginLineNumbers (2, true);
         auto_margin_width ();
@@ -2715,47 +2702,47 @@
         disconnect (m_edit_area, SIGNAL (linesChanged ()), nullptr, nullptr);
       }
 
-    m_smart_indent = settings->value ("editor/auto_indent",true).toBool ();
+    m_smart_indent = settings->value (ed_auto_indent).toBool ();
     m_edit_area->setAutoIndent (m_smart_indent);
     m_edit_area->setTabIndents
-      (settings->value ("editor/tab_indents_line",false).toBool ());
+      (settings->value (ed_tab_indents_line).toBool ());
     m_edit_area->setBackspaceUnindents
-      (settings->value ("editor/backspace_unindents_line",false).toBool ());
+      (settings->value (ed_backspace_unindents_line).toBool ());
     m_edit_area->setIndentationGuides
-      (settings->value ("editor/show_indent_guides",false).toBool ());
+      (settings->value (ed_show_indent_guides).toBool ());
     m_edit_area->setIndentationsUseTabs
-      (settings->value ("editor/indent_uses_tabs",false).toBool ());
+      (settings->value (ed_indent_uses_tabs).toBool ());
     m_edit_area->setIndentationWidth
-      (settings->value ("editor/indent_width",2).toInt ());
+      (settings->value (ed_indent_width).toInt ());
 
     m_edit_area->setTabWidth
-      (settings->value ("editor/tab_width",2).toInt ());
+      (settings->value (ed_tab_width).toInt ());
 
     m_ind_char_width = 1;
     if (m_edit_area->indentationsUseTabs ())
       m_ind_char_width = m_edit_area->tabWidth ();
 
     m_edit_area->SendScintilla (QsciScintillaBase::SCI_SETHSCROLLBAR,
-                               settings->value ("editor/show_hscroll_bar",true).toBool ());
+                               settings->value (ed_show_hscroll_bar).toBool ());
     m_edit_area->SendScintilla (QsciScintillaBase::SCI_SETSCROLLWIDTH,-1);
     m_edit_area->SendScintilla (QsciScintillaBase::SCI_SETSCROLLWIDTHTRACKING,true);
 
-    m_long_title = settings->value ("editor/longWindowTitle", false).toBool ();
+    m_long_title = settings->value (ed_long_window_title).toBool ();
     update_window_title (m_edit_area->isModified ());
 
-    m_auto_endif = settings->value ("editor/auto_endif",1).toInt ();
+    m_auto_endif = settings->value (ed_auto_endif).toInt ();
 
     // long line marker
-    int line_length = settings->value ("editor/long_line_column",80).toInt ();
+    int line_length = settings->value (ed_long_line_column).toInt ();
     m_edit_area->setEdgeColumn (line_length);
 
-    if (settings->value ("editor/long_line_marker",true).toBool ())
+    if (settings->value (ed_long_line_marker).toBool ())
       {
-        if (settings->value ("editor/long_line_marker_line",true).toBool ())
+        if (settings->value (ed_long_line_marker_line).toBool ())
           m_edit_area->setEdgeMode (QsciScintilla::EdgeLine);
         else
           {
-            if (settings->value ("editor/long_line_marker_background",false)
+            if (settings->value (ed_long_line_marker_background)
                 .toBool ())
               m_edit_area->setEdgeMode (QsciScintilla::EdgeBackground);
             else
@@ -2769,26 +2756,26 @@
     m_edit_area->setWrapVisualFlags (QsciScintilla::WrapFlagByBorder);
     m_edit_area->setWrapIndentMode (QsciScintilla::WrapIndentSame);
 
-    if (settings->value ("editor/wrap_lines",false).toBool ())
+    if (settings->value (ed_wrap_lines).toBool ())
       m_edit_area->setWrapMode (QsciScintilla::WrapWord);
     else
       m_edit_area->setWrapMode (QsciScintilla::WrapNone);
 
-    if (settings->value ("editor/break_lines",false).toBool ())
+    if (settings->value (ed_break_lines).toBool ())
       m_line_break = line_length;
     else
       m_line_break = 0;
 
     m_line_break_comments =
-      settings->value ("editor/break_lines_comments",false).toBool ();
+      settings->value (ed_break_lines_comments).toBool ();
 
     // highlight all occurrences of a word selected by a double click
     m_highlight_all_occurrences =
-      settings->value ("editor/highlight_all_occurrences", true).toBool ();
+      settings->value (ed_highlight_all_occurrences).toBool ();
 
     // reload changed files
     m_always_reload_changed_files =
-      settings->value ("editor/always_reload_changed_files",false).toBool ();
+      settings->value (ed_always_reload_changed_files).toBool ();
 
     // Set cursor blinking depending on the settings.
     // QScintilla ignores the application global settings, so some special
--- a/libgui/src/m-editor/file-editor.cc	Sat Dec 21 20:23:50 2019 +0100
+++ b/libgui/src/m-editor/file-editor.cc	Sat Dec 21 20:23:51 2019 +0100
@@ -280,7 +280,7 @@
   void file_editor::restore_session (gui_settings *settings)
   {
     //restore previous session
-    if (! settings->value ("editor/restoreSession", true).toBool ())
+    if (! settings->value (ed_restore_session).toBool ())
       return;
 
     // get the data from the settings file
@@ -1221,9 +1221,9 @@
       }
 
     // Min and max width for full path titles
-    int tab_width_min = settings->value ("editor/notebook_tab_width_min", 160)
+    int tab_width_min = settings->value (ed_notebook_tab_width_min)
                         .toInt ();
-    int tab_width_max = settings->value ("editor/notebook_tab_width_max", 300)
+    int tab_width_max = settings->value (ed_notebook_tab_width_max)
                         .toInt ();
 
     // Get suitable height of a tab related to font and icon size
@@ -1237,7 +1237,7 @@
                                    .arg (height);
 
     // Style sheet for tab height together with width
-    if (settings->value ("editor/longWindowTitle", false).toBool ())
+    if (settings->value (ed_long_window_title).toBool ())
       {
         style_sheet = QString ("QTabBar::tab "
                                " {max-" + height_str + ": %1px;"
@@ -1266,23 +1266,23 @@
     m_tab_widget->setStyleSheet (style_sheet);
 
     bool show_it;
-    show_it = settings->value ("editor/showLineNumbers",true).toBool ();
+    show_it = settings->value (ed_show_line_numbers).toBool ();
     m_show_linenum_action->setChecked (show_it);
-    show_it = settings->value ("editor/show_white_space",false).toBool ();
+    show_it = settings->value (ed_show_white_space).toBool ();
     m_show_whitespace_action->setChecked (show_it);
-    show_it = settings->value ("editor/show_eol_chars",false).toBool ();
+    show_it = settings->value (ed_show_eol_chars).toBool ();
     m_show_eol_action->setChecked (show_it);
-    show_it = settings->value ("editor/show_indent_guides",false).toBool ();
+    show_it = settings->value (ed_show_indent_guides).toBool ();
     m_show_indguide_action->setChecked (show_it);
-    show_it = settings->value ("editor/long_line_marker",true).toBool ();
+    show_it = settings->value (ed_long_line_marker).toBool ();
     m_show_longline_action->setChecked (show_it);
 
-    show_it = settings->value ("editor/show_toolbar",true).toBool ();
+    show_it = settings->value (ed_show_toolbar).toBool ();
     m_show_toolbar_action->setChecked (show_it);
     m_tool_bar->setVisible (show_it);
-    show_it = settings->value ("editor/show_edit_status_bar",true).toBool ();
+    show_it = settings->value (ed_show_edit_status_bar).toBool ();
     m_show_statusbar_action->setChecked (show_it);
-    show_it = settings->value ("editor/show_hscroll_bar",true).toBool ();
+    show_it = settings->value (ed_show_hscroll_bar).toBool ();
     m_show_hscrollbar_action->setChecked (show_it);
 
     set_shortcuts ();
@@ -1653,42 +1653,42 @@
 
   void file_editor::show_line_numbers (bool)
   {
-    toggle_preference ("editor/showLineNumbers",true);
+    toggle_preference (ed_show_line_numbers);
   }
 
   void file_editor::show_white_space (bool)
   {
-    toggle_preference ("editor/show_white_space",false);
+    toggle_preference (ed_show_white_space);
   }
 
   void file_editor::show_eol_chars (bool)
   {
-    toggle_preference ("editor/show_eol_chars",false);
+    toggle_preference (ed_show_eol_chars);
   }
 
   void file_editor::show_indent_guides (bool)
   {
-    toggle_preference ("editor/show_indent_guides",false);
+    toggle_preference (ed_show_indent_guides);
   }
 
   void file_editor::show_long_line (bool)
   {
-    toggle_preference ("editor/long_line_marker",true);
+    toggle_preference (ed_long_line_marker);
   }
 
   void file_editor::show_toolbar (bool)
   {
-    toggle_preference ("editor/show_toolbar",true);
+    toggle_preference (ed_show_toolbar);
   }
 
   void file_editor::show_statusbar (bool)
   {
-    toggle_preference ("editor/show_edit_status_bar",true);
+    toggle_preference (ed_show_edit_status_bar);
   }
 
   void file_editor::show_hscrollbar (bool)
   {
-    toggle_preference ("editor/show_hscroll_bar",true);
+    toggle_preference (ed_show_hscroll_bar);
   }
 
   void file_editor::zoom_in (bool)
@@ -1745,7 +1745,7 @@
   {
     resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
     gui_settings *settings = rmgr.get_settings ();
-    if (settings->value ("editor/hiding_closes_files",false).toBool ())
+    if (settings->value (ed_hiding_closes_files).toBool ())
       {
         if (check_closing ())
           {
@@ -1822,8 +1822,8 @@
 
     // the mru-list and an empty array of actions
     gui_settings *settings = rmgr.get_settings ();
-    m_mru_files = settings->value ("editor/mru_file_list").toStringList ();
-    m_mru_files_encodings = settings->value ("editor/mru_file_encodings")
+    m_mru_files = settings->value (ed_mru_file_list).toStringList ();
+    m_mru_files_encodings = settings->value (ed_mru_file_encodings)
                             .toStringList ();
 
     if (m_mru_files_encodings.count () != m_mru_files.count ())
@@ -2528,8 +2528,8 @@
     resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
     gui_settings *settings = rmgr.get_settings ();
 
-    settings->setValue ("editor/mru_file_list", m_mru_files);
-    settings->setValue ("editor/mru_file_encodings", m_mru_files_encodings);
+    settings->setValue (ed_mru_file_list.key,  m_mru_files);
+    settings->setValue (ed_mru_file_encodings.key,  m_mru_files_encodings);
     settings->sync ();
   }
 
@@ -2555,12 +2555,13 @@
     return false;
   }
 
-  void file_editor::toggle_preference (const QString& preference, bool def)
+  void file_editor::toggle_preference (const gui_pref& preference)
   {
     resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
     gui_settings *settings = rmgr.get_settings ();
-    bool old = settings->value (preference,def).toBool ();
-    settings->setValue (preference,! old);
+
+    bool old = settings->value (preference).toBool ();
+    settings->setValue (preference.key, ! old);
     notice_settings (settings);
   }
 
--- a/libgui/src/m-editor/file-editor.h	Sat Dec 21 20:23:50 2019 +0100
+++ b/libgui/src/m-editor/file-editor.h	Sat Dec 21 20:23:51 2019 +0100
@@ -320,7 +320,7 @@
     void mru_menu_update (void);
     bool call_custom_editor (const QString& file_name = QString (), int line = -1);
 
-    void toggle_preference (const QString& preference, bool def);
+    void toggle_preference (const gui_pref& preference);
 
     void handle_dir_remove (const QString& old_name, const QString& new_name);
 
--- a/libgui/src/settings-dialog.cc	Sat Dec 21 20:23:50 2019 +0100
+++ b/libgui/src/settings-dialog.cc	Sat Dec 21 20:23:51 2019 +0100
@@ -246,13 +246,12 @@
       settings->value (global_use_custom_editor.key, global_use_custom_editor.def).toBool ());
     customFileEditor->setText (
       settings->value (global_custom_editor.key, global_custom_editor.def).toString ());
-    editor_showLineNumbers->setChecked (settings->value ("editor/showLineNumbers", true).toBool ());
-    editor_linenr_size->setValue (settings->value ("editor/line_numbers_size", 0).toInt ());
+    editor_showLineNumbers->setChecked (settings->value (ed_show_line_numbers).toBool ());
+    editor_linenr_size->setValue (settings->value (ed_line_numbers_size).toInt ());
 
     rmgr.combo_encoding (editor_combo_encoding);
 
-    QColor default_var = QColor (240, 240, 240);
-    QColor setting_color = settings->value ("editor/highlight_current_line_color", default_var).value<QColor> ();
+    QColor setting_color = settings->value (ed_highlight_current_line_color).value<QColor> ();
     m_editor_current_line_color = new color_picker (setting_color);
     editor_grid_current_line->addWidget (m_editor_current_line_color, 0, 3);
     m_editor_current_line_color->setMinimumSize (20, 10);
@@ -261,40 +260,40 @@
     connect (editor_highlightCurrentLine, SIGNAL (toggled (bool)),
              m_editor_current_line_color, SLOT (setEnabled (bool)));
 
-    editor_highlightCurrentLine->setChecked (settings->value ("editor/highlightCurrentLine", true).toBool ());
-    editor_long_line_marker->setChecked (settings->value ("editor/long_line_marker", true).toBool ());
+    editor_highlightCurrentLine->setChecked (settings->value (ed_highlight_current_line).toBool ());
+    editor_long_line_marker->setChecked (settings->value (ed_long_line_marker).toBool ());
     bool long_line =
-      settings->value ("editor/long_line_marker_line", true).toBool ();
+      settings->value (ed_long_line_marker_line).toBool ();
     editor_long_line_marker_line->setChecked (long_line);
     bool long_back =
-      settings->value ("editor/long_line_marker_background", false).toBool ();
+      settings->value (ed_long_line_marker_background).toBool ();
     editor_long_line_marker_background->setChecked (long_back);
     if (! (long_line || long_back))
       editor_long_line_marker_line->setChecked (true);
-    editor_long_line_column->setValue (settings->value ("editor/long_line_column", 80).toInt ());
-    editor_break_checkbox->setChecked (settings->value ("editor/break_lines", false).toBool ());
-    editor_break_checkbox->setChecked (settings->value ("editor/break_lines_comments", false).toBool ());
-    editor_wrap_checkbox->setChecked (settings->value ("editor/wrap_lines", false).toBool ());
-    cb_edit_status_bar->setChecked (settings->value ("editor/show_edit_status_bar", true).toBool ());
-    cb_edit_tool_bar->setChecked (settings->value ("editor/show_toolbar", true).toBool ());
-    cb_code_folding->setChecked (settings->value ("editor/code_folding", true).toBool ());
-    editor_highlight_all_occurrences->setChecked (settings->value ("editor/highlight_all_occurrences", true).toBool ());
+    editor_long_line_column->setValue (settings->value (ed_long_line_column).toInt ());
+    editor_break_checkbox->setChecked (settings->value (ed_break_lines).toBool ());
+    editor_break_checkbox->setChecked (settings->value (ed_break_lines_comments).toBool ());
+    editor_wrap_checkbox->setChecked (settings->value (ed_wrap_lines).toBool ());
+    cb_edit_status_bar->setChecked (settings->value (ed_show_edit_status_bar).toBool ());
+    cb_edit_tool_bar->setChecked (settings->value (ed_show_toolbar).toBool ());
+    cb_code_folding->setChecked (settings->value (ed_code_folding).toBool ());
+    editor_highlight_all_occurrences->setChecked (settings->value (ed_highlight_all_occurrences).toBool ());
 
-    editor_auto_endif->setCurrentIndex (settings->value ("editor/auto_endif", 1).toInt () );
-    editor_codeCompletion->setChecked (settings->value ("editor/codeCompletion", true).toBool ());
-    editor_spinbox_ac_threshold->setValue (settings->value ("editor/codeCompletion_threshold", 2).toInt ());
-    editor_checkbox_ac_keywords->setChecked (settings->value ("editor/codeCompletion_keywords", true).toBool ());
+    editor_auto_endif->setCurrentIndex (settings->value (ed_auto_endif).toInt () );
+    editor_codeCompletion->setChecked (settings->value (ed_code_completion).toBool ());
+    editor_spinbox_ac_threshold->setValue (settings->value (ed_code_completion_threshold).toInt ());
+    editor_checkbox_ac_keywords->setChecked (settings->value (ed_code_completion_keywords).toBool ());
     editor_checkbox_ac_builtins->setEnabled (editor_checkbox_ac_keywords->isChecked ());
     editor_checkbox_ac_functions->setEnabled (editor_checkbox_ac_keywords->isChecked ());
-    editor_checkbox_ac_builtins->setChecked (settings->value ("editor/codeCompletion_octave_builtins", true).toBool ());
-    editor_checkbox_ac_functions->setChecked (settings->value ("editor/codeCompletion_octave_functions", true).toBool ());
-    editor_checkbox_ac_document->setChecked (settings->value ("editor/codeCompletion_document", false).toBool ());
-    editor_checkbox_ac_case->setChecked (settings->value ("editor/codeCompletion_case", true).toBool ());
-    editor_checkbox_ac_replace->setChecked (settings->value ("editor/codeCompletion_replace", false).toBool ());
-    editor_ws_checkbox->setChecked (settings->value ("editor/show_white_space", false).toBool ());
-    editor_ws_indent_checkbox->setChecked (settings->value ("editor/show_white_space_indent", false).toBool ());
-    cb_show_eol->setChecked (settings->value ("editor/show_eol_chars", false).toBool ());
-    cb_show_hscrollbar->setChecked (settings->value ("editor/show_hscroll_bar", true).toBool ());
+    editor_checkbox_ac_builtins->setChecked (settings->value (ed_code_completion_octave_builtins).toBool ());
+    editor_checkbox_ac_functions->setChecked (settings->value (ed_code_completion_octave_functions).toBool ());
+    editor_checkbox_ac_document->setChecked (settings->value (ed_code_completion_document).toBool ());
+    editor_checkbox_ac_case->setChecked (settings->value (ed_code_completion_case).toBool ());
+    editor_checkbox_ac_replace->setChecked (settings->value (ed_code_completion_replace).toBool ());
+    editor_ws_checkbox->setChecked (settings->value (ed_show_white_space).toBool ());
+    editor_ws_indent_checkbox->setChecked (settings->value (ed_show_white_space_indent).toBool ());
+    cb_show_eol->setChecked (settings->value (ed_show_eol_chars).toBool ());
+    cb_show_hscrollbar->setChecked (settings->value (ed_show_hscroll_bar).toBool ());
 
     editor_combox_tab_pos->insertItems (0, ed_tab_position_names);
     editor_combox_tab_pos->setCurrentIndex
@@ -330,30 +329,21 @@
       }
 
 
-#if defined (HAVE_QSCINTILLA)
-#  if defined (Q_OS_WIN32)
-    int eol_mode = QsciScintilla::EolWindows;
-#  else
-    int eol_mode = QsciScintilla::EolUnix;
-#  endif
-#else
-    int eol_mode = 2;
-#endif
-    combo_eol_mode->setCurrentIndex (settings->value ("editor/default_eol_mode", eol_mode).toInt ());
-    editor_auto_ind_checkbox->setChecked (settings->value ("editor/auto_indent", true).toBool ());
-    editor_tab_ind_checkbox->setChecked (settings->value ("editor/tab_indents_line", false).toBool ());
-    editor_bs_unind_checkbox->setChecked (settings->value ("editor/backspace_unindents_line", false).toBool ());
-    editor_ind_guides_checkbox->setChecked (settings->value ("editor/show_indent_guides", false).toBool ());
-    editor_ind_width_spinbox->setValue (settings->value ("editor/indent_width", 2).toInt ());
-    editor_ind_uses_tabs_checkbox->setChecked (settings->value ("editor/indent_uses_tabs", false).toBool ());
-    editor_tab_width_spinbox->setValue (settings->value ("editor/tab_width", 2).toInt ());
-    editor_longWindowTitle->setChecked (settings->value ("editor/longWindowTitle", false).toBool ());
-    editor_notebook_tab_width_min->setValue (settings->value ("editor/notebook_tab_width_min", 160).toInt ());
-    editor_notebook_tab_width_max->setValue (settings->value ("editor/notebook_tab_width_max", 300).toInt ());
-    editor_restoreSession->setChecked (settings->value ("editor/restoreSession", true).toBool ());
+    combo_eol_mode->setCurrentIndex (settings->value (ed_default_eol_mode).toInt ());
+    editor_auto_ind_checkbox->setChecked (settings->value (ed_auto_indent).toBool ());
+    editor_tab_ind_checkbox->setChecked (settings->value (ed_tab_indents_line).toBool ());
+    editor_bs_unind_checkbox->setChecked (settings->value (ed_backspace_unindents_line).toBool ());
+    editor_ind_guides_checkbox->setChecked (settings->value (ed_show_indent_guides).toBool ());
+    editor_ind_width_spinbox->setValue (settings->value (ed_indent_width).toInt ());
+    editor_ind_uses_tabs_checkbox->setChecked (settings->value (ed_indent_uses_tabs).toBool ());
+    editor_tab_width_spinbox->setValue (settings->value (ed_tab_width).toInt ());
+    editor_longWindowTitle->setChecked (settings->value (ed_long_window_title).toBool ());
+    editor_notebook_tab_width_min->setValue (settings->value (ed_notebook_tab_width_min).toInt ());
+    editor_notebook_tab_width_max->setValue (settings->value (ed_notebook_tab_width_max).toInt ());
+    editor_restoreSession->setChecked (settings->value (ed_restore_session).toBool ());
     editor_create_new_file->setChecked (settings->value (ed_create_new_file).toBool ());
-    editor_reload_changed_files->setChecked (settings->value ("editor/always_reload_changed_files", false).toBool ());
-    editor_hiding_closes_files->setChecked (settings->value ("editor/hiding_closes_files", false).toBool ());
+    editor_reload_changed_files->setChecked (settings->value (ed_always_reload_changed_files).toBool ());
+    editor_hiding_closes_files->setChecked (settings->value (ed_hiding_closes_files).toBool ());
     editor_show_dbg_file->setChecked (settings->value (ed_show_dbg_file).toBool ());
 
     // terminal
@@ -874,35 +864,35 @@
     //editor
     settings->setValue (global_use_custom_editor.key, useCustomFileEditor->isChecked ());
     settings->setValue (global_custom_editor.key, customFileEditor->text ());
-    settings->setValue ("editor/showLineNumbers", editor_showLineNumbers->isChecked ());
-    settings->setValue ("editor/line_numbers_size", editor_linenr_size->value ());
-    settings->setValue ("editor/highlightCurrentLine", editor_highlightCurrentLine->isChecked ());
-    settings->setValue ("editor/highlight_current_line_color", m_editor_current_line_color->color ());
-    settings->setValue ("editor/long_line_marker", editor_long_line_marker->isChecked ());
-    settings->setValue ("editor/long_line_marker_line", editor_long_line_marker_line->isChecked ());
-    settings->setValue ("editor/long_line_marker_background", editor_long_line_marker_background->isChecked ());
-    settings->setValue ("editor/long_line_column", editor_long_line_column->value ());
-    settings->setValue ("editor/break_lines", editor_break_checkbox->isChecked ());
-    settings->setValue ("editor/break_lines_comments", editor_break_comments_checkbox->isChecked ());
-    settings->setValue ("editor/wrap_lines", editor_wrap_checkbox->isChecked ());
-    settings->setValue ("editor/code_folding", cb_code_folding->isChecked ());
-    settings->setValue ("editor/show_edit_status_bar", cb_edit_status_bar->isChecked ());
-    settings->setValue ("editor/show_toolbar", cb_edit_tool_bar->isChecked ());
-    settings->setValue ("editor/highlight_all_occurrences", editor_highlight_all_occurrences->isChecked ());
-    settings->setValue ("editor/codeCompletion", editor_codeCompletion->isChecked ());
-    settings->setValue ("editor/codeCompletion_threshold", editor_spinbox_ac_threshold->value ());
-    settings->setValue ("editor/codeCompletion_keywords", editor_checkbox_ac_keywords->isChecked ());
-    settings->setValue ("editor/codeCompletion_octave_builtins", editor_checkbox_ac_builtins->isChecked ());
-    settings->setValue ("editor/codeCompletion_octave_functions", editor_checkbox_ac_functions->isChecked ());
-    settings->setValue ("editor/codeCompletion_document", editor_checkbox_ac_document->isChecked ());
-    settings->setValue ("editor/codeCompletion_case", editor_checkbox_ac_case->isChecked ());
-    settings->setValue ("editor/codeCompletion_replace", editor_checkbox_ac_replace->isChecked ());
-    settings->setValue ("editor/auto_endif", editor_auto_endif->currentIndex ());
-    settings->setValue ("editor/show_white_space", editor_ws_checkbox->isChecked ());
-    settings->setValue ("editor/show_white_space_indent", editor_ws_indent_checkbox->isChecked ());
-    settings->setValue ("editor/show_eol_chars", cb_show_eol->isChecked ());
-    settings->setValue ("editor/show_hscroll_bar", cb_show_hscrollbar->isChecked ());
-    settings->setValue ("editor/default_eol_mode", combo_eol_mode->currentIndex ());
+    settings->setValue (ed_show_line_numbers.key, editor_showLineNumbers->isChecked ());
+    settings->setValue (ed_line_numbers_size.key, editor_linenr_size->value ());
+    settings->setValue (ed_highlight_current_line.key, editor_highlightCurrentLine->isChecked ());
+    settings->setValue (ed_highlight_current_line_color.key, m_editor_current_line_color->color ());
+    settings->setValue (ed_long_line_marker.key, editor_long_line_marker->isChecked ());
+    settings->setValue (ed_long_line_marker_line.key, editor_long_line_marker_line->isChecked ());
+    settings->setValue (ed_long_line_marker_background.key, editor_long_line_marker_background->isChecked ());
+    settings->setValue (ed_long_line_column.key, editor_long_line_column->value ());
+    settings->setValue (ed_break_lines.key, editor_break_checkbox->isChecked ());
+    settings->setValue (ed_break_lines_comments.key, editor_break_comments_checkbox->isChecked ());
+    settings->setValue (ed_wrap_lines.key, editor_wrap_checkbox->isChecked ());
+    settings->setValue (ed_code_folding.key, cb_code_folding->isChecked ());
+    settings->setValue (ed_show_edit_status_bar.key, cb_edit_status_bar->isChecked ());
+    settings->setValue (ed_show_toolbar.key, cb_edit_tool_bar->isChecked ());
+    settings->setValue (ed_highlight_all_occurrences.key, editor_highlight_all_occurrences->isChecked ());
+    settings->setValue (ed_code_completion.key, editor_codeCompletion->isChecked ());
+    settings->setValue (ed_code_completion_threshold.key, editor_spinbox_ac_threshold->value ());
+    settings->setValue (ed_code_completion_keywords.key, editor_checkbox_ac_keywords->isChecked ());
+    settings->setValue (ed_code_completion_octave_builtins.key, editor_checkbox_ac_builtins->isChecked ());
+    settings->setValue (ed_code_completion_octave_functions.key, editor_checkbox_ac_functions->isChecked ());
+    settings->setValue (ed_code_completion_document.key, editor_checkbox_ac_document->isChecked ());
+    settings->setValue (ed_code_completion_case.key, editor_checkbox_ac_case->isChecked ());
+    settings->setValue (ed_code_completion_replace.key, editor_checkbox_ac_replace->isChecked ());
+    settings->setValue (ed_auto_endif.key, editor_auto_endif->currentIndex ());
+    settings->setValue (ed_show_white_space.key, editor_ws_checkbox->isChecked ());
+    settings->setValue (ed_show_white_space_indent.key, editor_ws_indent_checkbox->isChecked ());
+    settings->setValue (ed_show_eol_chars.key, cb_show_eol->isChecked ());
+    settings->setValue (ed_show_hscroll_bar.key, cb_show_hscrollbar->isChecked ());
+    settings->setValue (ed_default_eol_mode.key, combo_eol_mode->currentIndex ());
 
     settings->setValue (ed_tab_position.key, editor_combox_tab_pos->currentIndex ());
 
@@ -924,20 +914,20 @@
     settings->setValue (ed_uncomment_str.key, rb_uncomment);
 
     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 ());
-    settings->setValue ("editor/show_indent_guides", editor_ind_guides_checkbox->isChecked ());
-    settings->setValue ("editor/indent_width", editor_ind_width_spinbox->value ());
-    settings->setValue ("editor/indent_uses_tabs", editor_ind_uses_tabs_checkbox->isChecked ());
-    settings->setValue ("editor/tab_width", editor_tab_width_spinbox->value ());
-    settings->setValue ("editor/longWindowTitle", editor_longWindowTitle->isChecked ());
-    settings->setValue ("editor/notebook_tab_width_min", editor_notebook_tab_width_min->value ());
-    settings->setValue ("editor/notebook_tab_width_max", editor_notebook_tab_width_max->value ());
-    settings->setValue ("editor/restoreSession", editor_restoreSession->isChecked ());
+    settings->setValue (ed_auto_indent.key, editor_auto_ind_checkbox->isChecked ());
+    settings->setValue (ed_tab_indents_line.key, editor_tab_ind_checkbox->isChecked ());
+    settings->setValue (ed_backspace_unindents_line.key, editor_bs_unind_checkbox->isChecked ());
+    settings->setValue (ed_show_indent_guides.key, editor_ind_guides_checkbox->isChecked ());
+    settings->setValue (ed_indent_width.key, editor_ind_width_spinbox->value ());
+    settings->setValue (ed_indent_uses_tabs.key, editor_ind_uses_tabs_checkbox->isChecked ());
+    settings->setValue (ed_tab_width.key, editor_tab_width_spinbox->value ());
+    settings->setValue (ed_long_window_title.key, editor_longWindowTitle->isChecked ());
+    settings->setValue (ed_notebook_tab_width_min.key, editor_notebook_tab_width_min->value ());
+    settings->setValue (ed_notebook_tab_width_max.key, editor_notebook_tab_width_max->value ());
+    settings->setValue (ed_restore_session.key, editor_restoreSession->isChecked ());
     settings->setValue (ed_create_new_file.key, editor_create_new_file->isChecked ());
-    settings->setValue ("editor/hiding_closes_files", editor_hiding_closes_files->isChecked ());
-    settings->setValue ("editor/always_reload_changed_files", editor_reload_changed_files->isChecked ());
+    settings->setValue (ed_hiding_closes_files.key, editor_hiding_closes_files->isChecked ());
+    settings->setValue (ed_always_reload_changed_files.key, editor_reload_changed_files->isChecked ());
     settings->setValue (ed_show_dbg_file.key, editor_show_dbg_file->isChecked ());
 
     settings->setValue (cs_font_size.key, terminal_fontSize->value ());