From 8d857a650dd2374c4407504fd84cec7c9f0c6696 Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Sun, 15 Jul 2018 10:27:35 +0200 Subject: core: qPrefDisplay correct font setting. SettingsObjectWrapper contained some delicate font handling mixing font and font_size, breaking that into 2 parts broke font handling on some platforms Copy font + font_size handling 1-1 from SettingsObjectWrapper Signed-off-by: Jan Iversen --- core/settings/qPrefDisplay.cpp | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/core/settings/qPrefDisplay.cpp b/core/settings/qPrefDisplay.cpp index fee960f97..a248294d1 100644 --- a/core/settings/qPrefDisplay.cpp +++ b/core/settings/qPrefDisplay.cpp @@ -34,15 +34,17 @@ void qPrefDisplay::set_divelist_font(const QString& value) if (newValue != prefs.divelist_font && !subsurface_ignore_font(qPrintable(newValue))) { COPY_TXT(divelist_font, value); - qApp->setFont(QFont(newValue)); disk_divelist_font(true); + + qApp->setFont(QFont(newValue)); emit divelist_font_changed(value); } } void qPrefDisplay::disk_divelist_font(bool doSync) { - LOADSYNC_TXT("/divelist_font", divelist_font); - if (!doSync) + if (doSync) + LOADSYNC_TXT("/divelist_font", divelist_font) + else setCorrectFont(); } @@ -51,17 +53,19 @@ void qPrefDisplay::set_font_size(double value) { if (value != prefs.font_size) { prefs.font_size = value; + disk_font_size(true); + QFont defaultFont = qApp->font(); defaultFont.setPointSizeF(prefs.font_size); qApp->setFont(defaultFont); - disk_font_size(true); emit font_size_changed(value); } } void qPrefDisplay::disk_font_size(bool doSync) { - LOADSYNC_DOUBLE("/font_size", font_size); - if (!doSync) + if (doSync) + LOADSYNC_DOUBLE("/font_size", font_size) + else setCorrectFont(); } @@ -74,21 +78,30 @@ HANDLE_PREFERENCE_TXT(Display, "/theme", theme); void qPrefDisplay::setCorrectFont() { + bool doSync = false; + QSettings s; + QVariant v; + // get the font from the settings or our defaults // respect the system default font size if none is explicitly set - QFont defaultFont(prefs.divelist_font); + QFont defaultFont = s.value(group + "/divelist_font", prefs.divelist_font).value(); 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(group + "/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))) + if (subsurface_ignore_font(qPrintable(fontName))) { defaultFont = QFont(prefs.divelist_font); - else - COPY_TXT(divelist_font, fontName); + } else { + free((void *)prefs.divelist_font); + prefs.divelist_font = copy_qstring(fontName); + } defaultFont.setPointSizeF(prefs.font_size); qApp->setFont(defaultFont); + LOADSYNC_BOOL("/displayinvalid", display_invalid_dives); } -- cgit v1.2.3-70-g09d2