diff libgui/src/gui-settings.h @ 29484:bed2fd5b8263

allow a second color theme for the console window (dark mode) * QTerminal.cc (notice_settings): use new method color_value for reading the terminal colors from the gui_settings * color-picker.cc/.h (set_color): new method for updating the current color of a color picker * gui-preferences-cs.h: using the extensions for color preference keys of different color modes, define the keys for new mode, define preference for the selected modes * gui-settings.cc (color_value): new method for reading color values from the settings taking the mode into consideration and computing the default value from standard mode defaults, also allowing defaults given as QColor or ColorRoles; (set_color_value): new method for writing a color to the settings key, where the key name is determined depending on the key * gui-settings.h: new methods color_value, set_color_value, definition of some constant strings related to color modes * settings-dialog.cc (settings_dialog): reorder some action; (write_changed_settings): reorder some action; (read_terminal_colors): add checkbox for second color mode, connect trigger signal of this checkbos to new slot update_terminal_colors, use new method color_value for reading colors from the settings; (update_terminal_colors): slot for updating the current color picker colors depending on selected color mode; (write_terminal_colors): use new method set_color_value for writing colors to settings depending on color mode * settings-dialog.h: new slot update_terminal_colors
author Torsten Lilge <ttl-octave@mailbox.org>
date Fri, 02 Apr 2021 16:54:42 +0200
parents 0a5b15007766
children 00674bc1446d
line wrap: on
line diff
--- a/libgui/src/gui-settings.h	Thu Apr 01 23:18:50 2021 +0200
+++ b/libgui/src/gui-settings.h	Fri Apr 02 16:54:42 2021 +0200
@@ -68,12 +68,56 @@
       return value (pref.key, pref.def);
     }
 
+    /*!
+      Reading a color from the gui_settings taking possible color modes
+      into account. The default value for a second color mode @p mode=1 is
+      deterimined from the standard default value @p mode=0 by inverting
+      the lightness
+        \f{eqnarray*}{
+           H_1 &=& H_0\\
+           S_1 &=& S_0\\
+           L_1 &=& 1.0 - L_0
+        \f}
+
+      @param pref gui preference (key string, default value); the default
+                  value can be given by QColor or QPalette::ColorRole
+      @param mode Color mode (currently 0 or 1, default is 0)
+
+      @return Color as QColor
+    */
+    QColor color_value (const gui_pref& pref, int mode = 0) const;
+
+    /*!
+      Writing a color to the gui_settings taking possible color modes
+      into account. When @p mode is not zero (standard mode), the
+      extension related to the mode is appended to the settings key string
+
+      @param pref gui preference where the color should be written
+      @param color QColor to write to the settings
+      @param mode Color mode (currently 0 or 1, default is 0)
+
+    */
+    void set_color_value (const gui_pref& pref, const QColor& color,
+                          int mode = 0);
+
     QString sc_value (const sc_pref& pref) const;
 
     QKeySequence sc_def_value (const sc_pref& pref) const;
 
   };
+
 }
 
+// Some strings used several times in the settings
+
+// Other color schemes (currently one extra, but possibly more in the future)
+const QString settings_color_modes = QT_TRANSLATE_NOOP (
+    "octave::settings_dialog",
+    "Second color mode (light/dark)\n(discards non-applied current changes)");
+const QString settings_color_modes_tooltip = QT_TRANSLATE_NOOP (
+    "octave::settings_dialog",
+    "Switches to another set of colors. Useful for defining a dark/light mode");
+const QStringList settings_color_modes_ext (QStringList () << "" << "_2");
+
 #endif