mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-06 03:42:56 +00:00
Check GNotification option via base::options::lookup
This commit is contained in:
@@ -57,6 +57,12 @@ bool ServiceRegistered = false;
|
||||
ServerInformation CurrentServerInformation;
|
||||
std::vector<std::string> CurrentCapabilities;
|
||||
|
||||
[[nodiscard]] const auto &OptionGNotification() {
|
||||
static const auto &result = base::options::lookup<bool>(
|
||||
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() {
|
||||
|
||||
@@ -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(<gio/gio.hpp>)
|
||||
using namespace gi::repository;
|
||||
return bool(Gio::Application::get_default());
|
||||
#else // __has_include(<gio/gio.hpp>)
|
||||
return false;
|
||||
#endif // __has_include(<gio/gio.hpp>)
|
||||
},
|
||||
});
|
||||
|
||||
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(<gio/gio.hpp>)
|
||||
using namespace gi::repository;
|
||||
return bool(Gio::Application::get_default());
|
||||
#else // __has_include(<gio/gio.hpp>)
|
||||
return false;
|
||||
#endif // __has_include(<gio/gio.hpp>)
|
||||
},
|
||||
});
|
||||
|
||||
base::options::toggle HideReplyButtonOption({
|
||||
.id = kOptionHideReplyButton,
|
||||
.name = "Hide reply button",
|
||||
.description = "Hide reply button in notifications.",
|
||||
});
|
||||
|
||||
struct System::Waiter {
|
||||
NotificationInHistoryKey key;
|
||||
UserData *reactionOrVoteSender = nullptr;
|
||||
|
||||
@@ -77,21 +77,10 @@ struct custom_is_fast_copy_type<Window::Notifications::ChangeType> : std::true_t
|
||||
|
||||
} // namespace base
|
||||
|
||||
namespace base::options {
|
||||
|
||||
template <typename Type>
|
||||
class option;
|
||||
|
||||
using toggle = option<bool>;
|
||||
|
||||
} // 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;
|
||||
|
||||
Reference in New Issue
Block a user