summaryrefslogtreecommitdiffstats
path: root/core/settings/qPrefDisplay.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2018-09-22 16:09:31 -0700
committerGravatar Jan Mulder <jlmulder@xs4all.nl>2018-09-25 15:58:17 +0200
commit617019bc6b9e5bebba1cb96b1ed039befa8470ff (patch)
tree335bf32c030ba7f6394aa298ff8c5410f1e6e426 /core/settings/qPrefDisplay.cpp
parent38307a5b3c7bfd798815d18d7b2b982075ec8e12 (diff)
downloadsubsurface-617019bc6b9e5bebba1cb96b1ed039befa8470ff.tar.gz
qPref: add mobile_scale preference
We use that in the mobile app to scale the whole app, as all sizes there are relative to the default font. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/settings/qPrefDisplay.cpp')
-rw-r--r--core/settings/qPrefDisplay.cpp43
1 files changed, 37 insertions, 6 deletions
diff --git a/core/settings/qPrefDisplay.cpp b/core/settings/qPrefDisplay.cpp
index fcca8cd20..ca340d504 100644
--- a/core/settings/qPrefDisplay.cpp
+++ b/core/settings/qPrefDisplay.cpp
@@ -30,7 +30,7 @@ QByteArray qPrefDisplay::st_bottomSplitter;
static const QByteArray st_bottomSplitter_default = "";
bool qPrefDisplay::st_maximized;
-static bool st_maximized_default = false;
+static bool st_maximized_default = false;
QByteArray qPrefDisplay::st_geometry;
static const QByteArray st_geometry_default = 0;
@@ -39,7 +39,7 @@ QByteArray qPrefDisplay::st_windowState;
static const QByteArray st_windowState_default = 0;
int qPrefDisplay::st_lastState;
-static int st_lastState_default = false;
+static int st_lastState_default = false;
qPrefDisplay::qPrefDisplay(QObject *parent) : QObject(parent)
{
@@ -56,6 +56,7 @@ void qPrefDisplay::loadSync(bool doSync)
disk_animation_speed(doSync);
disk_divelist_font(doSync);
disk_font_size(doSync);
+ disk_mobile_scale(doSync);
disk_display_invalid_dives(doSync);
disk_show_developer(doSync);
if (!doSync) {
@@ -103,17 +104,46 @@ void qPrefDisplay::set_font_size(double value)
disk_font_size(true);
QFont defaultFont = qApp->font();
- defaultFont.setPointSizeF(prefs.font_size);
+ defaultFont.setPointSizeF(prefs.font_size * prefs.mobile_scale);
qApp->setFont(defaultFont);
emit instance()->font_sizeChanged(value);
}
}
+
void qPrefDisplay::disk_font_size(bool doSync)
{
- if (doSync)
- qPrefPrivate::propSetValue(keyFromGroupAndName(group, "font_size"), prefs.font_size, default_prefs.font_size);
+ // inverted logic compared to the other disk_xxx functions
+ if (!doSync)
+ setCorrectFont();
+#if !defined(SUBSURFACE_MOBILE)
+ // we never want to save the font_size to disk - we always want to grab that from the system default
else
+ qPrefPrivate::propSetValue(keyFromGroupAndName(group, "font_size"), prefs.font_size, default_prefs.font_size);
+#endif
+}
+
+void qPrefDisplay::set_mobile_scale(double value)
+{
+ if (!IS_FP_SAME(value, prefs.mobile_scale)) {
+ prefs.mobile_scale = value;
+ disk_mobile_scale(true);
+
+ QFont defaultFont = qApp->font();
+ defaultFont.setPointSizeF(prefs.font_size * prefs.mobile_scale);
+ qApp->setFont(defaultFont);
+ emit instance()->mobile_scaleChanged(value);
+ emit instance()->font_sizeChanged(value);
+ }
+}
+
+void qPrefDisplay::disk_mobile_scale(bool doSync)
+{
+ if (doSync) {
+ qPrefPrivate::propSetValue(keyFromGroupAndName(group, "mobile_scale"), prefs.mobile_scale, default_prefs.mobile_scale);
+ } else {
+ prefs.mobile_scale = qPrefPrivate::propValue(keyFromGroupAndName(group, "mobile_scale"), default_prefs.mobile_scale).toDouble();
setCorrectFont();
+ }
}
//JAN static const QString group = QStringLiteral("Animations");
@@ -134,6 +164,7 @@ void qPrefDisplay::setCorrectFont()
}
prefs.font_size = qPrefPrivate::propValue(keyFromGroupAndName(group, "font_size"), prefs.font_size).toFloat();
+
// painful effort to ignore previous default fonts on Windows - ridiculous
QString fontName = defaultFont.toString();
if (fontName.contains(","))
@@ -144,7 +175,7 @@ void qPrefDisplay::setCorrectFont()
free((void *)prefs.divelist_font);
prefs.divelist_font = copy_qstring(fontName);
}
- defaultFont.setPointSizeF(prefs.font_size);
+ defaultFont.setPointSizeF(prefs.font_size * prefs.mobile_scale);
qApp->setFont(defaultFont);
prefs.display_invalid_dives = qPrefPrivate::propValue(keyFromGroupAndName(group, "displayinvalid"), default_prefs.display_invalid_dives).toBool();