summary refs log tree commit diff
path: root/src/UserSettingsPage.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-03-05 03:25:24 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2022-03-05 03:34:29 +0100
commitc76cda0cbe1368dbf653ad8c50c1b932e69f7c0a (patch)
treeb3e7a3bb4c4eb69d82ac64cfe0f27260c62c57c5 /src/UserSettingsPage.cpp
parentOpen room members dialog when clicking the encryption indicator (diff)
downloadnheko-c76cda0cbe1368dbf653ad8c50c1b932e69f7c0a.tar.xz
Set font properly
When setting the default font, actually set the default font. When
setting a different font, change the application font.

fixes #801
fixes #232
fixes #224
Diffstat (limited to '')
-rw-r--r--src/UserSettingsPage.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp
index c7ac790a..1a24834e 100644
--- a/src/UserSettingsPage.cpp
+++ b/src/UserSettingsPage.cpp
@@ -79,15 +79,17 @@ UserSettings::load(std::optional<QString> profile)
     sortByImportance_ = settings.value(QStringLiteral("user/sort_by_unread"), true).toBool();
     readReceipts_     = settings.value(QStringLiteral("user/read_receipts"), true).toBool();
     theme_            = settings.value(QStringLiteral("user/theme"), defaultTheme_).toString();
-    font_             = settings.value(QStringLiteral("user/font_family"), "default").toString();
-    avatarCircles_    = settings.value(QStringLiteral("user/avatar_circles"), true).toBool();
-    useIdenticon_     = settings.value(QStringLiteral("user/use_identicon"), true).toBool();
-    decryptSidebar_   = settings.value(QStringLiteral("user/decrypt_sidebar"), true).toBool();
-    privacyScreen_    = settings.value(QStringLiteral("user/privacy_screen"), false).toBool();
+
+    font_ = settings.value(QStringLiteral("user/font_family"), "").toString();
+
+    avatarCircles_  = settings.value(QStringLiteral("user/avatar_circles"), true).toBool();
+    useIdenticon_   = settings.value(QStringLiteral("user/use_identicon"), true).toBool();
+    decryptSidebar_ = settings.value(QStringLiteral("user/decrypt_sidebar"), true).toBool();
+    privacyScreen_  = settings.value(QStringLiteral("user/privacy_screen"), false).toBool();
     privacyScreenTimeout_ =
       settings.value(QStringLiteral("user/privacy_screen_timeout"), 0).toInt();
     mobileMode_ = settings.value(QStringLiteral("user/mobile_mode"), false).toBool();
-    emojiFont_  = settings.value(QStringLiteral("user/emoji_font_family"), "default").toString();
+    emojiFont_  = settings.value(QStringLiteral("user/emoji_font_family"), "emoji").toString();
     baseFontSize_ =
       settings.value(QStringLiteral("user/font_size"), QFont().pointSizeF()).toDouble();
     auto tempPresence =
@@ -419,6 +421,12 @@ UserSettings::setFontSize(double size)
     if (size == baseFontSize_)
         return;
     baseFontSize_ = size;
+
+    const static auto defaultFamily = QFont().defaultFamily();
+    QFont f((font_.isEmpty() || font_ == QStringLiteral("default")) ? defaultFamily : font_);
+    f.setPointSizeF(fontSize());
+    QApplication::setFont(f);
+
     emit fontSizeChanged(size);
     save();
 }
@@ -429,6 +437,12 @@ UserSettings::setFontFamily(QString family)
     if (family == font_)
         return;
     font_ = family;
+
+    const static auto defaultFamily = QFont().defaultFamily();
+    QFont f((family.isEmpty() || family == QStringLiteral("default")) ? defaultFamily : family);
+    f.setPointSizeF(fontSize());
+    QApplication::setFont(f);
+
     emit fontChanged(family);
     save();
 }
@@ -440,7 +454,7 @@ UserSettings::setEmojiFontFamily(QString family)
         return;
 
     if (family == tr("Default")) {
-        emojiFont_ = QStringLiteral("default");
+        emojiFont_ = QStringLiteral("emoji");
     } else {
         emojiFont_ = family;
     }