diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index 7340567dd0..44f5acdad5 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -57,6 +57,12 @@ bool ServiceRegistered = false; ServerInformation CurrentServerInformation; std::vector CurrentCapabilities; +[[nodiscard]] const auto &OptionGNotification() { + static const auto &result = base::options::lookup( + Window::Notifications::kOptionGNotification); + return result; +} + [[nodiscard]] bool HasCapability(const char *value) { return ranges::contains(CurrentCapabilities, value); } @@ -137,7 +143,7 @@ bool UseGNotification() { return false; } - if (Window::Notifications::OptionGNotification.value()) { + if (OptionGNotification().value()) { return true; } @@ -207,8 +213,7 @@ bool Enforced() { // Wayland doesn't support positioning // and custom notifications don't work here return IsWayland() - || (Gio::Application::get_default() - && Window::Notifications::OptionGNotification.value()); + || (Gio::Application::get_default() && OptionGNotification().value()); } bool ByDefault() { diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index 19603878dc..1dc2c1ecca 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -70,6 +70,37 @@ constexpr auto kSystemAlertDuration = crl::time(1000); constexpr auto kSystemAlertDuration = crl::time(0); #endif // Q_OS_MAC +base::options::toggle OptionCustomNotification({ + .id = kOptionCustomNotification, + .name = "Force non-native notifications availability", + .description = "Allow to disable native notifications" + " even if custom notifications are broken on this platform", + .scope = [] { + return Platform::Notifications::Enforced(); + }, +}); + +base::options::toggle OptionGNotification({ + .id = kOptionGNotification, + .name = "GNotification", + .description = "Force enable GLib's GNotification." + " When disabled, autodetect is used.", + .scope = [] { +#if __has_include() + using namespace gi::repository; + return bool(Gio::Application::get_default()); +#else // __has_include() + return false; +#endif // __has_include() + }, +}); + +base::options::toggle HideReplyButtonOption({ + .id = kOptionHideReplyButton, + .name = "Hide reply button", + .description = "Hide reply button in notifications.", +}); + [[nodiscard]] QString PlaceholderReactionText() { static const auto result = QString::fromUtf8("\xf0\x9f\x92\xad"); return result; @@ -140,41 +171,9 @@ constexpr auto kSystemAlertDuration = crl::time(0); } // namespace const char kOptionCustomNotification[] = "custom-notification"; - -base::options::toggle OptionCustomNotification({ - .id = kOptionCustomNotification, - .name = "Force non-native notifications availability", - .description = "Allow to disable native notifications" - " even if custom notifications are broken on this platform", - .scope = [] { - return Platform::Notifications::Enforced(); - }, -}); - const char kOptionGNotification[] = "gnotification"; const char kOptionHideReplyButton[] = "hide-reply-button"; -base::options::toggle OptionGNotification({ - .id = kOptionGNotification, - .name = "GNotification", - .description = "Force enable GLib's GNotification." - " When disabled, autodetect is used.", - .scope = [] { -#if __has_include() - using namespace gi::repository; - return bool(Gio::Application::get_default()); -#else // __has_include() - return false; -#endif // __has_include() - }, -}); - -base::options::toggle HideReplyButtonOption({ - .id = kOptionHideReplyButton, - .name = "Hide reply button", - .description = "Hide reply button in notifications.", -}); - struct System::Waiter { NotificationInHistoryKey key; UserData *reactionOrVoteSender = nullptr; diff --git a/Telegram/SourceFiles/window/notifications_manager.h b/Telegram/SourceFiles/window/notifications_manager.h index c36c95d267..a3fa992d95 100644 --- a/Telegram/SourceFiles/window/notifications_manager.h +++ b/Telegram/SourceFiles/window/notifications_manager.h @@ -77,21 +77,10 @@ struct custom_is_fast_copy_type : std::true_t } // namespace base -namespace base::options { - -template -class option; - -using toggle = option; - -} // namespace base::options - namespace Window::Notifications { extern const char kOptionCustomNotification[]; extern const char kOptionGNotification[]; -extern base::options::toggle OptionGNotification; - extern const char kOptionHideReplyButton[]; class Manager;