Update settings configuration
There is a non-zero amount of settings that I need to set up for Espresso to work properly. This change is all about updating the view model and its binding to the UI.
This commit is contained in:
parent
ee932450df
commit
0e0bae0198
|
@ -3,7 +3,6 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
||||
|
||||
|
@ -15,11 +14,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
|||
|
||||
private EspressoSettings Settings { get; set; }
|
||||
|
||||
private string settingsConfigFileFolder = string.Empty;
|
||||
|
||||
private Func<string, int> SendConfigMSG { get; }
|
||||
|
||||
public EspressoViewModel(ISettingsRepository<GeneralSettings> settingsRepository, ISettingsRepository<EspressoSettings> moduleSettingsRepository, Func<string, int> ipcMSGCallBackFunc, string configFileSubfolder = "")
|
||||
public EspressoViewModel(ISettingsRepository<GeneralSettings> settingsRepository, ISettingsRepository<EspressoSettings> moduleSettingsRepository, Func<string, int> ipcMSGCallBackFunc)
|
||||
{
|
||||
// To obtain the general settings configurations of PowerToys Settings.
|
||||
if (settingsRepository == null)
|
||||
|
@ -28,7 +25,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
|||
}
|
||||
|
||||
GeneralSettingsConfig = settingsRepository.SettingsConfig;
|
||||
settingsConfigFileFolder = configFileSubfolder;
|
||||
|
||||
// To obtain the settings configurations of Fancy zones.
|
||||
if (moduleSettingsRepository == null)
|
||||
|
@ -45,7 +41,25 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
|||
// set the callback functions value to hangle outgoing IPC message.
|
||||
SendConfigMSG = ipcMSGCallBackFunc;
|
||||
|
||||
_isEnabled = GeneralSettingsConfig.Enabled.Espresso;
|
||||
IsEnabled = GeneralSettingsConfig.Enabled.Espresso;
|
||||
}
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
set
|
||||
{
|
||||
if (_isEnabled != value)
|
||||
{
|
||||
_isEnabled = value;
|
||||
OnPropertyChanged(nameof(IsEnabled));
|
||||
|
||||
GeneralSettingsConfig.Enabled.Espresso = value;
|
||||
var outgoing = new OutGoingGeneralSettings(GeneralSettingsConfig);
|
||||
|
||||
SendConfigMSG(outgoing.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isEnabled;
|
||||
|
|
|
@ -1179,4 +1179,7 @@ Win + Shift + O to toggle your video</value>
|
|||
<data name="Espresso_EnableDisplayKeepAwake.Header" xml:space="preserve">
|
||||
<value>Keep display on</value>
|
||||
</data>
|
||||
<data name="Espresso_Behavior_GroupSettings.Text" xml:space="preserve">
|
||||
<value>Behavior</value>
|
||||
</data>
|
||||
</root>
|
|
@ -53,38 +53,45 @@
|
|||
HorizontalAlignment="Left"
|
||||
Margin="0,0,48,0"
|
||||
MaxWidth="{StaticResource MaxContentWidth}">
|
||||
<ToggleSwitch x:Uid="Espresso_EnableEspresso" IsOn="True" />
|
||||
<ToggleSwitch x:Uid="Espresso_EnableDisplayKeepAwake" IsOn="True" />
|
||||
<ToggleSwitch x:Uid="Espresso_EnableEspresso" IsOn="{Binding IsEnabled, Mode=TwoWay}" />
|
||||
<!--IsOn="{x:Bind Mode=TwoWay, Path=ViewModel.EnablePowerLauncher}"/>-->
|
||||
|
||||
<!--<TextBlock x:Uid="Shortcuts"
|
||||
<!--<TextBlock x:Uid="Shortcuts"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"
|
||||
Foreground="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher, Converter={StaticResource ModuleEnabledToForegroundConverter}}"/>-->
|
||||
|
||||
<TextBlock x:Uid="FancyZones_Editor_GroupSettings"
|
||||
<TextBlock x:Uid="Espresso_Behavior_GroupSettings"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
||||
<ToggleSwitch x:Uid="Espresso_EnableDisplayKeepAwake"
|
||||
IsEnabled="{Binding IsEnabled}"
|
||||
IsOn="True" />
|
||||
<!--Foreground="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled, Converter={StaticResource ModuleEnabledToForegroundConverter}}"-->
|
||||
<RadioButton x:Uid="Espresso_IndefiniteKeepAwake">
|
||||
<RadioButton.Content>
|
||||
<TextBlock TextWrapping="WrapWholeWords" LineHeight="20">
|
||||
|
||||
<StackPanel Margin="{StaticResource MediumTopMargin}">
|
||||
<RadioButton x:Uid="Espresso_IndefiniteKeepAwake"
|
||||
IsEnabled="{Binding IsEnabled}">
|
||||
<RadioButton.Content>
|
||||
<TextBlock TextWrapping="WrapWholeWords" LineHeight="20">
|
||||
<Run x:Uid="Espresso_IndefiniteKeepAwakeContent"/>
|
||||
<LineBreak/>
|
||||
<Run Foreground="{ThemeResource SystemBaseMediumColor}"
|
||||
x:Uid="Espresso_IndefiniteKeepAwakeDescription"/>
|
||||
</TextBlock>
|
||||
</RadioButton.Content>
|
||||
</RadioButton>
|
||||
<RadioButton x:Uid="Espresso_TemporaryKeepAwake">
|
||||
<RadioButton.Content>
|
||||
<TextBlock TextWrapping="WrapWholeWords" LineHeight="20">
|
||||
</TextBlock>
|
||||
</RadioButton.Content>
|
||||
</RadioButton>
|
||||
<RadioButton x:Uid="Espresso_TemporaryKeepAwake"
|
||||
IsEnabled="{Binding IsEnabled}">
|
||||
<RadioButton.Content>
|
||||
<TextBlock TextWrapping="WrapWholeWords" LineHeight="20">
|
||||
<Run x:Uid="Espresso_TemporaryKeepAwakeContent"/>
|
||||
<LineBreak/>
|
||||
<Run Foreground="{ThemeResource SystemBaseMediumColor}"
|
||||
x:Uid="Espresso_TemporaryKeepAwakeDescription"/>
|
||||
</TextBlock>
|
||||
</RadioButton.Content>
|
||||
</RadioButton>
|
||||
</TextBlock>
|
||||
</RadioButton.Content>
|
||||
</RadioButton>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
<RelativePanel x:Name="SidePanel"
|
||||
HorizontalAlignment="Left"
|
||||
|
@ -136,7 +143,7 @@
|
|||
NavigateUri="https://medium.com/@Niels9001/a-fluent-color-meter-for-powertoys-20407ededf0c">
|
||||
<TextBlock Text="Niels Laute's UX concept" TextWrapping="Wrap" />
|
||||
</HyperlinkButton>
|
||||
|
||||
|
||||
</StackPanel>
|
||||
</RelativePanel>
|
||||
</Grid>
|
||||
|
|
Loading…
Reference in a new issue