From: Alexander Steinhöfer Date: Tue, 12 Apr 2022 13:21:20 +0000 (+0200) Subject: Moved settings. Fixed superflous notifications. X-Git-Tag: 1.9.9.2~2 X-Git-Url: https://repos.lx-s.de/gitweb/?a=commitdiff_plain;h=4e6e13aa07cef165752114c001481b48a9c72708;p=winmute.git Moved settings. Fixed superflous notifications. --- diff --git a/WinMute/MuteControl.cpp b/WinMute/MuteControl.cpp index 489a694..ba55e32 100644 --- a/WinMute/MuteControl.cpp +++ b/WinMute/MuteControl.cpp @@ -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(); + } + } } } diff --git a/WinMute/Settings_GeneralDlg.cpp b/WinMute/Settings_GeneralDlg.cpp index 84c73ec..47477d9 100644 --- a/WinMute/Settings_GeneralDlg.cpp +++ b/WinMute/Settings_GeneralDlg.cpp @@ -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(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); diff --git a/WinMute/Settings_MuteDlg.cpp b/WinMute/Settings_MuteDlg.cpp index 6b3734b..568fcda 100644 --- a/WinMute/Settings_MuteDlg.cpp +++ b/WinMute/Settings_MuteDlg.cpp @@ -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(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(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); diff --git a/WinMute/WinMute.cpp b/WinMute/WinMute.cpp index b440142..874e9be 100644 --- a/WinMute/WinMute.cpp +++ b/WinMute/WinMute.cpp @@ -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); diff --git a/WinMute/WinMute.rc b/WinMute/WinMute.rc index a37aacd..f4ef09c 100644 --- a/WinMute/WinMute.rc +++ b/WinMute/WinMute.rc @@ -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 diff --git a/WinMute/resource.h b/WinMute/resource.h index 637b678..8344d5d 100644 --- a/WinMute/resource.h +++ b/WinMute/resource.h @@ -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