mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-30 14:17:45 +00:00
Add gtk integration option
It is disabled by default to provide native Qt experience by default
This commit is contained in:
@@ -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";
|
||||
|
@@ -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",
|
||||
|
@@ -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 бота",
|
||||
|
@@ -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);
|
||||
});
|
||||
|
@@ -145,6 +145,7 @@ rpl::producer<int> RecentStickersLimitChanges() {
|
||||
|
||||
int gUserpicCornersType = 3;
|
||||
bool gShowTopBarUserpic = false;
|
||||
bool gGtkIntegration = false;
|
||||
bool gDisableTrayCounter = false;
|
||||
bool gUseTelegramPanelIcon = false;
|
||||
int gCustomAppIcon = 0;
|
||||
|
@@ -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);
|
||||
|
@@ -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<rpl::event_stream<bool>>(
|
||||
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<ConfirmBox>(
|
||||
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<rpl::event_stream<bool>>(
|
||||
container.get());
|
||||
|
@@ -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, "
|
||||
|
Reference in New Issue
Block a user