diff --git a/src/discord/LocalSettings.cpp b/src/discord/LocalSettings.cpp index 9abae70..c7d81b5 100644 --- a/src/discord/LocalSettings.cpp +++ b/src/discord/LocalSettings.cpp @@ -101,6 +101,12 @@ bool LocalSettings::Load() if (j.contains("ShowEmbedContent")) m_bShowEmbedContent = j["ShowEmbedContent"]; + if (j.contains("EnableNotifications")) + m_bEnableNotifications = j["EnableNotifications"]; + + if (j.contains("FlashOnNotification")) + m_bFlashOnNotification = j["FlashOnNotification"]; + if (m_bSaveWindowSize) { if (j.contains("WindowWidth")) @@ -160,6 +166,8 @@ bool LocalSettings::Save() j["ShowAttachmentImages"] = m_bShowAttachmentImages; j["ShowEmbedImages"] = m_bShowEmbedImages; j["ShowEmbedContent"] = m_bShowEmbedContent; + j["EnableNotifications"] = m_bEnableNotifications; + j["FlashOnNotification"] = m_bFlashOnNotification; if (m_bSaveWindowSize) { j["WindowWidth"] = m_width; diff --git a/src/discord/LocalSettings.hpp b/src/discord/LocalSettings.hpp index ad57273..d94e0ca 100644 --- a/src/discord/LocalSettings.hpp +++ b/src/discord/LocalSettings.hpp @@ -169,6 +169,18 @@ class LocalSettings void SetShowEmbedContent(bool b) { m_bShowEmbedContent = b; } + bool EnableNotifications() const { + return m_bEnableNotifications; + } + bool FlashOnNotification() const { + return m_bFlashOnNotification; + } + void SetEnableNotifications(bool b) { + m_bEnableNotifications = b; + } + void SetFlashOnNotification(bool b) { + m_bFlashOnNotification = b; + } private: std::string m_token; @@ -192,6 +204,8 @@ class LocalSettings bool m_bShowAttachmentImages = true; bool m_bShowEmbedImages = true; bool m_bShowEmbedContent = true; + bool m_bEnableNotifications = true; + bool m_bFlashOnNotification = true; time_t m_remindUpdatesOn = 0; int m_width = 1000; int m_height = 700; diff --git a/src/resource.rc b/src/resource.rc index b0668f6..a09b95e 100644 --- a/src/resource.rc +++ b/src/resource.rc @@ -649,13 +649,13 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x0 BEGIN GROUPBOX "Balloon Notifications",IDC_STATIC,6,7,248,65 CONTROL "Enable balloon notifications",IDC_ENABLE_BALLOON_NOTIFS, - "Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,12,18,103,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,18,235,10 CONTROL "Flash the window on the taskbar if a notification is received",IDC_FLASH_TASKBAR, - "Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,12,31,205,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,31,235,10 CONTROL "Play Discord notification sound when a notification is received",IDC_USE_DISCORD_SOUND, - "Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,12,57,212,10 + "Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,12,57,235,10 CONTROL "Don't play sound when a notification is received",IDC_MUTE_NOTIFICATIONS, - "Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,12,44,242,10 + "Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,12,44,235,10 END IDD_DIALOG_CHATSETTINGS DIALOGEX 0, 0, 260, 242 @@ -823,6 +823,7 @@ BEGIN LEFTMARGIN, 6 RIGHTMARGIN, 254 VERTGUIDE, 12 + VERTGUIDE, 247 TOPMARGIN, 7 BOTTOMMARGIN, 234 END diff --git a/src/windows/OptionsDialog.cpp b/src/windows/OptionsDialog.cpp index 5addf81..573a0e7 100644 --- a/src/windows/OptionsDialog.cpp +++ b/src/windows/OptionsDialog.cpp @@ -1,5 +1,6 @@ #include "Config.hpp" #include "OptionsDialog.hpp" +#include "ShellNotification.hpp" #include "../discord/LocalSettings.hpp" #ifdef NEW_WINDOWS @@ -226,6 +227,12 @@ void WINAPI OnChildDialogInit(HWND hwndDlg) break; } + case PG_NOTIFICATIONS: + { + CheckDlgButton(hwndDlg, IDC_ENABLE_BALLOON_NOTIFS, GetLocalSettings()->EnableNotifications() ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_FLASH_TASKBAR, GetLocalSettings()->FlashOnNotification() ? BST_CHECKED : BST_UNCHECKED); + break; + } case PG_CHAT: { CheckDlgButton(hwndDlg, IDC_IMAGES_WHEN_UPLOADED, GetLocalSettings()->ShowAttachmentImages() ? BST_CHECKED : BST_UNCHECKED); @@ -438,6 +445,19 @@ INT_PTR CALLBACK ChildDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa } break; } + case PG_NOTIFICATIONS: + { + switch (LOWORD(wParam)) + { + case IDC_ENABLE_BALLOON_NOTIFS: + GetLocalSettings()->SetEnableNotifications(IsDlgButtonChecked(hWnd, IDC_ENABLE_BALLOON_NOTIFS)); + break; + case IDC_FLASH_TASKBAR: + GetLocalSettings()->SetFlashOnNotification(IsDlgButtonChecked(hWnd, IDC_FLASH_TASKBAR)); + break; + } + break; + } case PG_CHAT: { switch (LOWORD(wParam)) diff --git a/src/windows/ShellNotification.cpp b/src/windows/ShellNotification.cpp index 332676a..f1a7a3a 100644 --- a/src/windows/ShellNotification.cpp +++ b/src/windows/ShellNotification.cpp @@ -1,5 +1,6 @@ #include "ShellNotification.hpp" #include "Main.hpp" +#include "../discord/LocalSettings.hpp" constexpr int NOTIFICATION_ID = 1000; @@ -51,6 +52,9 @@ void ShellNotification::Deinitialize() void ShellNotification::ShowBalloon(const std::string& titleString, const std::string& contents) { + if (!GetLocalSettings()->EnableNotifications()) + return; + // If user is in 'Do Not Disturb' mode, no taskbar notification should be fired. // However, other methods of checking notifications will still work, such as the menu. Profile* pf = GetDiscordInstance()->GetProfile(); @@ -60,6 +64,11 @@ void ShellNotification::ShowBalloon(const std::string& titleString, const std::s return; } + if (GetLocalSettings()->FlashOnNotification() && IsIconic(g_Hwnd)) + { + FlashWindow(g_Hwnd, FALSE); + } + NOTIFYICONDATA d; ZeroMemory(&d, sizeof d); d.cbSize = NOTIFYICONDATA_V2_SIZE;