MuteTypeCount // Meta
};
-MuteControl::MuteControl()
- : trayIcon_(nullptr), notificationsEnabled_(false), displayWasOffOnce_(false)
+MuteControl::MuteControl() :
+ restoreVolume_(false),
+ notificationsEnabled_(false),
+ displayWasOffOnce_(false),
+ trayIcon_(nullptr)
{
MuteConfig initMuteConf;
initMuteConf.active = false;
enum SettingsTabsIDs {
SETTINGS_TAB_GENERAL = 0,
+ SETTINGS_TAB_MUTE,
SETTINGS_TAB_QUIETHOURS,
SETTINGS_TAB_COUNT
};
extern INT_PTR CALLBACK Settings_QuietHoursDlgProc(HWND, UINT, WPARAM, LPARAM);
extern INT_PTR CALLBACK Settings_GeneralDlgProc(HWND, UINT, WPARAM, LPARAM);
+extern INT_PTR CALLBACK Settings_MuteDlgProc(HWND, UINT, WPARAM, LPARAM);
static void InsertTabItem(HWND hTabCtrl, UINT id, const TCHAR* itemName)
{
dlgData->hTabCtrl = GetDlgItem(hDlg, IDC_SETTINGS_TAB);
InsertTabItem(dlgData->hTabCtrl, SETTINGS_TAB_GENERAL, _T("General"));
+ InsertTabItem(dlgData->hTabCtrl, SETTINGS_TAB_MUTE, _T("Mute"));
InsertTabItem(dlgData->hTabCtrl, SETTINGS_TAB_QUIETHOURS, _T("Quiet Hours"));
dlgData->hTabs[SETTINGS_TAB_GENERAL] = CreateDialogParam(
dlgData->hTabCtrl,
Settings_GeneralDlgProc,
reinterpret_cast<LPARAM>(settings));
+ dlgData->hTabs[SETTINGS_TAB_MUTE] = CreateDialogParam(
+ nullptr,
+ MAKEINTRESOURCE(IDD_SETTINGS_MUTE),
+ dlgData->hTabCtrl,
+ Settings_MuteDlgProc,
+ reinterpret_cast<LPARAM>(settings));
dlgData->hTabs[SETTINGS_TAB_QUIETHOURS] = CreateDialogParam(
nullptr,
MAKEINTRESOURCE(IDD_SETTINGS_QUIETHOURS),
if (LOWORD(wParam) == IDOK) {
for (int i = 0; i < SETTINGS_TAB_COUNT; ++i) {
SendMessage(dlgData->hTabs[i], WM_SAVESETTINGS, 0, 0);
+ EndDialog(dlgData->hTabs[i], 0);
}
EndDialog(hDlg, 0);
} else if (LOWORD(wParam) == IDCANCEL) {
- EndDialog(hDlg, 0);
+ for (int i = 0; i < SETTINGS_TAB_COUNT; ++i) {
+ EndDialog(dlgData->hTabs[i], 0);
+ }
+ EndDialog(hDlg, 1);
}
return 0;
case WM_NOTIFY: {
return 0;
}
case WM_CLOSE:
- EndDialog(hDlg, 0);
+ EndDialog(hDlg, 1);
return TRUE;
case WM_DESTROY:
delete dlgData;
DWORD enabled = settings->IsAutostartEnabled();
Button_SetCheck(hAutostart, enabled ? BST_CHECKED : BST_UNCHECKED);
- enabled = !!settings->QueryValue(SettingsKey::NOTIFICATIONS_ENABLED, FALSE);
+ enabled = !!settings->QueryValue(SettingsKey::NOTIFICATIONS_ENABLED);
Button_SetCheck(hNotify, enabled ? BST_CHECKED : BST_UNCHECKED);
- enabled = !!settings->QueryValue(SettingsKey::LOGGING_ENABLED, FALSE);
+ enabled = !!settings->QueryValue(SettingsKey::LOGGING_ENABLED);
Button_SetCheck(hLogging, enabled ? BST_CHECKED : BST_UNCHECKED);
Button_Enable(hOpenLog, enabled);
--- /dev/null
+/*
+ WinMute
+ Copyright (c) 2022, Alexander Steinhoefer
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of the author nor the names of its contributors may
+ be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+#include "common.h"
+
+static void SetCheckButton(HWND hBtn, const WMSettings& settings, SettingsKey key)
+{
+ DWORD enabled = !!settings.QueryValue(key);
+ Button_SetCheck(hBtn, enabled ? BST_CHECKED : BST_UNCHECKED);
+}
+
+static void SetOption(HWND hBtn, WMSettings& settings, SettingsKey key)
+{
+ int enable = Button_GetCheck(hBtn) == BST_CHECKED;
+ settings.SetValue(key, enable);
+}
+
+INT_PTR CALLBACK Settings_MuteDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(wParam);
+
+ switch (msg) {
+ case WM_INITDIALOG:
+ {
+ if (IsAppThemed()) {
+ EnableThemeDialogTexture(hDlg, ETDT_ENABLETAB);
+ }
+
+ 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);
+ HWND hMuteOnRDP = GetDlgItem(hDlg, IDC_MUTE_WHEN_RDP_SESSION);
+ HWND hRestoreVolume = GetDlgItem(hDlg, IDC_RESTOREVOLUME);
+
+ HWND hMuteOnShutdown = GetDlgItem(hDlg, IDC_MUTE_WHEN_SHUTDOWN);
+ HWND hMuteOnSleep = GetDlgItem(hDlg, IDC_MUTE_WHEN_SLEEP);
+ HWND hMuteOnLogout = GetDlgItem(hDlg, IDC_MUTE_WHEN_LOGOUT);
+
+ WMSettings* settings = reinterpret_cast<WMSettings*>(lParam);
+ assert(settings != NULL);
+ SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(settings));
+
+ // With restore
+ SetCheckButton(hMuteOnLock, *settings, SettingsKey::MUTE_ON_LOCK);
+ SetCheckButton(hMuteOnScreensaver, *settings, SettingsKey::MUTE_ON_SCREENSAVER);
+ SetCheckButton(hMuteOnScreenOff, *settings, SettingsKey::MUTE_ON_DISPLAYSTANDBY);
+ SetCheckButton(hMuteOnRDP, *settings, SettingsKey::MUTE_ON_RDP);
+ SetCheckButton(hRestoreVolume, *settings, SettingsKey::RESTORE_AUDIO);
+
+ // Without restore
+ SetCheckButton(hMuteOnShutdown, *settings, SettingsKey::MUTE_ON_SHUTDOWN);
+ SetCheckButton(hMuteOnSleep, *settings, SettingsKey::MUTE_ON_SUSPEND);
+ SetCheckButton(hMuteOnLogout, *settings, SettingsKey::MUTE_ON_LOGOUT);
+
+ return TRUE;
+ }
+ case WM_SAVESETTINGS:
+ {
+ WMSettings* settings = reinterpret_cast<WMSettings*>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+
+ 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);
+ HWND hMuteOnRDP = GetDlgItem(hDlg, IDC_MUTE_WHEN_RDP_SESSION);
+ HWND hRestoreVolume = GetDlgItem(hDlg, IDC_RESTOREVOLUME);
+
+ HWND hMuteOnShutdown = GetDlgItem(hDlg, IDC_MUTE_WHEN_SHUTDOWN);
+ HWND hMuteOnSleep = GetDlgItem(hDlg, IDC_MUTE_WHEN_SLEEP);
+ HWND hMuteOnLogout = GetDlgItem(hDlg, IDC_MUTE_WHEN_LOGOUT);
+
+ // With restore
+ SetOption(hMuteOnLock, *settings, SettingsKey::MUTE_ON_LOCK);
+ SetOption(hMuteOnScreensaver, *settings, SettingsKey::MUTE_ON_SCREENSAVER);
+ SetOption(hMuteOnScreenOff, *settings, SettingsKey::MUTE_ON_DISPLAYSTANDBY);
+ SetOption(hMuteOnRDP, *settings, SettingsKey::MUTE_ON_RDP);
+ SetOption(hRestoreVolume, *settings, SettingsKey::RESTORE_AUDIO);
+
+ // Without restore
+ SetOption(hMuteOnShutdown, *settings, SettingsKey::MUTE_ON_SHUTDOWN);
+ SetOption(hMuteOnSleep, *settings, SettingsKey::MUTE_ON_SUSPEND);
+ SetOption(hMuteOnLogout, *settings, SettingsKey::MUTE_ON_LOGOUT);
+
+ return 0;
+ }
+ default:
+ break;
+ }
+ return FALSE;
+}
int setStart = start->wHour * 3600 + start->wMinute * 60 + start->wSecond;
int setEnd = end->wHour * 3600 + end->wMinute * 60 + end->wSecond;
- 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)) {
+ 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(
nullptr,
nullptr,
EnableThemeDialogTexture(hDlg, ETDT_ENABLETAB);
}
- DWORD qhEnabled = !!settings->QueryValue(SettingsKey::QUIETHOURS_ENABLE, FALSE);
+ DWORD qhEnabled = !!settings->QueryValue(SettingsKey::QUIETHOURS_ENABLE);
Button_SetCheck(hEnable, qhEnabled ? BST_CHECKED : BST_UNCHECKED);
- DWORD qhForceUnmute = !!settings->QueryValue(SettingsKey::QUIETHOURS_FORCEUNMUTE, FALSE);
+ DWORD qhForceUnmute = !!settings->QueryValue(SettingsKey::QUIETHOURS_FORCEUNMUTE);
Button_SetCheck(hForce, qhForceUnmute ? BST_CHECKED : BST_UNCHECKED);
- DWORD qhNotifications = !!settings->QueryValue(SettingsKey::QUIETHOURS_NOTIFICATIONS, FALSE);
+ DWORD qhNotifications = !!settings->QueryValue(SettingsKey::QUIETHOURS_NOTIFICATIONS);
Button_SetCheck(hNotify, qhNotifications ? BST_CHECKED : BST_UNCHECKED);
EnableWindow(hForce, qhEnabled);
EnableWindow(hStart, qhEnabled);
EnableWindow(hEnd, qhEnabled);
- int setStart = settings->QueryValue(SettingsKey::QUIETHOURS_START, 0);
- int setEnd = settings->QueryValue(SettingsKey::QUIETHOURS_END, 0);
+ int setStart = settings->QueryValue(SettingsKey::QUIETHOURS_START);
+ int setEnd = settings->QueryValue(SettingsKey::QUIETHOURS_END);
SYSTEMTIME start;
GetLocalTime(&start);
{
SYSTEMTIME start;
SYSTEMTIME end;
- HWND hEnable = GetDlgItem(hDlg, IDC_ENABLEQUIETHOURS);
- HWND hForce = GetDlgItem(hDlg, IDC_FORCEUNMUTE);
+ 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);
+ HWND hStart = GetDlgItem(hDlg, IDC_QUIETHOURS_START);
+ HWND hEnd = GetDlgItem(hDlg, IDC_QUIETHOURS_END);
WMSettings* settings = reinterpret_cast<WMSettings*>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
- int qhEnabled = Button_GetCheck(hEnable) == BST_CHECKED;
- int qhForceUnmute = Button_GetCheck(hForce) == BST_CHECKED;
+ 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);
case WM_COMMAND:
{
HWND hEnable = GetDlgItem(hDlg, IDC_ENABLEQUIETHOURS);
- HWND hForce = GetDlgItem(hDlg, IDC_FORCEUNMUTE);
+ 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);
+ HWND hStart = GetDlgItem(hDlg, IDC_QUIETHOURS_START);
+ HWND hEnd = GetDlgItem(hDlg, IDC_QUIETHOURS_END);
if (LOWORD(wParam) == IDC_ENABLEQUIETHOURS) {
int qhEnabled = Button_GetCheck(hEnable) == BST_CHECKED;
EnableWindow(hStart, qhEnabled);
lpszFunction,
lastError,
reinterpret_cast<TCHAR*>(lpMsgBuf));
- TaskDialog(nullptr,
+ TaskDialog(
+ nullptr,
nullptr,
PROGRAM_NAME,
static_cast<LPCTSTR>(lpDisplayBuf),
case SettingsKey::MUTE_ON_DISPLAYSTANDBY:
keyStr = _T("MuteOnDisplayStandby");
break;
+ case SettingsKey::MUTE_ON_RDP:
+ keyStr = _T("MuteOnRDP");
+ break;
case SettingsKey::RESTORE_AUDIO:
keyStr = _T("RestoreAudio");
break;
return keyStr;
}
+static DWORD GetDefaultSetting(SettingsKey key)
+{
+ switch (key) {
+ case SettingsKey::MUTE_ON_LOCK:
+ return 1;
+ case SettingsKey::MUTE_ON_SCREENSAVER:
+ return 1;
+ case SettingsKey::MUTE_ON_DISPLAYSTANDBY:
+ return 1;
+ case SettingsKey::MUTE_ON_RDP:
+ return 0;
+ case SettingsKey::RESTORE_AUDIO:
+ return 1;
+ case SettingsKey::MUTE_ON_SUSPEND:
+ return 0;
+ case SettingsKey::MUTE_ON_SHUTDOWN:
+ return 0;
+ case SettingsKey::MUTE_ON_LOGOUT:
+ return 0;
+ case SettingsKey::QUIETHOURS_ENABLE:
+ return 0;
+ case SettingsKey::QUIETHOURS_FORCEUNMUTE:
+ return 0;
+ case SettingsKey::QUIETHOURS_NOTIFICATIONS:
+ return 0;
+ case SettingsKey::QUIETHOURS_START:
+ return 0;
+ case SettingsKey::QUIETHOURS_END:
+ return 0;
+ case SettingsKey::LOGGING_ENABLED:
+ return 0;
+ case SettingsKey::NOTIFICATIONS_ENABLED:
+ return 0;
+ }
+ return 0;
+}
+
static bool ReadStringFromRegistry(HKEY hKey, const TCHAR* subKey, tstring& val)
{
bool success = false;
}
}
-DWORD WMSettings::QueryValue(SettingsKey key, DWORD defValue)
+DWORD WMSettings::QueryValue(SettingsKey key) const
{
auto keyStr = KeyToStr(key);
assert(keyStr != nullptr);
- DWORD value;
+ DWORD value = 0;
DWORD size = sizeof(DWORD);
DWORD regError = RegQueryValueEx(
hRegSettingsKey_,
nullptr,
reinterpret_cast<LPBYTE>(&value),
&size);
- if (regError == ERROR_FILE_NOT_FOUND) {
- return defValue;
- } else if (regError != ERROR_SUCCESS) {
- PrintWindowsError(_T("RegCreateKeyEx"), regError);
- return defValue;
+ if (regError != ERROR_SUCCESS) {
+ if (regError != ERROR_FILE_NOT_FOUND) {
+ PrintWindowsError(_T("RegCreateKeyEx"), regError);
+ }
+ return GetDefaultSetting(key);
}
return value;
MUTE_ON_LOCK
, MUTE_ON_SCREENSAVER
, MUTE_ON_DISPLAYSTANDBY
+ , MUTE_ON_RDP
, RESTORE_AUDIO
, MUTE_ON_SUSPEND
, MUTE_ON_SHUTDOWN
bool IsAutostartEnabled();
void EnableAutostart(bool enable);
- DWORD QueryValue(SettingsKey key, DWORD defValue);
- bool SetValue(SettingsKey key, DWORD value);
+ DWORD QueryValue(SettingsKey key) const;
+ bool SetValue(SettingsKey key, DWORD value);
private:
HKEY hRegSettingsKey_;
}
WinMute::MuteConfig::MuteConfig()
+ : showNotifications(false)
{
this->quietHours.enabled = false;
this->quietHours.forceUnmute = false;
(cond) ? MF_CHECKED : MF_UNCHECKED) != -1)
bool WinMute::InitTrayMenu()
{
- hTrayMenu_ = LoadMenu(hglobInstance, MAKEINTRESOURCE(IDR_TRAYMENU));
- if (!hTrayMenu_) {
- PrintWindowsError(_T("LoadMenu"));
- return false;
- } else if (
- !CHECK_MENU_ITEM(MUTEONLOCK, muteCtrl_.GetMuteOnWorkstationLock()) ||
- !CHECK_MENU_ITEM(MUTEONSCREENSAVER, muteCtrl_.GetMuteOnScreensaverActivation()) ||
- !CHECK_MENU_ITEM(RESTOREAUDIO, muteCtrl_.GetRestoreVolume()) ||
- !CHECK_MENU_ITEM(MUTEONSUSPEND, muteCtrl_.GetMuteOnSuspend()) ||
- !CHECK_MENU_ITEM(MUTEONSHUTDOWN, muteCtrl_.GetMuteOnShutdown()) ||
- !CHECK_MENU_ITEM(MUTEONLOGOUT, muteCtrl_.GetMuteOnLogout())) {
+ if (hTrayMenu_ == NULL) {
+ hTrayMenu_ = LoadMenu(hglobInstance, MAKEINTRESOURCE(IDR_TRAYMENU));
+ if (hTrayMenu_ == NULL) {
+ PrintWindowsError(_T("LoadMenu"));
+ return false;
+ }
+ }
+
+ if (!CHECK_MENU_ITEM(MUTEONLOCK, muteCtrl_.GetMuteOnWorkstationLock()) ||
+ !CHECK_MENU_ITEM(MUTEONSCREENSAVER, muteCtrl_.GetMuteOnScreensaverActivation()) ||
+ !CHECK_MENU_ITEM(RESTOREAUDIO, muteCtrl_.GetRestoreVolume()) ||
+ !CHECK_MENU_ITEM(MUTEONSUSPEND, muteCtrl_.GetMuteOnSuspend()) ||
+ !CHECK_MENU_ITEM(MUTEONSHUTDOWN, muteCtrl_.GetMuteOnShutdown()) ||
+ !CHECK_MENU_ITEM(MUTEONLOGOUT, muteCtrl_.GetMuteOnLogout())) {
return false;
}
return true;
return false;
}
- if (!LoadDefaults()) {
+ if (!LoadSettings()) {
return false;
}
return true;
}
-bool WinMute::LoadDefaults()
+bool WinMute::LoadSettings()
{
- muteCtrl_.SetRestoreVolume(!!settings_.QueryValue(SettingsKey::RESTORE_AUDIO, 1));
- muteCtrl_.SetMuteOnWorkstationLock(!!settings_.QueryValue(SettingsKey::MUTE_ON_LOCK, 1));
- muteCtrl_.SetMuteOnScreensaverActivation(!!settings_.QueryValue(SettingsKey::MUTE_ON_SCREENSAVER, 1));
- muteCtrl_.SetMuteOnDisplayStandby(!!settings_.QueryValue(SettingsKey::MUTE_ON_DISPLAYSTANDBY, 1));
- muteCtrl_.SetMuteOnLogout(!!settings_.QueryValue(SettingsKey::MUTE_ON_LOGOUT, 0));
- muteCtrl_.SetMuteOnSuspend(!!settings_.QueryValue(SettingsKey::MUTE_ON_SUSPEND, 0));
- muteCtrl_.SetMuteOnShutdown(!!settings_.QueryValue(SettingsKey::MUTE_ON_SHUTDOWN, 0));
-
- muteCtrl_.SetNotifications(settings_.QueryValue(SettingsKey::NOTIFICATIONS_ENABLED, 0) != 0);
-
- muteConfig_.showNotifications =
- settings_.QueryValue(SettingsKey::NOTIFICATIONS_ENABLED, 0) != 0;
- muteConfig_.quietHours.enabled =
- 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 =
- settings_.QueryValue(SettingsKey::QUIETHOURS_END, 0);
+ 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);
return true;
}
SendMessage(hWnd, WM_CLOSE, 0, 0);
break;
case ID_TRAYMENU_SETTINGS: {
- DialogBoxParam(
- hglobInstance,
- MAKEINTRESOURCE(IDD_SETTINGS),
- hWnd_,
- SettingsDlgProc,
- reinterpret_cast<LPARAM>(&settings_));
- bool notifications = settings_.QueryValue(SettingsKey::NOTIFICATIONS_ENABLED, 0) != 0;
- muteConfig_.showNotifications = notifications;
- muteCtrl_.SetNotifications(notifications);
+ if (DialogBoxParam(
+ hglobInstance,
+ MAKEINTRESOURCE(IDD_SETTINGS),
+ hWnd_,
+ SettingsDlgProc,
+ reinterpret_cast<LPARAM>(&settings_)) == 0) {
+ LoadSettings();
+ InitTrayMenu();
+ }
break;
}
case ID_TRAYMENU_MUTE: {
return 0;
case WM_WINMUTE_QUIETHOURS_CHANGE: {
muteConfig_.quietHours.enabled = settings_.QueryValue(
- SettingsKey::QUIETHOURS_ENABLE,
- 0);
+ SettingsKey::QUIETHOURS_ENABLE);
muteConfig_.quietHours.forceUnmute = settings_.QueryValue(
- SettingsKey::QUIETHOURS_FORCEUNMUTE,
- 0);
+ SettingsKey::QUIETHOURS_FORCEUNMUTE);
muteConfig_.quietHours.notifications = settings_.QueryValue(
- SettingsKey::QUIETHOURS_NOTIFICATIONS,
- 0);
+ SettingsKey::QUIETHOURS_NOTIFICATIONS);
CheckMenuItem(
hTrayMenu_,
ID_TRAYMENU_CONFIGUREQUIETHOURS,
if (muteConfig_.quietHours.enabled) {
muteConfig_.quietHours.start = settings_.QueryValue(
- SettingsKey::QUIETHOURS_START,
- 0);
+ SettingsKey::QUIETHOURS_START);
muteConfig_.quietHours.end = settings_.QueryValue(
- SettingsKey::QUIETHOURS_END,
- 0);
+ SettingsKey::QUIETHOURS_END);
}
ResetQuietHours();
int timerQhEnd = GetDiffMillseconds(&end, &now);
WMLog::GetInstance().Write(L"Mute: On | Quiet hours have already started");
muteCtrl_.NotifyQuietHours(true);
- if (SetTimer(hWnd_, QUIETHOURS_TIMER_END_ID, timerQhEnd, QuietHoursTimer) == 0) {
- MessageBox(hWnd_, L"Failed to create Timer", PROGRAM_NAME, MB_OK);
+ if (SetCoalescableTimer(
+ hWnd_,
+ QUIETHOURS_TIMER_END_ID,
+ timerQhEnd,
+ QuietHoursTimer,
+ TIMERV_DEFAULT_COALESCING) == 0) {
+ TaskDialog(
+ hWnd_,
+ hglobInstance,
+ PROGRAM_NAME,
+ _T("Quiet Hours Stop"),
+ _T("Failed to register end of quiet hours with windows timer system"),
+ TDCBF_OK_BUTTON,
+ TD_ERROR_ICON,
+ nullptr);
}
} else {
int timerQhStart = GetDiffMillseconds(&start, &now);
- if (SetTimer(hWnd_, QUIETHOURS_TIMER_START_ID, timerQhStart, QuietHoursTimer) == 0) {
- MessageBox(hWnd_, L"Failed to create Timer", PROGRAM_NAME, MB_OK);
+ if (SetCoalescableTimer(
+ hWnd_,
+ QUIETHOURS_TIMER_START_ID,
+ timerQhStart,
+ QuietHoursTimer,
+ TIMERV_DEFAULT_COALESCING) == 0) {
+ TaskDialog(
+ hWnd_,
+ hglobInstance,
+ PROGRAM_NAME,
+ _T("Quiet Hours Start"),
+ _T("Failed to register quiet hours start with windows timer system"),
+ TDCBF_OK_BUTTON,
+ TD_ERROR_ICON,
+ nullptr);
}
}
}
start.wHour = static_cast<WORD>((muteConfig_.quietHours.start - start.wMinute - start.wSecond) / 3600);
int timerQhStart = GetDiffMillseconds(&start, &now);
- if (SetTimer(hWnd_, QUIETHOURS_TIMER_START_ID, timerQhStart, QuietHoursTimer) == 0) {
- MessageBox(hWnd_, L"Failed to create Timer", PROGRAM_NAME, MB_OK);
+ if (SetCoalescableTimer(
+ hWnd_,
+ QUIETHOURS_TIMER_START_ID,
+ timerQhStart,
+ QuietHoursTimer,
+ TIMERV_DEFAULT_COALESCING) == 0) {
+ TaskDialog(
+ hWnd_,
+ hglobInstance,
+ PROGRAM_NAME,
+ _T("Quiet Hours Start"),
+ _T("Failed to register quiet hours start with windows timer system"),
+ TDCBF_OK_BUTTON,
+ TD_ERROR_ICON,
+ nullptr);
}
}
int timerQhEnd = GetDiffMillseconds(&end, &now);
if (timerQhEnd <= 0) {
SendMessage(hWnd_, WM_WINMUTE_QUIETHOURS_END, 0, 0);
- } else if (SetTimer(hWnd_, QUIETHOURS_TIMER_END_ID, timerQhEnd, QuietHoursTimer) == 0) {
- MessageBox(hWnd_, L"Failed to create Timer", PROGRAM_NAME, MB_OK);
+ } else if (SetCoalescableTimer(
+ hWnd_,
+ QUIETHOURS_TIMER_END_ID,
+ timerQhEnd,
+ QuietHoursTimer,
+ TIMERV_DEFAULT_COALESCING) == 0) {
+ TaskDialog(
+ hWnd_,
+ hglobInstance,
+ PROGRAM_NAME,
+ _T("Quiet Hours Stop"),
+ _T("Failed to register end of quiet hours with windows timer system"),
+ TDCBF_OK_BUTTON,
+ TD_ERROR_ICON,
+ nullptr);
}
}
bool InitWindow();
bool InitAudio();
bool InitTrayMenu();
- void InitMuteSettings();
- bool LoadDefaults();
+ bool LoadSettings();
void ResetQuietHours();
void SetQuietHoursStart();
CONTROL "",IDC_SETTINGS_TAB,"SysTabControl32",0x0,7,7,255,223
END
-IDD_SETTINGS_GENERAL DIALOGEX 0, 0, 201, 179
+IDD_SETTINGS_GENERAL DIALOGEX 0, 0, 233, 179
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,15,187,26
- CONTROL "Enable Logging",IDC_ENABLELOGGING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,61,187,21
+ "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,39,187,21
- PUSHBUTTON "Open Log File...",IDC_OPENLOG,22,82,58,15
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,27,219,21
+ PUSHBUTTON "Open Log File...",IDC_OPENLOG,22,69,58,15
END
-IDD_SETTINGS_QUIETHOURS DIALOGEX 0, 0, 234, 177
+IDD_SETTINGS_QUIETHOURS DIALOGEX 0, 0, 246, 198
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- LTEXT "During Quiet Hours WinMute automatically mutes your PC volumes and unmutes it afterwards.",IDC_STATIC,7,7,220,22
+ LTEXT "During Quiet Hours WinMute automatically mutes your PC volumes and unmutes it afterwards.",IDC_STATIC,7,9,232,22
CONTROL "Enable Quiet Hours",IDC_ENABLEQUIETHOURS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,31,120,15
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
- 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,23,111,204,37
+ 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
END
"SysLink",WS_TABSTOP,197,49,94,14
END
+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,104
+ CONTROL "... the workstation is locked",IDC_MUTE_WHEN_WS_LOCKED,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,48,105,10
+ CONTROL "... the screensaver starts",IDC_MUTE_WHEN_SCREENSAVER_STARTS,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,62,99,10
+ CONTROL "... the screen turns off",IDC_MUTE_WHEN_SCREEN_OFF,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,76,90,10
+ CONTROL "... a remote session is started",IDC_MUTE_WHEN_RDP_SESSION,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,90,112,10
+ CONTROL "Restore volume afterwards",IDC_RESTOREVOLUME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,105,103,10
+ GROUPBOX "Mute without volume restore, when...",IDC_STATIC,7,139,228,59
+ CONTROL "... the computer shuts down",IDC_MUTE_WHEN_SHUTDOWN,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,153,107,10
+ CONTROL "... you log out",IDC_MUTE_WHEN_LOGOUT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,181,62,10
+ CONTROL "... the computer goes into sleep/hibernate.",IDC_MUTE_WHEN_SLEEP,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,167,155,10
+ LTEXT "Here you can configure the various mute conditions and variations that WinMute supports.",IDC_STATIC,7,8,228,17
+END
+
/////////////////////////////////////////////////////////////////////////////
//
IDD_SETTINGS_GENERAL, DIALOG
BEGIN
LEFTMARGIN, 7
- RIGHTMARGIN, 194
+ RIGHTMARGIN, 226
TOPMARGIN, 7
BOTTOMMARGIN, 172
END
IDD_SETTINGS_QUIETHOURS, DIALOG
BEGIN
LEFTMARGIN, 7
- RIGHTMARGIN, 227
+ RIGHTMARGIN, 239
TOPMARGIN, 7
- BOTTOMMARGIN, 170
+ BOTTOMMARGIN, 191
END
IDD_ABOUT_LICENSE, DIALOG
TOPMARGIN, 7
BOTTOMMARGIN, 169
END
+
+ IDD_SETTINGS_MUTE, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 235
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 198
+ END
END
#endif // APSTUDIO_INVOKED
0
END
+IDD_SETTINGS_MUTE AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
/////////////////////////////////////////////////////////////////////////////
//
MENUITEM "... Workstation is locked", ID_TRAYMENU_MUTEONLOCK, CHECKED
MENUITEM "... Screensaver starts", ID_TRAYMENU_MUTEONSCREENSAVER, CHECKED
MENUITEM "... Screen turns off", ID_TRAYMENU_SCREENSUSPEND, CHECKED
- MENUITEM SEPARATOR
- MENUITEM "Restore previous volume afterwards", ID_TRAYMENU_RESTOREAUDIO, CHECKED
+ MENUITEM "Restore volume afterwards", ID_TRAYMENU_RESTOREAUDIO, CHECKED
MENUITEM SEPARATOR
MENUITEM "Mute on (no volume restore)", ID_TRAYMENU_AFTERWARDS, INACTIVE
MENUITEM "... Shutdown", ID_TRAYMENU_MUTEONSHUTDOWN
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
+ <ClCompile Include="Settings_MuteDlg.cpp" />
<ClCompile Include="WMLog.cpp" />
<ClCompile Include="MMNotificationClient.cpp" />
<ClCompile Include="MuteControl.cpp" />
<ClCompile Include="AboutDlg.cpp">
<Filter>Source Files\UI\Dialogs</Filter>
</ClCompile>
+ <ClCompile Include="Settings_MuteDlg.cpp">
+ <Filter>Source Files\UI\Dialogs\Settings</Filter>
+ </ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
#define IDD_ABOUT_WINMUTE 120
#define IDI_ICON1 122
#define IDI_SETTINGS 122
+#define IDD_SETTINGS_MUTE 123
#define IDC_LINK_HOMEPAGE 1001
#define IDC_LINK_SUPPORT 1002
#define IDC_LINK_PROJECT 1002
#define IDC_SETTINGS_TAB 1010
#define IDC_CHECK1 1011
#define IDC_RUNONSTARTUP 1011
+#define IDC_MUTE_WHEN_WS_LOCKED 1011
#define IDC_ENABLELOGGING 1012
#define IDC_CHECK3 1013
+#define IDC_ENABLESTOPPLAYBACK 1013
#define IDC_OPENLOG 1014
#define IDC_LICENSETEXT 1015
#define IDC_ABOUT_TAB 1016
#define IDC_ABOUTTEXT 1019
#define IDC_TITLE 1020
#define IDC_ABOUT_TITLE 1020
+#define IDC_MUTE_WHEN_SCREENSAVER_STARTS 1021
+#define IDC_MUTE_WHEN_SCREEN_OFF 1022
+#define IDC_MUTE_WHEN_RDP_SESSION 1023
+#define IDC_RESTOREVOLUME 1024
+#define IDC_MUTE_WHEN_SHUTDOWN 1025
+#define IDC_MUTE_WHEN_RDP_SESSION3 1026
+#define IDC_MUTE_WHEN_LOGOUT 1026
+#define IDC_MUTE_WHEN_SLEEP 1027
#define ID_TRAYMENU_INFO 40001
#define ID_TRAYMENU_ 40002
#define ID_TRAYMENU_MUTEON 40003
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 123
+#define _APS_NEXT_RESOURCE_VALUE 125
#define _APS_NEXT_COMMAND_VALUE 40028
-#define _APS_NEXT_CONTROL_VALUE 1021
+#define _APS_NEXT_CONTROL_VALUE 1022
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif