diff --git a/Telegram/SourceFiles/kotato/kotato_settings.cpp b/Telegram/SourceFiles/kotato/kotato_settings.cpp index 768e0200c..a9a2c9752 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings.cpp @@ -155,6 +155,22 @@ CheckHandler IntLimitMin(int min) { }; } +CheckHandler ScalesLimit() { + return [=] (QVariant value) -> QVariant { + auto newArrayValue = QJsonArray(); + if (value.canConvert()) { + auto arrayValue = value.toJsonArray(); + for (auto i = arrayValue.begin(); i != arrayValue.end() && arrayValue.size() <= 6; ++i) { + const auto scaleNumber = (*i).toDouble(); + if (scaleNumber >= style::kScaleMin && scaleNumber <= style::kScaleMax) { + newArrayValue.append(scaleNumber); + } + } + } + return newArrayValue; + }; +} + CheckHandler NetSpeedBoostConv(CheckHandler wrapped = nullptr) { return [=] (QVariant value) -> QVariant { @@ -293,6 +309,9 @@ const std::map> DefinitionMap { { "show_phone_in_drawer", { .type = SettingType::BoolSetting, .defaultValue = true, }}, + { "scales", { + .type = SettingType::QJsonArraySetting, + .limitHandler = ScalesLimit(), }}, }; using OldOptionKey = QString; diff --git a/Telegram/SourceFiles/settings/settings_main.cpp b/Telegram/SourceFiles/settings/settings_main.cpp index 371b65f10..4018f1f4f 100644 --- a/Telegram/SourceFiles/settings/settings_main.cpp +++ b/Telegram/SourceFiles/settings/settings_main.cpp @@ -44,6 +44,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_settings.h" #include "base/platform/base_platform_info.h" +#include + namespace Settings { void SetupLanguageButton( @@ -197,8 +199,22 @@ void SetupInterfaceScale( object_ptr(container, st::settingsSlider), icon ? st::settingsScalePadding : st::settingsBigScalePadding); + static const auto customScales = [&] { + const auto scalesJson = ::Kotato::JsonSettings::Get("scales").toJsonArray(); + auto result = std::vector(); + result.reserve(scalesJson.size()); + for (auto i = scalesJson.begin(); i != scalesJson.end(); ++i) { + if ((*i).type() != QJsonValue::Undefined) { + result.push_back(int((*i).toDouble())); + } + } + return result; + }(); + static const auto ScaleValues = [&] { - auto values = (cIntRetinaFactor() > 1) + auto values = (customScales.size() > 1) + ? customScales + : (cIntRetinaFactor() > 1) ? std::vector{ 100, 110, 120, 130, 140, 150 } : std::vector{ 100, 125, 150, 200, 250, 300 }; if (cConfigScale() == style::kScaleAuto) {