Skip to content

Commit 28efaa8

Browse files
authored
Settings in a window (microsoft#361)
- Settings are now in a window. - Moved pages into a separate pages folder We probably want to split up the extensions vs. general VMs, but we can do that later once we figured out what the Settings pages should look like. Related to microsoft#80
1 parent 62e99fb commit 28efaa8

19 files changed

+483
-294
lines changed

src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<!-- Other merged dictionaries here -->
1212
<ResourceDictionary Source="Styles/Button.xaml" />
1313
<ResourceDictionary Source="Styles/TextBox.xaml" />
14+
<ResourceDictionary Source="Styles/Settings.xaml" />
1415
<ResourceDictionary Source="Controls/Tag.xaml" />
1516
<ResourceDictionary Source="Controls/KeyVisual/KeyVisual.xaml" />
1617
</ResourceDictionary.MergedDictionaries>

src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/ShortcutDialogContentControl.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public List<object> Keys
2121
set { SetValue(KeysProperty, value); }
2222
}
2323

24-
public static readonly DependencyProperty KeysProperty = DependencyProperty.Register("Keys", typeof(List<object>), typeof(SettingsPage), new PropertyMetadata(default(string)));
24+
public static readonly DependencyProperty KeysProperty = DependencyProperty.Register("Keys", typeof(List<object>), typeof(ShortcutDialogContentControl), new PropertyMetadata(default(string)));
2525

2626
public bool IsError
2727
{

src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6-
xmlns:local="using:Microsoft.CmdPal.UI"
76
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:pages="using:Microsoft.CmdPal.UI.Pages"
88
xmlns:viewmodels="using:Microsoft.CmdPal.UI.ViewModels"
99
Activated="MainWindow_Activated"
1010
Closed="MainWindow_Closed"
1111
mc:Ignorable="d">
1212

13-
<local:ShellPage x:Name="RootShellPage" />
13+
<pages:ShellPage x:Name="RootShellPage" />
1414
</Window>

src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Runtime.InteropServices;
66
using CommunityToolkit.Mvvm.Messaging;
77
using Microsoft.CmdPal.Common.Services;
8+
using Microsoft.CmdPal.UI.Pages;
89
using Microsoft.CmdPal.UI.ViewModels;
910
using Microsoft.CmdPal.UI.ViewModels.Messages;
1011
using Microsoft.CmdPal.UI.ViewModels.Settings;

src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj

+24-4
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@
3939
<None Remove="ListDetailPage.xaml" />
4040
<None Remove="LoadingPage.xaml" />
4141
<None Remove="MainPage.xaml" />
42+
<None Remove="Pages\Settings\ExtensionsPage.xaml" />
43+
<None Remove="Pages\Settings\GeneralPage.xaml" />
44+
<None Remove="SettingsWindow.xaml" />
4245
<None Remove="ShellPage.xaml" />
43-
<None Remove="SettingsPage.xaml" />
4446
<None Remove="Styles\Button.xaml" />
47+
<None Remove="Styles\Settings.xaml" />
4548
<None Remove="Styles\TextBox.xaml" />
4649
</ItemGroup>
4750

@@ -129,9 +132,6 @@
129132
<Page Update="MainPage.xaml">
130133
<Generator>MSBuild:Compile</Generator>
131134
</Page>
132-
<Page Update="SettingsPage.xaml">
133-
<Generator>MSBuild:Compile</Generator>
134-
</Page>
135135
<Page Update="Controls\SearchBar.xaml">
136136
<Generator>MSBuild:Compile</Generator>
137137
</Page>
@@ -163,6 +163,26 @@
163163
<Content Include="$(PkgAdaptiveCards_ObjectModel_WinUI3)\$(AdaptiveCardsNative)\AdaptiveCards.ObjectModel.WinUI3.dll" Link="AdaptiveCards.ObjectModel.WinUI3.dll" CopyToOutputDirectory="PreserveNewest" />
164164
<Content Include="$(PkgAdaptiveCards_Rendering_WinUI3)\$(AdaptiveCardsNative)\AdaptiveCards.Rendering.WinUI3.dll" Link="AdaptiveCards.Rendering.WinUI3.dll" CopyToOutputDirectory="PreserveNewest" />
165165
</ItemGroup>
166+
<ItemGroup>
167+
<Page Update="Styles\Settings.xaml">
168+
<Generator>MSBuild:Compile</Generator>
169+
</Page>
170+
</ItemGroup>
171+
<ItemGroup>
172+
<Page Update="Pages\Settings\ExtensionsPage.xaml">
173+
<Generator>MSBuild:Compile</Generator>
174+
</Page>
175+
</ItemGroup>
176+
<ItemGroup>
177+
<Page Update="SettingsWindow.xaml">
178+
<Generator>MSBuild:Compile</Generator>
179+
</Page>
180+
</ItemGroup>
181+
<ItemGroup>
182+
<Page Update="Pages\Settings\GeneralPage.xaml">
183+
<Generator>MSBuild:Compile</Generator>
184+
</Page>
185+
</ItemGroup>
166186
<!-- </AdaptiveCardsWorkaround> -->
167187

168188
</Project>

src/modules/cmdpal/Microsoft.CmdPal.UI/LoadingPage.xaml src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/LoadingPage.xaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<Page
3-
x:Class="Microsoft.CmdPal.UI.LoadingPage"
3+
x:Class="Microsoft.CmdPal.UI.Pages.LoadingPage"
44
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
55
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
66
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7-
xmlns:local="using:Microsoft.CmdPal.UI"
87
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
98
mc:Ignorable="d">
109

src/modules/cmdpal/Microsoft.CmdPal.UI/LoadingPage.xaml.cs src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/LoadingPage.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using Microsoft.UI.Xaml.Controls;
88
using Microsoft.UI.Xaml.Navigation;
99

10-
namespace Microsoft.CmdPal.UI;
10+
namespace Microsoft.CmdPal.UI.Pages;
1111

1212
/// <summary>
1313
/// We use this page to do initialization of our extensions and cache loading to hydrate our ViewModels.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<Page
3+
x:Class="Microsoft.CmdPal.UI.Pages.ExtensionsPage"
4+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6+
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
7+
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
8+
xmlns:cpcontrols="using:Microsoft.CmdPal.UI.Controls"
9+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
10+
xmlns:helpers="using:Microsoft.CmdPal.UI.Helpers"
11+
xmlns:local="using:Microsoft.CmdPal.UI.Pages"
12+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
13+
xmlns:ui="using:CommunityToolkit.WinUI"
14+
xmlns:viewmodels="using:Microsoft.CmdPal.UI.ViewModels"
15+
mc:Ignorable="d">
16+
17+
<Grid>
18+
<Grid.RowDefinitions>
19+
<RowDefinition Height="Auto" />
20+
<RowDefinition Height="*" />
21+
</Grid.RowDefinitions>
22+
<TextBlock
23+
MaxWidth="1000"
24+
Style="{StaticResource TitleTextBlockStyle}"
25+
Text="Extensions" />
26+
<ScrollViewer Grid.Row="1" Padding="0,0,8,0">
27+
<Grid Padding="8,16,8,8">
28+
<StackPanel
29+
MaxWidth="1000"
30+
HorizontalAlignment="Stretch"
31+
Spacing="{StaticResource SettingsCardSpacing}">
32+
33+
<ItemsRepeater ItemsSource="{x:Bind viewModel.CommandProviders, Mode=OneWay}" Layout="{StaticResource VerticalStackLayout}">
34+
<ItemsRepeater.ItemTemplate>
35+
<DataTemplate x:DataType="viewmodels:ProviderSettingsViewModel">
36+
<controls:SettingsCard ContentAlignment="Left" IsClickEnabled="True">
37+
<!--
38+
What we're doing here is 90% stupid.
39+
40+
The SettingsCard APIs only explicitly allow an
41+
Icon as the content for the HeaderIcon property.
42+
We of course, have to do the goofy async IconBox thing.
43+
44+
To manage this, we have to basically re-create
45+
the layout of the SettingsCard HeaderIcon,
46+
Header & Description, all within the Content.
47+
48+
Most of what follows is lifted directly from
49+
https://github.com/CommunityToolkit/Windows/blob/main/components/SettingsControls/src/SettingsCard/SettingsCard.xaml
50+
-->
51+
<Grid Margin="0,-12,0,0" HorizontalAlignment="Stretch">
52+
<Grid.RowDefinitions>
53+
<RowDefinition Height="*" />
54+
<RowDefinition Height="Auto" />
55+
</Grid.RowDefinitions>
56+
<Grid.ColumnDefinitions>
57+
<ColumnDefinition Width="Auto" MinWidth="0" />
58+
<ColumnDefinition Width="*" />
59+
<ColumnDefinition Width="Auto" />
60+
<ColumnDefinition Width="Auto" />
61+
</Grid.ColumnDefinitions>
62+
63+
<Viewbox
64+
Grid.RowSpan="1"
65+
MaxWidth="20"
66+
MaxHeight="20"
67+
Margin="2,0,20,0">
68+
<cpcontrols:IconBox
69+
Width="20"
70+
Height="20"
71+
Margin="0,0,0,0"
72+
AutomationProperties.AccessibilityView="Raw"
73+
SourceKey="{x:Bind Icon, Mode=OneWay}"
74+
SourceRequested="{x:Bind helpers:IconCacheProvider.SourceRequested}" />
75+
</Viewbox>
76+
77+
<StackPanel
78+
Grid.Column="1"
79+
Margin="0,0,24,0"
80+
VerticalAlignment="Center"
81+
Orientation="Vertical">
82+
<ContentPresenter
83+
Grid.Column="1"
84+
HorizontalAlignment="Left"
85+
Content="{x:Bind DisplayName, Mode=OneWay}"
86+
HighContrastAdjustment="None"
87+
TextWrapping="Wrap" />
88+
89+
<ContentPresenter
90+
Content="{x:Bind ExtensionName, Mode=OneWay}"
91+
FontSize="12"
92+
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
93+
TextWrapping="Wrap" />
94+
</StackPanel>
95+
96+
<!--
97+
Because of this insane XAML thing we're
98+
doing, we can't effectively put content
99+
here on the right. Sad.
100+
-->
101+
102+
<!--<ContentPresenter
103+
Grid.Column="2"
104+
HorizontalAlignment="Right"
105+
VerticalAlignment="Center"
106+
HorizontalContentAlignment="Right">
107+
<ToggleSwitch IsOn="{x:Bind IsEnabled, Mode=TwoWay}"/>
108+
</ContentPresenter>-->
109+
</Grid>
110+
</controls:SettingsCard>
111+
</DataTemplate>
112+
</ItemsRepeater.ItemTemplate>
113+
</ItemsRepeater>
114+
</StackPanel>
115+
</Grid>
116+
</ScrollViewer>
117+
</Grid>
118+
</Page>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) Microsoft Corporation
2+
// The Microsoft Corporation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Collections.Generic;
7+
using System.IO;
8+
using System.Linq;
9+
using System.Runtime.InteropServices.WindowsRuntime;
10+
using Microsoft.CmdPal.UI.ViewModels;
11+
using Microsoft.Extensions.DependencyInjection;
12+
using Microsoft.UI.Xaml;
13+
using Microsoft.UI.Xaml.Controls;
14+
using Microsoft.UI.Xaml.Controls.Primitives;
15+
using Microsoft.UI.Xaml.Data;
16+
using Microsoft.UI.Xaml.Input;
17+
using Microsoft.UI.Xaml.Media;
18+
using Microsoft.UI.Xaml.Navigation;
19+
using Windows.Foundation;
20+
using Windows.Foundation.Collections;
21+
22+
namespace Microsoft.CmdPal.UI.Pages;
23+
24+
public sealed partial class ExtensionsPage : Page
25+
{
26+
private readonly TaskScheduler _mainTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
27+
28+
private SettingsViewModel? viewModel;
29+
30+
public ExtensionsPage()
31+
{
32+
this.InitializeComponent();
33+
34+
var settings = App.Current.Services.GetService<SettingsModel>()!;
35+
viewModel = new SettingsViewModel(settings, App.Current.Services, _mainTaskScheduler);
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<Page
3+
x:Class="Microsoft.CmdPal.UI.Pages.GeneralPage"
4+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6+
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
7+
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
8+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
9+
xmlns:local="using:Microsoft.CmdPal.UI.Pages"
10+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
11+
xmlns:ptControls="using:Microsoft.CmdPal.UI.Controls"
12+
xmlns:ui="using:CommunityToolkit.WinUI"
13+
xmlns:viewmodels="using:Microsoft.CmdPal.UI.ViewModels"
14+
mc:Ignorable="d">
15+
<Grid>
16+
<Grid.RowDefinitions>
17+
<RowDefinition Height="Auto" />
18+
<RowDefinition Height="*" />
19+
</Grid.RowDefinitions>
20+
<TextBlock
21+
MaxWidth="1000"
22+
Style="{StaticResource TitleTextBlockStyle}"
23+
Text="General" />
24+
<ScrollViewer Grid.Row="1" Padding="0,0,8,0">
25+
<Grid Padding="8,16,8,8">
26+
<StackPanel
27+
MaxWidth="1000"
28+
HorizontalAlignment="Stretch"
29+
Spacing="{StaticResource SettingsCardSpacing}">
30+
31+
<!--
32+
I got these from the samples, but they break XAML hot-reloading,
33+
so I commented them out.
34+
-->
35+
36+
<!--<StackPanel.ChildrenTransitions>
37+
<EntranceThemeTransition FromVerticalOffset="50" />
38+
<RepositionThemeTransition IsStaggeringEnabled="False" />
39+
</StackPanel.ChildrenTransitions>-->
40+
41+
<controls:SettingsExpander
42+
Description="This key will open the Command Palette"
43+
Header="Activation key"
44+
HeaderIcon="{ui:FontIcon Glyph=&#xEDA7;}"
45+
IsExpanded="True">
46+
<ptControls:ShortcutControl HotkeySettings="{x:Bind viewModel.Hotkey, Mode=TwoWay}" />
47+
48+
<controls:SettingsExpander.Items>
49+
<controls:SettingsCard
50+
Description="If enabled, the Command Palette will return to the home page when activated"
51+
Header="Go home when activated"
52+
HeaderIcon="{ui:FontIcon Glyph=&#xE80F;}">
53+
<ToggleSwitch IsOn="{x:Bind viewModel.HotkeyGoesHome, Mode=TwoWay}" />
54+
</controls:SettingsCard>
55+
<controls:SettingsCard Description="When enabled, the previous search text will be selected when the app is opened" Header="Highlight search on activate">
56+
<ToggleSwitch IsOn="{x:Bind viewModel.HighlightSearchOnActivate, Mode=TwoWay}" />
57+
</controls:SettingsCard>
58+
</controls:SettingsExpander.Items>
59+
</controls:SettingsExpander>
60+
61+
<controls:SettingsCard
62+
Description="Controls if app details are automatically expanded or not"
63+
Header="Show app details"
64+
HeaderIcon="{ui:FontIcon Glyph=&#xE8A0;}">
65+
<ToggleSwitch IsOn="{x:Bind viewModel.ShowAppDetails, Mode=TwoWay}" />
66+
</controls:SettingsCard>
67+
68+
<controls:SettingsCard
69+
Description="When enabled, pressing backspace when the search text is empty will take you back"
70+
Header="Backspace goes back"
71+
HeaderIcon="{ui:FontIcon Glyph=&#xE750;}">
72+
<ToggleSwitch IsOn="{x:Bind viewModel.BackspaceGoesBack, Mode=TwoWay}" />
73+
</controls:SettingsCard>
74+
75+
<controls:SettingsCard
76+
Description="When enabled, single click activates list items. When disabled, single click selects and double click activates."
77+
Header="Single-click activates"
78+
HeaderIcon="{ui:FontIcon Glyph=&#xE962;}">
79+
<ToggleSwitch IsOn="{x:Bind viewModel.SingleClickActivates, Mode=TwoWay}" />
80+
</controls:SettingsCard>
81+
82+
<!-- Example 'About' section -->
83+
<TextBlock x:Uid="AboutSettingsHeader" Style="{StaticResource SettingsSectionHeaderTextBlockStyle}" />
84+
85+
<controls:SettingsExpander
86+
Description="© 2025. All rights reserved."
87+
Header="Windows Command Palette"
88+
HeaderIcon="{ui:BitmapIcon Source=ms-appx:///Assets/StoreLogo.png}">
89+
<TextBlock
90+
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
91+
IsTextSelectionEnabled="True"
92+
Text="{x:Bind ApplicationVersion}" />
93+
<controls:SettingsExpander.Items>
94+
<controls:SettingsCard HorizontalContentAlignment="Left" ContentAlignment="Left">
95+
<StackPanel Margin="-12,0,0,0" Orientation="Vertical">
96+
<HyperlinkButton Content="View GitHub Repo" NavigateUri="https://github.com/zadjii-msft/PowerToys" />
97+
<HyperlinkButton Content="Extension SDK docs" NavigateUri="https://github.com/zadjii-msft/PowerToys/blob/main/src/modules/cmdpal/doc/initial-sdk-spec/initial-sdk-spec.md" />
98+
</StackPanel>
99+
</controls:SettingsCard>
100+
</controls:SettingsExpander.Items>
101+
</controls:SettingsExpander>
102+
<HyperlinkButton
103+
Margin="0,8,0,0"
104+
Content="Send feedback"
105+
NavigateUri="https://github.com/zadjii-msft/PowerToys/issues/new" />
106+
</StackPanel>
107+
</Grid>
108+
</ScrollViewer>
109+
</Grid>
110+
</Page>

0 commit comments

Comments
 (0)