Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new "Off" mode to the Light Switch module's schedule options, allowing users to disable automatic theme switching while still preserving manual toggle functionality. Additionally, Light Switch is now disabled by default for new installations.
Key Changes
- Added "Off" as a new schedule mode option, which suspends automatic theme switching
- Changed the default schedule mode from "FixedHours" to "Off"
- Implemented
is_enabled_by_default()to return false, disabling Light Switch by default
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/settings-ui/Settings.UI/ViewModels/LightSwitchViewModel.cs | Added "Off" to the AvailableScheduleModes collection |
| src/settings-ui/Settings.UI/Strings/en-us/Resources.resw | Added localized strings for the "Off" mode option and informational message |
| src/settings-ui/Settings.UI/SettingsXAML/Views/LightSwitchPage.xaml | Added UI elements for "Off" mode ComboBox item and InfoBar message with visibility converters |
| src/settings-ui/Settings.UI/Converters/HideIfEnumValueConverter.cs | New converter that hides UI elements when enum matches specified parameter |
| src/settings-ui/Settings.UI.Library/LightSwitchProperties.cs | Changed DefaultScheduleMode constant from "FixedHours" to "Off" |
| src/runner/general_settings.cpp | Added logging for powertoys disabled by default |
| src/modules/LightSwitch/LightSwitchService/ThemeHelper.cpp | Added ResetColorPrevalence() function to reset color prevalence when switching to light mode |
| src/modules/LightSwitch/LightSwitchService/LightSwitchSettings.h | Added "Off" enum value and updated ToString/FromString functions to handle it |
| src/modules/LightSwitch/LightSwitchService/LightSwitchService.cpp | Modified service worker to skip theme scheduling when mode is "Off" while maintaining settings monitoring |
| src/modules/LightSwitch/LightSwitchModuleInterface/dllmain.cpp | Added "Off" enum value, updated default schedule mode, and implemented is_enabled_by_default() returning false |
src/settings-ui/Settings.UI/Converters/HideIfEnumValueConverter.cs
Outdated
Show resolved
Hide resolved
src/modules/LightSwitch/LightSwitchService/LightSwitchService.cpp
Outdated
Show resolved
Hide resolved
src/modules/LightSwitch/LightSwitchService/LightSwitchService.cpp
Outdated
Show resolved
Hide resolved
|
Why does this need to be running in an "Off" mode? I'd expect it to disable/unregister the dedicated Service/DLL completely when it's turned off. |
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Adds new "Off" mode for the schedule mode options which disable the schedule. Adds explicit function to disable light switch by default. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist Closes: - #42402 New behavior: "Off" mode added. when off, the regular service loop stops and all actions are event driven to either resume the loop or listen for hotkey. - #42386 New behavior: Disabled explicitly by default - #42389 New behavior: When switching from dark to light mode the system theme will remove the accent color. - #42513 New behavior: Manual mode no longer gets reset. It was being overridden by the sun calculations that were invertedly running when in manual mode. Todo: - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx @alvinashcraft we will need to add this new mode to the documentation. ## Validation Steps Performed - Removed all default settings and tested new logic. Light Switch is set to off by default. - Updated UI and tested new "Off" mode, logs indicate mode switched and ticker stopped. Polling resumes on mode change. (need to check that the shortcut still works) --------- Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Gordon Lam <73506701+yeelam-gordon@users.noreply.github.com>
Hotfixes #42467 #42434 #42405 #42399 --------- Co-authored-by: Jiří Polášek <me@jiripolasek.com> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Jaylyn Barbee <51131738+Jaylyn-Barbee@users.noreply.github.com> Co-authored-by: Gordon Lam <73506701+yeelam-gordon@users.noreply.github.com> Co-authored-by: Dustin L. Howett <duhowett@microsoft.com>
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
src/modules/LightSwitch/LightSwitchService/LightSwitchService.cpp:1
- Grammatical error in comment. Should be 'if we are changing to light mode'.
#include <windows.h>
| SetSystemTheme(true); | ||
| Logger::info(L"[LightSwitchService] Changing system theme to light mode."); | ||
| if (settings.changeApps && !isAppsCurrentlyLight) | ||
| SetAppsTheme(true); | ||
| Logger::info(L"[LightSwitchService] Changing apps theme to light mode."); | ||
| } | ||
| else | ||
| { | ||
| if (settings.changeSystem && isSystemCurrentlyLight) | ||
| SetSystemTheme(false); | ||
| Logger::info(L"[LightSwitchService] Changing system theme to dark mode."); | ||
| if (settings.changeApps && isAppsCurrentlyLight) | ||
| SetAppsTheme(false); | ||
| Logger::info(L"[LightSwitchService] Changing apps theme to light mode."); |
There was a problem hiding this comment.
Line 201 incorrectly logs 'light mode' when setting dark mode. Should be 'Changing apps theme to dark mode.'. Additionally, missing braces around if-statement bodies cause Logger::info calls to execute unconditionally.
| SetSystemTheme(true); | |
| Logger::info(L"[LightSwitchService] Changing system theme to light mode."); | |
| if (settings.changeApps && !isAppsCurrentlyLight) | |
| SetAppsTheme(true); | |
| Logger::info(L"[LightSwitchService] Changing apps theme to light mode."); | |
| } | |
| else | |
| { | |
| if (settings.changeSystem && isSystemCurrentlyLight) | |
| SetSystemTheme(false); | |
| Logger::info(L"[LightSwitchService] Changing system theme to dark mode."); | |
| if (settings.changeApps && isAppsCurrentlyLight) | |
| SetAppsTheme(false); | |
| Logger::info(L"[LightSwitchService] Changing apps theme to light mode."); | |
| { | |
| SetSystemTheme(true); | |
| Logger::info(L"[LightSwitchService] Changing system theme to light mode."); | |
| } | |
| if (settings.changeApps && !isAppsCurrentlyLight) | |
| { | |
| SetAppsTheme(true); | |
| Logger::info(L"[LightSwitchService] Changing apps theme to light mode."); | |
| } | |
| } | |
| else | |
| { | |
| if (settings.changeSystem && isSystemCurrentlyLight) | |
| { | |
| SetSystemTheme(false); | |
| Logger::info(L"[LightSwitchService] Changing system theme to dark mode."); | |
| } | |
| if (settings.changeApps && isAppsCurrentlyLight) | |
| { | |
| SetAppsTheme(false); | |
| Logger::info(L"[LightSwitchService] Changing apps theme to dark mode."); | |
| } |
| RegSetValueEx(hKey, L"SystemUsesLightTheme", 0, REG_DWORD, reinterpret_cast<const BYTE*>(&value), sizeof(value)); | ||
| RegCloseKey(hKey); | ||
|
|
||
| if (mode) // if are changing to light mode |
There was a problem hiding this comment.
Grammatical error in comment. Should be 'if we are changing to light mode'.
| if (mode) // if are changing to light mode | |
| if (mode) // if we are changing to light mode |
| } | ||
|
|
||
| // --- Manual override triggered --- | ||
| if (wait == WAIT_OBJECT_0 + (hParent ? 2 : 1)) |
There was a problem hiding this comment.
Magic number calculation for wait index is error-prone. When hParent is null, manual override is at index 1, but when hParent exists, it's at index 2. Consider using named constants or calculating the index based on the order waits were added.
| } | ||
|
|
||
| // --- Settings file changed --- | ||
| if (wait == WAIT_OBJECT_0 + (hParent ? 3 : 2)) |
There was a problem hiding this comment.
Magic number calculation for wait index is error-prone. The settings event should always be the last one added. Consider calculating the index based on 'count - 1' to make the relationship explicit.
| if (wait == WAIT_OBJECT_0 + (hParent ? 3 : 2)) | |
| if (wait == WAIT_OBJECT_0 + count - 1) |
| ToString(newMode)); | ||
| g_settings.m_scheduleMode = newMode; | ||
|
|
||
| start_service_if_needed(); |
There was a problem hiding this comment.
[nitpick] The service is started regardless of whether the mode is 'Off' or not. When changing to 'Off' mode, the service should remain running (to handle manual overrides) but the logic should consider that starting when already running is redundant. However, this may be intentional since start_service_if_needed checks if the service is already running.
| start_service_if_needed(); | |
| if (newMode != ScheduleMode::Off) | |
| { | |
| start_service_if_needed(); | |
| } |
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Adds new "Off" mode for the schedule mode options which disable the schedule. Adds explicit function to disable light switch by default. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist Closes: - microsoft#42402 New behavior: "Off" mode added. when off, the regular service loop stops and all actions are event driven to either resume the loop or listen for hotkey. - microsoft#42386 New behavior: Disabled explicitly by default - microsoft#42389 New behavior: When switching from dark to light mode the system theme will remove the accent color. - microsoft#42513 New behavior: Manual mode no longer gets reset. It was being overridden by the sun calculations that were invertedly running when in manual mode. Todo: - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx @alvinashcraft we will need to add this new mode to the documentation. ## Validation Steps Performed - Removed all default settings and tested new logic. Light Switch is set to off by default. - Updated UI and tested new "Off" mode, logs indicate mode switched and ticker stopped. Polling resumes on mode change. (need to check that the shortcut still works) --------- Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Gordon Lam <73506701+yeelam-gordon@users.noreply.github.com>
Summary of the Pull Request
Adds new "Off" mode for the schedule mode options which disable the schedule.
Adds explicit function to disable light switch by default.
PR Checklist
Closes:
New behavior: "Off" mode added. when off, the regular service loop stops and all actions are event driven to either resume the loop or listen for hotkey.
New behavior: Disabled explicitly by default
New behavior: When switching from dark to light mode the system theme will remove the accent color.
New behavior: Manual mode no longer gets reset. It was being overridden by the sun calculations that were invertedly running when in manual mode.
Todo:
Validation Steps Performed