2020-04-08 01:19:14 +08:00
|
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
|
2020-03-25 10:55:02 +08:00
|
|
|
|
using System.Text.Json;
|
2020-04-17 02:45:27 +08:00
|
|
|
|
using System.Text.Json.Serialization;
|
2020-03-25 10:55:02 +08:00
|
|
|
|
|
2020-04-02 21:08:56 +08:00
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Lib
|
2020-03-25 10:55:02 +08:00
|
|
|
|
{
|
|
|
|
|
public class GeneralSettings
|
|
|
|
|
{
|
2020-04-08 01:19:14 +08:00
|
|
|
|
// Gets or sets a value indicating whether packaged.
|
2020-04-17 02:45:27 +08:00
|
|
|
|
[JsonPropertyName("packaged")]
|
2020-04-08 01:19:14 +08:00
|
|
|
|
public bool Packaged { get; set; }
|
|
|
|
|
|
|
|
|
|
// Gets or sets a value indicating whether run powertoys on start-up.
|
2020-04-17 02:45:27 +08:00
|
|
|
|
[JsonPropertyName("startup")]
|
|
|
|
|
public bool Startup { get; set; }
|
2020-04-08 01:19:14 +08:00
|
|
|
|
|
|
|
|
|
// Gets or sets a value indicating whether the powertoy elevated.
|
2020-04-17 02:45:27 +08:00
|
|
|
|
[JsonPropertyName("is_elevated")]
|
|
|
|
|
public bool IsElevated { get; set; }
|
2020-04-08 01:19:14 +08:00
|
|
|
|
|
|
|
|
|
// Gets or sets a value indicating whether powertoys should run elevated.
|
2020-04-17 02:45:27 +08:00
|
|
|
|
[JsonPropertyName("run_elevated")]
|
|
|
|
|
public bool RunElevated { get; set; }
|
2020-04-08 01:19:14 +08:00
|
|
|
|
|
|
|
|
|
// Gets or sets a value indicating whether is admin.
|
2020-04-17 02:45:27 +08:00
|
|
|
|
[JsonPropertyName("is_admin")]
|
|
|
|
|
public bool IsAdmin { get; set; }
|
2020-04-08 01:19:14 +08:00
|
|
|
|
|
|
|
|
|
// Gets or sets theme Name.
|
2020-04-17 02:45:27 +08:00
|
|
|
|
[JsonPropertyName("theme")]
|
|
|
|
|
public string Theme { get; set; }
|
2020-04-08 01:19:14 +08:00
|
|
|
|
|
|
|
|
|
// Gets or sets system theme name.
|
2020-04-17 02:45:27 +08:00
|
|
|
|
[JsonPropertyName("system_theme")]
|
|
|
|
|
public string SystemTheme { get; set; }
|
2020-04-08 01:19:14 +08:00
|
|
|
|
|
|
|
|
|
// Gets or sets powertoys version number.
|
2020-04-17 02:45:27 +08:00
|
|
|
|
[JsonPropertyName("powertoys_version")]
|
|
|
|
|
public string PowertoysVersion { get; set; }
|
|
|
|
|
|
2020-05-03 18:17:06 +08:00
|
|
|
|
[JsonPropertyName("action_name")]
|
|
|
|
|
public string CustomActionName { get; set; }
|
|
|
|
|
|
2020-04-17 02:45:27 +08:00
|
|
|
|
[JsonPropertyName("enabled")]
|
|
|
|
|
public EnabledModules Enabled { get; set; }
|
2020-03-25 10:55:02 +08:00
|
|
|
|
|
2020-05-03 18:17:06 +08:00
|
|
|
|
[JsonPropertyName("download_updates_automatically")]
|
|
|
|
|
public bool AutoDownloadUpdates { get; set; }
|
|
|
|
|
|
2020-03-30 20:38:03 +08:00
|
|
|
|
public GeneralSettings()
|
|
|
|
|
{
|
2020-04-17 02:45:27 +08:00
|
|
|
|
this.Packaged = false;
|
|
|
|
|
this.Startup = false;
|
|
|
|
|
this.IsAdmin = false;
|
|
|
|
|
this.IsElevated = false;
|
2020-05-03 18:17:06 +08:00
|
|
|
|
this.AutoDownloadUpdates = false;
|
2020-04-17 02:45:27 +08:00
|
|
|
|
this.Theme = "system";
|
|
|
|
|
this.SystemTheme = "light";
|
2020-05-06 07:01:55 +08:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
this.PowertoysVersion = DefaultPowertoysVersion();
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
this.PowertoysVersion = "v0.0.0";
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-17 02:45:27 +08:00
|
|
|
|
this.Enabled = new EnabledModules();
|
2020-05-03 18:17:06 +08:00
|
|
|
|
this.CustomActionName = string.Empty;
|
2020-03-30 20:38:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-08 01:19:14 +08:00
|
|
|
|
// converts the current to a json string.
|
2020-04-02 21:08:56 +08:00
|
|
|
|
public string ToJsonString()
|
2020-03-25 10:55:02 +08:00
|
|
|
|
{
|
|
|
|
|
return JsonSerializer.Serialize(this);
|
|
|
|
|
}
|
2020-05-06 07:01:55 +08:00
|
|
|
|
|
|
|
|
|
private string DefaultPowertoysVersion()
|
|
|
|
|
{
|
|
|
|
|
return interop.CommonManaged.GetProductVersion();
|
|
|
|
|
}
|
2020-03-25 10:55:02 +08:00
|
|
|
|
}
|
|
|
|
|
}
|