mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-13 08:08:24 +08:00
c1c14b4f2e
* Init * Fix running settings * UI design * Left click trigger Wire up colorpicker and pt run * Wire up others * Update FlyoutWindow.xaml.cs * Removed comments * Update FlyoutWindow.xaml * More work * Open Settings page * More UI work * Resolve conflicts * [General] SystemTray Flyout: Add update on tray items' visibility when module gets enabled/disabled Also remove context menu opening on tray icon. * Adding app list * Adding more buttons, resolving conflicts * [General] Flyout: improving opening, closing flyout/settings window. Implementing basic bahaviour on enabling/disabling modules. * [General] FlyoutWindow: proceed with implementation. GPO works. Main functionallity works (launching and enabling apps). * [general] flyout: fix exit button * [general] flyout: implement double click handling * Localization * [Generel] Flyout: Re-implement flyout launching, add workaround: disable flyout hiding in case the user switches on modules on the all apps page + minor changes * [general] flyout: restore the context menu when right clicking on system tray icon * Fix spellchecker * [installer] fixing missing dll files + suppress error on not signed script * Fix spell checker * Fix flyout not focusing when activated * Refresh Settings UI enabled state when flyout changes * fix spellcheck * Remove VCM from the list * [General] flyout: fix settings window opening. Switch to general page only if there is no page opened * [general] flyout: add launching hosts app * Fix CI build * adding check on elevation when launching hosts * Use localization strings that already exist * Remove dll not present in arm64 build * Adding GPO policy check for the launcher page items * fix hosts launching * Add telemetry * Also hide from all apps list when gpo is force enabling * fix spellchecker * Improve focus issues * Fix flickering Bitmap Icons * Fix telemetry error * Fix telemetry call * Fix wrong comment --------- Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Laszlo Nemeth <laszlo.nemeth.hu@gmail.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
118 lines
3.8 KiB
C#
118 lines
3.8 KiB
C#
// 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.
|
|
|
|
using System;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
|
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Library
|
|
{
|
|
public class GeneralSettings : ISettingsConfig
|
|
{
|
|
// Gets or sets a value indicating whether run powertoys on start-up.
|
|
[JsonPropertyName("startup")]
|
|
public bool Startup { get; set; }
|
|
|
|
// Gets or sets a value indicating whether the powertoy elevated.
|
|
[JsonPropertyName("is_elevated")]
|
|
public bool IsElevated { get; set; }
|
|
|
|
// Gets or sets a value indicating whether powertoys should run elevated.
|
|
[JsonPropertyName("run_elevated")]
|
|
public bool RunElevated { get; set; }
|
|
|
|
// Gets or sets a value indicating whether is admin.
|
|
[JsonPropertyName("is_admin")]
|
|
public bool IsAdmin { get; set; }
|
|
|
|
// Gets or sets theme Name.
|
|
[JsonPropertyName("theme")]
|
|
public string Theme { get; set; }
|
|
|
|
// Gets or sets system theme name.
|
|
[JsonPropertyName("system_theme")]
|
|
public string SystemTheme { get; set; }
|
|
|
|
// Gets or sets powertoys version number.
|
|
[JsonPropertyName("powertoys_version")]
|
|
public string PowertoysVersion { get; set; }
|
|
|
|
[JsonPropertyName("action_name")]
|
|
public string CustomActionName { get; set; }
|
|
|
|
[JsonPropertyName("enabled")]
|
|
public EnabledModules Enabled { get; set; }
|
|
|
|
[JsonPropertyName("download_updates_automatically")]
|
|
public bool AutoDownloadUpdates { get; set; }
|
|
|
|
public GeneralSettings()
|
|
{
|
|
Startup = false;
|
|
IsAdmin = false;
|
|
IsElevated = false;
|
|
AutoDownloadUpdates = false;
|
|
Theme = "system";
|
|
SystemTheme = "light";
|
|
try
|
|
{
|
|
PowertoysVersion = DefaultPowertoysVersion();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Logger.LogError("Exception encountered when getting PowerToys version", e);
|
|
PowertoysVersion = "v0.0.0";
|
|
}
|
|
|
|
Enabled = new EnabledModules();
|
|
CustomActionName = string.Empty;
|
|
}
|
|
|
|
// converts the current to a json string.
|
|
public string ToJsonString()
|
|
{
|
|
return JsonSerializer.Serialize(this);
|
|
}
|
|
|
|
private static string DefaultPowertoysVersion()
|
|
{
|
|
return interop.CommonManaged.GetProductVersion();
|
|
}
|
|
|
|
// This function is to implement the ISettingsConfig interface.
|
|
// This interface helps in getting the settings configurations.
|
|
public string GetModuleName()
|
|
{
|
|
// The SettingsUtils functions access general settings when the module name is an empty string.
|
|
return string.Empty;
|
|
}
|
|
|
|
public bool UpgradeSettingsConfiguration()
|
|
{
|
|
try
|
|
{
|
|
if (Helper.CompareVersions(PowertoysVersion, Helper.GetProductVersion()) != 0)
|
|
{
|
|
// Update settings
|
|
PowertoysVersion = Helper.GetProductVersion();
|
|
return true;
|
|
}
|
|
}
|
|
catch (FormatException)
|
|
{
|
|
// If there is an issue with the version number format, don't migrate settings.
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public void AddEnabledModuleChangeNotification(Action callBack)
|
|
{
|
|
Enabled.AddEnabledModuleChangeNotification(callBack);
|
|
}
|
|
}
|
|
}
|