[Option][GUI] Qt scale
This commit is contained in:
parent
c0462c21b6
commit
6712cccf21
7 changed files with 67 additions and 4 deletions
|
|
@ -55,6 +55,7 @@
|
||||||
"ktg_net_speed_boost_medium": "Medium",
|
"ktg_net_speed_boost_medium": "Medium",
|
||||||
"ktg_net_speed_boost_big": "Big",
|
"ktg_net_speed_boost_big": "Big",
|
||||||
"ktg_settings_system": "System",
|
"ktg_settings_system": "System",
|
||||||
|
"ktg_settings_qt_scale": "Qt scaling engine",
|
||||||
"ktg_settings_other": "Other",
|
"ktg_settings_other": "Other",
|
||||||
"ktg_profile_copy_id": "Copy ID",
|
"ktg_profile_copy_id": "Copy ID",
|
||||||
"ktg_profile_bot_id": "Bot ID",
|
"ktg_profile_bot_id": "Bot ID",
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
|
|
||||||
#include "kotato/kotato_lang.h"
|
#include "kotato/kotato_lang.h"
|
||||||
|
#include "kotato/kotato_settings.h"
|
||||||
#include "data/data_abstract_structure.h"
|
#include "data/data_abstract_structure.h"
|
||||||
#include "data/data_photo.h"
|
#include "data/data_photo.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
|
|
@ -222,9 +223,16 @@ void Application::run() {
|
||||||
_notifications = std::make_unique<Window::Notifications::System>();
|
_notifications = std::make_unique<Window::Notifications::System>();
|
||||||
|
|
||||||
startLocalStorage();
|
startLocalStorage();
|
||||||
ValidateScale();
|
|
||||||
Kotato::Lang::Load(Lang::GetInstance().baseId(), Lang::GetInstance().id());
|
Kotato::Lang::Load(Lang::GetInstance().baseId(), Lang::GetInstance().id());
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
if (!::Kotato::JsonSettings::GetBool("qt_scale")) {
|
||||||
|
#endif
|
||||||
|
ValidateScale();
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
refreshGlobalProxy(); // Depends on app settings being read.
|
refreshGlobalProxy(); // Depends on app settings being read.
|
||||||
|
|
||||||
if (Local::oldSettingsVersion() < AppVersion) {
|
if (Local::oldSettingsVersion() < AppVersion) {
|
||||||
|
|
|
||||||
|
|
@ -336,6 +336,13 @@ int Launcher::exec() {
|
||||||
base::options::init(cWorkingDir() + "tdata/experimental_options.json");
|
base::options::init(cWorkingDir() + "tdata/experimental_options.json");
|
||||||
Kotato::JsonSettings::Load();
|
Kotato::JsonSettings::Load();
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
if (::Kotato::JsonSettings::GetBool("qt_scale")) {
|
||||||
|
QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, false);
|
||||||
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (Logs::DebugEnabled()) {
|
if (Logs::DebugEnabled()) {
|
||||||
const auto openalLogPath = QDir::toNativeSeparators(
|
const auto openalLogPath = QDir::toNativeSeparators(
|
||||||
cWorkingDir() + qsl("DebugLogs/last_openal_log.txt"));
|
cWorkingDir() + qsl("DebugLogs/last_openal_log.txt"));
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "core/sandbox.h"
|
#include "core/sandbox.h"
|
||||||
|
|
||||||
|
#include "kotato/kotato_settings.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "platform/platform_specific.h"
|
#include "platform/platform_specific.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
|
|
@ -240,7 +241,11 @@ void Sandbox::setupScreenScale() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto ratio = devicePixelRatio();
|
const auto ratio = devicePixelRatio();
|
||||||
if (ratio > 1.) {
|
if (ratio > 1.
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
|| ::Kotato::JsonSettings::GetBool("qt_scale")
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
if (!Platform::IsMac() || (ratio != 2.)) {
|
if (!Platform::IsMac() || (ratio != 2.)) {
|
||||||
LOG(("Found non-trivial Device Pixel Ratio: %1").arg(ratio));
|
LOG(("Found non-trivial Device Pixel Ratio: %1").arg(ratio));
|
||||||
LOG(("Environmental variables: QT_DEVICE_PIXEL_RATIO='%1'").arg(qEnvironmentVariable("QT_DEVICE_PIXEL_RATIO")));
|
LOG(("Environmental variables: QT_DEVICE_PIXEL_RATIO='%1'").arg(qEnvironmentVariable("QT_DEVICE_PIXEL_RATIO")));
|
||||||
|
|
@ -249,7 +254,11 @@ void Sandbox::setupScreenScale() {
|
||||||
LOG(("Environmental variables: QT_SCREEN_SCALE_FACTORS='%1'").arg(qEnvironmentVariable("QT_SCREEN_SCALE_FACTORS")));
|
LOG(("Environmental variables: QT_SCREEN_SCALE_FACTORS='%1'").arg(qEnvironmentVariable("QT_SCREEN_SCALE_FACTORS")));
|
||||||
}
|
}
|
||||||
style::SetDevicePixelRatio(int(ratio));
|
style::SetDevicePixelRatio(int(ratio));
|
||||||
if (Platform::IsMac() && ratio == 2.) {
|
if (Platform::IsMac() && ratio == 2.
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
&& !::Kotato::JsonSettings::GetBool("qt_scale")
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
cSetScreenScale(110); // 110% for Retina screens by default.
|
cSetScreenScale(110); // 110% for Retina screens by default.
|
||||||
} else {
|
} else {
|
||||||
cSetScreenScale(style::kScaleDefault);
|
cSetScreenScale(style::kScaleDefault);
|
||||||
|
|
@ -366,7 +375,12 @@ void Sandbox::singleInstanceChecked() {
|
||||||
LOG(("App Info: Detected another instance"));
|
LOG(("App Info: Detected another instance"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ui::DisableCustomScaling();
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
if (!::Kotato::JsonSettings::GetBool("qt_scale")) {
|
||||||
|
Ui::DisableCustomScaling();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
refreshGlobalProxy();
|
refreshGlobalProxy();
|
||||||
if (!Logs::started() || !Logs::instanceChecked()) {
|
if (!Logs::started() || !Logs::instanceChecked()) {
|
||||||
new NotStartedWindow();
|
new NotStartedWindow();
|
||||||
|
|
|
||||||
|
|
@ -370,6 +370,12 @@ const std::map<QString, Definition, std::greater<QString>> DefinitionMap {
|
||||||
{ "always_show_top_userpic", {
|
{ "always_show_top_userpic", {
|
||||||
.type = SettingType::BoolSetting,
|
.type = SettingType::BoolSetting,
|
||||||
.defaultValue = false, }},
|
.defaultValue = false, }},
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
{ "qt_scale", {
|
||||||
|
.storage = SettingStorage::None,
|
||||||
|
.type = SettingType::BoolSetting,
|
||||||
|
.defaultValue = false, }},
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
using OldOptionKey = QString;
|
using OldOptionKey = QString;
|
||||||
|
|
|
||||||
|
|
@ -395,6 +395,28 @@ void SetupKotatoSystem(
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
AddSubsectionTitle(container, rktr("ktg_settings_system"));
|
AddSubsectionTitle(container, rktr("ktg_settings_system"));
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
AddButton(
|
||||||
|
container,
|
||||||
|
rktr("ktg_settings_qt_scale"),
|
||||||
|
st::settingsButton
|
||||||
|
)->toggleOn(
|
||||||
|
rpl::single(::Kotato::JsonSettings::GetBoolWithPending("qt_scale"))
|
||||||
|
)->toggledValue(
|
||||||
|
) | rpl::filter([](bool enabled) {
|
||||||
|
return (enabled != ::Kotato::JsonSettings::GetBoolWithPending("qt_scale"));
|
||||||
|
}) | rpl::start_with_next([=](bool enabled) {
|
||||||
|
::Kotato::JsonSettings::SetAfterRestart("qt_scale", enabled);
|
||||||
|
::Kotato::JsonSettings::Write();
|
||||||
|
|
||||||
|
Ui::show(Box<Ui::ConfirmBox>(
|
||||||
|
tr::lng_settings_need_restart(tr::now),
|
||||||
|
tr::lng_settings_restart_now(tr::now),
|
||||||
|
tr::lng_settings_restart_later(tr::now),
|
||||||
|
[] { Core::Restart(); }));
|
||||||
|
}, container->lifetime());
|
||||||
|
#endif // Qt < 6.0.0
|
||||||
|
|
||||||
|
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "settings/settings_main.h"
|
#include "settings/settings_main.h"
|
||||||
|
|
||||||
#include "kotato/kotato_lang.h"
|
#include "kotato/kotato_lang.h"
|
||||||
|
#include "kotato/kotato_settings.h"
|
||||||
#include "settings/settings_common.h"
|
#include "settings/settings_common.h"
|
||||||
#include "settings/settings_codes.h"
|
#include "settings/settings_codes.h"
|
||||||
#include "settings/settings_chat.h"
|
#include "settings/settings_chat.h"
|
||||||
|
|
@ -173,7 +174,11 @@ void SetupSections(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasInterfaceScale() {
|
bool HasInterfaceScale() {
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
return !::Kotato::JsonSettings::GetBool("qt_scale");
|
||||||
|
#else
|
||||||
return true;
|
return true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupInterfaceScale(
|
void SetupInterfaceScale(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue