summaryrefslogtreecommitdiffstats
path: root/core/settings/qPrefDisplay.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2018-07-14 08:14:31 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-07-14 08:14:31 -0700
commite834874a7a6f8e37fade28bf20640b8d0815373b (patch)
tree6a04abcf9c36a2a1cbd557af11eed0df379d0263 /core/settings/qPrefDisplay.cpp
parentcf329ca13100f3b8947c33c8e0a7f4a9cedd5e2b (diff)
parentaa0a918082dced90eb608ba44f39028bfe9ad0c1 (diff)
downloadsubsurface-e834874a7a6f8e37fade28bf20640b8d0815373b.tar.gz
Merge branch 'qPrefDisplay' of https://github.com/janiversen/subsurface
Diffstat (limited to 'core/settings/qPrefDisplay.cpp')
-rw-r--r--core/settings/qPrefDisplay.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/core/settings/qPrefDisplay.cpp b/core/settings/qPrefDisplay.cpp
index cf0a4e54d..fee960f97 100644
--- a/core/settings/qPrefDisplay.cpp
+++ b/core/settings/qPrefDisplay.cpp
@@ -39,7 +39,12 @@ void qPrefDisplay::set_divelist_font(const QString& value)
emit divelist_font_changed(value);
}
}
-DISK_LOADSYNC_TXT(Display, "/divelist_font", divelist_font);
+void qPrefDisplay::disk_divelist_font(bool doSync)
+{
+ LOADSYNC_TXT("/divelist_font", divelist_font);
+ if (!doSync)
+ setCorrectFont();
+}
GET_PREFERENCE_DOUBLE(Display, font_size);
void qPrefDisplay::set_font_size(double value)
@@ -53,10 +58,37 @@ void qPrefDisplay::set_font_size(double value)
emit font_size_changed(value);
}
}
-DISK_LOADSYNC_DOUBLE(Display, "/font_size", font_size);
+void qPrefDisplay::disk_font_size(bool doSync)
+{
+ LOADSYNC_DOUBLE("/font_size", font_size);
+ if (!doSync)
+ setCorrectFont();
+}
HANDLE_PREFERENCE_BOOL(Display, "/displayinvalid", display_invalid_dives);
HANDLE_PREFERENCE_BOOL(Display, "/show_developer", show_developer);
HANDLE_PREFERENCE_TXT(Display, "/theme", theme);
+
+
+void qPrefDisplay::setCorrectFont()
+{
+ // 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);
+ 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
+ }
+ // 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
+ COPY_TXT(divelist_font, fontName);
+ defaultFont.setPointSizeF(prefs.font_size);
+ qApp->setFont(defaultFont);
+}