mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
[Light Switch] Follow Night Light mode (#43683)
<!-- 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 Introduces a new mode that will have Light Switch follow Windows Night Light. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [x] Closes: https://github.com/microsoft/PowerToys/issues/42457 - [x] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [x] **Localization:** All end-user-facing strings can be localized - [ ] **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 <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments Strictly follows the state of Night Light. When NL is on, LS will be switch to dark mode and when NL is off, LS will switch to light mode (with respect to the users system/app selection). <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed Turn on Follow Night Light mode Change night light! ## Notes
This commit is contained in:
@@ -11,6 +11,7 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
|
||||
{
|
||||
public const string ColorsSettings = "ms-settings:colors";
|
||||
public const string DiagnosticsAndFeedback = "ms-settings:privacy-feedback";
|
||||
public const string NightLightSettings = "ms-settings:nightlight";
|
||||
|
||||
public static string AnimationsSettings => OSVersionHelper.IsWindows11()
|
||||
? "ms-settings:easeofaccess-visualeffects"
|
||||
|
||||
@@ -67,6 +67,10 @@
|
||||
x:Uid="LightSwitch_ModeSunsetToSunrise"
|
||||
AutomationProperties.AutomationId="SunCBItem_LightSwitch"
|
||||
Tag="SunsetToSunrise" />
|
||||
<ComboBoxItem
|
||||
x:Uid="LightSwitch_ModeFollowNightLight"
|
||||
AutomationProperties.AutomationId="FollowNightLightCBItem_LightSwitch"
|
||||
Tag="FollowNightLight" />
|
||||
</ComboBox>
|
||||
<tkcontrols:SettingsExpander.Items>
|
||||
<tkcontrols:SettingsCard
|
||||
@@ -152,6 +156,33 @@
|
||||
IsOpen="True"
|
||||
Severity="Informational" />
|
||||
</tkcontrols:SettingsCard>
|
||||
<tkcontrols:SettingsCard
|
||||
x:Name="FollowNightLightCard"
|
||||
Padding="0"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
Background="{ThemeResource InfoBarInformationalSeverityBackgroundBrush}"
|
||||
ContentAlignment="Vertical"
|
||||
Visibility="Collapsed">
|
||||
<InfoBar
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
IsClosable="False"
|
||||
IsOpen="True"
|
||||
Severity="Informational">
|
||||
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center">
|
||||
<Run x:Uid="LightSwitch_FollowNightLightCardMessage" />
|
||||
</TextBlock>
|
||||
|
||||
<HyperlinkButton
|
||||
x:Uid="LightSwitch_NightLightSettingsButton"
|
||||
Margin="3,0,0,0"
|
||||
Padding="0"
|
||||
Click="OpenNightLightSettings_Click" />
|
||||
</StackPanel>
|
||||
|
||||
</InfoBar>
|
||||
</tkcontrols:SettingsCard>
|
||||
</tkcontrols:SettingsExpander.Items>
|
||||
</tkcontrols:SettingsExpander>
|
||||
<InfoBar
|
||||
@@ -350,13 +381,25 @@
|
||||
<Setter Target="SunLocation_Card.Visibility" Value="Visible" />
|
||||
<Setter Target="SunOffset_Card.Visibility" Value="Visible" />
|
||||
<Setter Target="NoScheduleCard.Visibility" Value="Collapsed" />
|
||||
<Setter Target="FollowNightLightCard.Visibility" Value="Collapsed" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
|
||||
<VisualState x:Name="ManualState">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="Fixed_TurnOnCard.Visibility" Value="Visible" />
|
||||
<Setter Target="Fixed_TurnOffCard.Visibility" Value="Visible" />
|
||||
<Setter Target="NoScheduleCard.Visibility" Value="Collapsed" />
|
||||
<Setter Target="FollowNightLightCard.Visibility" Value="Collapsed" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
|
||||
<VisualState x:Name="FollowNightLightState">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="Fixed_TurnOnCard.Visibility" Value="Collapsed" />
|
||||
<Setter Target="Fixed_TurnOffCard.Visibility" Value="Collapsed" />
|
||||
<Setter Target="NoScheduleCard.Visibility" Value="Collapsed" />
|
||||
<Setter Target="FollowNightLightCard.Visibility" Value="Visible" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
|
||||
@@ -355,6 +355,10 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
VisualStateManager.GoToState(this, "SunsetToSunriseState", true);
|
||||
this.SunriseModeChartState();
|
||||
break;
|
||||
case "FollowNightLight":
|
||||
VisualStateManager.GoToState(this, "FollowNightLightState", true);
|
||||
TimelineCard.Visibility = Visibility.Collapsed;
|
||||
break;
|
||||
default:
|
||||
VisualStateManager.GoToState(this, "OffState", true);
|
||||
this.TimelineCard.Visibility = Visibility.Collapsed;
|
||||
@@ -362,6 +366,18 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenNightLightSettings_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Helpers.StartProcessHelper.Start(Helpers.StartProcessHelper.NightLightSettings);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError("Error while trying to open the system night light settings", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void SunriseModeChartState()
|
||||
{
|
||||
if (this.ViewModel.Latitude != "0.0" && this.ViewModel.Longitude != "0.0")
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
@@ -26,36 +26,36 @@
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
@@ -5760,4 +5760,13 @@ To record a specific window, enter the hotkey with the Alt key in the opposite m
|
||||
<value>A modern UI built with Fluent Design</value>
|
||||
<comment>Fluent Design is a product name, do not loc</comment>
|
||||
</data>
|
||||
</root>
|
||||
<data name="LightSwitch_ModeFollowNightLight.Content" xml:space="preserve">
|
||||
<value>Follow Night Light</value>
|
||||
</data>
|
||||
<data name="LightSwitch_NightLightSettingsButton.Content" xml:space="preserve">
|
||||
<value>Personalize your Night Light settings.</value>
|
||||
</data>
|
||||
<data name="LightSwitch_FollowNightLightCardMessage.Text" xml:space="preserve">
|
||||
<value>Following Night Light settings.</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -42,6 +42,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
"Off",
|
||||
"FixedHours",
|
||||
"SunsetToSunrise",
|
||||
"FollowNightLight",
|
||||
};
|
||||
|
||||
_toggleThemeHotkey = _moduleSettings.Properties.ToggleThemeHotkey.Value;
|
||||
|
||||
Reference in New Issue
Block a user