From 28ff6ac1acd7f59415d382458f29d30281aabc0f Mon Sep 17 00:00:00 2001
From: Vic <10308169+VictoriousRaptor@users.noreply.github.com>
Date: Mon, 3 Oct 2022 03:34:56 +0800
Subject: [PATCH] Allow HOTKEY+0 to open the 10th result
---
.../Converters/OpenResultHotkeyVisibilityConverter.cs | 8 ++++----
Flow.Launcher/Converters/OrdinalConverter.cs | 5 ++++-
Flow.Launcher/MainWindow.xaml | 5 +++++
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/Flow.Launcher/Converters/OpenResultHotkeyVisibilityConverter.cs b/Flow.Launcher/Converters/OpenResultHotkeyVisibilityConverter.cs
index e82fa959c8d..7586d1fcf22 100644
--- a/Flow.Launcher/Converters/OpenResultHotkeyVisibilityConverter.cs
+++ b/Flow.Launcher/Converters/OpenResultHotkeyVisibilityConverter.cs
@@ -11,17 +11,17 @@ namespace Flow.Launcher.Converters
[ValueConversion(typeof(bool), typeof(Visibility))]
public class OpenResultHotkeyVisibilityConverter : IValueConverter
{
- private const int MaxVisibleHotkeys = 9;
+ private const int MaxVisibleHotkeys = 10;
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- var hotkeyNumber = int.MaxValue;
+ var number = int.MaxValue;
if (value is ListBoxItem listBoxItem
&& ItemsControl.ItemsControlFromItemContainer(listBoxItem) is ListBox listBox)
- hotkeyNumber = listBox.ItemContainerGenerator.IndexFromContainer(listBoxItem) + 1;
+ number = listBox.ItemContainerGenerator.IndexFromContainer(listBoxItem) + 1;
- return hotkeyNumber <= MaxVisibleHotkeys ? Visibility.Visible : Visibility.Collapsed;
+ return number <= MaxVisibleHotkeys ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new System.InvalidOperationException();
diff --git a/Flow.Launcher/Converters/OrdinalConverter.cs b/Flow.Launcher/Converters/OrdinalConverter.cs
index f9fa220e324..0c716ac7e87 100644
--- a/Flow.Launcher/Converters/OrdinalConverter.cs
+++ b/Flow.Launcher/Converters/OrdinalConverter.cs
@@ -10,7 +10,10 @@ public object Convert(object value, System.Type targetType, object parameter, Cu
{
if (value is ListBoxItem listBoxItem
&& ItemsControl.ItemsControlFromItemContainer(listBoxItem) is ListBox listBox)
- return listBox.ItemContainerGenerator.IndexFromContainer(listBoxItem) + 1;
+ {
+ var res = listBox.ItemContainerGenerator.IndexFromContainer(listBoxItem) + 1;
+ return res == 10 ? 0 : res; // 10th item => HOTKEY+0
+ }
return 0;
}
diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml
index bd02b560a87..dc3b3f1454b 100644
--- a/Flow.Launcher/MainWindow.xaml
+++ b/Flow.Launcher/MainWindow.xaml
@@ -150,6 +150,11 @@
Command="{Binding OpenResultCommand}"
CommandParameter="8"
Modifiers="{Binding OpenResultCommandModifiers}" />
+