Option to set custom interface scales
This commit is contained in:
parent
aea5ca9013
commit
70229dcb65
5 changed files with 47 additions and 3 deletions
|
|
@ -13,5 +13,6 @@
|
||||||
// "always_show_scheduled": true,
|
// "always_show_scheduled": true,
|
||||||
// "show_chat_id": true,
|
// "show_chat_id": true,
|
||||||
// "net_speed_boost": null,
|
// "net_speed_boost": null,
|
||||||
// "show_phone_in_drawer": true
|
// "show_phone_in_drawer": true,
|
||||||
|
// "scales": []
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,20 @@ bool Manager::readCustomFile() {
|
||||||
if (settingsShowDrawerPhoneIt != settings.constEnd() && (*settingsShowDrawerPhoneIt).isBool()) {
|
if (settingsShowDrawerPhoneIt != settings.constEnd() && (*settingsShowDrawerPhoneIt).isBool()) {
|
||||||
cSetShowPhoneInDrawer((*settingsShowDrawerPhoneIt).toBool());
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -257,6 +271,9 @@ void Manager::writeDefaultFile() {
|
||||||
settings.insert(qsl("net_speed_boost"), QJsonValue(QJsonValue::Null));
|
settings.insert(qsl("net_speed_boost"), QJsonValue(QJsonValue::Null));
|
||||||
settings.insert(qsl("show_phone_in_drawer"), cShowPhoneInDrawer());
|
settings.insert(qsl("show_phone_in_drawer"), cShowPhoneInDrawer());
|
||||||
|
|
||||||
|
auto settingsScales = QJsonArray();
|
||||||
|
settings.insert(qsl("scales"), settingsScales);
|
||||||
|
|
||||||
auto document = QJsonDocument();
|
auto document = QJsonDocument();
|
||||||
document.setObject(settings);
|
document.setObject(settings);
|
||||||
file.write(document.toJson(QJsonDocument::Indented));
|
file.write(document.toJson(QJsonDocument::Indented));
|
||||||
|
|
|
||||||
|
|
@ -222,3 +222,21 @@ int gNetMaxFileQueries = 16;
|
||||||
int gNetUploadRequestInterval = 500;
|
int gNetUploadRequestInterval = 500;
|
||||||
|
|
||||||
bool gShowPhoneInDrawer = true;
|
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();
|
||||||
|
}
|
||||||
|
|
@ -195,4 +195,10 @@ DeclareSetting(int, NetUploadSessionsCount);
|
||||||
DeclareSetting(int, NetMaxFileQueries);
|
DeclareSetting(int, NetMaxFileQueries);
|
||||||
DeclareSetting(int, NetUploadRequestInterval);
|
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();
|
||||||
|
|
@ -137,7 +137,9 @@ void SetupInterfaceScale(
|
||||||
icon ? st::settingsScalePadding : st::settingsBigScalePadding);
|
icon ? st::settingsScalePadding : st::settingsBigScalePadding);
|
||||||
|
|
||||||
static const auto ScaleValues = [&] {
|
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, 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