]> repos.lx-s.de Git - winmute.git/commitdiff
Moved settings. Fixed superflous notifications.
authorAlexander Steinhöfer <kontakt@lx-s.de>
Tue, 12 Apr 2022 13:21:20 +0000 (15:21 +0200)
committerAlexander Steinhöfer <kontakt@lx-s.de>
Tue, 12 Apr 2022 13:21:20 +0000 (15:21 +0200)
WinMute/MuteControl.cpp
WinMute/Settings_GeneralDlg.cpp
WinMute/Settings_MuteDlg.cpp
WinMute/WinMute.cpp
WinMute/WinMute.rc
WinMute/resource.h

index 489a69458d9427383d24d8f43819abcff435196c..ba55e3246a6571db7614a710ff9dbe151057e874 100644 (file)
@@ -226,8 +226,12 @@ void MuteControl::NotifyRestoreCondition(int type, bool active)
          winAudio_->SetMute(true);
       }
    } else {
-      muteConfig_[type].active = active;
-      RestoreVolume();
+      if (muteConfig_[type].active) {
+         muteConfig_[type].active = false;
+         if (muteConfig_[type].shouldMute) {
+            RestoreVolume();
+         }
+      }
    }
 }
 
index 84c73ecda2e84aec31767b26e49878a6926c445a..47477d9e8ecfb1b5ecc9f14067ccc52d62da02db 100644 (file)
@@ -38,7 +38,6 @@ INT_PTR CALLBACK Settings_GeneralDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPA
    switch (msg) {
    case WM_INITDIALOG: {
       HWND hAutostart = GetDlgItem(hDlg, IDC_RUNONSTARTUP);
-      HWND hNotify = GetDlgItem(hDlg, IDC_SHOWNOTIFICATIONS);
       HWND hLogging = GetDlgItem(hDlg, IDC_ENABLELOGGING);
       HWND hOpenLog = GetDlgItem(hDlg, IDC_OPENLOG);
 
@@ -53,9 +52,6 @@ INT_PTR CALLBACK Settings_GeneralDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPA
       DWORD enabled = settings->IsAutostartEnabled();
       Button_SetCheck(hAutostart, enabled ? BST_CHECKED : BST_UNCHECKED);
 
-      enabled = !!settings->QueryValue(SettingsKey::NOTIFICATIONS_ENABLED);
-      Button_SetCheck(hNotify, enabled ? BST_CHECKED : BST_UNCHECKED);
-
       enabled = !!settings->QueryValue(SettingsKey::LOGGING_ENABLED);
       Button_SetCheck(hLogging, enabled ? BST_CHECKED : BST_UNCHECKED);
       Button_Enable(hOpenLog, enabled);
@@ -77,12 +73,8 @@ INT_PTR CALLBACK Settings_GeneralDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPA
       WMSettings* settings = reinterpret_cast<WMSettings*>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
 
       HWND hAutostart = GetDlgItem(hDlg, IDC_RUNONSTARTUP);
-      HWND hNotify = GetDlgItem(hDlg, IDC_SHOWNOTIFICATIONS);
       HWND hLogging = GetDlgItem(hDlg, IDC_ENABLELOGGING);
 
-      int showNotifications = Button_GetCheck(hNotify) == BST_CHECKED;
-      settings->SetValue(SettingsKey::NOTIFICATIONS_ENABLED, showNotifications);
-
       int enableLog = Button_GetCheck(hLogging) == BST_CHECKED;
       settings->SetValue(SettingsKey::LOGGING_ENABLED, enableLog);
       WMLog::GetInstance().SetEnabled(enableLog);
index 6b3734b6de1056dfe5c0327682b41f4257a6e5b4..568fcdaa753264284c592ebb2af1309386187f98 100644 (file)
@@ -56,6 +56,8 @@ INT_PTR CALLBACK Settings_MuteDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
          EnableThemeDialogTexture(hDlg, ETDT_ENABLETAB);
       }
 
+      HWND hNotify = GetDlgItem(hDlg, IDC_SHOWNOTIFICATIONS);
+
       HWND hMuteOnLock = GetDlgItem(hDlg, IDC_MUTE_WHEN_WS_LOCKED);
       HWND hMuteOnScreensaver = GetDlgItem(hDlg, IDC_MUTE_WHEN_SCREENSAVER_STARTS);
       HWND hMuteOnScreenOff = GetDlgItem(hDlg, IDC_MUTE_WHEN_SCREEN_OFF);
@@ -70,6 +72,9 @@ INT_PTR CALLBACK Settings_MuteDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
       assert(settings != NULL);
       SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(settings));
 
+      // General
+      SetCheckButton(hNotify, *settings, SettingsKey::NOTIFICATIONS_ENABLED);
+
       // With restore
       SetCheckButton(hMuteOnLock, *settings, SettingsKey::MUTE_ON_LOCK);
       SetCheckButton(hMuteOnScreensaver, *settings, SettingsKey::MUTE_ON_SCREENSAVER);
@@ -88,6 +93,8 @@ INT_PTR CALLBACK Settings_MuteDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
    {
       WMSettings* settings = reinterpret_cast<WMSettings*>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
 
+      HWND hNotify = GetDlgItem(hDlg, IDC_SHOWNOTIFICATIONS);
+
       HWND hMuteOnLock = GetDlgItem(hDlg, IDC_MUTE_WHEN_WS_LOCKED);
       HWND hMuteOnScreensaver = GetDlgItem(hDlg, IDC_MUTE_WHEN_SCREENSAVER_STARTS);
       HWND hMuteOnScreenOff = GetDlgItem(hDlg, IDC_MUTE_WHEN_SCREEN_OFF);
@@ -98,6 +105,9 @@ INT_PTR CALLBACK Settings_MuteDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
       HWND hMuteOnSleep = GetDlgItem(hDlg, IDC_MUTE_WHEN_SLEEP);
       HWND hMuteOnLogout = GetDlgItem(hDlg, IDC_MUTE_WHEN_LOGOUT);
 
+      // General
+      SetOption(hNotify, *settings, SettingsKey::NOTIFICATIONS_ENABLED);
+
       // With restore
       SetOption(hMuteOnLock, *settings, SettingsKey::MUTE_ON_LOCK);
       SetOption(hMuteOnScreensaver, *settings, SettingsKey::MUTE_ON_SCREENSAVER);
index b44014230f74ab6baa6a886a626303e923b36f24..874e9be8acff8bacdc8cc179c845f5d4fa757011 100644 (file)
@@ -310,20 +310,20 @@ bool WinMute::Init()
 
 bool WinMute::LoadSettings()
 {
-   muteCtrl_.SetRestoreVolume(!!settings_.QueryValue(SettingsKey::RESTORE_AUDIO));
-   muteCtrl_.SetMuteOnWorkstationLock(!!settings_.QueryValue(SettingsKey::MUTE_ON_LOCK));
-   muteCtrl_.SetMuteOnScreensaverActivation(!!settings_.QueryValue(SettingsKey::MUTE_ON_SCREENSAVER));
-   muteCtrl_.SetMuteOnDisplayStandby(!!settings_.QueryValue(SettingsKey::MUTE_ON_DISPLAYSTANDBY));
-   muteCtrl_.SetMuteOnLogout(!!settings_.QueryValue(SettingsKey::MUTE_ON_LOGOUT));
-   muteCtrl_.SetMuteOnSuspend(!!settings_.QueryValue(SettingsKey::MUTE_ON_SUSPEND));
-   muteCtrl_.SetMuteOnShutdown(!!settings_.QueryValue(SettingsKey::MUTE_ON_SHUTDOWN));
-
-   muteCtrl_.SetNotifications(!!settings_.QueryValue(SettingsKey::NOTIFICATIONS_ENABLED));
-
-   muteConfig_.showNotifications = !!settings_.QueryValue(SettingsKey::NOTIFICATIONS_ENABLED);
-   muteConfig_.quietHours.enabled = !!settings_.QueryValue(SettingsKey::QUIETHOURS_ENABLE);
-   muteConfig_.quietHours.forceUnmute = !!settings_.QueryValue(SettingsKey::QUIETHOURS_FORCEUNMUTE);
-   muteConfig_.quietHours.notifications = !!settings_.QueryValue(SettingsKey::QUIETHOURS_NOTIFICATIONS);
+   muteCtrl_.SetRestoreVolume(settings_.QueryValue(SettingsKey::RESTORE_AUDIO));
+   muteCtrl_.SetMuteOnWorkstationLock(settings_.QueryValue(SettingsKey::MUTE_ON_LOCK));
+   muteCtrl_.SetMuteOnScreensaverActivation(settings_.QueryValue(SettingsKey::MUTE_ON_SCREENSAVER));
+   muteCtrl_.SetMuteOnDisplayStandby(settings_.QueryValue(SettingsKey::MUTE_ON_DISPLAYSTANDBY));
+   muteCtrl_.SetMuteOnLogout(settings_.QueryValue(SettingsKey::MUTE_ON_LOGOUT));
+   muteCtrl_.SetMuteOnSuspend(settings_.QueryValue(SettingsKey::MUTE_ON_SUSPEND));
+   muteCtrl_.SetMuteOnShutdown(settings_.QueryValue(SettingsKey::MUTE_ON_SHUTDOWN));
+
+   muteCtrl_.SetNotifications(settings_.QueryValue(SettingsKey::NOTIFICATIONS_ENABLED));
+
+   muteConfig_.showNotifications = settings_.QueryValue(SettingsKey::NOTIFICATIONS_ENABLED);
+   muteConfig_.quietHours.enabled = settings_.QueryValue(SettingsKey::QUIETHOURS_ENABLE);
+   muteConfig_.quietHours.forceUnmute = settings_.QueryValue(SettingsKey::QUIETHOURS_FORCEUNMUTE);
+   muteConfig_.quietHours.notifications = settings_.QueryValue(SettingsKey::QUIETHOURS_NOTIFICATIONS);
    muteConfig_.quietHours.start = settings_.QueryValue(SettingsKey::QUIETHOURS_START);
    muteConfig_.quietHours.end = settings_.QueryValue(SettingsKey::QUIETHOURS_END);
 
index a37aacdf8df2100f12dbcfd23517f63d5642637d..f4ef09cc3bf1ccb57c5786a56893630b2b09c38c 100644 (file)
@@ -76,11 +76,9 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
 FONT 8, "MS Shell Dlg", 400, 0, 0x1
 BEGIN
     CONTROL         "Start WinMute on system startup",IDC_RUNONSTARTUP,
-                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,3,219,26
-    CONTROL         "Enable Logging",IDC_ENABLELOGGING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,48,219,21
-    CONTROL         "Show mute event notifications",IDC_SHOWNOTIFICATIONS,
-                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,27,219,21
-    PUSHBUTTON      "Open Log File...",IDC_OPENLOG,22,69,58,15
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,9,219,17
+    CONTROL         "Enable logging",IDC_ENABLELOGGING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,31,219,15
+    PUSHBUTTON      "Open log file...",IDC_OPENLOG,22,50,58,15
 END
 
 IDD_SETTINGS_QUIETHOURS DIALOGEX 0, 0, 246, 198
@@ -92,7 +90,8 @@ BEGIN
     CONTROL         "",IDC_QUIETHOURS_START,"SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | WS_TABSTOP | 0x8,73,47,65,18
     CONTROL         "",IDC_QUIETHOURS_END,"SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | WS_TABSTOP | 0x8,72,71,67,19
     CONTROL         "Force unmute",IDC_FORCEUNMUTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,94,86,16
-    CONTROL         "Show notifications",IDC_SHOWNOTIFICATIONS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,146,81,21
+    CONTROL         "Show quiet hours notifications",IDC_SHOWNOTIFICATIONS,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,146,180,21
     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,33,111,204,37
     LTEXT           "Start time:",IDC_STATIC,23,50,43,13
     LTEXT           "End time:",IDC_STATIC,24,73,32,16
@@ -122,23 +121,25 @@ IDD_SETTINGS_MUTE DIALOGEX 0, 0, 242, 205
 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
 FONT 8, "MS Shell Dlg", 400, 0, 0x1
 BEGIN
-    GROUPBOX        "Mute with volume restore, when...",IDC_STATIC,7,33,228,75
+    GROUPBOX        "Mute with volume restore, when...",IDC_STATIC,7,42,228,75
     CONTROL         "... the workstation is locked.",IDC_MUTE_WHEN_WS_LOCKED,
-                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,48,107,10
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,57,107,10
     CONTROL         "... the screensaver starts.",IDC_MUTE_WHEN_SCREENSAVER_STARTS,
-                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,62,101,10
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,71,101,10
     CONTROL         "... the screen turns off.",IDC_MUTE_WHEN_SCREEN_OFF,
-                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,76,93,10
-    CONTROL         "Restore volume afterwards.",IDC_RESTOREVOLUME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,92,106,10
-    GROUPBOX        "Mute without volume restore, when...",IDC_STATIC,7,112,228,73
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,85,93,10
+    CONTROL         "Restore volume afterwards.",IDC_RESTOREVOLUME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,101,106,10
+    GROUPBOX        "Mute without volume restore, when...",IDC_STATIC,7,121,228,73
     CONTROL         "... the computer shuts down.",IDC_MUTE_WHEN_SHUTDOWN,
-                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,126,110,10
-    CONTROL         "... you log out.",IDC_MUTE_WHEN_LOGOUT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,154,65,10
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,135,110,10
+    CONTROL         "... you log out.",IDC_MUTE_WHEN_LOGOUT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,163,65,10
     CONTROL         "... the computer goes into sleep/hibernate.",IDC_MUTE_WHEN_SLEEP,
-                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,140,155,10
-    LTEXT           "Here you can configure the various mute conditions and variations that WinMute supports.",IDC_STATIC,7,8,228,17
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,149,155,10
     CONTROL         "... when WinMute is started within a RDP session.",IDC_MUTE_WHEN_RDP_SESSION,
-                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,167,175,10
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,177,175,10
+    GROUPBOX        "General",IDC_STATIC,7,7,228,31
+    CONTROL         "Show mute event notifications",IDC_SHOWNOTIFICATIONS,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,17,219,18
 END
 
 
index 637b6784fa88d94e713b99807256a46170ab52da..8344d5df146d497085342130991d8c810abde1d1 100644 (file)
@@ -78,9 +78,9 @@
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        125
+#define _APS_NEXT_RESOURCE_VALUE        127
 #define _APS_NEXT_COMMAND_VALUE         40029
-#define _APS_NEXT_CONTROL_VALUE         1022
+#define _APS_NEXT_CONTROL_VALUE         1023
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif