[PT Run] Option for override theme (#7355)

* option for override PT Run theme

* fix startup theme detection and moved strings in resources

* xaml fixed

* fix title spacing

* launcher theme fix

moved theme enum
removed settings direct access

* missing files

* theme manager dispose removed

Co-authored-by: Clint Rutkas <clint@rutkas.com>
This commit is contained in:
Davide Giacometti
2020-10-24 00:05:07 +02:00
committed by GitHub
parent 6424667396
commit 146e7866a6
23 changed files with 189 additions and 48 deletions

View File

@@ -51,6 +51,7 @@
<ItemGroup>
<ProjectReference Include="..\..\common\interop\interop.vcxproj" />
<ProjectReference Include="..\..\common\ManagedCommon\ManagedCommon.csproj" />
<ProjectReference Include="..\..\common\ManagedTelemetry\Telemetry\Telemetry.csproj" />
</ItemGroup>

View File

@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System.Text.Json.Serialization;
using ManagedCommon;
namespace Microsoft.PowerToys.Settings.UI.Library
{
@@ -44,6 +45,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library
[JsonPropertyName("clear_input_on_launch")]
public bool ClearInputOnLaunch { get; set; }
[JsonPropertyName("theme")]
public Theme Theme { get; set; }
public PowerLauncherProperties()
{
OpenPowerLauncher = new HotkeySettings(false, false, true, false, 32);
@@ -56,6 +60,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
DisableDriveDetectionWarning = false;
ClearInputOnLaunch = false;
MaximumNumberOfResults = 4;
Theme = Theme.System;
}
}
}

View File

@@ -6,6 +6,7 @@ using System;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Text.Json;
using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
@@ -13,6 +14,10 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
{
public class PowerLauncherViewModel : Observable
{
private bool _isDarkThemeRadioButtonChecked;
private bool _isLightThemeRadioButtonChecked;
private bool _isSystemThemeRadioButtonChecked;
private GeneralSettings GeneralSettingsConfig { get; set; }
private readonly ISettingsUtils _settingsUtils;
@@ -63,6 +68,19 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
settings.Properties.MaximumNumberOfResults = 4;
callback(settings);
}
switch (settings.Properties.Theme)
{
case Theme.Light:
_isLightThemeRadioButtonChecked = true;
break;
case Theme.Dark:
_isDarkThemeRadioButtonChecked = true;
break;
case Theme.System:
_isSystemThemeRadioButtonChecked = true;
break;
}
}
public PowerLauncherViewModel(PowerLauncherSettings settings, SendCallback callback)
@@ -149,6 +167,63 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
}
}
public bool IsDarkThemeRadioButtonChecked
{
get
{
return _isDarkThemeRadioButtonChecked;
}
set
{
if (value == true)
{
settings.Properties.Theme = Theme.Dark;
_isDarkThemeRadioButtonChecked = value;
UpdateSettings();
}
}
}
public bool IsLightThemeRadioButtonChecked
{
get
{
return _isLightThemeRadioButtonChecked;
}
set
{
if (value == true)
{
settings.Properties.Theme = Theme.Light;
_isDarkThemeRadioButtonChecked = value;
UpdateSettings();
}
}
}
public bool IsSystemThemeRadioButtonChecked
{
get
{
return _isSystemThemeRadioButtonChecked;
}
set
{
if (value == true)
{
settings.Properties.Theme = Theme.System;
_isDarkThemeRadioButtonChecked = value;
UpdateSettings();
}
}
}
public HotkeySettings OpenPowerLauncher
{
get

View File

@@ -302,6 +302,9 @@
<data name="PowerLauncher_ClearInputOnLaunch.Content" xml:space="preserve">
<value>Clear the previous query on launch</value>
</data>
<data name="PowerLauncher_Theme.Text" xml:space="preserve">
<value>Choose color</value>
</data>
<data name="KeyboardManager_KeysMappingLayoutRightHeader.Text" xml:space="preserve">
<value>To:</value>
<comment>Keyboard Manager mapping keys view right header</comment>
@@ -774,4 +777,13 @@
<data name="ImageResizer_FilenameFormatPlaceholder.PlaceholderText" xml:space="preserve">
<value>Example: %1 (%2)</value>
</data>
<data name="PowerLauncher_Radio_Theme_Dark.Content" xml:space="preserve">
<value>Dark</value>
</data>
<data name="PowerLauncher_Radio_Theme_Default.Content" xml:space="preserve">
<value>System default</value>
</data>
<data name="PowerLauncher_Radio_Theme_Light.Content" xml:space="preserve">
<value>Light</value>
</data>
</root>

View File

@@ -143,7 +143,22 @@
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.DisableDriveDetectionWarning}"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}"
/>
<TextBlock x:Uid="Appearance_GroupSettings"
Style="{StaticResource SettingsGroupTitleStyle}"
Foreground="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher, Converter={StaticResource ModuleEnabledToForegroundConverter}}" />
<TextBlock x:Uid="PowerLauncher_Theme"
Margin="{StaticResource SmallTopMargin}"
Foreground="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher, Converter={StaticResource ModuleEnabledToForegroundConverter}}" />
<muxc:RadioButtons IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}">
<RadioButton x:Uid="PowerLauncher_Radio_Theme_Dark"
IsChecked="{Binding Mode=TwoWay, Path=IsDarkThemeRadioButtonChecked}" />
<RadioButton x:Uid="PowerLauncher_Radio_Theme_Light"
IsChecked="{Binding Mode=TwoWay, Path=IsLightThemeRadioButtonChecked}" />
<RadioButton x:Uid="PowerLauncher_Radio_Theme_Default"
IsChecked="{Binding Mode=TwoWay, Path=IsSystemThemeRadioButtonChecked}" />
</muxc:RadioButtons>
</StackPanel>
<RelativePanel x:Name="SidePanel"