From 131f7ec5bb35f45c58672d1d951c7b302185c3cc Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 26 Sep 2018 18:30:42 +0300 Subject: [PATCH] Add install beta toggle to Settings > Advanced. --- Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/facades.cpp | 22 ++++--- Telegram/SourceFiles/facades.h | 1 + .../settings/settings_advanced.cpp | 63 +++++++++++++------ 4 files changed, 62 insertions(+), 25 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index b4f13a479..1bd0e33ed 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -294,6 +294,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_languages" = "Languages"; "lng_sure_save_language" = "Telegram will restart in order to change language"; "lng_settings_update_automatically" = "Update automatically"; +"lng_settings_install_beta" = "Install beta versions"; "lng_settings_current_version_label" = "Version {version}:"; "lng_settings_current_version" = "Version {version}"; "lng_settings_check_now" = "Check for updates"; diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index 8bcc08454..7692f196f 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -439,6 +439,17 @@ bool CheckAlphaVersionDir() { return true; } +QString InstallBetaVersionsSettingPath() { + return cWorkingDir() + qsl("tdata/devversion"); +} + +void WriteInstallBetaVersionsSetting() { + QFile f(InstallBetaVersionsSettingPath()); + if (f.open(QIODevice::WriteOnly)) { + f.write(cInstallBetaVersion() ? "1" : "0"); + } +} + void WorkingDirReady() { if (QFile(cWorkingDir() + qsl("tdata/withtestmode")).exists()) { cSetTestMode(true); @@ -447,19 +458,16 @@ void WorkingDirReady() { && QFile(cWorkingDir() + qsl("tdata/withdebug")).exists()) { Logs::SetDebugEnabled(true); } - const auto installBetaPath = cWorkingDir() + qsl("tdata/devversion"); + const auto installBetaSettingPath = InstallBetaVersionsSettingPath(); if (cAlphaVersion()) { cSetInstallBetaVersion(false); - } else if (QFile(installBetaPath).exists()) { - QFile f(installBetaPath); + } else if (QFile(installBetaSettingPath).exists()) { + QFile f(installBetaSettingPath); if (f.open(QIODevice::ReadOnly)) { cSetInstallBetaVersion(f.read(1) != "0"); } } else if (AppBetaVersion) { - QFile f(installBetaPath); - if (f.open(QIODevice::WriteOnly)) { - f.write(cInstallBetaVersion() ? "1" : "0"); - } + WriteInstallBetaVersionsSetting(); } srand((int32)time(NULL)); diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index a18287816..3e9f0de60 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -187,6 +187,7 @@ namespace Sandbox { bool CheckAlphaVersionDir(); void WorkingDirReady(); +void WriteInstallBetaVersionsSetting(); void MainThreadTaskAdded(); diff --git a/Telegram/SourceFiles/settings/settings_advanced.cpp b/Telegram/SourceFiles/settings/settings_advanced.cpp index 73b815a1d..b75c31c83 100644 --- a/Telegram/SourceFiles/settings/settings_advanced.cpp +++ b/Telegram/SourceFiles/settings/settings_advanced.cpp @@ -95,18 +95,26 @@ void SetupUpdate(not_null container) { texts->events(), st::settingsUpdateState); - const auto check = container->add(object_ptr>( - container, - object_ptr