Add disabled launcher items
This commit is contained in:
@@ -94,7 +94,7 @@ public partial class LauncherPopup : Window
|
||||
ItemsPanel.Children.Clear();
|
||||
visibleLaunchButtons.Clear();
|
||||
|
||||
if (config.RecentItems.Count > 0)
|
||||
if (config.RecentItems.Any(item => !item.IsDisabled))
|
||||
{
|
||||
ItemsPanel.Children.Add(CreateRecentItemsControl());
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public partial class LauncherPopup : Window
|
||||
};
|
||||
|
||||
StackPanel recentItems = new();
|
||||
foreach (LauncherItem item in config.RecentItems)
|
||||
foreach (LauncherItem item in config.RecentItems.Where(item => !item.IsDisabled))
|
||||
{
|
||||
recentItems.Children.Add(CreateItemControl(item, 1, expandMenusByDefault: false, allowEdit: false));
|
||||
}
|
||||
@@ -195,6 +195,7 @@ public partial class LauncherPopup : Window
|
||||
contextMenu.Items.Add(openAllMenuItem);
|
||||
contextMenu.Items.Add(new Separator());
|
||||
contextMenu.Items.Add(CreatePinMenuItem(item));
|
||||
contextMenu.Items.Add(CreateDisableMenuItem(item));
|
||||
contextMenu.Items.Add(CreateEditMenuItem(item));
|
||||
|
||||
return new TextBlock
|
||||
@@ -208,6 +209,7 @@ public partial class LauncherPopup : Window
|
||||
{
|
||||
System.Windows.Controls.ContextMenu contextMenu = new();
|
||||
contextMenu.Items.Add(CreatePinMenuItem(item));
|
||||
contextMenu.Items.Add(CreateDisableMenuItem(item));
|
||||
contextMenu.Items.Add(CreateEditMenuItem(item));
|
||||
return contextMenu;
|
||||
}
|
||||
@@ -230,6 +232,24 @@ public partial class LauncherPopup : Window
|
||||
return pinMenuItem;
|
||||
}
|
||||
|
||||
private System.Windows.Controls.MenuItem CreateDisableMenuItem(LauncherItem item)
|
||||
{
|
||||
System.Windows.Controls.MenuItem disableMenuItem = new()
|
||||
{
|
||||
Header = item.IsDisabled ? "Enable Item" : "Disable Item"
|
||||
};
|
||||
disableMenuItem.Click += (_, e) =>
|
||||
{
|
||||
item.IsDisabled = !item.IsDisabled;
|
||||
ConfigService.Save(config);
|
||||
BuildItems();
|
||||
QueueReposition();
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
return disableMenuItem;
|
||||
}
|
||||
|
||||
private System.Windows.Controls.MenuItem CreateEditMenuItem(LauncherItem item)
|
||||
{
|
||||
System.Windows.Controls.MenuItem editMenuItem = new()
|
||||
@@ -248,12 +268,14 @@ public partial class LauncherPopup : Window
|
||||
|
||||
private static bool IsLaunchable(LauncherItem item)
|
||||
{
|
||||
return item.Type != LauncherItemType.Menu && !string.IsNullOrWhiteSpace(item.Target);
|
||||
return item.Type != LauncherItemType.Menu && !item.IsDisabled && !string.IsNullOrWhiteSpace(item.Target);
|
||||
}
|
||||
|
||||
private static IEnumerable<LauncherItem> GetDisplayItems(IEnumerable<LauncherItem> items)
|
||||
{
|
||||
return items.OrderByDescending(item => item.IsFavorite);
|
||||
return items
|
||||
.Where(item => !item.IsDisabled)
|
||||
.OrderByDescending(item => item.IsFavorite);
|
||||
}
|
||||
|
||||
private void SearchBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
@@ -300,7 +322,7 @@ public partial class LauncherPopup : Window
|
||||
{
|
||||
foreach (LauncherItem item in GetDisplayItems(items))
|
||||
{
|
||||
bool isLaunchable = item.Type != LauncherItemType.Menu;
|
||||
bool isLaunchable = item.Type != LauncherItemType.Menu && !item.IsDisabled;
|
||||
if (isLaunchable && Matches(item, query))
|
||||
{
|
||||
matches.Add(item);
|
||||
|
||||
Reference in New Issue
Block a user