🧼 PowerToys Awake (#11593)

* Scrubbing name conventions

* Fix naming for projects

* Fix folder naming

* More folder cleanup

* More left-over file changes

* Reverting LCL files, because these will be handled by the loc team

* Remove legacy file that is no longer used.

* Update latest
This commit is contained in:
Den Delimarsky
2021-06-09 09:13:58 -07:00
committed by GitHub
parent c9c54b7780
commit c5e464a704
49 changed files with 272 additions and 271 deletions

View File

@@ -6,30 +6,30 @@ using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Library
{
public class EspressoProperties
public class AwakeProperties
{
public EspressoProperties()
public AwakeProperties()
{
KeepDisplayOn = false;
Mode = EspressoMode.PASSIVE;
Mode = AwakeMode.PASSIVE;
Hours = 0;
Minutes = 0;
}
[JsonPropertyName("espresso_keep_display_on")]
[JsonPropertyName("awake_keep_display_on")]
public bool KeepDisplayOn { get; set; }
[JsonPropertyName("espresso_mode")]
public EspressoMode Mode { get; set; }
[JsonPropertyName("awake_mode")]
public AwakeMode Mode { get; set; }
[JsonPropertyName("espresso_hours")]
[JsonPropertyName("awake_hours")]
public uint Hours { get; set; }
[JsonPropertyName("espresso_minutes")]
[JsonPropertyName("awake_minutes")]
public uint Minutes { get; set; }
}
public enum EspressoMode
public enum AwakeMode
{
PASSIVE = 0,
INDEFINITE = 1,

View File

@@ -7,20 +7,20 @@ using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
namespace Microsoft.PowerToys.Settings.UI.Library
{
public class EspressoSettings : BasePTModuleSettings, ISettingsConfig
public class AwakeSettings : BasePTModuleSettings, ISettingsConfig
{
public const string ModuleName = "Espresso";
public const string ModuleName = "Awake";
public const string ModuleVersion = "0.0.1";
public EspressoSettings()
public AwakeSettings()
{
Name = ModuleName;
Version = ModuleVersion;
Properties = new EspressoProperties();
Properties = new AwakeProperties();
}
[JsonPropertyName("properties")]
public EspressoProperties Properties { get; set; }
public AwakeProperties Properties { get; set; }
public string GetModuleName()
{

View File

@@ -143,18 +143,18 @@ namespace Microsoft.PowerToys.Settings.UI.Library
}
}
private bool espresso;
private bool awake;
[JsonPropertyName("Espresso")]
public bool Espresso
[JsonPropertyName("Awake")]
public bool Awake
{
get => espresso;
get => awake;
set
{
if (espresso != value)
if (awake != value)
{
LogTelemetryEvent(value);
espresso = value;
awake = value;
}
}
}

View File

@@ -2,24 +2,21 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Library
{
public class SndEspressoSettings
public class SndAwakeSettings
{
[JsonPropertyName("Espresso")]
public EspressoSettings Settings { get; set; }
[JsonPropertyName("Awake")]
public AwakeSettings Settings { get; set; }
public SndEspressoSettings()
public SndAwakeSettings()
{
}
public SndEspressoSettings(EspressoSettings settings)
public SndAwakeSettings(AwakeSettings settings)
{
Settings = settings;
}

View File

@@ -9,15 +9,15 @@ using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
{
public class EspressoViewModel : Observable
public class AwakeViewModel : Observable
{
private GeneralSettings GeneralSettingsConfig { get; set; }
private EspressoSettings Settings { get; set; }
private AwakeSettings Settings { get; set; }
private Func<string, int> SendConfigMSG { get; }
public EspressoViewModel(ISettingsRepository<GeneralSettings> settingsRepository, ISettingsRepository<EspressoSettings> moduleSettingsRepository, Func<string, int> ipcMSGCallBackFunc)
public AwakeViewModel(ISettingsRepository<GeneralSettings> settingsRepository, ISettingsRepository<AwakeSettings> moduleSettingsRepository, Func<string, int> ipcMSGCallBackFunc)
{
// To obtain the general settings configurations of PowerToys Settings.
if (settingsRepository == null)
@@ -35,7 +35,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
Settings = moduleSettingsRepository.SettingsConfig;
_isEnabled = GeneralSettingsConfig.Enabled.Espresso;
_isEnabled = GeneralSettingsConfig.Enabled.Awake;
_keepDisplayOn = Settings.Properties.KeepDisplayOn;
_mode = Settings.Properties.Mode;
_hours = Settings.Properties.Hours;
@@ -54,7 +54,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
{
_isEnabled = value;
GeneralSettingsConfig.Enabled.Espresso = value;
GeneralSettingsConfig.Enabled.Awake = value;
OnPropertyChanged(nameof(IsEnabled));
OnPropertyChanged(nameof(IsTimeConfigurationEnabled));
@@ -67,10 +67,10 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
public bool IsTimeConfigurationEnabled
{
get => _mode == EspressoMode.TIMED && _isEnabled;
get => _mode == AwakeMode.TIMED && _isEnabled;
}
public EspressoMode Mode
public AwakeMode Mode
{
get => _mode;
set
@@ -140,8 +140,8 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
OnPropertyChanged(propertyName);
if (SendConfigMSG != null)
{
SndEspressoSettings outsettings = new SndEspressoSettings(Settings);
SndModuleSettings<SndEspressoSettings> ipcMessage = new SndModuleSettings<SndEspressoSettings>(outsettings);
SndAwakeSettings outsettings = new SndAwakeSettings(Settings);
SndModuleSettings<SndAwakeSettings> ipcMessage = new SndModuleSettings<SndAwakeSettings>(outsettings);
var targetMessage = ipcMessage.ToJsonString();
SendConfigMSG(targetMessage);
@@ -152,6 +152,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
private uint _hours;
private uint _minutes;
private bool _keepDisplayOn;
private EspressoMode _mode;
private AwakeMode _mode;
}
}