]> repos.lx-s.de Git - winmute.git/commitdiff
New Settings Dialog.
authorAlexander Steinhöfer <alexander@steinhoefer.net>
Tue, 5 Apr 2022 09:18:35 +0000 (11:18 +0200)
committerAlexander Steinhöfer <alexander@steinhoefer.net>
Tue, 5 Apr 2022 09:18:35 +0000 (11:18 +0200)
WinMute/SettingsDlg.cpp [new file with mode: 0644]
WinMute/Settings_GeneralDlg.cpp [new file with mode: 0644]
WinMute/Settings_QuietHoursDlg.cpp [moved from WinMute/QuietHoursDlg.cpp with 79% similarity]
WinMute/WinMute.cpp
WinMute/WinMute.rc
WinMute/WinMute.vcxproj
WinMute/WinMute.vcxproj.filters
WinMute/common.h
WinMute/resource.h

diff --git a/WinMute/SettingsDlg.cpp b/WinMute/SettingsDlg.cpp
new file mode 100644 (file)
index 0000000..dd4364a
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+ 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"
+
+enum SettingsTabsIDs {
+   SETTINGS_TAB_GENERAL = 0,
+   SETTINGS_TAB_QUIETHOURS,
+   SETTINGS_TAB_COUNT
+};
+
+struct SettingsDlgData {
+   HWND hTabCtrl;
+   HWND hTabs[SETTINGS_TAB_COUNT];
+
+   HWND hActiveTab;
+   Settings* settings;
+
+   SettingsDlgData(Settings* settings)
+      : settings(settings), hTabCtrl(NULL), hActiveTab(NULL)
+   {
+      ZeroMemory(hTabs, sizeof(hTabs));
+   }
+};
+
+extern INT_PTR CALLBACK Settings_QuietHoursDlgProc(HWND, UINT, WPARAM, LPARAM);
+extern INT_PTR CALLBACK Settings_GeneralDlgProc(HWND, UINT, WPARAM, LPARAM);
+
+static void InsertTabItem(HWND hTabCtrl, UINT id, const TCHAR* itemName)
+{
+   constexpr int bufSize = 50;
+   TCHAR buf[bufSize];
+   TC_ITEM tcItem;
+   ZeroMemory(&tcItem, sizeof(tcItem));
+   tcItem.mask |= TCIF_TEXT;
+   StringCchCopy(buf, bufSize, itemName);
+   tcItem.pszText = buf;
+   tcItem.cchTextMax = bufSize;
+
+   TabCtrl_InsertItem(hTabCtrl, id, &tcItem);
+}
+
+static void SwitchTab(SettingsDlgData* dlgData, HWND hNewTab)
+{
+   if (dlgData->hActiveTab != NULL) {
+      ShowWindow(dlgData->hActiveTab, SW_HIDE);
+   }
+   dlgData->hActiveTab = hNewTab;
+   ShowWindow(dlgData->hActiveTab, SW_SHOW);
+}
+
+static void ResizeTab(HWND hTabCtrl, HWND hTabPage)
+{
+   RECT r = { 0 };
+   GetClientRect(hTabPage, &r);
+   TabCtrl_AdjustRect(hTabCtrl, FALSE, &r);
+   MoveWindow(hTabPage, r.left, r.top, r.right, r.bottom, TRUE);
+}
+
+INT_PTR CALLBACK SettingsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+   SettingsDlgData* dlgData =
+      reinterpret_cast<SettingsDlgData*>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+   switch (msg) {
+   case WM_INITDIALOG: {
+      assert(dlgData == nullptr);
+      Settings* settings = reinterpret_cast<Settings*>(lParam);
+      dlgData = new SettingsDlgData(settings);
+      SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(dlgData));
+      
+      dlgData->hTabCtrl = GetDlgItem(hDlg, IDC_SETTINGS_TAB);
+
+      InsertTabItem(dlgData->hTabCtrl, SETTINGS_TAB_GENERAL, _T("General"));
+      InsertTabItem(dlgData->hTabCtrl, SETTINGS_TAB_QUIETHOURS, _T("Quiet Hours"));
+
+      dlgData->hTabs[SETTINGS_TAB_GENERAL] = CreateDialogParam(
+         nullptr,
+         MAKEINTRESOURCE(IDD_SETTINGS_GENERAL),
+         dlgData->hTabCtrl,
+         Settings_GeneralDlgProc,
+         reinterpret_cast<LPARAM>(settings));
+      dlgData->hTabs[SETTINGS_TAB_QUIETHOURS] = CreateDialogParam(
+         nullptr,
+         MAKEINTRESOURCE(IDD_SETTINGS_QUIETHOURS),
+         dlgData->hTabCtrl,
+         Settings_QuietHoursDlgProc,
+         reinterpret_cast<LPARAM>(settings));
+
+      // Init tab pages
+      for (int i = 0; i < SETTINGS_TAB_COUNT; ++i) {
+         HWND hCurTab = dlgData->hTabs[i];
+         ShowWindow(hCurTab, SW_HIDE);
+         ResizeTab(dlgData->hTabCtrl, hCurTab);
+      }
+
+      SwitchTab(dlgData, dlgData->hTabs[SETTINGS_TAB_GENERAL]);
+      return TRUE;
+   }
+   case WM_COMMAND:
+      if (LOWORD(wParam) == IDOK) {
+         for (int i = 0; i < SETTINGS_TAB_COUNT; ++i) {
+            SendMessage(dlgData->hTabs[i], WM_SAVESETTINGS, 0, 0);
+         }
+         EndDialog(hDlg, 0); 
+      } else if (LOWORD(wParam) == IDCANCEL) {
+         EndDialog(hDlg, 0);
+      }
+      return 0;
+   case WM_NOTIFY: {
+      const LPNMHDR lpnmhdr = reinterpret_cast<LPNMHDR>(lParam);
+      if (lpnmhdr->code == TCN_SELCHANGE
+          && lpnmhdr->hwndFrom == dlgData->hTabCtrl) {
+         const int curSel = TabCtrl_GetCurSel(dlgData->hTabCtrl);
+         if (curSel >= 0 && curSel <= SETTINGS_TAB_COUNT) {
+            SwitchTab(dlgData, dlgData->hTabs[curSel]);
+         }
+      }
+      return 0;
+   }
+   case WM_CLOSE:
+      EndDialog(hDlg, 0);
+      return TRUE;
+   case WM_DESTROY:
+      delete dlgData;
+      SetWindowLongPtr(hDlg, GWLP_USERDATA, NULL);
+      return 0;
+   default:
+      break;
+   }
+   return FALSE;
+}
diff --git a/WinMute/Settings_GeneralDlg.cpp b/WinMute/Settings_GeneralDlg.cpp
new file mode 100644 (file)
index 0000000..137f4b5
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ 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"
+
+INT_PTR CALLBACK Settings_GeneralDlgProc(HWND hDlg, UINT msg, WPARAM, LPARAM)
+{
+   switch (msg) {
+   case WM_INITDIALOG:
+      if (IsAppThemed()) {
+         EnableThemeDialogTexture(hDlg, ETDT_ENABLETAB);
+      }
+      return TRUE;
+   case WM_SAVESETTINGS:
+
+      return 0;
+   default:
+      break;
+   }
+   return FALSE;
+}
similarity index 79%
rename from WinMute/QuietHoursDlg.cpp
rename to WinMute/Settings_QuietHoursDlg.cpp
index 3626d3bc302d9ce7b8fd40e227023c6b8fe39d7d..1bd20c3f021067dcbc0467d0be8b6d2d2c30643f 100644 (file)
@@ -74,10 +74,10 @@ static bool SaveQuietHours(
    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)) {
+      !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,
@@ -93,7 +93,7 @@ static bool SaveQuietHours(
    return true;
 }
 
-INT_PTR CALLBACK QuietHoursDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK Settings_QuietHoursDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
    UNREFERENCED_PARAMETER(lParam);
    switch (msg) {
@@ -104,10 +104,15 @@ INT_PTR CALLBACK QuietHoursDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP
       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);
       assert(settings != NULL);
       SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(settings));
 
+      if (IsAppThemed()) {
+         EnableThemeDialogTexture(hDlg, ETDT_ENABLETAB);
+      }
+
       DWORD qhEnabled = !!settings->QueryValue(SettingsKey::QUIETHOURS_ENABLE, FALSE);
       Button_SetCheck(hEnable, qhEnabled ? BST_CHECKED : BST_UNCHECKED);
 
@@ -145,30 +150,36 @@ INT_PTR CALLBACK QuietHoursDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP
 
       return TRUE;
    }
-   case WM_COMMAND:
+   case WM_SAVESETTINGS:
    {
+      SYSTEMTIME start;
+      SYSTEMTIME end;
       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) {
-         SYSTEMTIME start;
-         SYSTEMTIME end;
-         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, qhNotifications, &start, &end)) {
-            SendMessage(GetParent(hDlg), WM_WINMUTE_QUIETHOURS_CHANGE, 0, 0);
-            EndDialog(hDlg, 0);
-         }
-      } else if (LOWORD(wParam) == IDCANCEL) {
+      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, qhNotifications, &start, &end)) {
+         SendMessage(GetParent(hDlg), WM_WINMUTE_QUIETHOURS_CHANGE, 0, 0);
          EndDialog(hDlg, 0);
-      } else if (LOWORD(wParam) == IDC_ENABLEQUIETHOURS) {
+      }
+      return 0;
+   }
+   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) == IDC_ENABLEQUIETHOURS) {
          int qhEnabled = Button_GetCheck(hEnable) == BST_CHECKED;
          EnableWindow(hStart, qhEnabled);
          EnableWindow(hEnd, qhEnabled);
index 0419946ab3a40ae89e17fd03b38ff006c33a10a9..8d6a0693ac69275f1747e70635a1ca3debe4897d 100644 (file)
@@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
 extern HINSTANCE hglobInstance;
 extern INT_PTR CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM);
 extern INT_PTR CALLBACK QuietHoursDlgProc(HWND, UINT, WPARAM, LPARAM);
+extern INT_PTR CALLBACK SettingsDlgProc(HWND, UINT, WPARAM, LPARAM);
 
 static LPCTSTR WINMUTE_CLASS_NAME = _T("WinMute");
 
@@ -305,6 +306,14 @@ LRESULT CALLBACK WinMute::WindowProc(
       case ID_TRAYMENU_EXIT:
          SendMessage(hWnd, WM_CLOSE, 0, 0);
          break;
+      case ID_TRAYMENU_SETTINGS:
+         DialogBoxParam(
+            hglobInstance,
+            MAKEINTRESOURCE(IDD_SETTINGS),
+            hWnd_,
+            SettingsDlgProc,
+            reinterpret_cast<LPARAM>(&settings_));
+         break;
       case ID_TRAYMENU_MUTE: {
          bool state = false;
          ToggleMenuCheck(ID_TRAYMENU_MUTE, &state);
@@ -400,7 +409,7 @@ LRESULT CALLBACK WinMute::WindowProc(
          const PPOWERBROADCAST_SETTING bs =
             reinterpret_cast<PPOWERBROADCAST_SETTING>(lParam);
          if (IsEqualGUID(bs->PowerSetting, GUID_CONSOLE_DISPLAY_STATE)) {
-            const DWORD state = reinterpret_cast<DWORD>(bs->Data);
+            const DWORD state = bs->Data[0];
             if (state == 0x0) { // Display off
                muteCtrl_.NotifyDisplayStandby(true);
             } else if (state == 0x1) { // Display on
index d597c192757688317777d0ea4fdb0887b6da7584..225ce8d68edf94116f66112778211a6d2b210d35 100644 (file)
@@ -65,48 +65,39 @@ BEGIN
                     "SysLink",WS_TABSTOP,106,33,60,14
 END
 
-IDD_QUIETHOURS DIALOGEX 0, 0, 212, 197
+IDD_SETTINGS DIALOGEX 0, 0, 269, 253
 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
-BEGIN
-    DEFPUSHBUTTON   "Save",IDOK,101,176,50,14
-    PUSHBUTTON      "Cancel",IDCANCEL,155,176,50,14
-    LTEXT           "During Quiet Hours WinMute automatically mutes your PC volumes and unmutes it afterwards.",IDC_STATIC,11,10,182,22
-    CONTROL         "Enable Quiet Hours",IDC_ENABLEQUIETHOURS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,34,120,15
-    CONTROL         "",IDC_QUIETHOURS_START,"SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | WS_TABSTOP | 0x8,77,51,65,18
-    CONTROL         "",IDC_QUIETHOURS_END,"SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | WS_TABSTOP | 0x8,76,74,67,19
-    CONTROL         "Force unmute",IDC_FORCEUNMUTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,97,86,16
-    CONTROL         "Show notifications",IDC_SHOWNOTIFICATIONS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,150,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,27,115,161,37
-    LTEXT           "Start time:",IDC_STATIC,27,54,43,13
-    LTEXT           "End time:",IDC_STATIC,28,76,32,16
-END
-
-IDD_SETTINGS DIALOGEX 0, 0, 272, 199
-STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Settings"
 FONT 8, "MS Shell Dlg", 400, 0, 0x1
 BEGIN
-    DEFPUSHBUTTON   "OK",IDOK,158,178,50,14
-    PUSHBUTTON      "Cancel",IDCANCEL,213,178,50,14
-    CONTROL         "",IDC_TAB1,"SysTabControl32",0x0,7,7,258,167
+    DEFPUSHBUTTON   "OK",IDOK,158,232,50,14
+    PUSHBUTTON      "Cancel",IDCANCEL,212,232,50,14
+    CONTROL         "",IDC_SETTINGS_TAB,"SysTabControl32",0x0,7,7,255,223
 END
 
-IDD_SETTINGS_GENERAL DIALOGEX 0, 0, 297, 171
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_SYSMENU
+IDD_SETTINGS_GENERAL DIALOGEX 0, 0, 201, 179
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
 FONT 8, "MS Shell Dlg", 400, 0, 0x1
 BEGIN
     CONTROL         "Start WinMute on system startup",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,15,132,26
     CONTROL         "Enable Logging",IDC_ENABLELOGGING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,61,101,21
     CONTROL         "Show notifications",IDC_SHOWNOTIFICATIONS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,40,86,21
+    PUSHBUTTON      "Open Log...",IDC_OPENLOG,17,81,58,17
 END
 
-IDD_SETTINGS_QUIETHOURS DIALOGEX 0, 0, 310, 177
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_SYSMENU
+IDD_SETTINGS_QUIETHOURS DIALOGEX 0, 0, 202, 177
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
 FONT 8, "MS Shell Dlg", 400, 0, 0x1
 BEGIN
-    LTEXT           "QUIET HOURS",IDC_STATIC,14,26,110,33
+    LTEXT           "During Quiet Hours WinMute automatically mutes your PC volumes and unmutes it afterwards.",IDC_STATIC,7,7,182,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,161,37
+    LTEXT           "Start time:",IDC_STATIC,23,50,43,13
+    LTEXT           "End time:",IDC_STATIC,24,73,32,16
 END
 
 
@@ -126,34 +117,26 @@ BEGIN
         BOTTOMMARGIN, 49
     END
 
-    IDD_QUIETHOURS, DIALOG
-    BEGIN
-        LEFTMARGIN, 7
-        RIGHTMARGIN, 205
-        TOPMARGIN, 7
-        BOTTOMMARGIN, 190
-    END
-
     IDD_SETTINGS, DIALOG
     BEGIN
         LEFTMARGIN, 7
-        RIGHTMARGIN, 265
+        RIGHTMARGIN, 262
         TOPMARGIN, 7
-        BOTTOMMARGIN, 192
+        BOTTOMMARGIN, 246
     END
 
     IDD_SETTINGS_GENERAL, DIALOG
     BEGIN
         LEFTMARGIN, 7
-        RIGHTMARGIN, 290
+        RIGHTMARGIN, 194
         TOPMARGIN, 7
-        BOTTOMMARGIN, 164
+        BOTTOMMARGIN, 172
     END
 
     IDD_SETTINGS_QUIETHOURS, DIALOG
     BEGIN
         LEFTMARGIN, 7
-        RIGHTMARGIN, 303
+        RIGHTMARGIN, 195
         TOPMARGIN, 7
         BOTTOMMARGIN, 170
     END
@@ -171,11 +154,6 @@ BEGIN
     0
 END
 
-IDD_QUIETHOURS AFX_DIALOG_LAYOUT
-BEGIN
-    0
-END
-
 IDD_SETTINGS AFX_DIALOG_LAYOUT
 BEGIN
     0
@@ -230,6 +208,7 @@ BEGIN
         MENUITEM "... Sleep",                   ID_TRAYMENU_MUTEONSUSPEND
         MENUITEM "... Logout",                  ID_TRAYMENU_MUTEONLOGOUT
         MENUITEM SEPARATOR
+        MENUITEM "Settings...",                 ID_TRAYMENU_SETTINGS
         MENUITEM "Mute now",                    ID_TRAYMENU_MUTE
         MENUITEM SEPARATOR
         MENUITEM "Exit",                        ID_TRAYMENU_EXIT
index adc1bda067f06d337544428407b63937d1f0b4ec..4a6b042135fc35e29a937a82efe315d92552e68d 100644 (file)
     <Link>
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>strsafe.lib;comctl32.lib;WtsApi32.lib;Winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>strsafe.lib;comctl32.lib;WtsApi32.lib;Winmm.lib;UxTheme.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <Manifest>
       <EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>strsafe.lib;comctl32.lib;WtsApi32.lib;Winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>strsafe.lib;comctl32.lib;WtsApi32.lib;Winmm.lib;UxTheme.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <Manifest>
       <EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
     <Link>
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>strsafe.lib;comctl32.lib;WtsApi32.lib;Winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>strsafe.lib;comctl32.lib;WtsApi32.lib;Winmm.lib;UxTheme.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <Manifest>
       <EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>strsafe.lib;comctl32.lib;WtsApi32.lib;Winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>strsafe.lib;comctl32.lib;WtsApi32.lib;Winmm.lib;UxTheme.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <Manifest>
       <EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
     <ClCompile Include="QuietHoursDlg.cpp" />
     <ClCompile Include="ScreensaverNotifier.cpp" />
     <ClCompile Include="Settings.cpp" />
+    <ClCompile Include="SettingsDlg.cpp" />
+    <ClCompile Include="Settings_GeneralDlg.cpp" />
+    <ClCompile Include="Settings_QuietHoursDlg.cpp" />
     <ClCompile Include="TrayIcon.cpp" />
     <ClCompile Include="Utility.cpp" />
     <ClCompile Include="VistaAudio.cpp" />
index 3d631a08789e9db101dc41a8bbaff9738e406294..a6f7fa0fcadce4903603aa93995501c01c7817d4 100644 (file)
@@ -48,6 +48,9 @@
     <Filter Include="Source Files\UI\TrayIcon">
       <UniqueIdentifier>{21b7f94e-74d0-4737-bd72-da855556df2d}</UniqueIdentifier>
     </Filter>
+    <Filter Include="Source Files\UI\Dialogs\Settings">
+      <UniqueIdentifier>{c4de9bea-a833-43ac-8021-6e5cf7d048e8}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="WinAudio.h">
     <ClCompile Include="MuteControl.cpp">
       <Filter>Source Files\Controllers\Muting</Filter>
     </ClCompile>
+    <ClCompile Include="SettingsDlg.cpp">
+      <Filter>Source Files\UI\Dialogs\Settings</Filter>
+    </ClCompile>
+    <ClCompile Include="Settings_QuietHoursDlg.cpp">
+      <Filter>Source Files\UI\Dialogs\Settings</Filter>
+    </ClCompile>
+    <ClCompile Include="Settings_GeneralDlg.cpp">
+      <Filter>Source Files\UI\Dialogs\Settings</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>
\ No newline at end of file
index 47bd3f4f4a76e25a41ac86ced5a72d2476249091..766268dbb22681bec71746c90b6067354ef03913 100644 (file)
@@ -69,6 +69,7 @@ POSSIBILITY OF SUCH DAMAGE.
 #include <tchar.h>
 #include <strsafe.h>
 #include <time.h>
+#include <uxtheme.h>
 
 #include "resource.h"
 
@@ -86,6 +87,7 @@ POSSIBILITY OF SUCH DAMAGE.
 void PrintWindowsError(LPCWSTR lpszFunction, DWORD lastError = -1);
 
 static const LPCTSTR PROGRAM_NAME = _T("WinMute");
+constexpr int WM_SAVESETTINGS = WM_USER + 300;
 
 template<class Interface>
 inline void SafeRelease(Interface** ppInterfaceToRelease)
index 1191b591109546bd78a0061730e2122be93b5ef0..f72273307c77fb7084152de15891293074972301 100644 (file)
@@ -7,7 +7,6 @@
 #define IDI_TRAY_BRIGHT                 104
 #define IDI_TRAY_DARK                   105
 #define IDR_TRAYMENU                    106
-#define IDD_QUIETHOURS                  107
 #define IDD_SETTINGS                    109
 #define IDD_SETTINGS_GENERAL            114
 #define IDD_SETTINGS_QUIETHOURS         116
 #define IDC_SHOWNOTIFICATIONS           1007
 #define IDC_TREE1                       1008
 #define IDC_TAB1                        1010
+#define IDC_SETTINGS_TAB                1010
 #define IDC_CHECK1                      1011
 #define IDC_ENABLELOGGING               1012
 #define IDC_CHECK3                      1013
+#define IDC_BUTTON1                     1014
+#define IDC_OPENLOG                     1014
 #define ID_TRAYMENU_INFO                40001
 #define ID_TRAYMENU_                    40002
 #define ID_TRAYMENU_MUTEON              40003
 #define ID_TRAYMENU_EXIT                40022
 #define ID_TRAYMENU_MUTE                40023
 #define ID_TRAYMENU_MUTEONLOCK          40024
+#define ID_TRAYMENU_SETTINGS            40025
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        118
-#define _APS_NEXT_COMMAND_VALUE         40025
-#define _APS_NEXT_CONTROL_VALUE         1014
+#define _APS_NEXT_COMMAND_VALUE         40026
+#define _APS_NEXT_CONTROL_VALUE         1015
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif