Преглед на файлове

IRCClient: Add NotifyOnMessage/NotifyOnMention config options

Allow IRCClient user to opt out of notifications.
Brendan Coles преди 5 години
родител
ревизия
63f8cbfb56
променени са 4 файла, в които са добавени 17 реда и са изтрити 1 реда
  1. 3 0
      Applications/IRCClient/IRCClient.cpp
  2. 6 0
      Applications/IRCClient/IRCClient.h
  3. 4 1
      Applications/IRCClient/IRCWindow.cpp
  4. 4 0
      Base/home/anon/IRCClient.ini

+ 3 - 0
Applications/IRCClient/IRCClient.cpp

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

+ 6 - 0
Applications/IRCClient/IRCClient.h

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

+ 4 - 1
Applications/IRCClient/IRCWindow.cpp

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

+ 4 - 0
Base/home/anon/IRCClient.ini

@@ -14,3 +14,7 @@ FingerReply=anon
 [Messaging]
 ShowJoinPartMessages=1
 ShowNickChangeMessages=1
+
+[Notifications]
+NotifyOnMessage=1
+NotifyOnMention=1