diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Dock/DockViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Dock/DockViewModel.cs index 95aa493d01..e1e306345e 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Dock/DockViewModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Dock/DockViewModel.cs @@ -166,6 +166,13 @@ public enum DockPinSide End, } +public enum ShowLabelsOption +{ + Default, + ShowLabels, + HideLabels, +} + // public class DockSettingsViewModel : ObservableObject // { // private readonly DockSettings _settingsModel; @@ -188,6 +195,8 @@ public partial class DockBandSettingsViewModel : ObservableObject { // TODO! we should have a way of saying "pinned from {extension}" vs // just a band that's from an extension + // + // TODO! add the number of items in the band return $"{_adapter.ExtensionName}"; } } @@ -196,10 +205,37 @@ public partial class DockBandSettingsViewModel : ObservableObject public IconInfoViewModel Icon => _adapter.IconViewModel; - public bool ShowLabels + public ShowLabelsOption ShowLabels { - get => _dockSettingsModel.ShowLabels ?? true; // TODO! deal with the fact it might be null - set => _dockSettingsModel.ShowLabels = value; // TODO! save settings + get + { + if (_dockSettingsModel.ShowLabels == null) + { + return ShowLabelsOption.Default; + } + + return _dockSettingsModel.ShowLabels.Value ? ShowLabelsOption.ShowLabels : ShowLabelsOption.HideLabels; + } + + set + { + _dockSettingsModel.ShowLabels = value switch + { + ShowLabelsOption.Default => null, + ShowLabelsOption.ShowLabels => true, + ShowLabelsOption.HideLabels => false, + _ => null, + }; + + // TODO! save settings + } + } + + // used to map to ComboBox selection + public int ShowLabelsIndex + { + get => (int)ShowLabels; + set => ShowLabels = (ShowLabelsOption)value; } [ObservableProperty] diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Settings/DockSettings.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Settings/DockSettings.cs index 0c4f1d9be4..f23d2060da 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Settings/DockSettings.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Settings/DockSettings.cs @@ -23,6 +23,8 @@ public class DockSettings public List StartBands { get; set; } = []; public List EndBands { get; set; } = []; + + public bool ShowLabels { get; set; } = true; } public class DockBandSettings @@ -30,6 +32,8 @@ public class DockBandSettings public string Id { get; set; } = string.Empty; public bool? ShowLabels { get; set; } + + public bool ResolveShowLabels(bool defaultValue) => ShowLabels ?? defaultValue; } public enum DockSide diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsViewModel.cs index b7b10f231b..9b590c9ecd 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsViewModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsViewModel.cs @@ -168,6 +168,16 @@ public partial class SettingsViewModel : INotifyPropertyChanged } } + public bool Dock_ShowLabels + { + get => _settings.DockSettings.ShowLabels; + set + { + _settings.DockSettings.ShowLabels = value; + Save(); + } + } + public bool EnableDock { get => _settings.EnableDock; diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml index d3d8190b9a..d0a278e1cf 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml @@ -88,6 +88,19 @@ + + + + Choose whether to show labels for dock items by default. + + + + + + @@ -133,10 +146,11 @@ - + + + + + diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml.cs index ac2b165349..032e060d41 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml.cs @@ -56,6 +56,12 @@ public sealed partial class DockSettingsPage : Page set => viewModel.Dock_Backdrop = SelectedIndexToBackdrop(value); } + public bool ShowLabels + { + get => viewModel.Dock_ShowLabels; + set => viewModel.Dock_ShowLabels = value; + } + // Conversion methods for ComboBox bindings private static int DockSizeToSelectedIndex(DockSize size) => size switch {