Skip to content

Commit 518f01b

Browse files
committed
Settings in a window vs inline
1 parent 4d464bc commit 518f01b

19 files changed

+506
-290
lines changed

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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 24 additions & 4 deletions
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

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

167187
</Project>

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

Lines changed: 1 addition & 2 deletions
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 renamed to src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/LoadingPage.xaml.cs

Lines changed: 1 addition & 1 deletion
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.
Lines changed: 118 additions & 0 deletions
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>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
public SettingsViewModel? ViewModel
29+
{
30+
get => (SettingsViewModel?)GetValue(ViewModelProperty);
31+
set => SetValue(ViewModelProperty, value);
32+
}
33+
34+
// Using a DependencyProperty as the backing store for ViewModel. This enables animation, styling, binding, etc...
35+
public static readonly DependencyProperty ViewModelProperty =
36+
DependencyProperty.Register(nameof(ViewModel), typeof(SettingsViewModel), typeof(ExtensionsPage), new PropertyMetadata(null, null));
37+
38+
public ExtensionsPage()
39+
{
40+
this.InitializeComponent();
41+
42+
var settings = App.Current.Services.GetService<SettingsModel>()!;
43+
ViewModel = new SettingsViewModel(settings, App.Current.Services, _mainTaskScheduler);
44+
}
45+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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="Version 0.0.1" />
93+
<controls:SettingsExpander.Items>
94+
<controls:SettingsCard HorizontalContentAlignment="Left" ContentAlignment="Left">
95+
<StackPanel Margin="-12,0,0,0" Orientation="Vertical">
96+
<HyperlinkButton Content="Link 1" />
97+
<HyperlinkButton Content="Link 2" />
98+
<HyperlinkButton Content="Link 3" />
99+
</StackPanel>
100+
</controls:SettingsCard>
101+
</controls:SettingsExpander.Items>
102+
</controls:SettingsExpander>
103+
<HyperlinkButton Margin="0,8,0,0" Content="Send feedback" />
104+
</StackPanel>
105+
</Grid>
106+
</ScrollViewer>
107+
</Grid>
108+
</Page>

0 commit comments

Comments
 (0)