Added '-scale' command-line argument for custom scale.

- Fixed #5272.
 - Fixed #5365.
 - Fixed #6055.
This commit is contained in:
23rd 2019-05-25 13:06:12 +03:00 committed by John Preston
parent 5f97b3bc22
commit 47910b2ae1
3 changed files with 27 additions and 5 deletions

View File

@ -425,6 +425,7 @@ void Launcher::processArguments() {
{ "-sendpath" , KeyFormat::AllLeftValues },
{ "-workdir" , KeyFormat::OneValue },
{ "--" , KeyFormat::OneValue },
{ "-scale" , KeyFormat::OneValue },
};
auto parseResult = QMap<QByteArray, QStringList>();
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() {

View File

@ -125,14 +125,24 @@ void SetupInterfaceScale(
object_ptr<Ui::SettingsSlider>(container, st::settingsSlider),
icon ? st::settingsScalePadding : st::settingsBigScalePadding);
static const auto ScaleValues = (cIntRetinaFactor() > 1)
? std::vector<int>{ 100, 110, 120, 130, 140, 150 }
: std::vector<int>{ 100, 125, 150, 200, 250, 300 };
static const auto ScaleValues = [&] {
auto values = (cIntRetinaFactor() > 1)
? std::vector<int>{ 100, 110, 120, 130, 140, 150 }
: std::vector<int>{ 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;

View File

@ -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: {