mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-01-11 14:56:48 +01:00
Abstracting core settings out
This commit is contained in:
@@ -32,9 +32,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MastodonExtension", "extens
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Built-in Extensions", "Built-in Extensions", "{272D0E9A-8FC3-49F5-8FAD-79ABAE8AB1E4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CmdPal.Ext.Bookmarks", "src\Exts\Microsoft.CmdPal.Ext.Bookmark\Microsoft.CmdPal.Ext.Bookmarks.csproj", "{C5BADA22-70FF-41D1-9529-28F4891316A8}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CmdPal.Ext.Calc", "src\Exts\Microsoft.CmdPal.Ext.Calc\Microsoft.CmdPal.Ext.Calc.csproj", "{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CmdPal.Ext.Bookmarks", "src\Exts\Microsoft.CmdPal.Ext.Bookmark\Microsoft.CmdPal.Ext.Bookmarks.csproj", "{C5BADA22-70FF-41D1-9529-28F4891316A8}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CmdPal.Ext.Settings", "src\Exts\Microsoft.CmdPal.Ext.CmdPalSettings\Microsoft.CmdPal.Ext.Settings.csproj", "{7F6796A4-4233-4CEC-914F-95EC7A5283A0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -144,14 +146,6 @@ Global
|
||||
{65E22130-6A8F-4AB7-80EC-FF75475DE821}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{65E22130-6A8F-4AB7-80EC-FF75475DE821}.Release|x64.ActiveCfg = Release|x64
|
||||
{65E22130-6A8F-4AB7-80EC-FF75475DE821}.Release|x64.Build.0 = Release|x64
|
||||
{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4}.Debug|x64.Build.0 = Debug|x64
|
||||
{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4}.Release|x64.ActiveCfg = Release|x64
|
||||
{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4}.Release|x64.Build.0 = Release|x64
|
||||
{C5BADA22-70FF-41D1-9529-28F4891316A8}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{C5BADA22-70FF-41D1-9529-28F4891316A8}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{C5BADA22-70FF-41D1-9529-28F4891316A8}.Debug|x64.ActiveCfg = Debug|x64
|
||||
@@ -160,6 +154,22 @@ Global
|
||||
{C5BADA22-70FF-41D1-9529-28F4891316A8}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{C5BADA22-70FF-41D1-9529-28F4891316A8}.Release|x64.ActiveCfg = Release|x64
|
||||
{C5BADA22-70FF-41D1-9529-28F4891316A8}.Release|x64.Build.0 = Release|x64
|
||||
{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4}.Debug|x64.Build.0 = Debug|x64
|
||||
{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4}.Release|x64.ActiveCfg = Release|x64
|
||||
{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4}.Release|x64.Build.0 = Release|x64
|
||||
{7F6796A4-4233-4CEC-914F-95EC7A5283A0}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{7F6796A4-4233-4CEC-914F-95EC7A5283A0}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{7F6796A4-4233-4CEC-914F-95EC7A5283A0}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{7F6796A4-4233-4CEC-914F-95EC7A5283A0}.Debug|x64.Build.0 = Debug|x64
|
||||
{7F6796A4-4233-4CEC-914F-95EC7A5283A0}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{7F6796A4-4233-4CEC-914F-95EC7A5283A0}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{7F6796A4-4233-4CEC-914F-95EC7A5283A0}.Release|x64.ActiveCfg = Release|x64
|
||||
{7F6796A4-4233-4CEC-914F-95EC7A5283A0}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -176,8 +186,9 @@ Global
|
||||
{9456257A-3292-4A8D-AF63-9830EABE7ED2} = {B7FF739F-7716-4FC3-B622-705486187B87}
|
||||
{EB13FDBD-7DD5-4E7E-8BEB-727B3C9331CB} = {B7FF739F-7716-4FC3-B622-705486187B87}
|
||||
{65E22130-6A8F-4AB7-80EC-FF75475DE821} = {B7FF739F-7716-4FC3-B622-705486187B87}
|
||||
{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4} = {272D0E9A-8FC3-49F5-8FAD-79ABAE8AB1E4}
|
||||
{C5BADA22-70FF-41D1-9529-28F4891316A8} = {272D0E9A-8FC3-49F5-8FAD-79ABAE8AB1E4}
|
||||
{42DB35EE-1EDB-41E4-9C9F-A3520EBC5CC4} = {272D0E9A-8FC3-49F5-8FAD-79ABAE8AB1E4}
|
||||
{7F6796A4-4233-4CEC-914F-95EC7A5283A0} = {272D0E9A-8FC3-49F5-8FAD-79ABAE8AB1E4}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {BC94BFC2-A741-4978-B6A4-9E01B7660E6B}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\..\..\..\Common.Dotnet.CsWinRT.props" />
|
||||
<PropertyGroup>
|
||||
<RootNamespace>Microsoft.CmdPal.Ext.Settings</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\extensionsdk\Microsoft.Windows.CommandPalette.Extensions.Helpers\Microsoft.CmdPal.Extensions.Helpers.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,31 @@
|
||||
// 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 Microsoft.Windows.CommandPalette.Extensions;
|
||||
using Microsoft.Windows.CommandPalette.Extensions.Helpers;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.Settings;
|
||||
|
||||
public class SettingsActionProvider : ICommandProvider
|
||||
{
|
||||
public string DisplayName => $"Settings";
|
||||
|
||||
private readonly SettingsPage settingsPage = new();
|
||||
|
||||
public SettingsActionProvider()
|
||||
{
|
||||
}
|
||||
|
||||
public IconDataType Icon => new(string.Empty);
|
||||
|
||||
#pragma warning disable CA1816 // Dispose methods should call SuppressFinalize
|
||||
public void Dispose() => throw new NotImplementedException();
|
||||
#pragma warning restore CA1816 // Dispose methods should call SuppressFinalize
|
||||
|
||||
public IListItem[] TopLevelCommands()
|
||||
{
|
||||
return [new ListItem(settingsPage) { Subtitle = "CmdPal settings" }];
|
||||
}
|
||||
}
|
||||
@@ -2,30 +2,11 @@
|
||||
// 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.Nodes;
|
||||
using Microsoft.CmdPal.Common.Contracts;
|
||||
using Microsoft.CmdPal.Common.Extensions;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.Windows.CommandPalette.Extensions;
|
||||
using Microsoft.Windows.CommandPalette.Extensions.Helpers;
|
||||
|
||||
// To learn more about WinUI, the WinUI project structure,
|
||||
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
||||
|
||||
namespace WindowsCommandPalette.Builtins;
|
||||
|
||||
internal sealed class SettingsPage : FormPage
|
||||
{
|
||||
private readonly SettingsForm _settings = new();
|
||||
|
||||
public override IForm[] Forms() => [_settings];
|
||||
|
||||
public SettingsPage()
|
||||
{
|
||||
Icon = new("\uE713");
|
||||
Name = "Settings";
|
||||
}
|
||||
}
|
||||
namespace Microsoft.CmdPal.Ext.Settings;
|
||||
|
||||
internal sealed class SettingsForm : Form
|
||||
{
|
||||
@@ -76,23 +57,17 @@ internal sealed class SettingsForm : Form
|
||||
|
||||
public override string DataJson()
|
||||
{
|
||||
var t = GetSettingsDataJson();
|
||||
t.ConfigureAwait(false);
|
||||
return t.Result;
|
||||
return GetSettingsDataJson();
|
||||
|
||||
// var t = GetSettingsDataJson();
|
||||
// t.ConfigureAwait(false);
|
||||
// return t.Result;
|
||||
}
|
||||
|
||||
private static async Task<string> GetSettingsDataJson()
|
||||
private static string GetSettingsDataJson()
|
||||
{
|
||||
|
||||
var hotkey = "win+ctrl+.";
|
||||
try
|
||||
{
|
||||
hotkey = await Application.Current.GetService<ILocalSettingsService>().ReadSettingAsync<string>("GlobalHotkey");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_ = ex.Message;
|
||||
}
|
||||
|
||||
return $$"""
|
||||
{
|
||||
"hotkey": "{{hotkey}}"
|
||||
@@ -109,32 +84,8 @@ internal sealed class SettingsForm : Form
|
||||
{
|
||||
return ActionResult.GoHome();
|
||||
}
|
||||
Application.Current.GetService<ILocalSettingsService>().SaveSettingAsync("GlobalHotkey", formInput["hotkey"]?.ToString() ?? string.Empty);
|
||||
|
||||
// Application.Current.GetService<ILocalSettingsService>().SaveSettingAsync("GlobalHotkey", formInput["hotkey"]?.ToString() ?? string.Empty);
|
||||
return ActionResult.GoHome();
|
||||
}
|
||||
}
|
||||
|
||||
public class SettingsActionProvider : ICommandProvider
|
||||
{
|
||||
public string DisplayName => $"Settings";
|
||||
|
||||
private readonly SettingsPage settingsPage = new();
|
||||
|
||||
public SettingsActionProvider()
|
||||
{
|
||||
}
|
||||
|
||||
public IconDataType Icon => new(string.Empty);
|
||||
|
||||
#pragma warning disable CA1816 // Dispose methods should call SuppressFinalize
|
||||
public void Dispose() => throw new NotImplementedException();
|
||||
#pragma warning restore CA1816 // Dispose methods should call SuppressFinalize
|
||||
|
||||
|
||||
public IListItem[] TopLevelCommands()
|
||||
{
|
||||
return [new ListItem(settingsPage) { Subtitle = "CmdPal settings" }];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// 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 Microsoft.Windows.CommandPalette.Extensions;
|
||||
using Microsoft.Windows.CommandPalette.Extensions.Helpers;
|
||||
|
||||
// To learn more about WinUI, the WinUI project structure,
|
||||
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
||||
namespace Microsoft.CmdPal.Ext.Settings;
|
||||
|
||||
internal sealed class SettingsPage : FormPage
|
||||
{
|
||||
private readonly SettingsForm _settings = new();
|
||||
|
||||
public override IForm[] Forms() => [_settings];
|
||||
|
||||
public SettingsPage()
|
||||
{
|
||||
Icon = new("\uE713");
|
||||
Name = "Settings";
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,12 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="Builtins\NewFolder\**" />
|
||||
<EmbeddedResource Remove="Builtins\NewFolder\**" />
|
||||
<None Remove="Builtins\NewFolder\**" />
|
||||
<Page Remove="Builtins\NewFolder\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||
@@ -71,6 +77,7 @@
|
||||
<ProjectReference Include="..\..\extensionsdk\Microsoft.Windows.CommandPalette.Extensions.Helpers\Microsoft.CmdPal.Extensions.Helpers.csproj" />
|
||||
<ProjectReference Include="..\Exts\Microsoft.CmdPal.Ext.Bookmark\Microsoft.CmdPal.Ext.Bookmarks.csproj" />
|
||||
<ProjectReference Include="..\Exts\Microsoft.CmdPal.Ext.Calc\Microsoft.CmdPal.Ext.Calc.csproj" />
|
||||
<ProjectReference Include="..\Exts\Microsoft.CmdPal.Ext.CmdPalSettings\Microsoft.CmdPal.Ext.Settings.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.CmdPal.Common\Microsoft.CmdPal.Common.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.Terminal.UI\Microsoft.Terminal.UI.vcxproj">
|
||||
<ReferenceOutputAssembly>True</ReferenceOutputAssembly>
|
||||
@@ -106,6 +113,9 @@
|
||||
<Copy SourceFiles="$(PkgAdaptiveCards_ObjectModel_WinUI3)\runtimes\win10-$(Platform)\native\AdaptiveCards.ObjectModel.WinUI3.dll" DestinationFolder="$(TargetDir)" />
|
||||
<Copy SourceFiles="$(PkgAdaptiveCards_Rendering_WinUI3)\runtimes\win10-$(Platform)\native\AdaptiveCards.Rendering.WinUI3.dll" DestinationFolder="$(TargetDir)" />
|
||||
</Target>
|
||||
<ItemGroup>
|
||||
<PRIResource Remove="Builtins\NewFolder\**" />
|
||||
</ItemGroup>
|
||||
<!-- </AdaptiveCardsWorkaround> -->
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -19,7 +19,6 @@ using Windows.Foundation;
|
||||
using Windows.Win32;
|
||||
using WindowsCommandPalette.BuiltinCommands;
|
||||
using WindowsCommandPalette.BuiltinCommands.AllApps;
|
||||
using WindowsCommandPalette.Builtins;
|
||||
|
||||
namespace WindowsCommandPalette.Views;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ using Microsoft.CmdPal.Common.Extensions;
|
||||
using Microsoft.CmdPal.Common.Services;
|
||||
using Microsoft.CmdPal.Ext.Bookmarks;
|
||||
using Microsoft.CmdPal.Ext.Calc;
|
||||
using Microsoft.CmdPal.Ext.Settings;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
@@ -21,7 +22,6 @@ using Windows.Foundation;
|
||||
using Windows.Win32;
|
||||
using WindowsCommandPalette.BuiltinCommands;
|
||||
using WindowsCommandPalette.BuiltinCommands.AllApps;
|
||||
using WindowsCommandPalette.Builtins;
|
||||
|
||||
namespace WindowsCommandPalette.Views;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user