From 47910b2ae180b6429adafef13ebf97cb75ad9dca Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sat, 25 May 2019 13:06:12 +0300 Subject: [PATCH] Added '-scale' command-line argument for custom scale. - Fixed #5272. - Fixed #5365. - Fixed #6055. --- Telegram/SourceFiles/core/launcher.cpp | 9 +++++++++ .../SourceFiles/settings/settings_main.cpp | 18 ++++++++++++++---- Telegram/SourceFiles/storage/localstorage.cpp | 5 ++++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/core/launcher.cpp b/Telegram/SourceFiles/core/launcher.cpp index b1246588a..851ed591e 100644 --- a/Telegram/SourceFiles/core/launcher.cpp +++ b/Telegram/SourceFiles/core/launcher.cpp @@ -425,6 +425,7 @@ void Launcher::processArguments() { { "-sendpath" , KeyFormat::AllLeftValues }, { "-workdir" , KeyFormat::OneValue }, { "--" , KeyFormat::OneValue }, + { "-scale" , KeyFormat::OneValue }, }; auto parseResult = QMap(); auto parsingKey = QByteArray(); @@ -474,6 +475,14 @@ void Launcher::processArguments() { } } gStartUrl = parseResult.value("--", {}).join(QString()); + + const auto scaleKey = parseResult.value("-scale", {}); + if (scaleKey.size() > 0) { + const auto value = scaleKey[0].toInt(); + gConfigScale = ((value < 75) || (value > 300)) + ? kInterfaceScaleAuto + : value; + } } int Launcher::executeApplication() { diff --git a/Telegram/SourceFiles/settings/settings_main.cpp b/Telegram/SourceFiles/settings/settings_main.cpp index 18552902b..afa4ed38c 100644 --- a/Telegram/SourceFiles/settings/settings_main.cpp +++ b/Telegram/SourceFiles/settings/settings_main.cpp @@ -125,14 +125,24 @@ void SetupInterfaceScale( object_ptr(container, st::settingsSlider), icon ? st::settingsScalePadding : st::settingsBigScalePadding); - static const auto ScaleValues = (cIntRetinaFactor() > 1) - ? std::vector{ 100, 110, 120, 130, 140, 150 } - : std::vector{ 100, 125, 150, 200, 250, 300 }; + static const auto ScaleValues = [&] { + auto values = (cIntRetinaFactor() > 1) + ? std::vector{ 100, 110, 120, 130, 140, 150 } + : std::vector{ 100, 125, 150, 200, 250, 300 }; + if (cConfigScale() == kInterfaceScaleAuto) { + return values; + } + if (ranges::find(values, cConfigScale()) == end(values)) { + values.push_back(cConfigScale()); + } + return values; + }(); + const auto sectionFromScale = [](int scale) { scale = cEvalScale(scale); auto result = 0; for (const auto value : ScaleValues) { - if (scale <= value) { + if (scale == value) { break; } ++result; diff --git a/Telegram/SourceFiles/storage/localstorage.cpp b/Telegram/SourceFiles/storage/localstorage.cpp index 97d805e59..8715d0bd3 100644 --- a/Telegram/SourceFiles/storage/localstorage.cpp +++ b/Telegram/SourceFiles/storage/localstorage.cpp @@ -1521,7 +1521,10 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSetting stream >> v; if (!_checkStreamStatus(stream)) return false; - SetScaleChecked(v); + // If cConfigScale() has value then it was set via command line. + if (cConfigScale() == kInterfaceScaleAuto) { + SetScaleChecked(v); + } } break; case dbiLangOld: {