IRCClient: Add NotifyOnMessage/NotifyOnMention config options
Allow IRCClient user to opt out of notifications.
This commit is contained in:
parent
070a8f2689
commit
63f8cbfb56
Notes:
sideshowbarker
2024-07-19 07:44:49 +09:00
Author: https://github.com/bcoles Commit: https://github.com/SerenityOS/serenity/commit/63f8cbfb564 Pull-request: https://github.com/SerenityOS/serenity/pull/1728
4 changed files with 17 additions and 1 deletions
|
@ -82,6 +82,9 @@ IRCClient::IRCClient()
|
|||
m_show_join_part_messages = m_config->read_bool_entry("Messaging", "ShowJoinPartMessages", 1);
|
||||
m_show_nick_change_messages = m_config->read_bool_entry("Messaging", "ShowNickChangeMessages", 1);
|
||||
|
||||
m_notify_on_message = m_config->read_bool_entry("Notifications", "NotifyOnMessage", 1);
|
||||
m_notify_on_mention = m_config->read_bool_entry("Notifications", "NotifyOnMention", 1);
|
||||
|
||||
m_ctcp_version_reply = m_config->read_entry("CTCP", "VersionReply", "IRC Client [x86] / Serenity OS");
|
||||
m_ctcp_userinfo_reply = m_config->read_entry("CTCP", "UserInfoReply", user_pw->pw_name);
|
||||
m_ctcp_finger_reply = m_config->read_entry("CTCP", "FingerReply", user_pw->pw_name);
|
||||
|
|
|
@ -63,6 +63,9 @@ public:
|
|||
bool show_join_part_messages() const { return m_show_join_part_messages; }
|
||||
bool show_nick_change_messages() const { return m_show_nick_change_messages; }
|
||||
|
||||
bool notify_on_message() const { return m_notify_on_message; }
|
||||
bool notify_on_mention() const { return m_notify_on_mention; }
|
||||
|
||||
void join_channel(const String&);
|
||||
void part_channel(const String&);
|
||||
void change_nick(const String&);
|
||||
|
@ -214,6 +217,9 @@ private:
|
|||
bool m_show_join_part_messages { 1 };
|
||||
bool m_show_nick_change_messages { 1 };
|
||||
|
||||
bool m_notify_on_message { 1 };
|
||||
bool m_notify_on_mention { 1 };
|
||||
|
||||
String m_ctcp_version_reply;
|
||||
String m_ctcp_userinfo_reply;
|
||||
String m_ctcp_finger_reply;
|
||||
|
|
|
@ -194,7 +194,8 @@ void IRCWindow::post_notification_if_needed(const String& name, const String& me
|
|||
auto notification = GUI::Notification::construct();
|
||||
|
||||
if (type() == Type::Channel) {
|
||||
|
||||
if (!m_client.notify_on_mention())
|
||||
return;
|
||||
if (!message.contains(m_client.nickname()))
|
||||
return;
|
||||
|
||||
|
@ -204,6 +205,8 @@ void IRCWindow::post_notification_if_needed(const String& name, const String& me
|
|||
builder.append(m_name);
|
||||
notification->set_title(builder.to_string());
|
||||
} else {
|
||||
if (!m_client.notify_on_message())
|
||||
return;
|
||||
notification->set_title(name);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,3 +14,7 @@ FingerReply=anon
|
|||
[Messaging]
|
||||
ShowJoinPartMessages=1
|
||||
ShowNickChangeMessages=1
|
||||
|
||||
[Notifications]
|
||||
NotifyOnMessage=1
|
||||
NotifyOnMention=1
|
||||
|
|
Loading…
Add table
Reference in a new issue