mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-30 22:25:12 +00:00
Add an option to use Qt scale engine (#158)
This commit is contained in:
@@ -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";
|
||||
|
@@ -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",
|
||||
|
@@ -206,7 +206,10 @@ void Application::run() {
|
||||
startLocalStorage();
|
||||
Lang::GetInstance().fillDefaultJson();
|
||||
Lang::GetInstance().fillFromJson();
|
||||
ValidateScale();
|
||||
|
||||
if (!cQtScale()) {
|
||||
ValidateScale();
|
||||
}
|
||||
|
||||
if (Local::oldSettingsVersion() < AppVersion) {
|
||||
psNewVersion();
|
||||
|
@@ -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())
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
});
|
||||
|
@@ -147,6 +147,8 @@ rpl::producer<int> RecentStickersLimitChanges() {
|
||||
|
||||
int gUserpicCornersType = 3;
|
||||
bool gShowTopBarUserpic = false;
|
||||
|
||||
bool gQtScale = Platform::IsLinux();
|
||||
bool gGtkIntegration = false;
|
||||
|
||||
rpl::variable<Platform::FileDialog::ImplementationType> gFileDialogType = Platform::FileDialog::ImplementationType::Default;
|
||||
|
@@ -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);
|
||||
|
@@ -440,6 +440,33 @@ void SetupKotatoSystem(
|
||||
AddSkip(container);
|
||||
AddSubsectionTitle(container, tr::ktg_settings_system());
|
||||
|
||||
const auto qtScaleToggled = Ui::CreateChild<rpl::event_stream<bool>>(
|
||||
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<ConfirmBox>(
|
||||
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<rpl::event_stream<bool>>(
|
||||
|
@@ -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()) {
|
||||
|
@@ -173,7 +173,7 @@ void SetupSections(
|
||||
}
|
||||
|
||||
bool HasInterfaceScale() {
|
||||
return true;
|
||||
return !cQtScale();
|
||||
}
|
||||
|
||||
void SetupInterfaceScale(
|
||||
|
Reference in New Issue
Block a user