diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml index c0477917d..9b26f1e26 100644 --- a/.github/workflows/appimage.yml +++ b/.github/workflows/appimage.yml @@ -520,7 +520,6 @@ jobs: -qt-libpng \ -qt-harfbuzz \ -qt-pcre \ - -no-gtk \ -no-feature-xcb-sm \ -no-feature-wayland-server \ -openssl-linked \ 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/core/core_settings.h b/Telegram/SourceFiles/core/core_settings.h index c6333ba82..ddf6eebc2 100644 --- a/Telegram/SourceFiles/core/core_settings.h +++ b/Telegram/SourceFiles/core/core_settings.h @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once +#include "base/platform/base_platform_info.h" #include "window/themes/window_themes_embedded.h" #include "window/window_controls_layout.h" #include "ui/chat/attach/attach_send_files_way.h" @@ -518,7 +519,7 @@ private: bool _desktopNotify = true; bool _flashBounceNotify = true; DBINotifyView _notifyView = dbinvShowPreview; - bool _nativeNotifications = false; + bool _nativeNotifications = Platform::IsLinux(); int _notificationsCount = 3; ScreenCorner _notificationsCorner = ScreenCorner::BottomRight; bool _includeMutedCounter = true; @@ -561,7 +562,7 @@ private: rpl::variable _dialogsWidthRatio; // per-window rpl::variable _thirdColumnWidth = kDefaultThirdColumnWidth; // p-w bool _notifyFromAll = true; - rpl::variable _nativeWindowFrame = false; + rpl::variable _nativeWindowFrame = Platform::IsLinux(); rpl::variable> _systemDarkMode = std::nullopt; rpl::variable _systemDarkModeEnabled = false; rpl::variable _windowControlsLayout; 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..6fccc44b6 100644 --- a/Telegram/SourceFiles/kotato/settings.cpp +++ b/Telegram/SourceFiles/kotato/settings.cpp @@ -7,6 +7,8 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL */ #include "kotato/settings.h" +#include "base/platform/base_platform_info.h" + bool gKotatoFirstRun = true; QString gMainFont, gSemiboldFont, gMonospaceFont; @@ -145,7 +147,8 @@ rpl::producer RecentStickersLimitChanges() { int gUserpicCornersType = 3; bool gShowTopBarUserpic = false; -bool gDisableTrayCounter = false; +bool gGtkIntegration = false; +bool gDisableTrayCounter = Platform::IsLinux(); 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..e5ec3a887 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,34 +438,65 @@ void SetupKotatoSystem( AddSkip(container); AddSubsectionTitle(container, tr::ktg_settings_system()); -#if defined Q_OS_MAC - const auto useNativeDecorationsToggled = Ui::CreateChild>( - container.get()); - AddButton( - container, - tr::lng_settings_native_frame(), - st::settingsButton - )->toggleOn( - useNativeDecorationsToggled->events_starting_with_copy(cUseNativeDecorations()) - )->toggledValue( - ) | rpl::filter([](bool enabled) { - return (enabled != cUseNativeDecorations()); - }) | rpl::start_with_next([=](bool enabled) { - const auto confirmed = [=] { - cSetUseNativeDecorations(enabled); - ::Kotato::JsonSettings::Write(); - App::restart(); - }; - const auto cancelled = [=] { - useNativeDecorationsToggled->fire(cUseNativeDecorations() == true); - }; - Ui::show(Box( - tr::lng_settings_need_restart(tr::now), - tr::lng_settings_restart_now(tr::now), - confirmed, - cancelled)); - }, container->lifetime()); -#endif // Q_OS_MAC +#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 (Platform::IsMac()) { + const auto useNativeDecorationsToggled = Ui::CreateChild>( + container.get()); + AddButton( + container, + tr::lng_settings_native_frame(), + st::settingsButton + )->toggleOn( + useNativeDecorationsToggled->events_starting_with_copy(cUseNativeDecorations()) + )->toggledValue( + ) | rpl::filter([](bool enabled) { + return (enabled != cUseNativeDecorations()); + }) | rpl::start_with_next([=](bool enabled) { + const auto confirmed = [=] { + cSetUseNativeDecorations(enabled); + ::Kotato::JsonSettings::Write(); + App::restart(); + }; + const auto cancelled = [=] { + useNativeDecorationsToggled->fire(cUseNativeDecorations() == true); + }; + Ui::show(Box( + tr::lng_settings_need_restart(tr::now), + tr::lng_settings_restart_now(tr::now), + confirmed, + cancelled)); + }, container->lifetime()); + } AddButton( container, @@ -481,22 +513,22 @@ void SetupKotatoSystem( ::Kotato::JsonSettings::Write(); }, container->lifetime()); -#if defined Q_OS_UNIX && !defined Q_OS_MAC - AddButton( - container, - tr::ktg_settings_use_telegram_panel_icon(), - st::settingsButton - )->toggleOn( - rpl::single(cUseTelegramPanelIcon()) - )->toggledValue( - ) | rpl::filter([](bool enabled) { - return (enabled != cUseTelegramPanelIcon()); - }) | rpl::start_with_next([controller](bool enabled) { - cSetUseTelegramPanelIcon(enabled); - controller->session().data().notifyUnreadBadgeChanged(); - ::Kotato::JsonSettings::Write(); - }, container->lifetime()); -#endif // Q_OS_UNIX && !Q_OS_MAC + if (Platform::IsLinux()) { + AddButton( + container, + tr::ktg_settings_use_telegram_panel_icon(), + st::settingsButton + )->toggleOn( + rpl::single(cUseTelegramPanelIcon()) + )->toggledValue( + ) | rpl::filter([](bool enabled) { + return (enabled != cUseTelegramPanelIcon()); + }) | rpl::start_with_next([controller](bool enabled) { + cSetUseTelegramPanelIcon(enabled); + controller->session().data().notifyUnreadBadgeChanged(); + ::Kotato::JsonSettings::Write(); + }, container->lifetime()); + } const QMap trayIconOptions = { { 0, TrayIconLabel(0) }, 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, "