aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar jan Iversen <jani@apache.org>2018-07-15 10:27:35 +0200
committerGravatar bstoeger <32835590+bstoeger@users.noreply.github.com>2018-07-15 14:35:31 +0200
commit8d857a650dd2374c4407504fd84cec7c9f0c6696 (patch)
tree226f8bcc56c48893dc44af4abc05ee5a9ff86136 /core
parent55336bd7ad27e23a78cf51626cbc1eef7a22aa42 (diff)
downloadsubsurface-8d857a650dd2374c4407504fd84cec7c9f0c6696.tar.gz
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 <jani@apache.org>
Diffstat (limited to 'core')
-rw-r--r--core/settings/qPrefDisplay.cpp33
1 files 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<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(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);
}