From df7878342b6c49bdb7caaa14e61fd652c2588c5f Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Mon, 13 Jan 2025 14:48:32 -0600 Subject: [PATCH] Add a setting to control if details are shown for apps (#300) Adds a setting to control if the `Details` pane is shown for apps on the main page or not. I'm defaulting this to off, because that pane doesn't add any value currently. --- .../Commands/MainListPage.cs | 15 ++++++++++++++- .../SettingsModel.cs | 2 ++ .../SettingsViewModel.cs | 10 ++++++++++ .../Microsoft.CmdPal.UI.csproj | 3 +++ .../cmdpal/Microsoft.CmdPal.UI/SettingsPage.xaml | 7 +++++++ 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs index 46463c812c..bbfeba4348 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs @@ -34,7 +34,6 @@ public partial class MainListPage : DynamicListPage, { Name = "Command Palette"; Icon = new(Path.Combine(AppDomain.CurrentDomain.BaseDirectory.ToString(), "Assets\\StoreLogo.scale-200.png")); - ShowDetails = true; _serviceProvider = serviceProvider; var tlcManager = _serviceProvider.GetService()!; @@ -46,6 +45,10 @@ public partial class MainListPage : DynamicListPage, WeakReferenceMessenger.Default.Register(this); + var settings = _serviceProvider.GetService()!; + settings.SettingsChanged += SettingsChangedHandler; + HotReloadSettings(settings); + IsLoading = true; } @@ -180,4 +183,14 @@ public partial class MainListPage : DynamicListPage, { SearchText = string.Empty; } + + private void SettingsChangedHandler(SettingsModel sender, object? args) + { + HotReloadSettings(sender); + } + + private void HotReloadSettings(SettingsModel settings) + { + ShowDetails = settings.ShowAppDetails; + } } diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs index f9d1122643..3f6ed42eb5 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs @@ -23,6 +23,8 @@ public partial class SettingsModel : ObservableObject // SETTINGS HERE public HotkeySettings? Hotkey { get; set; } = new HotkeySettings(true, true, false, false, 0xBE); + public bool ShowAppDetails { get; set; } + public Dictionary ProviderSettings { get; set; } = []; // END SETTINGS diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsViewModel.cs index c73c8c23f7..ea71219744 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsViewModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsViewModel.cs @@ -23,6 +23,16 @@ public partial class SettingsViewModel : PageViewModel } } + public bool ShowAppDetails + { + get => _settings.ShowAppDetails; + set + { + _settings.ShowAppDetails = value; + Save(); + } + } + public ObservableCollection CommandProviders { get; } = []; public SettingsViewModel(SettingsModel settings, IServiceProvider serviceProvider, TaskScheduler scheduler) diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj b/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj index 769dcc7c0a..154f1a8d16 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj @@ -16,6 +16,9 @@ false false + + + true diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/SettingsPage.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/SettingsPage.xaml index b8091afc33..db075424bc 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/SettingsPage.xaml +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/SettingsPage.xaml @@ -64,6 +64,13 @@ HeaderIcon="{ui:FontIcon Glyph=}"> + + + +