mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge 8b6c694434 into 5ef6a2b688
This commit is contained in:
commit
d89ea1dad4
4 changed files with 36 additions and 12 deletions
|
|
@ -17,7 +17,17 @@ public class OpenResultHotkeyVisibilityConverter : IValueConverter
|
||||||
|
|
||||||
if (value is ListBoxItem listBoxItem
|
if (value is ListBoxItem listBoxItem
|
||||||
&& ItemsControl.ItemsControlFromItemContainer(listBoxItem) is ListBox listBox)
|
&& ItemsControl.ItemsControlFromItemContainer(listBoxItem) is ListBox listBox)
|
||||||
number = listBox.ItemContainerGenerator.IndexFromContainer(listBoxItem) + 1;
|
{
|
||||||
|
var dataItem = listBoxItem.DataContext;
|
||||||
|
if (dataItem != null)
|
||||||
|
{
|
||||||
|
var index = listBox.Items.IndexOf(dataItem);
|
||||||
|
if (index >= 0)
|
||||||
|
{
|
||||||
|
number = index + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return number <= MaxVisibleHotkeys ? Visibility.Visible : Visibility.Collapsed;
|
return number <= MaxVisibleHotkeys ? Visibility.Visible : Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
|
|
@ -15,9 +15,20 @@ public class OrdinalConverter : IValueConverter
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var res = listBox.ItemContainerGenerator.IndexFromContainer(listBoxItem) + 1;
|
var dataItem = listBoxItem.DataContext;
|
||||||
return res == 10 ? 0 : res; // 10th item => HOTKEY+0
|
if (dataItem == null)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var index = listBox.Items.IndexOf(dataItem);
|
||||||
|
if (index < 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var res = index + 1;
|
||||||
|
return res == 10 ? 0 : res; // 10th item => HOTKEY+0
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new InvalidOperationException();
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new InvalidOperationException();
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
Style="{DynamicResource BaseListboxStyle}"
|
Style="{DynamicResource BaseListboxStyle}"
|
||||||
VirtualizingPanel.ScrollUnit="Item"
|
VirtualizingPanel.ScrollUnit="Item"
|
||||||
VirtualizingStackPanel.IsVirtualizing="True"
|
VirtualizingStackPanel.IsVirtualizing="True"
|
||||||
VirtualizingStackPanel.VirtualizationMode="Standard"
|
VirtualizingStackPanel.VirtualizationMode="Recycling"
|
||||||
Visibility="{Binding Visibility}"
|
Visibility="{Binding Visibility}"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<!-- IsSynchronizedWithCurrentItem: http://stackoverflow.com/a/7833798/2833083 -->
|
<!-- IsSynchronizedWithCurrentItem: http://stackoverflow.com/a/7833798/2833083 -->
|
||||||
|
|
@ -82,7 +82,7 @@
|
||||||
<TextBlock.Text>
|
<TextBlock.Text>
|
||||||
<MultiBinding StringFormat="{}{0}+{1}">
|
<MultiBinding StringFormat="{}{0}+{1}">
|
||||||
<Binding Mode="OneWay" Path="Settings.OpenResultModifiers" />
|
<Binding Mode="OneWay" Path="Settings.OpenResultModifiers" />
|
||||||
<Binding Converter="{StaticResource ResourceKey=OrdinalConverter}" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}" />
|
<Binding Converter="{StaticResource ResourceKey=OrdinalConverter}" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}"/>
|
||||||
</MultiBinding>
|
</MultiBinding>
|
||||||
</TextBlock.Text>
|
</TextBlock.Text>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace Flow.Launcher
|
||||||
{
|
{
|
||||||
protected Lock _lock = new();
|
protected Lock _lock = new();
|
||||||
private Point _lastpos;
|
private Point _lastpos;
|
||||||
private ListBoxItem curItem = null;
|
private ResultViewModel _currentResult = null;
|
||||||
public ResultListBox()
|
public ResultListBox()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
@ -60,9 +60,12 @@ namespace Flow.Launcher
|
||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
curItem = (ListBoxItem)sender;
|
if (sender is FrameworkElement { DataContext: ResultViewModel result })
|
||||||
var p = e.GetPosition((IInputElement)sender);
|
{
|
||||||
_lastpos = p;
|
_currentResult = result;
|
||||||
|
var p = e.GetPosition((IInputElement)sender);
|
||||||
|
_lastpos = p;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,9 +85,9 @@ namespace Flow.Launcher
|
||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
if (curItem != null)
|
if (_currentResult != null && sender is ListBox listBox)
|
||||||
{
|
{
|
||||||
curItem.IsSelected = true;
|
listBox.SelectedItem = _currentResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue