mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
Add settings for All Apps (#424)
Expose a couple of the settings for apps as actual settings in the settings UI
This commit is contained in:
@@ -20,6 +20,7 @@ public partial class AllAppsCommandProvider : CommandProvider
|
||||
Id = "AllApps";
|
||||
DisplayName = Resources.installed_apps;
|
||||
Icon = new IconInfo("\ue71d");
|
||||
Settings = AllAppsSettings.Instance.Settings;
|
||||
|
||||
_listItem = new(Page) { Subtitle = Resources.search_installed_apps };
|
||||
}
|
||||
|
||||
@@ -4,12 +4,19 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.CmdPal.Ext.Apps.Programs;
|
||||
using Microsoft.CmdPal.Ext.Apps.Properties;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.Apps;
|
||||
|
||||
public class AllAppsSettings
|
||||
public class AllAppsSettings : JsonSettingsManager
|
||||
{
|
||||
private static readonly string _namespace = "apps";
|
||||
|
||||
private static string Namespaced(string propertyName) => $"{_namespace}.{propertyName}";
|
||||
|
||||
#pragma warning disable SA1401 // Fields should be private
|
||||
internal static AllAppsSettings Instance = new();
|
||||
#pragma warning restore SA1401 // Fields should be private
|
||||
@@ -24,15 +31,63 @@ public class AllAppsSettings
|
||||
|
||||
public List<string> RunCommandSuffixes { get; set; } = new List<string>() { "bat", "appref-ms", "exe", "lnk", "url", "cpl", "msc" };
|
||||
|
||||
public bool EnableStartMenuSource { get; set; } = true;
|
||||
public bool EnableStartMenuSource => _enableStartMenuSource.Value;
|
||||
|
||||
public bool EnableDesktopSource { get; set; } = true;
|
||||
public bool EnableDesktopSource => _enableDesktopSource.Value;
|
||||
|
||||
public bool EnableRegistrySource { get; set; } = true;
|
||||
public bool EnableRegistrySource => _enableRegistrySource.Value;
|
||||
|
||||
public bool EnablePathEnvironmentVariableSource { get; set; } = true;
|
||||
public bool EnablePathEnvironmentVariableSource => _enablePathEnvironmentVariableSource.Value;
|
||||
|
||||
private readonly ToggleSetting _enableStartMenuSource = new(
|
||||
Namespaced(nameof(EnableStartMenuSource)),
|
||||
Resources.enable_start_menu_source,
|
||||
Resources.enable_start_menu_source,
|
||||
true);
|
||||
|
||||
private readonly ToggleSetting _enableDesktopSource = new(
|
||||
Namespaced(nameof(EnableDesktopSource)),
|
||||
Resources.enable_desktop_source,
|
||||
Resources.enable_desktop_source,
|
||||
true);
|
||||
|
||||
private readonly ToggleSetting _enableRegistrySource = new(
|
||||
Namespaced(nameof(EnableRegistrySource)),
|
||||
Resources.enable_registry_source,
|
||||
Resources.enable_registry_source,
|
||||
false); // This one is very noisy
|
||||
|
||||
private readonly ToggleSetting _enablePathEnvironmentVariableSource = new(
|
||||
Namespaced(nameof(EnablePathEnvironmentVariableSource)),
|
||||
Resources.enable_path_environment_variable_source,
|
||||
Resources.enable_path_environment_variable_source,
|
||||
true);
|
||||
|
||||
public double MinScoreThreshold { get; set; } = 0.75;
|
||||
|
||||
internal const char SuffixSeparator = ';';
|
||||
|
||||
internal static string SettingsJsonPath()
|
||||
{
|
||||
var directory = Utilities.BaseSettingsPath("Microsoft.CmdPal");
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
// now, the state is just next to the exe
|
||||
return Path.Combine(directory, "settings.json");
|
||||
}
|
||||
|
||||
public AllAppsSettings()
|
||||
{
|
||||
FilePath = SettingsJsonPath();
|
||||
|
||||
Settings.Add(_enableStartMenuSource);
|
||||
Settings.Add(_enableDesktopSource);
|
||||
Settings.Add(_enableRegistrySource);
|
||||
Settings.Add(_enablePathEnvironmentVariableSource);
|
||||
|
||||
// Load settings from file upon initialization
|
||||
LoadSettings();
|
||||
|
||||
Settings.SettingsChanged += (s, a) => this.SaveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,42 @@ namespace Microsoft.CmdPal.Ext.Apps.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Include apps found on the desktop.
|
||||
/// </summary>
|
||||
internal static string enable_desktop_source {
|
||||
get {
|
||||
return ResourceManager.GetString("enable_desktop_source", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Include apps anywhere on the %PATH%.
|
||||
/// </summary>
|
||||
internal static string enable_path_environment_variable_source {
|
||||
get {
|
||||
return ResourceManager.GetString("enable_path_environment_variable_source", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Include apps registered in the Registry.
|
||||
/// </summary>
|
||||
internal static string enable_registry_source {
|
||||
get {
|
||||
return ResourceManager.GetString("enable_registry_source", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Include apps found in the Start Menu.
|
||||
/// </summary>
|
||||
internal static string enable_start_menu_source {
|
||||
get {
|
||||
return ResourceManager.GetString("enable_start_menu_source", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to File.
|
||||
/// </summary>
|
||||
|
||||
@@ -59,10 +59,7 @@
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root"
|
||||
xmlns=""
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
@@ -172,4 +169,16 @@
|
||||
<data name="run_as_different_user" xml:space="preserve">
|
||||
<value>Run as different user</value>
|
||||
</data>
|
||||
<data name="enable_start_menu_source" xml:space="preserve">
|
||||
<value>Include apps found in the Start Menu</value>
|
||||
</data>
|
||||
<data name="enable_desktop_source" xml:space="preserve">
|
||||
<value>Include apps found on the desktop</value>
|
||||
</data>
|
||||
<data name="enable_registry_source" xml:space="preserve">
|
||||
<value>Include apps registered in the Registry</value>
|
||||
</data>
|
||||
<data name="enable_path_environment_variable_source" xml:space="preserve">
|
||||
<value>Include apps anywhere on the %PATH%</value>
|
||||
</data>
|
||||
</root>
|
||||
Reference in New Issue
Block a user