]> repos.lx-s.de Git - winmute.git/commitdiff
Added option to disable notifications.
authorlx-s <hello@lx-s.de>
Wed, 28 Oct 2020 10:58:49 +0000 (11:58 +0100)
committerlx-s <hello@lx-s.de>
Wed, 28 Oct 2020 10:58:49 +0000 (11:58 +0100)
WinMute/QuietHoursDlg.cpp
WinMute/Settings.cpp
WinMute/Settings.h
WinMute/WinMute.cpp
WinMute/WinMute.h
WinMute/res.rc
WinMute/resource.h

index 7b3bad9de8220f199fe489ab3abe5bce1714cae2..d9a9138870ab2f2029cf781f52d6e85e8bcccb4a 100644 (file)
@@ -56,6 +56,7 @@ static bool SaveQuietHours(
    Settings *settings,
    const int enabled,
    const int forceUnmute,
+   const int showNotifications,
    const LPSYSTEMTIME start,
    const LPSYSTEMTIME end)
 {
@@ -80,6 +81,7 @@ static bool SaveQuietHours(
 
    if (!settings->SetValue(SettingsKey::QUIETHOURS_ENABLE, enabled) ||
        !settings->SetValue(SettingsKey::QUIETHOURS_FORCEUNMUTE, forceUnmute) ||
+       !settings->SetValue(SettingsKey::QUIETHOURS_NOTIFICATIONS, showNotifications) ||
        !settings->SetValue(SettingsKey::QUIETHOURS_START, setStart) ||
        !settings->SetValue(SettingsKey::QUIETHOURS_END, setEnd)) {
       TaskDialog(
@@ -104,6 +106,7 @@ INT_PTR CALLBACK QuietHoursDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP
    case WM_INITDIALOG: {
       HWND hEnable = GetDlgItem(hDlg, IDC_ENABLEQUIETHOURS);
       HWND hForce = GetDlgItem(hDlg, IDC_FORCEUNMUTE);
+      HWND hNotify = GetDlgItem(hDlg, IDC_SHOWNOTIFICATIONS);
       HWND hStart = GetDlgItem(hDlg, IDC_QUIETHOURS_START);
       HWND hEnd = GetDlgItem(hDlg, IDC_QUIETHOURS_END);
       Settings *settings = reinterpret_cast<Settings*>(lParam);
@@ -116,7 +119,11 @@ INT_PTR CALLBACK QuietHoursDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP
       DWORD qhForceUnmute = !!settings->QueryValue(SettingsKey::QUIETHOURS_FORCEUNMUTE, FALSE);
       Button_SetCheck(hForce, qhForceUnmute ? BST_CHECKED : BST_UNCHECKED);
 
+      DWORD qhNotifications = !!settings->QueryValue(SettingsKey::QUIETHOURS_NOTIFICATIONS, FALSE);
+      Button_SetCheck(hNotify, qhNotifications ? BST_CHECKED : BST_UNCHECKED);
+
       EnableWindow(hForce, qhEnabled);
+      EnableWindow(hNotify, qhEnabled);
       EnableWindow(hStart, qhEnabled);
       EnableWindow(hEnd, qhEnabled);
 
@@ -146,6 +153,7 @@ INT_PTR CALLBACK QuietHoursDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP
    case WM_COMMAND: {
       HWND hEnable = GetDlgItem(hDlg, IDC_ENABLEQUIETHOURS);
       HWND hForce = GetDlgItem(hDlg, IDC_FORCEUNMUTE);
+      HWND hNotify = GetDlgItem(hDlg, IDC_SHOWNOTIFICATIONS);
       HWND hStart = GetDlgItem(hDlg, IDC_QUIETHOURS_START);
       HWND hEnd = GetDlgItem(hDlg, IDC_QUIETHOURS_END);
       if (LOWORD(wParam) == IDOK) {
@@ -154,10 +162,11 @@ INT_PTR CALLBACK QuietHoursDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP
          Settings *settings = reinterpret_cast<Settings*>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
          int qhEnabled = Button_GetCheck(hEnable) == BST_CHECKED;
          int qhForceUnmute = Button_GetCheck(hForce) == BST_CHECKED;
+         int qhNotifications = Button_GetCheck(hNotify) == BST_CHECKED;
          DateTime_GetSystemtime(hStart, &start);
          DateTime_GetSystemtime(hEnd, &end);
          settings->SetValue(SettingsKey::QUIETHOURS_ENABLE, qhEnabled);
-         if (SaveQuietHours(settings, qhEnabled, qhForceUnmute, &start, &end)) {
+         if (SaveQuietHours(settings, qhEnabled, qhForceUnmute, qhNotifications, &start, &end)) {
             SendMessage(GetParent(hDlg), WM_WINMUTE_QUIETHOURS_CHANGE, 0, 0);
             EndDialog(hDlg, 0);
          }
index aaf8a1f38104bd5cdb4bde493eeeef0e919e451b..22bda636135ea46c1d269f78e97a3778697a0ee0 100644 (file)
@@ -65,6 +65,9 @@ static LPCWSTR KeyToStr(SettingsKey key)
    case SettingsKey::QUIETHOURS_FORCEUNMUTE:
       keyStr = _T("QuietHoursForceUnmute");
       break;
+   case SettingsKey::QUIETHOURS_NOTIFICATIONS:
+      keyStr = _T("QuietHoursNotifications");
+      break;
    case SettingsKey::QUIETHOURS_START:
       keyStr = _T("QuietHoursStart");
       break;
index 56c213e81b645f9b65015690e3bf78e51c5b6ec3..2a96321a69a675505617d073644ddfd1cedd50f8 100644 (file)
@@ -44,6 +44,7 @@ enum class SettingsKey {
    , MUTE_ON_LOGOUT
    , QUIETHOURS_ENABLE
    , QUIETHOURS_FORCEUNMUTE
+   , QUIETHOURS_NOTIFICATIONS
    , QUIETHOURS_START
    , QUIETHOURS_END
 };
index f0c159d05da9b8b1e18293c4263ac2a508c76681..3f812902bb7bf0627b355763b063d4eca5138ff3 100644 (file)
@@ -71,6 +71,7 @@ WinMute::MuteConfig::MuteConfig()
 
    this->quietHours.enabled = false;
    this->quietHours.forceUnmute = false;
+   this->quietHours.notifications = false;
    this->quietHours.start = 0;
    this->quietHours.end = 0;
 }
@@ -223,6 +224,8 @@ bool WinMute::LoadDefaults()
       settings_.QueryValue(SettingsKey::QUIETHOURS_ENABLE, 0) != 0;
    muteConfig_.quietHours.forceUnmute =
       settings_.QueryValue(SettingsKey::QUIETHOURS_FORCEUNMUTE, 0) != 0;
+   muteConfig_.quietHours.notifications =
+      settings_.QueryValue(SettingsKey::QUIETHOURS_NOTIFICATIONS, 0) != 0;
    muteConfig_.quietHours.start =
       settings_.QueryValue(SettingsKey::QUIETHOURS_START, 0);
    muteConfig_.quietHours.end =
@@ -385,21 +388,27 @@ LRESULT CALLBACK WinMute::WindowProc(
    case WM_WINMUTE_QUIETHOURS_START:
       wsAlreadyMuted_ = audio_->IsMuted();
       audio_->Mute();
-      trayIcon_.ShowPopup(
-         _T("WinMute: Quiet hours started"),
-         _T("Your workstation audio is now muted"));
+      if (muteConfig_.quietHours.notifications) {
+         trayIcon_.ShowPopup(
+            _T("WinMute: Quiet hours started"),
+            _T("Your workstation audio is now muted"));
+      }
       return 0;
    case WM_WINMUTE_QUIETHOURS_END:
       if (wsAlreadyMuted_ && muteConfig_.quietHours.forceUnmute ||
           !wsAlreadyMuted_) {
          audio_->UnMute();
-         trayIcon_.ShowPopup(
-            _T("WinMute: Quiet Hours ended"),
-            _T("Your workstation audio has been restored."));
+         if (muteConfig_.quietHours.notifications) {
+            trayIcon_.ShowPopup(
+               _T("WinMute: Quiet Hours ended"),
+               _T("Your workstation audio has been restored."));
+         }
       } else {
-         trayIcon_.ShowPopup(
-            _T("WinMute: Quiet Hours ended"),
-            _T("Quiet hours ended, your workstation remains muted."));
+         if (muteConfig_.quietHours.notifications) {
+            trayIcon_.ShowPopup(
+               _T("WinMute: Quiet Hours ended"),
+               _T("Quiet hours ended, your workstation remains muted."));
+         }
       }
       return 0;
    case WM_WINMUTE_MUTE: {
@@ -415,6 +424,12 @@ LRESULT CALLBACK WinMute::WindowProc(
       muteConfig_.quietHours.enabled = settings_.QueryValue(
          SettingsKey::QUIETHOURS_ENABLE,
          0);
+      muteConfig_.quietHours.forceUnmute = settings_.QueryValue(
+         SettingsKey::QUIETHOURS_FORCEUNMUTE,
+         0);
+      muteConfig_.quietHours.notifications = settings_.QueryValue(
+         SettingsKey::QUIETHOURS_NOTIFICATIONS,
+         0);
       CheckMenuItem(
          hTrayMenu_,
          ID_TRAYMENU_CONFIGUREQUIETHOURS,
index e53d5a87e24105d73c6f64dcaf0b012ddfa817e3..e95ca37cddc81d7e03d013c184d62654e436176f 100644 (file)
@@ -75,6 +75,7 @@ private:
       struct {
          bool enabled;
          bool forceUnmute;
+         bool notifications;
          time_t start;
          time_t end;
       } quietHours;
index 6484b8198b8786b637c1a0cf80473b08fb37d193..ea20a9ff5e300bd3239150174fa4021e53c3d79e 100644 (file)
@@ -96,7 +96,7 @@ BEGIN
                     "SysLink",WS_TABSTOP,119,35,36,13
 END
 
-IDD_QUIETHOURS DIALOGEX 0, 0, 201, 190
+IDD_QUIETHOURS DIALOGEX 0, 0, 201, 205
 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Configure Quiet Hours"
 FONT 8, "MS Shell Dlg", 400, 0, 0x1
@@ -105,12 +105,13 @@ BEGIN
     CONTROL         "",IDC_QUIETHOURS_START,"SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | WS_TABSTOP | 0x8,79,58,54,15
     CONTROL         "",IDC_QUIETHOURS_END,"SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | WS_TABSTOP | 0x8,79,80,54,15
     CONTROL         "Force unmute",IDC_FORCEUNMUTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,31,102,60,10
-    DEFPUSHBUTTON   "Save",IDOK,63,165,50,14
-    PUSHBUTTON      "Cancel",IDCANCEL,123,165,50,14
+    DEFPUSHBUTTON   "Save",IDOK,63,174,50,14
+    PUSHBUTTON      "Cancel",IDCANCEL,123,174,50,14
     LTEXT           "If force unmute is enabled, WinMute will unmute your workstation when quiet hours end and not take into account if your workstation was already muted before quiet hours started.",IDC_STATIC,32,115,162,38
     LTEXT           "Start time:",IDC_STATIC,31,60,42,12
     LTEXT           "End time:",IDC_STATIC,31,82,43,12
     LTEXT           "During Quiet Hours WinMute automatically mutes your PC volumes and unmutes it afterwards.",IDC_STATIC,14,15,180,24
+    CONTROL         "Show notifications",IDC_SHOWNOTIFICATIONS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,32,153,74,10
 END
 
 
@@ -136,7 +137,7 @@ BEGIN
         LEFTMARGIN, 7
         RIGHTMARGIN, 194
         TOPMARGIN, 7
-        BOTTOMMARGIN, 183
+        BOTTOMMARGIN, 198
     END
 END
 #endif    // APSTUDIO_INVOKED
index cd00b1fee7a7f4ec80adefdf85898071cb46f873..c8aaadee463bc5cdbced4a41edd863816a611394 100644 (file)
@@ -15,6 +15,8 @@
 #define IDC_ENABLEQUIETHOURS            1003
 #define IDC_QUIETHOURS_END              1004
 #define IDC_FORCEUNMUTE                 1005
+#define IDC_FORCEUNMUTE2                1006
+#define IDC_SHOWNOTIFICATIONS           1006
 #define ID_TRAYMENU_INFO                40001
 #define ID_TRAYMENU_EXIT                40002
 #define ID_TRAYMENU_MUTEONLOCK          40003