diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 25e9bb820..2b8212d73 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2752,6 +2752,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "ktg_net_speed_boost_big" = "Big"; "ktg_settings_system" = "System"; +"ktg_settings_qt_scale" = "Use Qt scale engine"; "ktg_settings_gtk_integration" = "GTK integration"; "ktg_settings_file_dialog_type" = "File dialog"; diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index 5b3354b29..7cd80dcb0 100644 --- a/Telegram/Resources/langs/rewrites/en.json +++ b/Telegram/Resources/langs/rewrites/en.json @@ -67,6 +67,7 @@ "ktg_net_speed_boost_medium": "Medium", "ktg_net_speed_boost_big": "Big", "ktg_settings_system": "System", + "ktg_settings_qt_scale": "Use Qt scale engine", "ktg_settings_gtk_integration": "GTK integration", "ktg_settings_file_dialog_type": "File dialog", "ktg_file_dialog_type_default": "Default", diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index b7f384ec6..edc3dd4e8 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -206,7 +206,10 @@ void Application::run() { startLocalStorage(); Lang::GetInstance().fillDefaultJson(); Lang::GetInstance().fillFromJson(); - ValidateScale(); + + if (!cQtScale()) { + ValidateScale(); + } if (Local::oldSettingsVersion() < AppVersion) { psNewVersion(); diff --git a/Telegram/SourceFiles/core/launcher.cpp b/Telegram/SourceFiles/core/launcher.cpp index 083466d7d..27d06d274 100644 --- a/Telegram/SourceFiles/core/launcher.cpp +++ b/Telegram/SourceFiles/core/launcher.cpp @@ -300,7 +300,11 @@ void Launcher::init() { QApplication::setApplicationName(qsl("KotatogramDesktop")); #ifndef OS_MAC_OLD - QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true); + if (cQtScale()) { + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); + } else { + QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true); + } #endif // OS_MAC_OLD // fallback session management is useless for tdesktop since it doesn't have @@ -346,7 +350,10 @@ int Launcher::exec() { // Must be started before Sandbox is created. Platform::start(); - Ui::DisableCustomScaling(); + + if (!cQtScale()) { + Ui::DisableCustomScaling(); + } if (cUseEnvApi() && qEnvironmentVariableIsSet(kApiIdVarName.utf8().constData()) diff --git a/Telegram/SourceFiles/core/sandbox.cpp b/Telegram/SourceFiles/core/sandbox.cpp index 299f1084c..d1002b892 100644 --- a/Telegram/SourceFiles/core/sandbox.cpp +++ b/Telegram/SourceFiles/core/sandbox.cpp @@ -200,7 +200,7 @@ void Sandbox::setupScreenScale() { } const auto ratio = devicePixelRatio(); - if (ratio > 1.) { + if (ratio > 1. || cQtScale()) { if (!Platform::IsMac() || (ratio != 2.)) { LOG(("Found non-trivial Device Pixel Ratio: %1").arg(ratio)); LOG(("Environmental variables: QT_DEVICE_PIXEL_RATIO='%1'").arg(qEnvironmentVariable("QT_DEVICE_PIXEL_RATIO"))); @@ -209,7 +209,7 @@ void Sandbox::setupScreenScale() { LOG(("Environmental variables: QT_SCREEN_SCALE_FACTORS='%1'").arg(qEnvironmentVariable("QT_SCREEN_SCALE_FACTORS"))); } style::SetDevicePixelRatio(int(ratio)); - if (Platform::IsMac() && ratio == 2.) { + if (Platform::IsMac() && ratio == 2. && !cQtScale()) { cSetScreenScale(110); // 110% for Retina screens by default. } else { cSetScreenScale(style::kScaleDefault); diff --git a/Telegram/SourceFiles/kotato/json_settings.cpp b/Telegram/SourceFiles/kotato/json_settings.cpp index ea1afc0be..464264048 100644 --- a/Telegram/SourceFiles/kotato/json_settings.cpp +++ b/Telegram/SourceFiles/kotato/json_settings.cpp @@ -369,6 +369,7 @@ QByteArray GenerateSettingsJson(bool areDefault = false) { settings.insert(qsl("recent_stickers_limit"), RecentStickersLimit()); settings.insert(qsl("userpic_corner_type"), cUserpicCornersType()); settings.insert(qsl("always_show_top_userpic"), cShowTopBarUserpic()); + settings.insert(qsl("qt_scale"), cQtScale()); settings.insert(qsl("gtk_integration"), cGtkIntegration()); settings.insert(qsl("file_dialog_type"), int(FileDialogType())); settings.insert(qsl("disable_tray_counter"), cDisableTrayCounter()); @@ -613,6 +614,10 @@ bool Manager::readCustomFile() { cSetShowTopBarUserpic(v); }); + ReadBoolOption(settings, "qt_scale", [&](auto v) { + cSetQtScale(v); + }); + ReadBoolOption(settings, "gtk_integration", [&](auto v) { cSetGtkIntegration(v); }); diff --git a/Telegram/SourceFiles/kotato/settings.cpp b/Telegram/SourceFiles/kotato/settings.cpp index 6b058606e..3ccb544fd 100644 --- a/Telegram/SourceFiles/kotato/settings.cpp +++ b/Telegram/SourceFiles/kotato/settings.cpp @@ -147,6 +147,8 @@ rpl::producer RecentStickersLimitChanges() { int gUserpicCornersType = 3; bool gShowTopBarUserpic = false; + +bool gQtScale = Platform::IsLinux(); bool gGtkIntegration = false; rpl::variable gFileDialogType = Platform::FileDialog::ImplementationType::Default; diff --git a/Telegram/SourceFiles/kotato/settings.h b/Telegram/SourceFiles/kotato/settings.h index 8ef3971ad..209c5133d 100644 --- a/Telegram/SourceFiles/kotato/settings.h +++ b/Telegram/SourceFiles/kotato/settings.h @@ -103,6 +103,8 @@ void SetRecentStickersLimit(int limit); DeclareSetting(int, UserpicCornersType); DeclareSetting(bool, ShowTopBarUserpic); + +DeclareSetting(bool, QtScale); DeclareSetting(bool, GtkIntegration); void SetFileDialogType(Platform::FileDialog::ImplementationType t); diff --git a/Telegram/SourceFiles/kotato/settings_menu.cpp b/Telegram/SourceFiles/kotato/settings_menu.cpp index 1c120164c..2c836018c 100644 --- a/Telegram/SourceFiles/kotato/settings_menu.cpp +++ b/Telegram/SourceFiles/kotato/settings_menu.cpp @@ -440,6 +440,33 @@ void SetupKotatoSystem( AddSkip(container); AddSubsectionTitle(container, tr::ktg_settings_system()); + const auto qtScaleToggled = Ui::CreateChild>( + container.get()); + AddButton( + container, + tr::ktg_settings_qt_scale(), + st::settingsButton + )->toggleOn( + qtScaleToggled->events_starting_with_copy(cQtScale()) + )->toggledValue( + ) | rpl::filter([](bool enabled) { + return (enabled != cQtScale()); + }) | rpl::start_with_next([=](bool enabled) { + const auto confirmed = [=] { + cSetQtScale(enabled); + ::Kotato::JsonSettings::Write(); + App::restart(); + }; + const auto cancelled = [=] { + qtScaleToggled->fire(cQtScale() == true); + }; + Ui::show(Box( + tr::lng_settings_need_restart(tr::now), + tr::lng_settings_restart_now(tr::now), + confirmed, + cancelled)); + }, container->lifetime()); + #ifndef DESKTOP_APP_DISABLE_GTK_INTEGRATION if (Platform::IsLinux()) { const auto gtkIntegrationToggled = Ui::CreateChild>( diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index e3ec08535..f6226211b 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -955,7 +955,9 @@ void start() { integration->load(); } - SetGtkScaleFactor(); + if (!cQtScale()) { + SetGtkScaleFactor(); + } // wait for interface announce to know if native window frame is supported if (const auto integration = WaylandIntegration::Instance()) { diff --git a/Telegram/SourceFiles/settings/settings_main.cpp b/Telegram/SourceFiles/settings/settings_main.cpp index cadd9613f..93ce769c4 100644 --- a/Telegram/SourceFiles/settings/settings_main.cpp +++ b/Telegram/SourceFiles/settings/settings_main.cpp @@ -173,7 +173,7 @@ void SetupSections( } bool HasInterfaceScale() { - return true; + return !cQtScale(); } void SetupInterfaceScale(