mirror of https://github.com/procxx/kepka.git
Fix auto interface scale by primary screen dpi.
This commit is contained in:
parent
91a6af71a0
commit
711b8cfa36
|
@ -44,7 +44,6 @@ uint32 gConnectionsInSession = 1;
|
||||||
QString gLoggedPhoneNumber;
|
QString gLoggedPhoneNumber;
|
||||||
|
|
||||||
QByteArray gLocalSalt;
|
QByteArray gLocalSalt;
|
||||||
int gRealScale = kInterfaceScaleAuto;
|
|
||||||
int gScreenScale = kInterfaceScaleAuto;
|
int gScreenScale = kInterfaceScaleAuto;
|
||||||
int gConfigScale = kInterfaceScaleAuto;
|
int gConfigScale = kInterfaceScaleAuto;
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,6 @@ DeclareSetting(bool, StartToSettings);
|
||||||
DeclareReadSetting(bool, ManyInstance);
|
DeclareReadSetting(bool, ManyInstance);
|
||||||
|
|
||||||
DeclareSetting(QByteArray, LocalSalt);
|
DeclareSetting(QByteArray, LocalSalt);
|
||||||
DeclareSetting(int, RealScale);
|
|
||||||
DeclareSetting(int, ScreenScale);
|
DeclareSetting(int, ScreenScale);
|
||||||
DeclareSetting(int, ConfigScale);
|
DeclareSetting(int, ConfigScale);
|
||||||
DeclareSetting(QString, TimeFormat);
|
DeclareSetting(QString, TimeFormat);
|
||||||
|
@ -194,7 +193,7 @@ inline int cEvalScale(int scale) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int cScale() {
|
inline int cScale() {
|
||||||
return cEvalScale(cRealScale());
|
return cEvalScale(cConfigScale());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -214,5 +213,4 @@ inline void SetScaleChecked(int scale) {
|
||||||
? kInterfaceScaleAuto
|
? kInterfaceScaleAuto
|
||||||
: snap(scale, kInterfaceScaleMin, kInterfaceScaleMax / cIntRetinaFactor());
|
: snap(scale, kInterfaceScaleMin, kInterfaceScaleMax / cIntRetinaFactor());
|
||||||
cSetConfigScale(checked);
|
cSetConfigScale(checked);
|
||||||
cSetRealScale(checked);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,8 +112,7 @@ void SetupInterfaceScale(
|
||||||
container,
|
container,
|
||||||
rpl::event_stream<bool>());
|
rpl::event_stream<bool>());
|
||||||
|
|
||||||
const auto switched = (cConfigScale() == kInterfaceScaleAuto)
|
const auto switched = (cConfigScale() == kInterfaceScaleAuto);
|
||||||
|| (cConfigScale() == cScreenScale());
|
|
||||||
const auto button = AddButton(
|
const auto button = AddButton(
|
||||||
container,
|
container,
|
||||||
lng_settings_default_scale,
|
lng_settings_default_scale,
|
||||||
|
@ -129,6 +128,7 @@ void SetupInterfaceScale(
|
||||||
? 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 };
|
||||||
const auto sectionFromScale = [](int scale) {
|
const auto sectionFromScale = [](int scale) {
|
||||||
|
scale = cEvalScale(scale);
|
||||||
auto result = 0;
|
auto result = 0;
|
||||||
for (const auto value : ScaleValues) {
|
for (const auto value : ScaleValues) {
|
||||||
if (scale <= value) {
|
if (scale <= value) {
|
||||||
|
@ -145,19 +145,11 @@ void SetupInterfaceScale(
|
||||||
*inSetScale = true;
|
*inSetScale = true;
|
||||||
const auto guard = gsl::finally([=] { *inSetScale = false; });
|
const auto guard = gsl::finally([=] { *inSetScale = false; });
|
||||||
|
|
||||||
if (scale == cScreenScale()) {
|
|
||||||
scale = kInterfaceScaleAuto;
|
|
||||||
}
|
|
||||||
toggled->fire(scale == kInterfaceScaleAuto);
|
toggled->fire(scale == kInterfaceScaleAuto);
|
||||||
const auto applying = scale;
|
|
||||||
if (scale == kInterfaceScaleAuto) {
|
|
||||||
scale = cScreenScale();
|
|
||||||
}
|
|
||||||
slider->setActiveSection(sectionFromScale(scale));
|
slider->setActiveSection(sectionFromScale(scale));
|
||||||
|
if (cEvalScale(scale) != cEvalScale(cConfigScale())) {
|
||||||
if (cEvalScale(scale) != cEvalScale(cRealScale())) {
|
|
||||||
const auto confirmed = crl::guard(button, [=] {
|
const auto confirmed = crl::guard(button, [=] {
|
||||||
cSetConfigScale(applying);
|
cSetConfigScale(scale);
|
||||||
Local::writeSettings();
|
Local::writeSettings();
|
||||||
App::restart();
|
App::restart();
|
||||||
});
|
});
|
||||||
|
@ -165,45 +157,18 @@ void SetupInterfaceScale(
|
||||||
App::CallDelayed(
|
App::CallDelayed(
|
||||||
st::defaultSettingsSlider.duration,
|
st::defaultSettingsSlider.duration,
|
||||||
button,
|
button,
|
||||||
[=] { (*setScale)(cRealScale()); });
|
[=] { (*setScale)(cConfigScale()); });
|
||||||
});
|
});
|
||||||
Ui::show(Box<ConfirmBox>(
|
Ui::show(Box<ConfirmBox>(
|
||||||
lang(lng_settings_need_restart),
|
lang(lng_settings_need_restart),
|
||||||
lang(lng_settings_restart_now),
|
lang(lng_settings_restart_now),
|
||||||
confirmed,
|
confirmed,
|
||||||
cancelled));
|
cancelled));
|
||||||
} else {
|
} else if (scale != cConfigScale()) {
|
||||||
cSetConfigScale(scale);
|
cSetConfigScale(scale);
|
||||||
Local::writeSettings();
|
Local::writeSettings();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
button->toggledValue(
|
|
||||||
) | rpl::start_with_next([=](bool checked) {
|
|
||||||
auto scale = checked ? kInterfaceScaleAuto : cEvalScale(cConfigScale());
|
|
||||||
if (scale == cScreenScale()) {
|
|
||||||
if (scale != cScale()) {
|
|
||||||
scale = cScale();
|
|
||||||
} else {
|
|
||||||
auto selected = 0;
|
|
||||||
for (const auto possible : ScaleValues) {
|
|
||||||
if (possible == scale) {
|
|
||||||
if (selected) {
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
selected = -1;
|
|
||||||
}
|
|
||||||
} else if (selected == -1) {
|
|
||||||
selected = possible;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
selected = possible;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scale = selected;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(*setScale)(scale);
|
|
||||||
}, button->lifetime());
|
|
||||||
|
|
||||||
const auto label = [](int scale) {
|
const auto label = [](int scale) {
|
||||||
return QString::number(scale) + '%';
|
return QString::number(scale) + '%';
|
||||||
|
@ -217,9 +182,20 @@ void SetupInterfaceScale(
|
||||||
}
|
}
|
||||||
slider->setActiveSectionFast(sectionFromScale(cConfigScale()));
|
slider->setActiveSectionFast(sectionFromScale(cConfigScale()));
|
||||||
slider->sectionActivated(
|
slider->sectionActivated(
|
||||||
) | rpl::start_with_next([=](int section) {
|
) | rpl::map([=](int section) {
|
||||||
(*setScale)(scaleByIndex(section));
|
return scaleByIndex(section);
|
||||||
|
}) | rpl::start_with_next([=](int scale) {
|
||||||
|
(*setScale)((scale == cScreenScale())
|
||||||
|
? kInterfaceScaleAuto
|
||||||
|
: scale);
|
||||||
}, slider->lifetime());
|
}, slider->lifetime());
|
||||||
|
|
||||||
|
button->toggledValue(
|
||||||
|
) | rpl::map([](bool checked) {
|
||||||
|
return checked ? kInterfaceScaleAuto : cEvalScale(cConfigScale());
|
||||||
|
}) | rpl::start_with_next([=](int scale) {
|
||||||
|
(*setScale)(scale);
|
||||||
|
}, button->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenFaq() {
|
void OpenFaq() {
|
||||||
|
|
|
@ -1383,7 +1383,7 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSetting
|
||||||
case kOneAndHalf: return 150;
|
case kOneAndHalf: return 150;
|
||||||
case kTwo: return 200;
|
case kTwo: return 200;
|
||||||
}
|
}
|
||||||
return cRealScale();
|
return cConfigScale();
|
||||||
}());
|
}());
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
|
|
@ -47,10 +47,8 @@ void unregisterModule(ModuleBase *module) {
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
void startManager() {
|
void startManager() {
|
||||||
if ((cIntRetinaFactor() * cConfigScale() > kInterfaceScaleMax)
|
if (cIntRetinaFactor() * cConfigScale() > kInterfaceScaleMax) {
|
||||||
|| (cIntRetinaFactor() * cRealScale() > kInterfaceScaleMax)) {
|
|
||||||
cSetConfigScale(kInterfaceScaleDefault);
|
cSetConfigScale(kInterfaceScaleDefault);
|
||||||
cSetRealScale(kInterfaceScaleDefault);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal::registerFontFamily(qsl("Open Sans"));
|
internal::registerFontFamily(qsl("Open Sans"));
|
||||||
|
|
Loading…
Reference in New Issue