add runtime settings for notis

This commit is contained in:
ouwou
2023-04-05 02:32:07 -04:00
parent 02f7bfefe3
commit e9dd1a8ceb
4 changed files with 16 additions and 1 deletions

View File

@@ -87,6 +87,7 @@ bool CheckGuildMessage(const Message &message) {
}
void Notifications::CheckMessage(const Message &message) {
if (!Abaddon::Get().GetSettings().NotificationsEnabled) return;
// ignore if our status is do not disturb
if (IsDND()) return;
auto &discord = Abaddon::Get().GetDiscordClient();

View File

@@ -35,7 +35,9 @@ void Notifier::Notify(const Glib::ustring &id, const Glib::ustring &title, const
g_object_unref(file);
#ifdef ENABLE_NOTIFICATION_SOUNDS
ma_engine_play_sound(&m_engine, Abaddon::Get().GetResPath("/sound/message.mp3").c_str(), nullptr);
if (Abaddon::Get().GetSettings().NotificationsPlaySound) {
ma_engine_play_sound(&m_engine, Abaddon::Get().GetResPath("/sound/message.mp3").c_str(), nullptr);
}
#endif
}

View File

@@ -68,6 +68,8 @@ void SettingsManager::ReadSettings() {
SMSTR("style", "mentionbadgecolor", MentionBadgeColor);
SMSTR("style", "mentionbadgetextcolor", MentionBadgeTextColor);
SMSTR("style", "unreadcolor", UnreadIndicatorColor);
SMBOOL("notifications", "enabled", NotificationsEnabled);
SMBOOL("notifications", "playsound", NotificationsPlaySound);
#ifdef WITH_KEYCHAIN
keychain::Error error {};
@@ -149,6 +151,8 @@ void SettingsManager::Close() {
SMSTR("style", "mentionbadgecolor", MentionBadgeColor);
SMSTR("style", "mentionbadgetextcolor", MentionBadgeTextColor);
SMSTR("style", "unreadcolor", UnreadIndicatorColor);
SMBOOL("notifications", "enabled", NotificationsEnabled);
SMBOOL("notifications", "playsound", NotificationsPlaySound);
#ifdef WITH_KEYCHAIN
keychain::Error error {};

View File

@@ -44,6 +44,14 @@ public:
std::string MentionBadgeColor { "#b82525" };
std::string MentionBadgeTextColor { "#fbfbfb" };
std::string UnreadIndicatorColor { "#ffffff" };
// [notifications]
#ifdef _WIN32
bool NotificationsEnabled { false };
#else
bool NotificationsEnabled { true };
#endif
bool NotificationsPlaySound { true };
};
SettingsManager(const std::string &filename);