[Option][JSON] Custom scales
This commit is contained in:
parent
cb1a2c6d04
commit
6ed812fa13
2 changed files with 36 additions and 1 deletions
|
|
@ -155,6 +155,22 @@ CheckHandler IntLimitMin(int min) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckHandler ScalesLimit() {
|
||||||
|
return [=] (QVariant value) -> QVariant {
|
||||||
|
auto newArrayValue = QJsonArray();
|
||||||
|
if (value.canConvert<QJsonArray>()) {
|
||||||
|
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) {
|
CheckHandler NetSpeedBoostConv(CheckHandler wrapped = nullptr) {
|
||||||
return [=] (QVariant value) -> QVariant {
|
return [=] (QVariant value) -> QVariant {
|
||||||
|
|
@ -293,6 +309,9 @@ const std::map<QString, Definition, std::greater<QString>> DefinitionMap {
|
||||||
{ "show_phone_in_drawer", {
|
{ "show_phone_in_drawer", {
|
||||||
.type = SettingType::BoolSetting,
|
.type = SettingType::BoolSetting,
|
||||||
.defaultValue = true, }},
|
.defaultValue = true, }},
|
||||||
|
{ "scales", {
|
||||||
|
.type = SettingType::QJsonArraySetting,
|
||||||
|
.limitHandler = ScalesLimit(), }},
|
||||||
};
|
};
|
||||||
|
|
||||||
using OldOptionKey = QString;
|
using OldOptionKey = QString;
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "styles/style_settings.h"
|
#include "styles/style_settings.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
|
|
||||||
|
#include <QtCore/QJsonArray>
|
||||||
|
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
|
|
||||||
void SetupLanguageButton(
|
void SetupLanguageButton(
|
||||||
|
|
@ -197,8 +199,22 @@ void SetupInterfaceScale(
|
||||||
object_ptr<Ui::SettingsSlider>(container, st::settingsSlider),
|
object_ptr<Ui::SettingsSlider>(container, st::settingsSlider),
|
||||||
icon ? st::settingsScalePadding : st::settingsBigScalePadding);
|
icon ? st::settingsScalePadding : st::settingsBigScalePadding);
|
||||||
|
|
||||||
|
static const auto customScales = [&] {
|
||||||
|
const auto scalesJson = ::Kotato::JsonSettings::Get("scales").toJsonArray();
|
||||||
|
auto result = std::vector<int>();
|
||||||
|
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 = [&] {
|
static const auto ScaleValues = [&] {
|
||||||
auto values = (cIntRetinaFactor() > 1)
|
auto values = (customScales.size() > 1)
|
||||||
|
? customScales
|
||||||
|
: (cIntRetinaFactor() > 1)
|
||||||
? std::vector<int>{ 100, 110, 120, 130, 140, 150 }
|
? std::vector<int>{ 100, 110, 120, 130, 140, 150 }
|
||||||
: std::vector<int>{ 100, 125, 150, 200, 250, 300 };
|
: std::vector<int>{ 100, 125, 150, 200, 250, 300 };
|
||||||
if (cConfigScale() == style::kScaleAuto) {
|
if (cConfigScale() == style::kScaleAuto) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue