diff options
author | willemferguson <willemferguson@zoology.up.ac.za> | 2020-11-01 20:43:54 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-11-03 23:08:39 -0800 |
commit | 8b36cf10518c54d76134686a3e079bbde176022b (patch) | |
tree | 2ad17a80d75c585ba6ac2887c9dc2a427a65e15c /core/settings | |
parent | 1ff488a4392f4d9a41cf1652c351e7b59bc03928 (diff) | |
download | subsurface-8b36cf10518c54d76134686a3e079bbde176022b.tar.gz |
desktop: offer different colors for info tab titles
Add a preference option to set the color of the text on the information tab to
either MediumBlue, LightBlue or Black. The last two of these colors are meant
to enable areadable font contrast on displays with dark mode.
The choice is saved with the other preferences.
[Dirk Hohndel: this isn't really about dark mode, so changed many of the types
and variable names, changed the user visible texts, and
addressed some whitespace issues]
Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/settings')
-rw-r--r-- | core/settings/qPrefDisplay.cpp | 24 | ||||
-rw-r--r-- | core/settings/qPrefDisplay.h | 5 |
2 files changed, 29 insertions, 0 deletions
diff --git a/core/settings/qPrefDisplay.cpp b/core/settings/qPrefDisplay.cpp index c733b0c6b..9425062dc 100644 --- a/core/settings/qPrefDisplay.cpp +++ b/core/settings/qPrefDisplay.cpp @@ -55,6 +55,7 @@ void qPrefDisplay::loadSync(bool doSync) disk_mobile_scale(doSync); disk_display_invalid_dives(doSync); disk_show_developer(doSync); + disk_headerstyle_color(doSync); if (!doSync) { load_tooltip_position(); load_theme(); @@ -176,6 +177,29 @@ void qPrefDisplay::setCorrectFont() prefs.display_invalid_dives = qPrefPrivate::propValue(keyFromGroupAndName(group, "displayinvalid"), default_prefs.display_invalid_dives).toBool(); } +void qPrefDisplay::set_headerstyle_color(enum headerstyle_color_values value) +{ + if (value != prefs.headerstyle_color) { + prefs.headerstyle_color = value; + disk_headerstyle_color(true); + emit instance()->headerstyle_colorChanged(value); + } +} + +void qPrefDisplay::disk_headerstyle_color(bool doSync) +{ + static enum headerstyle_color_values current_state; + if (doSync) { + if (current_state != prefs.headerstyle_color) { + current_state = prefs.headerstyle_color; + qPrefPrivate::propSetValue(keyFromGroupAndName(group, "headerstyle_color"), prefs.headerstyle_color, default_prefs.headerstyle_color); + } + } else { + prefs.headerstyle_color = (enum headerstyle_color_values)qPrefPrivate::propValue(keyFromGroupAndName(group, "headerstyle_color"), default_prefs.headerstyle_color).toInt(); + current_state = prefs.headerstyle_color; + } +} + HANDLE_PROP_QSTRING(Display, "FileDialog/LastDir", lastDir); HANDLE_PROP_QSTRING(Display, "Theme/currentTheme", theme); diff --git a/core/settings/qPrefDisplay.h b/core/settings/qPrefDisplay.h index 61fa5dbaf..6c265c593 100644 --- a/core/settings/qPrefDisplay.h +++ b/core/settings/qPrefDisplay.h @@ -8,6 +8,7 @@ class qPrefDisplay : public QObject { Q_OBJECT + Q_PROPERTY(enum headerstyle_color_values headerstyle_color READ headerstyle_color WRITE set_headerstyle_color NOTIFY headerstyle_colorChanged) Q_PROPERTY(int animation_speed READ animation_speed WRITE set_animation_speed NOTIFY animation_speedChanged) Q_PROPERTY(QString divelist_font READ divelist_font WRITE set_divelist_font NOTIFY divelist_fontChanged) Q_PROPERTY(double font_size READ font_size WRITE set_font_size NOTIFY font_sizeChanged) @@ -35,6 +36,7 @@ public: static void sync() { loadSync(true); } public: + static enum headerstyle_color_values headerstyle_color() { return prefs.headerstyle_color; } static int animation_speed() { return prefs.animation_speed; } static QString divelist_font() { return prefs.divelist_font; } static double font_size() { return prefs.font_size; } @@ -54,6 +56,7 @@ public: static bool singleColumnPortrait() { return st_singleColumnPortrait; } public slots: + static void set_headerstyle_color(enum headerstyle_color_values value); static void set_animation_speed(int value); static void set_divelist_font(const QString &value); static void set_font_size(double value); @@ -73,6 +76,7 @@ public slots: static void set_singleColumnPortrait(bool value); signals: + void headerstyle_colorChanged(enum headerstyle_color_values value); void animation_speedChanged(int value); void divelist_fontChanged(const QString &value); void font_sizeChanged(double value); @@ -95,6 +99,7 @@ private: qPrefDisplay() {} // functions to load/sync variable with disk + static void disk_headerstyle_color(bool doSync); static void disk_animation_speed(bool doSync); static void disk_divelist_font(bool doSync); static void disk_font_size(bool doSync); |