Merge pull request #130 from ilya-fedin/gtk-integration-option

This commit is contained in:
Eric Kotato 2020-12-25 23:25:07 +03:00 committed by GitHub
commit 1a201087b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 93 additions and 65 deletions

View file

@ -520,7 +520,6 @@ jobs:
-qt-libpng \
-qt-harfbuzz \
-qt-pcre \
-no-gtk \
-no-feature-xcb-sm \
-no-feature-wayland-server \
-openssl-linked \

View file

@ -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";

View file

@ -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",

View file

@ -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 бота",

View file

@ -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<float64> _dialogsWidthRatio; // per-window
rpl::variable<int> _thirdColumnWidth = kDefaultThirdColumnWidth; // p-w
bool _notifyFromAll = true;
rpl::variable<bool> _nativeWindowFrame = false;
rpl::variable<bool> _nativeWindowFrame = Platform::IsLinux();
rpl::variable<std::optional<bool>> _systemDarkMode = std::nullopt;
rpl::variable<bool> _systemDarkModeEnabled = false;
rpl::variable<Window::ControlsLayout> _windowControlsLayout;

View file

@ -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);
});

View file

@ -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<int> RecentStickersLimitChanges() {
int gUserpicCornersType = 3;
bool gShowTopBarUserpic = false;
bool gDisableTrayCounter = false;
bool gGtkIntegration = false;
bool gDisableTrayCounter = Platform::IsLinux();
bool gUseTelegramPanelIcon = false;
int gCustomAppIcon = 0;

View file

@ -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);

View file

@ -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<rpl::event_stream<bool>>(
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<ConfirmBox>(
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<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 (Platform::IsMac()) {
const auto useNativeDecorationsToggled = Ui::CreateChild<rpl::event_stream<bool>>(
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<ConfirmBox>(
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<int, QString> trayIconOptions = {
{ 0, TrayIconLabel(0) },

View file

@ -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, "