diff --git a/Telegram/SourceFiles/settings.cpp b/Telegram/SourceFiles/settings.cpp index 0ab38d691..28d99889c 100644 --- a/Telegram/SourceFiles/settings.cpp +++ b/Telegram/SourceFiles/settings.cpp @@ -44,7 +44,6 @@ uint32 gConnectionsInSession = 1; QString gLoggedPhoneNumber; QByteArray gLocalSalt; -int gRealScale = kInterfaceScaleAuto; int gScreenScale = kInterfaceScaleAuto; int gConfigScale = kInterfaceScaleAuto; diff --git a/Telegram/SourceFiles/settings.h b/Telegram/SourceFiles/settings.h index 1a319e34b..1016a3910 100644 --- a/Telegram/SourceFiles/settings.h +++ b/Telegram/SourceFiles/settings.h @@ -90,7 +90,6 @@ DeclareSetting(bool, StartToSettings); DeclareReadSetting(bool, ManyInstance); DeclareSetting(QByteArray, LocalSalt); -DeclareSetting(int, RealScale); DeclareSetting(int, ScreenScale); DeclareSetting(int, ConfigScale); DeclareSetting(QString, TimeFormat); @@ -194,7 +193,7 @@ inline int cEvalScale(int scale) { } inline int cScale() { - return cEvalScale(cRealScale()); + return cEvalScale(cConfigScale()); } template @@ -214,5 +213,4 @@ inline void SetScaleChecked(int scale) { ? kInterfaceScaleAuto : snap(scale, kInterfaceScaleMin, kInterfaceScaleMax / cIntRetinaFactor()); cSetConfigScale(checked); - cSetRealScale(checked); } diff --git a/Telegram/SourceFiles/settings/settings_main.cpp b/Telegram/SourceFiles/settings/settings_main.cpp index 9e9ed5759..347035f2a 100644 --- a/Telegram/SourceFiles/settings/settings_main.cpp +++ b/Telegram/SourceFiles/settings/settings_main.cpp @@ -112,8 +112,7 @@ void SetupInterfaceScale( container, rpl::event_stream()); - const auto switched = (cConfigScale() == kInterfaceScaleAuto) - || (cConfigScale() == cScreenScale()); + const auto switched = (cConfigScale() == kInterfaceScaleAuto); const auto button = AddButton( container, lng_settings_default_scale, @@ -129,6 +128,7 @@ void SetupInterfaceScale( ? std::vector{ 100, 110, 120, 130, 140, 150 } : std::vector{ 100, 125, 150, 200, 250, 300 }; const auto sectionFromScale = [](int scale) { + scale = cEvalScale(scale); auto result = 0; for (const auto value : ScaleValues) { if (scale <= value) { @@ -145,19 +145,11 @@ void SetupInterfaceScale( *inSetScale = true; const auto guard = gsl::finally([=] { *inSetScale = false; }); - if (scale == cScreenScale()) { - scale = kInterfaceScaleAuto; - } toggled->fire(scale == kInterfaceScaleAuto); - const auto applying = scale; - if (scale == kInterfaceScaleAuto) { - scale = cScreenScale(); - } slider->setActiveSection(sectionFromScale(scale)); - - if (cEvalScale(scale) != cEvalScale(cRealScale())) { + if (cEvalScale(scale) != cEvalScale(cConfigScale())) { const auto confirmed = crl::guard(button, [=] { - cSetConfigScale(applying); + cSetConfigScale(scale); Local::writeSettings(); App::restart(); }); @@ -165,45 +157,18 @@ void SetupInterfaceScale( App::CallDelayed( st::defaultSettingsSlider.duration, button, - [=] { (*setScale)(cRealScale()); }); + [=] { (*setScale)(cConfigScale()); }); }); Ui::show(Box( lang(lng_settings_need_restart), lang(lng_settings_restart_now), confirmed, cancelled)); - } else { + } else if (scale != cConfigScale()) { cSetConfigScale(scale); Local::writeSettings(); } }; - button->toggledValue( - ) | rpl::start_with_next([=](bool checked) { - auto scale = checked ? kInterfaceScaleAuto : cEvalScale(cConfigScale()); - if (scale == cScreenScale()) { - if (scale != cScale()) { - scale = cScale(); - } else { - auto selected = 0; - for (const auto possible : ScaleValues) { - if (possible == scale) { - if (selected) { - break; - } else { - selected = -1; - } - } else if (selected == -1) { - selected = possible; - break; - } else { - selected = possible; - } - } - scale = selected; - } - } - (*setScale)(scale); - }, button->lifetime()); const auto label = [](int scale) { return QString::number(scale) + '%'; @@ -217,9 +182,20 @@ void SetupInterfaceScale( } slider->setActiveSectionFast(sectionFromScale(cConfigScale())); slider->sectionActivated( - ) | rpl::start_with_next([=](int section) { - (*setScale)(scaleByIndex(section)); + ) | rpl::map([=](int section) { + return scaleByIndex(section); + }) | rpl::start_with_next([=](int scale) { + (*setScale)((scale == cScreenScale()) + ? kInterfaceScaleAuto + : scale); }, slider->lifetime()); + + button->toggledValue( + ) | rpl::map([](bool checked) { + return checked ? kInterfaceScaleAuto : cEvalScale(cConfigScale()); + }) | rpl::start_with_next([=](int scale) { + (*setScale)(scale); + }, button->lifetime()); } void OpenFaq() { diff --git a/Telegram/SourceFiles/storage/localstorage.cpp b/Telegram/SourceFiles/storage/localstorage.cpp index 44e9219da..fd034cc4d 100644 --- a/Telegram/SourceFiles/storage/localstorage.cpp +++ b/Telegram/SourceFiles/storage/localstorage.cpp @@ -1383,7 +1383,7 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSetting case kOneAndHalf: return 150; case kTwo: return 200; } - return cRealScale(); + return cConfigScale(); }()); } break; diff --git a/Telegram/SourceFiles/ui/style/style_core.cpp b/Telegram/SourceFiles/ui/style/style_core.cpp index 6ef4db56e..b518599b0 100644 --- a/Telegram/SourceFiles/ui/style/style_core.cpp +++ b/Telegram/SourceFiles/ui/style/style_core.cpp @@ -47,10 +47,8 @@ void unregisterModule(ModuleBase *module) { } // namespace internal void startManager() { - if ((cIntRetinaFactor() * cConfigScale() > kInterfaceScaleMax) - || (cIntRetinaFactor() * cRealScale() > kInterfaceScaleMax)) { + if (cIntRetinaFactor() * cConfigScale() > kInterfaceScaleMax) { cSetConfigScale(kInterfaceScaleDefault); - cSetRealScale(kInterfaceScaleDefault); } internal::registerFontFamily(qsl("Open Sans"));