Option to set custom interface scales

This commit is contained in:
Eric Kotato 2019-10-07 04:44:41 +03:00
parent aea5ca9013
commit 70229dcb65
5 changed files with 47 additions and 3 deletions

View file

@ -13,5 +13,6 @@
// "always_show_scheduled": true,
// "show_chat_id": true,
// "net_speed_boost": null,
// "show_phone_in_drawer": true
// "show_phone_in_drawer": true,
// "scales": []
}

View file

@ -223,6 +223,20 @@ bool Manager::readCustomFile() {
if (settingsShowDrawerPhoneIt != settings.constEnd() && (*settingsShowDrawerPhoneIt).isBool()) {
cSetShowPhoneInDrawer((*settingsShowDrawerPhoneIt).toBool());
}
const auto settingsScalesIt = settings.constFind(qsl("scales"));
if (settingsScalesIt != settings.constEnd() && (*settingsScalesIt).isArray()) {
const auto settingsScalesArray = (*settingsScalesIt).toArray();
ClearCustomScales();
for (auto i = settingsScalesArray.constBegin(), e = settingsScalesArray.constEnd(); i != e; ++i) {
if (!(*i).isDouble()) {
continue;
}
AddCustomScale((*i).toInt());
}
}
return true;
}
@ -257,6 +271,9 @@ void Manager::writeDefaultFile() {
settings.insert(qsl("net_speed_boost"), QJsonValue(QJsonValue::Null));
settings.insert(qsl("show_phone_in_drawer"), cShowPhoneInDrawer());
auto settingsScales = QJsonArray();
settings.insert(qsl("scales"), settingsScales);
auto document = QJsonDocument();
document.setObject(settings);
file.write(document.toJson(QJsonDocument::Indented));

View file

@ -222,3 +222,21 @@ int gNetMaxFileQueries = 16;
int gNetUploadRequestInterval = 500;
bool gShowPhoneInDrawer = true;
ScaleVector gInterfaceScales;
bool HasCustomScales() {
return (!gInterfaceScales.empty());
}
bool AddCustomScale(int scale) {
if (gInterfaceScales.size() > 6) {
return false;
}
gInterfaceScales.push_back(style::CheckScale(scale));
return true;
}
void ClearCustomScales() {
gInterfaceScales.clear();
}

View file

@ -195,4 +195,10 @@ DeclareSetting(int, NetUploadSessionsCount);
DeclareSetting(int, NetMaxFileQueries);
DeclareSetting(int, NetUploadRequestInterval);
DeclareSetting(bool, ShowPhoneInDrawer);
DeclareSetting(bool, ShowPhoneInDrawer);
using ScaleVector = std::std::vector<int>;
DeclareRefSetting(ScaleVector, InterfaceScales);
bool HasCustomScales();
bool AddCustomScale(int scale);
void ClearCustomScales();

View file

@ -137,7 +137,9 @@ void SetupInterfaceScale(
icon ? st::settingsScalePadding : st::settingsBigScalePadding);
static const auto ScaleValues = [&] {
auto values = (cIntRetinaFactor() > 1)
auto values = HasCustomScales()
? cInterfaceScales()
: (cIntRetinaFactor() > 1)
? std::vector<int>{ 100, 110, 120, 130, 140, 150 }
: std::vector<int>{ 100, 125, 150, 200, 250, 300 };
if (cConfigScale() == style::kScaleAuto) {