mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge branch 'dev' into handle-icon-urls
This commit is contained in:
commit
e5948a70c4
14 changed files with 282 additions and 27297 deletions
|
|
@ -64,16 +64,5 @@
|
|||
<PackageReference Include="ToolGood.Words.Pinyin" Version="3.0.1.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="pinyindb\pinyin_gwoyeu_mapping.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="pinyindb\pinyin_mapping.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="pinyindb\unicode_to_hanyu_pinyin.txt">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -15,7 +15,7 @@ namespace Flow.Launcher.Infrastructure
|
|||
|
||||
private List<int> originalIndexs = new List<int>();
|
||||
private List<int> translatedIndexs = new List<int>();
|
||||
private int translaedLength = 0;
|
||||
private int translatedLength = 0;
|
||||
|
||||
public string key { get; private set; }
|
||||
|
||||
|
|
@ -32,13 +32,13 @@ namespace Flow.Launcher.Infrastructure
|
|||
originalIndexs.Add(originalIndex);
|
||||
translatedIndexs.Add(translatedIndex);
|
||||
translatedIndexs.Add(translatedIndex + length);
|
||||
translaedLength += length - 1;
|
||||
translatedLength += length - 1;
|
||||
}
|
||||
|
||||
public int MapToOriginalIndex(int translatedIndex)
|
||||
{
|
||||
if (translatedIndex > translatedIndexs.Last())
|
||||
return translatedIndex - translaedLength - 1;
|
||||
return translatedIndex - translatedLength - 1;
|
||||
|
||||
int lowerBound = 0;
|
||||
int upperBound = originalIndexs.Count - 1;
|
||||
|
|
@ -83,7 +83,7 @@ namespace Flow.Launcher.Infrastructure
|
|||
translatedIndex < translatedIndexs[upperBound * 2])
|
||||
{
|
||||
int indexDef = 0;
|
||||
|
||||
|
||||
for (int j = 0; j < upperBound; j++)
|
||||
{
|
||||
indexDef += translatedIndexs[j * 2 + 1] - translatedIndexs[j * 2];
|
||||
|
|
@ -102,9 +102,24 @@ namespace Flow.Launcher.Infrastructure
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translate a language to English letters using a given rule.
|
||||
/// </summary>
|
||||
public interface IAlphabet
|
||||
{
|
||||
/// <summary>
|
||||
/// Translate a string to English letters, using a given rule.
|
||||
/// </summary>
|
||||
/// <param name="stringToTranslate">String to translate.</param>
|
||||
/// <returns></returns>
|
||||
public (string translation, TranslationMapping map) Translate(string stringToTranslate);
|
||||
|
||||
/// <summary>
|
||||
/// Determine if a string can be translated to English letter with this Alphabet.
|
||||
/// </summary>
|
||||
/// <param name="stringToTranslate">String to translate.</param>
|
||||
/// <returns></returns>
|
||||
public bool CanBeTranslated(string stringToTranslate);
|
||||
}
|
||||
|
||||
public class PinyinAlphabet : IAlphabet
|
||||
|
|
@ -119,63 +134,70 @@ namespace Flow.Launcher.Infrastructure
|
|||
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
|
||||
}
|
||||
|
||||
public bool CanBeTranslated(string stringToTranslate)
|
||||
{
|
||||
return WordsHelper.HasChinese(stringToTranslate);
|
||||
}
|
||||
|
||||
public (string translation, TranslationMapping map) Translate(string content)
|
||||
{
|
||||
if (_settings.ShouldUsePinyin)
|
||||
{
|
||||
if (!_pinyinCache.ContainsKey(content))
|
||||
{
|
||||
if (WordsHelper.HasChinese(content))
|
||||
{
|
||||
var resultList = WordsHelper.GetPinyinList(content);
|
||||
|
||||
StringBuilder resultBuilder = new StringBuilder();
|
||||
TranslationMapping map = new TranslationMapping();
|
||||
|
||||
bool pre = false;
|
||||
|
||||
for (int i = 0; i < resultList.Length; i++)
|
||||
{
|
||||
if (content[i] >= 0x3400 && content[i] <= 0x9FD5)
|
||||
{
|
||||
map.AddNewIndex(i, resultBuilder.Length, resultList[i].Length + 1);
|
||||
resultBuilder.Append(' ');
|
||||
resultBuilder.Append(resultList[i]);
|
||||
pre = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pre)
|
||||
{
|
||||
pre = false;
|
||||
resultBuilder.Append(' ');
|
||||
}
|
||||
|
||||
resultBuilder.Append(resultList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
map.endConstruct();
|
||||
|
||||
var key = resultBuilder.ToString();
|
||||
map.setKey(key);
|
||||
|
||||
return _pinyinCache[content] = (key, map);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (content, null);
|
||||
}
|
||||
return BuildCacheFromContent(content);
|
||||
}
|
||||
else
|
||||
{
|
||||
return _pinyinCache[content];
|
||||
}
|
||||
}
|
||||
return (content, null);
|
||||
}
|
||||
|
||||
private (string translation, TranslationMapping map) BuildCacheFromContent(string content)
|
||||
{
|
||||
if (WordsHelper.HasChinese(content))
|
||||
{
|
||||
var resultList = WordsHelper.GetPinyinList(content);
|
||||
|
||||
StringBuilder resultBuilder = new StringBuilder();
|
||||
TranslationMapping map = new TranslationMapping();
|
||||
|
||||
bool pre = false;
|
||||
|
||||
for (int i = 0; i < resultList.Length; i++)
|
||||
{
|
||||
if (content[i] >= 0x3400 && content[i] <= 0x9FD5)
|
||||
{
|
||||
map.AddNewIndex(i, resultBuilder.Length, resultList[i].Length + 1);
|
||||
resultBuilder.Append(' ');
|
||||
resultBuilder.Append(resultList[i]);
|
||||
pre = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pre)
|
||||
{
|
||||
pre = false;
|
||||
resultBuilder.Append(' ');
|
||||
}
|
||||
|
||||
resultBuilder.Append(resultList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
map.endConstruct();
|
||||
|
||||
var key = resultBuilder.ToString();
|
||||
map.setKey(key);
|
||||
|
||||
return _pinyinCache[content] = (key, map);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (content, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using Flow.Launcher.Plugin.SharedModels;
|
||||
using Flow.Launcher.Plugin.SharedModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
@ -60,8 +60,13 @@ namespace Flow.Launcher.Infrastructure
|
|||
return new MatchResult(false, UserSettingSearchPrecision);
|
||||
|
||||
query = query.Trim();
|
||||
TranslationMapping translationMapping;
|
||||
(stringToCompare, translationMapping) = _alphabet?.Translate(stringToCompare) ?? (stringToCompare, null);
|
||||
TranslationMapping translationMapping = null;
|
||||
if (_alphabet is not null && !_alphabet.CanBeTranslated(query))
|
||||
{
|
||||
// We assume that if a query can be translated (containing characters of a language, like Chinese)
|
||||
// it actually means user doesn't want it to be translated to English letters.
|
||||
(stringToCompare, translationMapping) = _alphabet.Translate(stringToCompare);
|
||||
}
|
||||
|
||||
var currentAcronymQueryIndex = 0;
|
||||
var acronymMatchData = new List<int>();
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<Window
|
||||
x:Class="Flow.Launcher.MainWindow"
|
||||
<Window x:Class="Flow.Launcher.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:converters="clr-namespace:Flow.Launcher.Converters"
|
||||
|
|
@ -40,164 +39,145 @@
|
|||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
</Window.Resources>
|
||||
<Window.InputBindings>
|
||||
<KeyBinding Key="Escape" Command="{Binding EscCommand}" />
|
||||
<KeyBinding Key="F1" Command="{Binding StartHelpCommand}" />
|
||||
<KeyBinding Key="F5" Command="{Binding ReloadPluginDataCommand}" />
|
||||
<KeyBinding Key="Tab" Command="{Binding AutocompleteQueryCommand}" />
|
||||
<KeyBinding
|
||||
Key="Tab"
|
||||
<KeyBinding Key="Escape"
|
||||
Command="{Binding EscCommand}" />
|
||||
<KeyBinding Key="F1"
|
||||
Command="{Binding StartHelpCommand}" />
|
||||
<KeyBinding Key="F5"
|
||||
Command="{Binding ReloadPluginDataCommand}" />
|
||||
<KeyBinding Key="Tab"
|
||||
Command="{Binding AutocompleteQueryCommand}" />
|
||||
<KeyBinding Key="Tab"
|
||||
Command="{Binding AutocompleteQueryCommand}"
|
||||
Modifiers="Shift" />
|
||||
<KeyBinding
|
||||
Key="I"
|
||||
<KeyBinding Key="I"
|
||||
Command="{Binding OpenSettingCommand}"
|
||||
Modifiers="Ctrl" />
|
||||
<KeyBinding
|
||||
Key="N"
|
||||
<KeyBinding Key="N"
|
||||
Command="{Binding SelectNextItemCommand}"
|
||||
Modifiers="Ctrl" />
|
||||
<KeyBinding
|
||||
Key="J"
|
||||
<KeyBinding Key="J"
|
||||
Command="{Binding SelectNextItemCommand}"
|
||||
Modifiers="Ctrl" />
|
||||
<KeyBinding
|
||||
Key="D"
|
||||
<KeyBinding Key="D"
|
||||
Command="{Binding SelectNextPageCommand}"
|
||||
Modifiers="Ctrl" />
|
||||
<KeyBinding
|
||||
Key="P"
|
||||
<KeyBinding Key="P"
|
||||
Command="{Binding SelectPrevItemCommand}"
|
||||
Modifiers="Ctrl" />
|
||||
<KeyBinding
|
||||
Key="K"
|
||||
<KeyBinding Key="K"
|
||||
Command="{Binding SelectPrevItemCommand}"
|
||||
Modifiers="Ctrl" />
|
||||
<KeyBinding
|
||||
Key="U"
|
||||
<KeyBinding Key="U"
|
||||
Command="{Binding SelectPrevPageCommand}"
|
||||
Modifiers="Ctrl" />
|
||||
<KeyBinding
|
||||
Key="Home"
|
||||
<KeyBinding Key="Home"
|
||||
Command="{Binding SelectFirstResultCommand}"
|
||||
Modifiers="Alt" />
|
||||
<KeyBinding
|
||||
Key="O"
|
||||
<KeyBinding Key="O"
|
||||
Command="{Binding LoadContextMenuCommand}"
|
||||
Modifiers="Ctrl" />
|
||||
<KeyBinding Key="Right" Command="{Binding LoadContextMenuCommand}" />
|
||||
<KeyBinding Key="Left" Command="{Binding EscCommand}" />
|
||||
<KeyBinding
|
||||
Key="H"
|
||||
<KeyBinding Key="Right"
|
||||
Command="{Binding LoadContextMenuCommand}" />
|
||||
<KeyBinding Key="Left"
|
||||
Command="{Binding EscCommand}" />
|
||||
<KeyBinding Key="H"
|
||||
Command="{Binding LoadHistoryCommand}"
|
||||
Modifiers="Ctrl" />
|
||||
<KeyBinding Key="Right" Command="{Binding LoadContextMenuCommand}" />
|
||||
<KeyBinding Key="Left" Command="{Binding EscCommand}" />
|
||||
<KeyBinding
|
||||
Key="OemCloseBrackets"
|
||||
<KeyBinding Key="Right"
|
||||
Command="{Binding LoadContextMenuCommand}" />
|
||||
<KeyBinding Key="Left"
|
||||
Command="{Binding EscCommand}" />
|
||||
<KeyBinding Key="OemCloseBrackets"
|
||||
Command="{Binding IncreaseWidthCommand}"
|
||||
Modifiers="Control" />
|
||||
<KeyBinding
|
||||
Key="OemOpenBrackets"
|
||||
<KeyBinding Key="OemOpenBrackets"
|
||||
Command="{Binding DecreaseWidthCommand}"
|
||||
Modifiers="Control" />
|
||||
<KeyBinding
|
||||
Key="OemPlus"
|
||||
<KeyBinding Key="OemPlus"
|
||||
Command="{Binding IncreaseMaxResultCommand}"
|
||||
Modifiers="Control" />
|
||||
<KeyBinding
|
||||
Key="OemMinus"
|
||||
<KeyBinding Key="OemMinus"
|
||||
Command="{Binding DecreaseMaxResultCommand}"
|
||||
Modifiers="Control" />
|
||||
<KeyBinding
|
||||
Key="H"
|
||||
<KeyBinding Key="H"
|
||||
Command="{Binding LoadHistoryCommand}"
|
||||
Modifiers="Ctrl" />
|
||||
<KeyBinding
|
||||
Key="Enter"
|
||||
<KeyBinding Key="Enter"
|
||||
Command="{Binding OpenResultCommand}"
|
||||
Modifiers="Ctrl+Shift" />
|
||||
<KeyBinding
|
||||
Key="Enter"
|
||||
<KeyBinding Key="Enter"
|
||||
Command="{Binding LoadContextMenuCommand}"
|
||||
Modifiers="Shift" />
|
||||
<KeyBinding Key="Enter" Command="{Binding OpenResultCommand}" />
|
||||
<KeyBinding
|
||||
Key="Enter"
|
||||
<KeyBinding Key="Enter"
|
||||
Command="{Binding OpenResultCommand}" />
|
||||
<KeyBinding Key="Enter"
|
||||
Command="{Binding OpenResultCommand}"
|
||||
Modifiers="Ctrl" />
|
||||
<KeyBinding
|
||||
Key="Enter"
|
||||
<KeyBinding Key="Enter"
|
||||
Command="{Binding OpenResultCommand}"
|
||||
Modifiers="Alt" />
|
||||
<KeyBinding
|
||||
Key="D1"
|
||||
<KeyBinding Key="D1"
|
||||
Command="{Binding OpenResultCommand}"
|
||||
CommandParameter="0"
|
||||
Modifiers="{Binding OpenResultCommandModifiers}" />
|
||||
<KeyBinding
|
||||
Key="D2"
|
||||
<KeyBinding Key="D2"
|
||||
Command="{Binding OpenResultCommand}"
|
||||
CommandParameter="1"
|
||||
Modifiers="{Binding OpenResultCommandModifiers}" />
|
||||
<KeyBinding
|
||||
Key="D3"
|
||||
<KeyBinding Key="D3"
|
||||
Command="{Binding OpenResultCommand}"
|
||||
CommandParameter="2"
|
||||
Modifiers="{Binding OpenResultCommandModifiers}" />
|
||||
<KeyBinding
|
||||
Key="D4"
|
||||
<KeyBinding Key="D4"
|
||||
Command="{Binding OpenResultCommand}"
|
||||
CommandParameter="3"
|
||||
Modifiers="{Binding OpenResultCommandModifiers}" />
|
||||
<KeyBinding
|
||||
Key="D5"
|
||||
<KeyBinding Key="D5"
|
||||
Command="{Binding OpenResultCommand}"
|
||||
CommandParameter="4"
|
||||
Modifiers="{Binding OpenResultCommandModifiers}" />
|
||||
<KeyBinding
|
||||
Key="D6"
|
||||
<KeyBinding Key="D6"
|
||||
Command="{Binding OpenResultCommand}"
|
||||
CommandParameter="5"
|
||||
Modifiers="{Binding OpenResultCommandModifiers}" />
|
||||
<KeyBinding
|
||||
Key="D7"
|
||||
<KeyBinding Key="D7"
|
||||
Command="{Binding OpenResultCommand}"
|
||||
CommandParameter="6"
|
||||
Modifiers="{Binding OpenResultCommandModifiers}" />
|
||||
<KeyBinding
|
||||
Key="D8"
|
||||
<KeyBinding Key="D8"
|
||||
Command="{Binding OpenResultCommand}"
|
||||
CommandParameter="7"
|
||||
Modifiers="{Binding OpenResultCommandModifiers}" />
|
||||
<KeyBinding
|
||||
Key="D9"
|
||||
<KeyBinding Key="D9"
|
||||
Command="{Binding OpenResultCommand}"
|
||||
CommandParameter="8"
|
||||
Modifiers="{Binding OpenResultCommandModifiers}" />
|
||||
<KeyBinding
|
||||
Key="D0"
|
||||
<KeyBinding Key="D0"
|
||||
Command="{Binding OpenResultCommand}"
|
||||
CommandParameter="9"
|
||||
Modifiers="{Binding OpenResultCommandModifiers}" />
|
||||
</Window.InputBindings>
|
||||
<Grid>
|
||||
<Border MouseDown="OnMouseDown" Style="{DynamicResource WindowBorderStyle}">
|
||||
<Border MouseDown="OnMouseDown"
|
||||
Style="{DynamicResource WindowBorderStyle}">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Grid>
|
||||
<TextBox
|
||||
x:Name="QueryTextSuggestionBox"
|
||||
<TextBox x:Name="QueryTextSuggestionBox"
|
||||
IsEnabled="False"
|
||||
Style="{DynamicResource QuerySuggestionBoxStyle}">
|
||||
<TextBox.Text>
|
||||
<MultiBinding Converter="{StaticResource QuerySuggestionBoxConverter}">
|
||||
<Binding ElementName="QueryTextBox" Mode="OneTime" />
|
||||
<Binding ElementName="ResultListBox" Path="SelectedItem" />
|
||||
<Binding ElementName="QueryTextBox" Path="Text" />
|
||||
<Binding ElementName="QueryTextBox"
|
||||
Mode="OneTime" />
|
||||
<Binding ElementName="ResultListBox"
|
||||
Path="SelectedItem" />
|
||||
<Binding ElementName="QueryTextBox"
|
||||
Path="Text" />
|
||||
</MultiBinding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
<TextBox
|
||||
x:Name="QueryTextBox"
|
||||
<TextBox x:Name="QueryTextBox"
|
||||
AllowDrop="True"
|
||||
Background="Transparent"
|
||||
PreviewDragOver="OnPreviewDragOver"
|
||||
|
|
@ -206,35 +186,40 @@
|
|||
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Visibility="Visible">
|
||||
<TextBox.CommandBindings>
|
||||
<CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" />
|
||||
<CommandBinding Command="ApplicationCommands.Copy"
|
||||
Executed="OnCopy" />
|
||||
</TextBox.CommandBindings>
|
||||
<TextBox.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Command="ApplicationCommands.Cut" Header="{DynamicResource cut}">
|
||||
<MenuItem Command="ApplicationCommands.Cut"
|
||||
Header="{DynamicResource cut}">
|
||||
<MenuItem.Icon>
|
||||
<ui:FontIcon Glyph="" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Command="ApplicationCommands.Copy" Header="{DynamicResource copy}">
|
||||
<MenuItem Command="ApplicationCommands.Copy"
|
||||
Header="{DynamicResource copy}">
|
||||
<MenuItem.Icon>
|
||||
<ui:FontIcon Glyph="" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Command="ApplicationCommands.Paste" Header="{DynamicResource paste}">
|
||||
<MenuItem Command="ApplicationCommands.Paste"
|
||||
Header="{DynamicResource paste}">
|
||||
<MenuItem.Icon>
|
||||
<ui:FontIcon Glyph="" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator
|
||||
Margin="0"
|
||||
<Separator Margin="0"
|
||||
Padding="0,4,0,4"
|
||||
Background="{DynamicResource ContextSeparator}" />
|
||||
<MenuItem Click="OnContextMenusForSettingsClick" Header="{DynamicResource flowlauncher_settings}">
|
||||
<MenuItem Click="OnContextMenusForSettingsClick"
|
||||
Header="{DynamicResource flowlauncher_settings}">
|
||||
<MenuItem.Icon>
|
||||
<ui:FontIcon Glyph="" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Command="{Binding EscCommand}" Header="{DynamicResource closeWindow}">
|
||||
<MenuItem Command="{Binding EscCommand}"
|
||||
Header="{DynamicResource closeWindow}">
|
||||
<MenuItem.Icon>
|
||||
<ui:FontIcon Glyph="" />
|
||||
</MenuItem.Icon>
|
||||
|
|
@ -243,23 +228,19 @@
|
|||
</TextBox.ContextMenu>
|
||||
</TextBox>
|
||||
|
||||
<StackPanel
|
||||
x:Name="ClockPanel"
|
||||
<StackPanel x:Name="ClockPanel"
|
||||
IsHitTestVisible="False"
|
||||
Style="{DynamicResource ClockPanel}">
|
||||
<TextBlock
|
||||
Style="{DynamicResource DateBox}"
|
||||
<TextBlock Style="{DynamicResource DateBox}"
|
||||
Text="{Binding DateText}"
|
||||
Visibility="{Binding Settings.UseDate, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
<TextBlock
|
||||
Style="{DynamicResource ClockBox}"
|
||||
<TextBlock Style="{DynamicResource ClockBox}"
|
||||
Text="{Binding ClockText}"
|
||||
Visibility="{Binding Settings.UseClock, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
</StackPanel>
|
||||
|
||||
<Canvas Style="{DynamicResource SearchIconPosition}">
|
||||
<Image
|
||||
x:Name="PluginActivationIcon"
|
||||
<Image x:Name="PluginActivationIcon"
|
||||
Width="32"
|
||||
Height="32"
|
||||
Margin="0,0,0,0"
|
||||
|
|
@ -270,8 +251,7 @@
|
|||
Source="{Binding PluginIconPath}"
|
||||
Stretch="Uniform"
|
||||
Style="{DynamicResource PluginActivationIcon}" />
|
||||
<Path
|
||||
Name="SearchIcon"
|
||||
<Path Name="SearchIcon"
|
||||
Margin="0"
|
||||
Data="{DynamicResource SearchIconImg}"
|
||||
Stretch="Fill"
|
||||
|
|
@ -284,27 +264,32 @@
|
|||
<ContentControl>
|
||||
<ContentControl.Style>
|
||||
<Style TargetType="ContentControl">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
<Setter Property="Visibility"
|
||||
Value="Collapsed" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ElementName=ResultListBox, Path=Visibility}" Value="Visible">
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
<DataTrigger Binding="{Binding ElementName=ResultListBox, Path=Visibility}"
|
||||
Value="Visible">
|
||||
<Setter Property="Visibility"
|
||||
Value="Visible" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding ElementName=ContextMenu, Path=Visibility}" Value="Visible">
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
<DataTrigger Binding="{Binding ElementName=ContextMenu, Path=Visibility}"
|
||||
Value="Visible">
|
||||
<Setter Property="Visibility"
|
||||
Value="Visible" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding ElementName=History, Path=Visibility}" Value="Visible">
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
<DataTrigger Binding="{Binding ElementName=History, Path=Visibility}"
|
||||
Value="Visible">
|
||||
<Setter Property="Visibility"
|
||||
Value="Visible" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ContentControl.Style>
|
||||
<Rectangle
|
||||
Width="Auto"
|
||||
<Rectangle Width="Auto"
|
||||
HorizontalAlignment="Stretch"
|
||||
Style="{DynamicResource SeparatorStyle}" />
|
||||
</ContentControl>
|
||||
<Line
|
||||
x:Name="ProgressBar"
|
||||
<Line x:Name="ProgressBar"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualWidth}"
|
||||
Height="2"
|
||||
HorizontalAlignment="Right"
|
||||
|
|
@ -320,46 +305,55 @@
|
|||
<Border Style="{DynamicResource WindowRadius}">
|
||||
<Border.Clip>
|
||||
<MultiBinding Converter="{StaticResource BorderClipConverter}">
|
||||
<Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}" />
|
||||
<Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}" />
|
||||
<Binding Path="CornerRadius" RelativeSource="{RelativeSource Self}" />
|
||||
<Binding Path="ActualWidth"
|
||||
RelativeSource="{RelativeSource Self}" />
|
||||
<Binding Path="ActualHeight"
|
||||
RelativeSource="{RelativeSource Self}" />
|
||||
<Binding Path="CornerRadius"
|
||||
RelativeSource="{RelativeSource Self}" />
|
||||
</MultiBinding>
|
||||
</Border.Clip>
|
||||
<ContentControl>
|
||||
<flowlauncher:ResultListBox
|
||||
x:Name="ResultListBox"
|
||||
<flowlauncher:ResultListBox x:Name="ResultListBox"
|
||||
DataContext="{Binding Results}"
|
||||
PreviewMouseLeftButtonUp="OnPreviewMouseButtonDown" />
|
||||
LeftClickResultCommand="{Binding LeftClickResultCommand}"
|
||||
RightClickResultCommand="{Binding RightClickResultCommand}" />
|
||||
</ContentControl>
|
||||
</Border>
|
||||
<Border Style="{DynamicResource WindowRadius}">
|
||||
<Border.Clip>
|
||||
<MultiBinding Converter="{StaticResource BorderClipConverter}">
|
||||
<Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}" />
|
||||
<Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}" />
|
||||
<Binding Path="CornerRadius" RelativeSource="{RelativeSource Self}" />
|
||||
<Binding Path="ActualWidth"
|
||||
RelativeSource="{RelativeSource Self}" />
|
||||
<Binding Path="ActualHeight"
|
||||
RelativeSource="{RelativeSource Self}" />
|
||||
<Binding Path="CornerRadius"
|
||||
RelativeSource="{RelativeSource Self}" />
|
||||
</MultiBinding>
|
||||
</Border.Clip>
|
||||
<ContentControl>
|
||||
<flowlauncher:ResultListBox
|
||||
x:Name="ContextMenu"
|
||||
<flowlauncher:ResultListBox x:Name="ContextMenu"
|
||||
DataContext="{Binding ContextMenu}"
|
||||
PreviewMouseDown="OnPreviewMouseButtonDown" />
|
||||
LeftClickResultCommand="{Binding LeftClickResultCommand}"
|
||||
RightClickResultCommand="{Binding RightClickResultCommand}" />
|
||||
</ContentControl>
|
||||
</Border>
|
||||
<Border Style="{DynamicResource WindowRadius}">
|
||||
<Border.Clip>
|
||||
<MultiBinding Converter="{StaticResource BorderClipConverter}">
|
||||
<Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}" />
|
||||
<Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}" />
|
||||
<Binding Path="CornerRadius" RelativeSource="{RelativeSource Self}" />
|
||||
<Binding Path="ActualWidth"
|
||||
RelativeSource="{RelativeSource Self}" />
|
||||
<Binding Path="ActualHeight"
|
||||
RelativeSource="{RelativeSource Self}" />
|
||||
<Binding Path="CornerRadius"
|
||||
RelativeSource="{RelativeSource Self}" />
|
||||
</MultiBinding>
|
||||
</Border.Clip>
|
||||
<ContentControl>
|
||||
<flowlauncher:ResultListBox
|
||||
x:Name="History"
|
||||
<flowlauncher:ResultListBox x:Name="History"
|
||||
DataContext="{Binding History}"
|
||||
PreviewMouseDown="OnPreviewMouseButtonDown" />
|
||||
LeftClickResultCommand="{Binding LeftClickResultCommand}"
|
||||
RightClickResultCommand="{Binding RightClickResultCommand}" />
|
||||
</ContentControl>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
|
|
|||
|
|
@ -405,28 +405,6 @@ namespace Flow.Launcher
|
|||
if (e.ChangedButton == MouseButton.Left) DragMove();
|
||||
}
|
||||
|
||||
private void OnPreviewMouseButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (sender != null && e.OriginalSource != null)
|
||||
{
|
||||
var r = (ResultListBox)sender;
|
||||
var d = (DependencyObject)e.OriginalSource;
|
||||
var item = ItemsControl.ContainerFromElement(r, d) as ListBoxItem;
|
||||
var result = (ResultViewModel)item?.DataContext;
|
||||
if (result != null)
|
||||
{
|
||||
if (e.ChangedButton == MouseButton.Left)
|
||||
{
|
||||
_viewModel.OpenResultCommand.Execute(null);
|
||||
}
|
||||
else if (e.ChangedButton == MouseButton.Right)
|
||||
{
|
||||
_viewModel.LoadContextMenuCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPreviewDragOver(object sender, DragEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@
|
|||
Visibility="{Binding Visbility}"
|
||||
mc:Ignorable="d"
|
||||
PreviewMouseMove="ResultList_MouseMove"
|
||||
PreviewMouseLeftButtonDown="ResultList_PreviewMouseLeftButtonDown">
|
||||
PreviewMouseLeftButtonDown="ResultList_PreviewMouseLeftButtonDown"
|
||||
PreviewMouseLeftButtonUp="ResultListBox_OnPreviewMouseUp"
|
||||
PreviewMouseRightButtonDown="ResultListBox_OnPreviewMouseRightButtonDown">
|
||||
<!-- IsSynchronizedWithCurrentItem: http://stackoverflow.com/a/7833798/2833083 -->
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
|
|
@ -137,10 +139,11 @@
|
|||
x:Name="Title"
|
||||
VerticalAlignment="Center"
|
||||
DockPanel.Dock="Left"
|
||||
IsHitTestVisible="False"
|
||||
Style="{DynamicResource ItemTitleStyle}"
|
||||
Text="{Binding Result.Title}"
|
||||
ToolTip="{Binding ShowTitleToolTip}">
|
||||
ToolTip="{Binding ShowTitleToolTip}"
|
||||
ToolTipService.ShowOnDisabled="True"
|
||||
IsEnabled="False">
|
||||
<vm:ResultsViewModel.FormattedText>
|
||||
<MultiBinding Converter="{StaticResource HighlightTextConverter}">
|
||||
<Binding Path="Result.Title" />
|
||||
|
|
@ -151,11 +154,11 @@
|
|||
<TextBlock
|
||||
x:Name="SubTitle"
|
||||
Grid.Row="1"
|
||||
IsHitTestVisible="False"
|
||||
IsEnabled="False"
|
||||
ToolTipService.ShowOnDisabled="True"
|
||||
Style="{DynamicResource ItemSubTitleStyle}"
|
||||
Text="{Binding Result.SubTitle}"
|
||||
ToolTip="{Binding ShowSubTitleToolTip}" />
|
||||
|
||||
ToolTip="{Binding ShowSubTitleToolTip}"/>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,36 @@ namespace Flow.Launcher
|
|||
InitializeComponent();
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty RightClickResultCommandProperty =
|
||||
DependencyProperty.Register("RightClickResultCommand", typeof(ICommand), typeof(ResultListBox), new UIPropertyMetadata(null));
|
||||
|
||||
public ICommand RightClickResultCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ICommand)GetValue(RightClickResultCommandProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(RightClickResultCommandProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty LeftClickResultCommandProperty =
|
||||
DependencyProperty.Register("LeftClickResultCommand", typeof(ICommand), typeof(ResultListBox), new UIPropertyMetadata(null));
|
||||
|
||||
public ICommand LeftClickResultCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ICommand)GetValue(LeftClickResultCommandProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(LeftClickResultCommandProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (e.AddedItems.Count > 0 && e.AddedItems[0] != null)
|
||||
|
|
@ -98,10 +128,24 @@ namespace Flow.Launcher
|
|||
path
|
||||
});
|
||||
DragDrop.DoDragDrop((DependencyObject)sender, data, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
|
||||
|
||||
App.API.ChangeQuery(query, true);
|
||||
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
private void ResultListBox_OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (Mouse.DirectlyOver is not FrameworkElement { DataContext: ResultViewModel result })
|
||||
return;
|
||||
|
||||
RightClickResultCommand?.Execute(result.Result);
|
||||
}
|
||||
private void ResultListBox_OnPreviewMouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (Mouse.DirectlyOver is not FrameworkElement { DataContext: ResultViewModel result })
|
||||
return;
|
||||
|
||||
LeftClickResultCommand?.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,12 +77,22 @@ namespace Flow.Launcher.ViewModel
|
|||
_userSelectedRecord = _userSelectedRecordStorage.Load();
|
||||
_topMostRecord = _topMostRecordStorage.Load();
|
||||
|
||||
ContextMenu = new ResultsViewModel(Settings);
|
||||
Results = new ResultsViewModel(Settings);
|
||||
History = new ResultsViewModel(Settings);
|
||||
InitializeKeyCommands();
|
||||
|
||||
ContextMenu = new ResultsViewModel(Settings)
|
||||
{
|
||||
LeftClickResultCommand = OpenResultCommand, RightClickResultCommand = LoadContextMenuCommand
|
||||
};
|
||||
Results = new ResultsViewModel(Settings)
|
||||
{
|
||||
LeftClickResultCommand = OpenResultCommand, RightClickResultCommand = LoadContextMenuCommand
|
||||
};
|
||||
History = new ResultsViewModel(Settings)
|
||||
{
|
||||
LeftClickResultCommand = OpenResultCommand, RightClickResultCommand = LoadContextMenuCommand
|
||||
};
|
||||
_selectedResults = Results;
|
||||
|
||||
InitializeKeyCommands();
|
||||
|
||||
RegisterViewUpdate();
|
||||
RegisterResultsUpdatedEvent();
|
||||
|
|
@ -199,15 +209,10 @@ namespace Flow.Launcher.ViewModel
|
|||
PluginManager.API.OpenUrl("https://github.com/Flow-Launcher/Flow.Launcher/wiki/Flow-Launcher/");
|
||||
});
|
||||
OpenSettingCommand = new RelayCommand(_ => { App.API.OpenSettingDialog(); });
|
||||
OpenResultCommand = new RelayCommand(async index =>
|
||||
OpenResultCommand = new AsyncRelayCommand(async _ =>
|
||||
{
|
||||
var results = SelectedResults;
|
||||
|
||||
if (index != null)
|
||||
{
|
||||
results.SelectedIndex = int.Parse(index.ToString()!);
|
||||
}
|
||||
|
||||
var result = results.SelectedItem?.Result;
|
||||
if (result == null)
|
||||
{
|
||||
|
|
@ -363,9 +368,9 @@ namespace Flow.Launcher.ViewModel
|
|||
{
|
||||
if (MainWindowWidth + 100 > 1920 || Settings.WindowSize == 1920)
|
||||
{
|
||||
Settings.WindowSize = 1920;
|
||||
Settings.WindowSize = 1920;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
Settings.WindowSize += 100;
|
||||
Settings.WindowLeft -= 50;
|
||||
|
|
@ -648,7 +653,7 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
if (currentCancellationToken.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
|
||||
|
||||
// handle the exclusiveness of plugin using action keyword
|
||||
RemoveOldQueryResults(query);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ using System.Windows;
|
|||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Flow.Launcher.ViewModel
|
||||
{
|
||||
|
|
@ -49,6 +51,9 @@ namespace Flow.Launcher.ViewModel
|
|||
public ResultViewModel SelectedItem { get; set; }
|
||||
public Thickness Margin { get; set; }
|
||||
public Visibility Visbility { get; set; } = Visibility.Collapsed;
|
||||
|
||||
public ICommand RightClickResultCommand { get; init; }
|
||||
public ICommand LeftClickResultCommand { get; init; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
/// Path of the actual executable file.
|
||||
/// </summary>
|
||||
public string ExecutablePath => LnkResolvedPath ?? FullPath;
|
||||
public string WorkingDir => Directory.GetParent(ExecutablePath)?.FullName ?? string.Empty;
|
||||
public string ParentDirectory { get; set; }
|
||||
public string ExecutableName { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
|
@ -140,8 +139,8 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
|
||||
var info = new ProcessStartInfo
|
||||
{
|
||||
FileName = ExecutablePath,
|
||||
WorkingDirectory = WorkingDir,
|
||||
FileName = FullPath,
|
||||
WorkingDirectory = ParentDirectory,
|
||||
UseShellExecute = true,
|
||||
Verb = runAsAdmin ? "runas" : null
|
||||
};
|
||||
|
|
@ -167,8 +166,8 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
{
|
||||
var info = new ProcessStartInfo
|
||||
{
|
||||
FileName = ExecutablePath,
|
||||
WorkingDirectory = WorkingDir,
|
||||
FileName = FullPath,
|
||||
WorkingDirectory = ParentDirectory,
|
||||
UseShellExecute = true
|
||||
};
|
||||
|
||||
|
|
@ -187,7 +186,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
var info = new ProcessStartInfo
|
||||
{
|
||||
FileName = ExecutablePath,
|
||||
WorkingDirectory = WorkingDir,
|
||||
WorkingDirectory = ParentDirectory,
|
||||
Verb = "runas",
|
||||
UseShellExecute = true
|
||||
};
|
||||
|
|
@ -221,8 +220,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
return Name;
|
||||
}
|
||||
|
||||
public static List<FileSystemWatcher> Watchers = new List<FileSystemWatcher>();
|
||||
|
||||
private static List<FileSystemWatcher> Watchers = new List<FileSystemWatcher>();
|
||||
|
||||
private static Win32 Win32Program(string path)
|
||||
{
|
||||
|
|
@ -573,6 +571,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
|
||||
private static IEnumerable<Win32> ProgramsHasher(IEnumerable<Win32> programs)
|
||||
{
|
||||
// TODO: Unable to distinguish multiple lnks to the same excutable but with different params
|
||||
return programs.GroupBy(p => p.ExecutablePath.ToLowerInvariant())
|
||||
.AsParallel()
|
||||
.SelectMany(g =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue