diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index b82d366e5..15946ccf9 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2606,6 +2606,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "ktg_net_speed_boost_big" = "Big"; "ktg_settings_system" = "System"; +"ktg_settings_gtk_integration" = "GTK integration"; "ktg_settings_other" = "Other"; "ktg_profile_copy_id" = "Copy ID"; diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index a323bc7bc..ffe2cace7 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_gtk_integration": "GTK integration", "ktg_settings_other": "Other", "ktg_profile_copy_id": "Copy ID", "ktg_profile_bot_id": "Bot ID", diff --git a/Telegram/Resources/langs/rewrites/ru.json b/Telegram/Resources/langs/rewrites/ru.json index d88df348b..1316a57a3 100644 --- a/Telegram/Resources/langs/rewrites/ru.json +++ b/Telegram/Resources/langs/rewrites/ru.json @@ -66,6 +66,7 @@ "ktg_net_speed_boost_medium": "Среднее", "ktg_net_speed_boost_big": "Высокое", "ktg_settings_system": "Система", + "ktg_settings_gtk_integration": "GTK-интеграция", "ktg_settings_other": "Прочие", "ktg_profile_copy_id": "Копировать ID", "ktg_profile_bot_id": "ID бота", diff --git a/Telegram/SourceFiles/kotato/json_settings.cpp b/Telegram/SourceFiles/kotato/json_settings.cpp index 355e79269..ca362d95d 100644 --- a/Telegram/SourceFiles/kotato/json_settings.cpp +++ b/Telegram/SourceFiles/kotato/json_settings.cpp @@ -378,6 +378,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("gtk_integration"), cGtkIntegration()); settings.insert(qsl("disable_tray_counter"), cDisableTrayCounter()); settings.insert(qsl("use_telegram_panel_icon"), cUseTelegramPanelIcon()); settings.insert(qsl("custom_app_icon"), cCustomAppIcon()); @@ -620,6 +621,10 @@ bool Manager::readCustomFile() { cSetShowTopBarUserpic(v); }); + ReadBoolOption(settings, "gtk_integration", [&](auto v) { + cSetGtkIntegration(v); + }); + ReadBoolOption(settings, "disable_tray_counter", [&](auto v) { cSetDisableTrayCounter(v); }); diff --git a/Telegram/SourceFiles/kotato/settings.cpp b/Telegram/SourceFiles/kotato/settings.cpp index 00b74a742..48a47595a 100644 --- a/Telegram/SourceFiles/kotato/settings.cpp +++ b/Telegram/SourceFiles/kotato/settings.cpp @@ -145,6 +145,7 @@ rpl::producer RecentStickersLimitChanges() { int gUserpicCornersType = 3; bool gShowTopBarUserpic = false; +bool gGtkIntegration = false; bool gDisableTrayCounter = false; bool gUseTelegramPanelIcon = false; int gCustomAppIcon = 0; diff --git a/Telegram/SourceFiles/kotato/settings.h b/Telegram/SourceFiles/kotato/settings.h index cac33a2c7..d7ac4eabd 100644 --- a/Telegram/SourceFiles/kotato/settings.h +++ b/Telegram/SourceFiles/kotato/settings.h @@ -101,6 +101,7 @@ void SetRecentStickersLimit(int limit); DeclareSetting(int, UserpicCornersType); DeclareSetting(bool, ShowTopBarUserpic); +DeclareSetting(bool, GtkIntegration); DeclareSetting(bool, DisableTrayCounter); DeclareSetting(bool, UseTelegramPanelIcon); DeclareSetting(int, CustomAppIcon); diff --git a/Telegram/SourceFiles/kotato/settings_menu.cpp b/Telegram/SourceFiles/kotato/settings_menu.cpp index 0b23863f9..ee9928a6a 100644 --- a/Telegram/SourceFiles/kotato/settings_menu.cpp +++ b/Telegram/SourceFiles/kotato/settings_menu.cpp @@ -7,6 +7,7 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL */ #include "kotato/settings_menu.h" +#include "base/platform/base_platform_info.h" #include "settings/settings_common.h" #include "settings/settings_chat.h" #include "ui/wrap/vertical_layout.h" @@ -437,6 +438,37 @@ void SetupKotatoSystem( AddSkip(container); AddSubsectionTitle(container, tr::ktg_settings_system()); +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION + if (Platform::IsLinux()) { + const auto gtkIntegrationToggled = Ui::CreateChild>( + container.get()); + AddButton( + container, + tr::ktg_settings_gtk_integration(), + st::settingsButton + )->toggleOn( + gtkIntegrationToggled->events_starting_with_copy(cGtkIntegration()) + )->toggledValue( + ) | rpl::filter([](bool enabled) { + return (enabled != cGtkIntegration()); + }) | rpl::start_with_next([=](bool enabled) { + const auto confirmed = [=] { + cSetGtkIntegration(enabled); + ::Kotato::JsonSettings::Write(); + App::restart(); + }; + const auto cancelled = [=] { + gtkIntegrationToggled->fire(cGtkIntegration() == true); + }; + Ui::show(Box( + tr::lng_settings_need_restart(tr::now), + tr::lng_settings_restart_now(tr::now), + confirmed, + cancelled)); + }, container->lifetime()); + } +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION + #if defined Q_OS_MAC const auto useNativeDecorationsToggled = Ui::CreateChild>( container.get()); diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index a571e35e1..0f95f12ef 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -67,7 +67,6 @@ using Platform::internal::WaylandIntegration; namespace Platform { namespace { -constexpr auto kDisableGtkIntegration = "TDESKTOP_DISABLE_GTK_INTEGRATION"_cs; constexpr auto kIgnoreGtkIncompatibility = "TDESKTOP_I_KNOW_ABOUT_GTK_INCOMPATIBILITY"_cs; constexpr auto kDesktopFile = ":/misc/kotatogramdesktop.desktop"_cs; @@ -583,8 +582,7 @@ bool IsStaticBinary() { bool UseGtkIntegration() { #ifndef TDESKTOP_DISABLE_GTK_INTEGRATION - static const auto Result = !qEnvironmentVariableIsSet( - kDisableGtkIntegration.utf8()); + static const auto Result = cGtkIntegration(); return Result; #endif // !TDESKTOP_DISABLE_GTK_INTEGRATION @@ -1008,13 +1006,6 @@ void start() { "this will lead to a crash.", kIgnoreGtkIncompatibility.utf8().constData()); - g_message( - "GTK integration can be disabled by setting %s to any value. " - "Keep in mind that this will lead to clipboard issues " - "and tdesktop will be unable to get settings from GTK " - "(such as decoration layout, dark mode & more).", - kDisableGtkIntegration.utf8().constData()); - qunsetenv("QT_QPA_PLATFORMTHEME"); qunsetenv("QT_STYLE_OVERRIDE"); @@ -1024,13 +1015,6 @@ void start() { } } - if (!UseGtkIntegration()) { - g_warning( - "GTK integration was disabled on build or in runtime. " - "This will lead to clipboard issues and a lack of some features " - "(like Auto-Night Mode or system window controls layout)."); - } - #ifdef DESKTOP_APP_USE_PACKAGED_RLOTTIE g_warning( "Application has been built with foreign rlottie, "