Simplify settings handling to not rely on complex properties

This commit is contained in:
Den Delimarsky
2021-05-11 21:41:07 -07:00
parent 65ecfd2424
commit d566d0bdf0
5 changed files with 34 additions and 35 deletions

View File

@@ -10,23 +10,23 @@ namespace Microsoft.PowerToys.Settings.UI.Library
{
public EspressoProperties()
{
KeepDisplayOn = new BoolProperty();
KeepDisplayOn = false;
Mode = EspressoMode.INDEFINITE;
Hours = new IntProperty();
Minutes = new IntProperty();
Hours = 0;
Minutes = 0;
}
[JsonPropertyName("espresso_keep_display_on")]
public BoolProperty KeepDisplayOn { get; set; }
public bool KeepDisplayOn { get; set; }
[JsonPropertyName("espresso_mode")]
public EspressoMode Mode { get; set; }
[JsonPropertyName("espresso_hours")]
public IntProperty Hours { get; set; }
public uint Hours { get; set; }
[JsonPropertyName("espresso_minutes")]
public IntProperty Minutes { get; set; }
public uint Minutes { get; set; }
}
public enum EspressoMode

View File

@@ -36,10 +36,10 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
Settings = moduleSettingsRepository.SettingsConfig;
_isEnabled = GeneralSettingsConfig.Enabled.Espresso;
_keepDisplayOn = Settings.Properties.KeepDisplayOn.Value;
_keepDisplayOn = Settings.Properties.KeepDisplayOn;
_mode = Settings.Properties.Mode;
_hours = Settings.Properties.Hours.Value;
_minutes = Settings.Properties.Minutes.Value;
_hours = Settings.Properties.Hours;
_minutes = Settings.Properties.Minutes;
// set the callback functions value to hangle outgoing IPC message.
SendConfigMSG = ipcMSGCallBackFunc;
@@ -89,13 +89,12 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
_keepDisplayOn = value;
OnPropertyChanged(nameof(KeepDisplayOn));
Settings.Properties.KeepDisplayOn = new BoolProperty(value);
NotifyPropertyChanged();
Settings.Properties.KeepDisplayOn = value;
}
}
}
public int Hours
public uint Hours
{
get => _hours;
set
@@ -105,13 +104,13 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
_hours = value;
OnPropertyChanged(nameof(Hours));
Settings.Properties.Hours = new IntProperty(value);
Settings.Properties.Hours = value;
NotifyPropertyChanged();
}
}
}
public int Minutes
public uint Minutes
{
get => _minutes;
set
@@ -121,7 +120,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
_minutes = value;
OnPropertyChanged(nameof(Minutes));
Settings.Properties.Minutes = new IntProperty(value);
Settings.Properties.Minutes = value;
NotifyPropertyChanged();
}
}
@@ -141,8 +140,8 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
}
private bool _isEnabled;
private int _hours;
private int _minutes;
private uint _hours;
private uint _minutes;
private bool _keepDisplayOn;
private EspressoMode _mode;
}