diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2018-07-14 08:14:31 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-07-14 08:14:31 -0700 |
commit | e834874a7a6f8e37fade28bf20640b8d0815373b (patch) | |
tree | 6a04abcf9c36a2a1cbd557af11eed0df379d0263 /core/subsurface-qt/SettingsObjectWrapper.cpp | |
parent | cf329ca13100f3b8947c33c8e0a7f4a9cedd5e2b (diff) | |
parent | aa0a918082dced90eb608ba44f39028bfe9ad0c1 (diff) | |
download | subsurface-e834874a7a6f8e37fade28bf20640b8d0815373b.tar.gz |
Merge branch 'qPrefDisplay' of https://github.com/janiversen/subsurface
Diffstat (limited to 'core/subsurface-qt/SettingsObjectWrapper.cpp')
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.cpp | 97 |
1 files changed, 4 insertions, 93 deletions
diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp index 80b9df8ee..c5a335a8e 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/core/subsurface-qt/SettingsObjectWrapper.cpp @@ -1913,75 +1913,6 @@ void GeneralSettingsObjectWrapper::setAutoRecalculateThumbnails(bool value) emit autoRecalculateThumbnailsChanged(value); } -DisplaySettingsObjectWrapper::DisplaySettingsObjectWrapper(QObject *parent) : - QObject(parent) -{ -} - -QString DisplaySettingsObjectWrapper::divelistFont() const -{ - return prefs.divelist_font; -} - -double DisplaySettingsObjectWrapper::fontSize() const -{ - return prefs.font_size; -} - -bool DisplaySettingsObjectWrapper::displayInvalidDives() const -{ - return prefs.display_invalid_dives; -} - -void DisplaySettingsObjectWrapper::setDivelistFont(const QString& value) -{ - - QString newValue = value; - if (value.contains(",")) - newValue = value.left(value.indexOf(",")); - - if (newValue == prefs.divelist_font) - return; - - QSettings s; - s.beginGroup(group); - s.setValue("divelist_font", value); - - if (!subsurface_ignore_font(qPrintable(newValue))) { - free((void *)prefs.divelist_font); - prefs.divelist_font = copy_qstring(newValue); - qApp->setFont(QFont(newValue)); - } - emit divelistFontChanged(newValue); -} - -void DisplaySettingsObjectWrapper::setFontSize(double value) -{ - if (value == prefs.font_size) - return; - - QSettings s; - s.beginGroup(group); - s.setValue("font_size", value); - prefs.font_size = value; - QFont defaultFont = qApp->font(); - defaultFont.setPointSizeF(prefs.font_size); - qApp->setFont(defaultFont); - emit fontSizeChanged(value); -} - -void DisplaySettingsObjectWrapper::setDisplayInvalidDives(bool value) -{ - if (value == prefs.display_invalid_dives) - return; - - QSettings s; - s.beginGroup(group); - s.setValue("displayinvalid", value); - prefs.display_invalid_dives = value; - emit displayInvalidDivesChanged(value); -} - LanguageSettingsObjectWrapper::LanguageSettingsObjectWrapper(QObject *parent) : QObject(parent) { @@ -2194,7 +2125,7 @@ QObject(parent), planner_settings(new DivePlannerSettings(this)), unit_settings(new UnitsSettings(this)), general_settings(new GeneralSettingsObjectWrapper(this)), - display_settings(new DisplaySettingsObjectWrapper(this)), + display_settings(new qPrefDisplay(this)), language_settings(new LanguageSettingsObjectWrapper(this)), animation_settings(new AnimationsSettingsObjectWrapper(this)), location_settings(new LocationServiceSettingsObjectWrapper(this)), @@ -2287,29 +2218,7 @@ void SettingsObjectWrapper::load() GET_BOOL("auto_recalculate_thumbnails", auto_recalculate_thumbnails); s.endGroup(); - s.beginGroup("Display"); - // get the font from the settings or our defaults - // respect the system default font size if none is explicitly set - QFont defaultFont = s.value("divelist_font", prefs.divelist_font).value<QFont>(); - if (IS_FP_SAME(system_divelist_default_font_size, -1.0)) { - prefs.font_size = qApp->font().pointSizeF(); - system_divelist_default_font_size = prefs.font_size; // this way we don't save it on exit - } - prefs.font_size = s.value("font_size", prefs.font_size).toFloat(); - // painful effort to ignore previous default fonts on Windows - ridiculous - QString fontName = defaultFont.toString(); - if (fontName.contains(",")) - fontName = fontName.left(fontName.indexOf(",")); - if (subsurface_ignore_font(qPrintable(fontName))) { - defaultFont = QFont(prefs.divelist_font); - } else { - free((void *)prefs.divelist_font); - prefs.divelist_font = copy_qstring(fontName); - } - defaultFont.setPointSizeF(prefs.font_size); - qApp->setFont(defaultFont); - GET_BOOL("displayinvalid", display_invalid_dives); - s.endGroup(); + qPrefDisplay::instance()->load(); s.beginGroup("Animations"); GET_INT("animation_speed", animation_speed); @@ -2420,6 +2329,8 @@ void SettingsObjectWrapper::load() void SettingsObjectWrapper::sync() { + qPrefDisplay::instance()->sync(); + QSettings s; s.beginGroup("Planner"); s.setValue("last_stop", prefs.last_stop); |