From 5610529bac4c0316852bf9806690d8a3a5e1b881 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Tue, 30 Mar 2021 22:42:23 -0400 Subject: [PATCH] Some defaults vary per platform Although this was set up for Android, it applies certain changes to iOS as well, in case nheko ever is ported to iOS. --- src/UserSettingsPage.cpp | 26 +++++++++++++++++++------- src/UserSettingsPage.h | 4 ++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index 7b01b0b8..242fb0d3 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -37,6 +38,15 @@ #include "config/nheko.h" +namespace UserSettingsDefault { +constexpr auto os = QOperatingSystemVersion::currentType(); +constexpr bool mobileOS = + (os == QOperatingSystemVersion::Android || os == QOperatingSystemVersion::IOS); +constexpr bool mobileMode = mobileOS; +// TODO: this should always be false; this is a temporary hack to get Android working +constexpr bool disableCertificateValidation = mobileOS ? true : false; +} + QSharedPointer UserSettings::instance_; UserSettings::UserSettings() @@ -90,11 +100,11 @@ UserSettings::load(std::optional profile) decryptSidebar_ = settings.value("user/decrypt_sidebar", true).toBool(); privacyScreen_ = settings.value("user/privacy_screen", false).toBool(); privacyScreenTimeout_ = settings.value("user/privacy_screen_timeout", 0).toInt(); - mobileMode_ = settings.value("user/mobile_mode", false).toBool(); - emojiFont_ = settings.value("user/emoji_font_family", "default").toString(); - baseFontSize_ = settings.value("user/font_size", QFont().pointSizeF()).toDouble(); - auto tempPresence = settings.value("user/presence", "").toString().toStdString(); - auto presenceValue = QMetaEnum::fromType().keyToValue(tempPresence.c_str()); + mobileMode_ = settings.value("user/mobile_mode", UserSettingsDefault::mobileMode).toBool(); + emojiFont_ = settings.value("user/emoji_font_family", "default").toString(); + baseFontSize_ = settings.value("user/font_size", QFont().pointSizeF()).toDouble(); + auto tempPresence = settings.value("user/presence", "").toString().toStdString(); + auto presenceValue = QMetaEnum::fromType().keyToValue(tempPresence.c_str()); if (presenceValue < 0) presenceValue = 0; presence_ = static_cast(presenceValue); @@ -128,8 +138,10 @@ UserSettings::load(std::optional profile) settings.value(prefix + "user/only_share_keys_with_verified_users", false).toBool(); useOnlineKeyBackup_ = settings.value(prefix + "user/online_key_backup", false).toBool(); - disableCertificateValidation_ = - settings.value("disable_certificate_validation", false).toBool(); + disableCertificateValidation_ = settings + .value("disable_certificate_validation", + UserSettingsDefault::disableCertificateValidation) + .toBool(); applyTheme(); } diff --git a/src/UserSettingsPage.h b/src/UserSettingsPage.h index ce6fec9d..193f4efa 100644 --- a/src/UserSettingsPage.h +++ b/src/UserSettingsPage.h @@ -235,9 +235,9 @@ public: bool disableCertificateValidation() const { #ifdef Q_OS_ANDROID - return true; + return true; #else - return disableCertificateValidation_; + return disableCertificateValidation_; #endif } QStringList hiddenTags() const { return hiddenTags_; }