فهرست منبع

Fixed filter commands not having a icon evaluator and allow adding multiple filter attributes to the same filter

CPKreuz 2 سال پیش
والد
کامیت
29661ed679
2فایلهای تغییر یافته به همراه11 افزوده شده و 1 حذف شده
  1. 6 0
      src/PixiEditor/Models/Commands/CommandController.cs
  2. 5 1
      src/PixiEditor/Views/Dialogs/CommandDebugPopup.xaml.cs

+ 6 - 0
src/PixiEditor/Models/Commands/CommandController.cs

@@ -216,16 +216,22 @@ internal class CommandController
                     }
                     else if (attribute is CommandAttribute.FilterAttribute menu)
                     {
+                        bool hasFilter = FilterCommands.ContainsKey(menu.SearchTerm);
+                        
                         foreach (var menuCommand in commandAttrs.Where(x => x is not CommandAttribute.FilterAttribute))
                         {
                             FilterCommands.Add(menu.SearchTerm, Commands[menuCommand.InternalName]);
                         }
+
+                        if (hasFilter)
+                            continue;
                         
                         Commands.Add(new Command.BasicCommand(_ => ViewModelMain.Current.SearchSubViewModel.OpenSearchWindow($":{menu.SearchTerm}:"), CanExecuteEvaluator.AlwaysTrue)
                         {
                             InternalName = menu.InternalName,
                             DisplayName = menu.DisplayName,
                             Description = string.Empty,
+                            IconEvaluator = IconEvaluator.Default,
                             DefaultShortcut = menu.GetShortcut(),
                             Shortcut = GetShortcut(name, attribute.GetShortcut(), template)
                         });

+ 5 - 1
src/PixiEditor/Views/Dialogs/CommandDebugPopup.xaml.cs

@@ -92,7 +92,11 @@ public partial class CommandDebugPopup : Window
             }
         }
 
-        if (command.IconEvaluator != IconEvaluator.Default)
+        if (command.IconEvaluator == null)
+        {
+            Warning("Icon evaluator is null");
+        }
+        else if (command.IconEvaluator != IconEvaluator.Default)
         {
             Info($"Uses custom icon evaluator ({command.IconEvaluator.Name})\n");
         }