diff --git a/RetroBar/Controls/Toolbar.xaml.cs b/RetroBar/Controls/Toolbar.xaml.cs index 35286403..55c7ddc5 100644 --- a/RetroBar/Controls/Toolbar.xaml.cs +++ b/RetroBar/Controls/Toolbar.xaml.cs @@ -10,6 +10,7 @@ using ManagedShell.Common.Logging; using ManagedShell.ShellFolders; using ManagedShell.ShellFolders.Enums; +using RetroBar.Extensions; using RetroBar.Utilities; namespace RetroBar.Controls @@ -84,6 +85,10 @@ private void Settings_PropertyChanged(object sender, System.ComponentModel.Prope { Refresh(); } + else if (e.PropertyName == nameof(Settings.QuickLaunchIconSettings)) + { + Refresh(); + } } private void Refresh() @@ -116,9 +121,16 @@ private void SetItemsSource() ToolbarItems.ItemsSource = Folder.Files; ListCollectionView cvs = (ListCollectionView)CollectionViewSource.GetDefaultView(Folder.Files); cvs.CustomSort = new ToolbarSorter(this); + cvs.Filter = ShouldShowIcon; } } + private bool ShouldShowIcon(object item) + { + ShellFile file = item as ShellFile; + return file.IsEnabledOnDisplay(Host.Screen.DeviceName); + } + public void SaveItemOrder() { List itemPaths = new List(); diff --git a/RetroBar/Converters/BoolAndConverter.cs b/RetroBar/Converters/BoolAndConverter.cs new file mode 100644 index 00000000..93ed3ab5 --- /dev/null +++ b/RetroBar/Converters/BoolAndConverter.cs @@ -0,0 +1,25 @@ +using System; +using System.Windows.Data; + +namespace RetroBar.Converters +{ + public class BoolAndConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + foreach (object value in values) + { + if ((value is bool) && (bool)value == false) + { + return false; + } + } + return true; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotSupportedException(); + } + } +} \ No newline at end of file diff --git a/RetroBar/Extensions/QuickLaunchIconExtensions.cs b/RetroBar/Extensions/QuickLaunchIconExtensions.cs new file mode 100644 index 00000000..f88d1f58 --- /dev/null +++ b/RetroBar/Extensions/QuickLaunchIconExtensions.cs @@ -0,0 +1,74 @@ +using ManagedShell.ShellFolders; +using RetroBar.Utilities; +using System.Collections.Generic; + +namespace RetroBar.Extensions +{ + public static class QuickLaunchIconExtensions + { + public static bool IsEnabledOnDisplay(this ShellFile file, string deviceName) + { + var setting = Settings.Instance.QuickLaunchIconSettings.Find(s => s.Path == file.Path); + + // No setting means show everywhere (default) + if (setting.Path == null) + { + return true; + } + + return setting.DisabledOnDisplays == null || !setting.DisabledOnDisplays.Contains(deviceName); + } + + public static void SetEnabledOnDisplay(this ShellFile file, string deviceName, bool enabled) + { + var settings = new List(Settings.Instance.QuickLaunchIconSettings); + var currentSettingIndex = settings.FindIndex(s => s.Path == file.Path); + + if (currentSettingIndex >= 0) + { + var disabledDisplays = new List(settings[currentSettingIndex].DisabledOnDisplays ?? new List()); + + if (!enabled && !disabledDisplays.Contains(deviceName)) + { + disabledDisplays.Add(deviceName); + } + else if (enabled) + { + disabledDisplays.Remove(deviceName); + } + + if (disabledDisplays.Count == 0) + { + // Back to default (show everywhere) — remove the entry entirely + settings.RemoveAt(currentSettingIndex); + } + else + { + settings[currentSettingIndex] = new QuickLaunchIconSetting + { + Path = file.Path, + DisabledOnDisplays = disabledDisplays + }; + } + } + else + { + if (!enabled) + { + settings.Add(new QuickLaunchIconSetting + { + Path = file.Path, + DisabledOnDisplays = new List { deviceName } + }); + } + else + { + // Enabling on a display when no setting exists — already shown everywhere, nothing to do + return; + } + } + + Settings.Instance.QuickLaunchIconSettings = settings; + } + } +} \ No newline at end of file diff --git a/RetroBar/Languages/English.xaml b/RetroBar/Languages/English.xaml index 76415dd6..2fb126aa 100644 --- a/RetroBar/Languages/English.xaml +++ b/RetroBar/Languages/English.xaml @@ -30,6 +30,7 @@ Show the cloc_k Show on _multiple displays Show _Start button on all taskbars + Show _Quick Launch on all taskbars Show _Quick Launch _Select location... Quick Launch - Choose a folder @@ -101,6 +102,9 @@ Behavior Invert + Customize Quick Launch + Select which icons to show on each taskbar per display. + Start start Click here to begin. diff --git a/RetroBar/PropertiesWindow.xaml b/RetroBar/PropertiesWindow.xaml index 27c78bfe..cfa9dc7f 100644 --- a/RetroBar/PropertiesWindow.xaml +++ b/RetroBar/PropertiesWindow.xaml @@ -25,6 +25,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +