From 0824d2da20350dc348c3183f674948ad33193e1a Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 19 Jun 2020 19:51:51 +0400 Subject: [PATCH] Reset some settings on full logout. --- Telegram/SourceFiles/core/core_settings.cpp | 51 +++++++++++++++++++ Telegram/SourceFiles/core/core_settings.h | 2 + Telegram/SourceFiles/storage/localstorage.cpp | 13 +++-- .../window/themes/window_theme.cpp | 1 + 4 files changed, 62 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/core/core_settings.cpp b/Telegram/SourceFiles/core/core_settings.cpp index 9305a5cc5a..9a4cbd243e 100644 --- a/Telegram/SourceFiles/core/core_settings.cpp +++ b/Telegram/SourceFiles/core/core_settings.cpp @@ -289,4 +289,55 @@ QString Settings::getSoundPath(const QString &key) const { return qsl(":/sounds/") + key + qsl(".mp3"); } +void Settings::resetOnLastLogout() { + _adaptiveForWide = true; + _moderateModeEnabled = false; + + _songVolume = kDefaultVolume; + _videoVolume = kDefaultVolume; + + _askDownloadPath = false; + _downloadPath = QString(); + _downloadPathBookmark = QByteArray(); + + _voiceMsgPlaybackDoubled = false; + _soundNotify = true; + _desktopNotify = true; + _flashBounceNotify = true; + _notifyView = dbinvShowPreview; + //_nativeNotifications = false; + //_notificationsCount = 3; + //_notificationsCorner = ScreenCorner::BottomRight; + _includeMutedCounter = true; + _countUnreadMessages = true; + _notifyAboutPinned = true; + //_autoLock = 3600; + + //_callOutputDeviceID = u"default"_q; + //_callInputDeviceID = u"default"_q; + //_callOutputVolume = 100; + //_callInputVolume = 100; + //_callAudioDuckingEnabled = true; + + //_themesAccentColors = Window::Theme::AccentColors(); + + _lastSeenWarningSeen = false; + _sendFilesWay = SendFilesWay::Album; + //_sendSubmitWay = Ui::InputSubmitSettings::Enter; + _soundOverrides = {}; + + _exeLaunchWarning = true; + _loopAnimatedStickers = true; + _largeEmoji = true; + _replaceEmoji = true; + _suggestEmoji = true; + _suggestStickersByEmoji = true; + _spellcheckerEnabled = true; + _videoPlaybackSpeed = 1.; + //_videoPipGeometry = QByteArray(); + _dictionariesEnabled = std::vector(); + _autoDownloadDictionaries = true; + +} + } // namespace Core diff --git a/Telegram/SourceFiles/core/core_settings.h b/Telegram/SourceFiles/core/core_settings.h index cb19532110..a1351280f6 100644 --- a/Telegram/SourceFiles/core/core_settings.h +++ b/Telegram/SourceFiles/core/core_settings.h @@ -357,6 +357,8 @@ public: return (std::clamp(speed, 0, 6) + 2) / 4.; } + void resetOnLastLogout(); + private: bool _adaptiveForWide = true; bool _moderateModeEnabled = false; diff --git a/Telegram/SourceFiles/storage/localstorage.cpp b/Telegram/SourceFiles/storage/localstorage.cpp index 6563361f47..00a30ea01f 100644 --- a/Telegram/SourceFiles/storage/localstorage.cpp +++ b/Telegram/SourceFiles/storage/localstorage.cpp @@ -137,11 +137,6 @@ void applyReadContext(ReadSettingsContext &&context) { _useGlobalBackgroundKeys = context.backgroundKeysRead; _langPackKey = context.langPackKey; _languagesKey = context.languagesKey; - - if (context.tileRead && _useGlobalBackgroundKeys) { - Window::Theme::Background()->setTileDayValue(context.tileDay); - Window::Theme::Background()->setTileNightValue(context.tileNight); - } } bool _readOldSettings(bool remove, ReadSettingsContext &context) { @@ -411,6 +406,12 @@ void start() { applyReadContext(std::move(context)); InitialLoadTheme(); + + if (context.tileRead && _useGlobalBackgroundKeys) { + Window::Theme::Background()->setTileDayValue(context.tileDay); + Window::Theme::Background()->setTileNightValue(context.tileNight); + } + readLangPack(); } @@ -795,6 +796,8 @@ void reset() { Window::Theme::Background()->reset(); _oldSettingsVersion = 0; + Core::App().settings().resetOnLastLogout(); + writeSettings(); } int32 oldSettingsVersion() { diff --git a/Telegram/SourceFiles/window/themes/window_theme.cpp b/Telegram/SourceFiles/window/themes/window_theme.cpp index 2f170c3b46..b89bc969a9 100644 --- a/Telegram/SourceFiles/window/themes/window_theme.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme.cpp @@ -913,6 +913,7 @@ void ChatBackground::reset() { notify(BackgroundUpdate(BackgroundUpdate::Type::TestingTheme, tile()), true); notify(BackgroundUpdate(BackgroundUpdate::Type::ApplyingTheme, tile()), true); } + writeNewBackgroundSettings(); } void ChatBackground::saveForRevert() {