2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Add interface scale (100%..150%) for Retina.

Fixes #69, fixes #3126, fixes #3789.
This commit is contained in:
John Preston
2018-10-15 22:42:10 +03:00
parent f2866442d2
commit 5b4abe69aa
19 changed files with 111 additions and 106 deletions

View File

@@ -95,28 +95,6 @@ DeclareSetting(int, ScreenScale);
DeclareSetting(int, ConfigScale);
DeclareSetting(QString, TimeFormat);
constexpr auto kInterfaceScaleAuto = 0;
inline int cEvalScale(int scale) {
return (scale == kInterfaceScaleAuto) ? cScreenScale() : scale;
}
inline int cScale() {
return cEvalScale(cRealScale());
}
template <typename T>
inline T ConvertScale(T value, int scale) {
return (value < 0.)
? (-ConvertScale(-value, scale))
: T(std::round((float64(value) * scale / 100.) - 0.01));
}
template <typename T>
inline T ConvertScale(T value) {
return ConvertScale(value, cScale());
}
inline void cChangeTimeFormat(const QString &newFormat) {
if (!newFormat.isEmpty()) cSetTimeFormat(newFormat);
}
@@ -177,7 +155,6 @@ inline bool passcodeCanTry() {
DeclareSetting(QStringList, SendPaths);
DeclareSetting(QString, StartUrl);
DeclareSetting(bool, Retina);
DeclareSetting(float64, RetinaFactor);
DeclareSetting(int32, IntRetinaFactor);
@@ -206,3 +183,36 @@ DeclareSetting(int32, AutoDownloadPhoto);
DeclareSetting(int32, AutoDownloadAudio);
DeclareSetting(int32, AutoDownloadGif);
DeclareSetting(bool, AutoPlayGif);
constexpr auto kInterfaceScaleAuto = 0;
constexpr auto kInterfaceScaleMin = 100;
constexpr auto kInterfaceScaleDefault = 100;
constexpr auto kInterfaceScaleMax = 300;
inline int cEvalScale(int scale) {
return (scale == kInterfaceScaleAuto) ? cScreenScale() : scale;
}
inline int cScale() {
return cEvalScale(cRealScale());
}
template <typename T>
inline T ConvertScale(T value, int scale) {
return (value < 0.)
? (-ConvertScale(-value, scale))
: T(std::round((float64(value) * scale / 100.) - 0.01));
}
template <typename T>
inline T ConvertScale(T value) {
return ConvertScale(value, cScale());
}
inline void SetScaleChecked(int scale) {
const auto checked = (scale == kInterfaceScaleAuto)
? kInterfaceScaleAuto
: snap(scale, kInterfaceScaleMin, kInterfaceScaleMax / cIntRetinaFactor());
cSetConfigScale(checked);
cSetRealScale(checked);
}