mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge branch 'dev'
This commit is contained in:
commit
24cf015b0a
10 changed files with 123 additions and 20 deletions
|
|
@ -72,6 +72,7 @@ namespace Wox.Plugin.WebSearch
|
|||
SubTitle = subtitle,
|
||||
Score = 6,
|
||||
IcoPath = searchSource.IconPath,
|
||||
ActionKeywordAssigned = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? string.Empty : searchSource.ActionKeyword,
|
||||
Action = c =>
|
||||
{
|
||||
if (_settings.OpenInNewBrowser)
|
||||
|
|
@ -137,6 +138,7 @@ namespace Wox.Plugin.WebSearch
|
|||
SubTitle = subtitle,
|
||||
Score = 5,
|
||||
IcoPath = searchSource.IconPath,
|
||||
ActionKeywordAssigned = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? string.Empty : searchSource.ActionKeyword,
|
||||
Action = c =>
|
||||
{
|
||||
if (_settings.OpenInNewBrowser)
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ Features
|
|||
**New from this fork:**
|
||||
- Portable mode
|
||||
- Drastically improved search experience
|
||||
- Auto-complete text suggestion
|
||||
- Search all subfolders and files
|
||||
- Option to always run CMD or Powershell as administrator
|
||||
- Run CMD, Powershell and programs as a different user
|
||||
|
|
|
|||
|
|
@ -191,6 +191,11 @@ namespace Wox.Core.Plugin
|
|||
r.PluginDirectory = metadata.PluginDirectory;
|
||||
r.PluginID = metadata.ID;
|
||||
r.OriginQuery = query;
|
||||
|
||||
// ActionKeywordAssigned is used for constructing MainViewModel's query text auto-complete suggestions
|
||||
// Plugins may have multi-actionkeywords eg. WebSearches. In this scenario it needs to be overriden on the plugin level
|
||||
if (metadata.ActionKeywords.Count == 1)
|
||||
r.ActionKeywordAssigned = query.ActionKeyword;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -124,6 +124,12 @@ namespace Wox.Core.Resource
|
|||
queryBoxStyle.Setters.Add(new Setter(TextBox.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(Settings.QueryBoxFontStyle)));
|
||||
queryBoxStyle.Setters.Add(new Setter(TextBox.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(Settings.QueryBoxFontWeight)));
|
||||
queryBoxStyle.Setters.Add(new Setter(TextBox.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(Settings.QueryBoxFontStretch)));
|
||||
|
||||
var caretBrushPropertyValue = queryBoxStyle.Setters.OfType<Setter>().Any(x => x.Property.Name == "CaretBrush");
|
||||
var foregroundPropertyValue = queryBoxStyle.Setters.OfType<Setter>().Where(x => x.Property.Name == "Foreground")
|
||||
.Select(x => x.Value).FirstOrDefault();
|
||||
if (!caretBrushPropertyValue && foregroundPropertyValue != null) //otherwise BaseQueryBoxStyle will handle styling
|
||||
queryBoxStyle.Setters.Add(new Setter(TextBox.CaretBrushProperty, foregroundPropertyValue));
|
||||
}
|
||||
|
||||
Style resultItemStyle = dict["ItemTitleStyle"] as Style;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,12 @@ namespace Wox.Plugin
|
|||
public string Title { get; set; }
|
||||
public string SubTitle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This holds the action keyword that triggered the result.
|
||||
/// If result is triggered by global keyword: *, this should be empty.
|
||||
/// </summary>
|
||||
public string ActionKeywordAssigned { get; set; }
|
||||
|
||||
public string IcoPath
|
||||
{
|
||||
get { return _icoPath; }
|
||||
|
|
@ -53,7 +59,7 @@ namespace Wox.Plugin
|
|||
public IList<int> SubTitleHighlightData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Only resulsts that originQuery match with curren query will be displayed in the panel
|
||||
/// Only results that originQuery match with current query will be displayed in the panel
|
||||
/// </summary>
|
||||
internal Query OriginQuery { get; set; }
|
||||
|
||||
|
|
@ -98,13 +104,14 @@ namespace Wox.Plugin
|
|||
return Title + SubTitle;
|
||||
}
|
||||
|
||||
[Obsolete("Use IContextMenu instead")]
|
||||
|
||||
/// <summary>
|
||||
/// Context menus associate with this result
|
||||
/// </summary>
|
||||
[Obsolete("Use IContextMenu instead")]
|
||||
public List<Result> ContextMenu { get; set; }
|
||||
|
||||
[Obsolete("Use Object initializers instead")]
|
||||
[Obsolete("Use Object initializer instead")]
|
||||
public Result(string Title, string IcoPath, string SubTitle = null)
|
||||
{
|
||||
this.Title = Title;
|
||||
|
|
|
|||
61
Wox/Converters/QuerySuggestionBoxConverter.cs
Normal file
61
Wox/Converters/QuerySuggestionBoxConverter.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using Wox.ViewModel;
|
||||
|
||||
namespace Wox.Converters
|
||||
{
|
||||
public class QuerySuggestionBoxConverter : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (values.Length != 2)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
// first prop is the current query string
|
||||
var queryText = (string)values[0];
|
||||
|
||||
if (string.IsNullOrEmpty(queryText))
|
||||
return "Type here to search";
|
||||
|
||||
// second prop is the current selected item result
|
||||
var val = values[1];
|
||||
if (val == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
if (!(val is ResultViewModel))
|
||||
{
|
||||
return System.Windows.Data.Binding.DoNothing;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var selectedItem = (ResultViewModel)val;
|
||||
|
||||
var selectedResult = selectedItem.Result;
|
||||
var selectedResultActionKeyword = string.IsNullOrEmpty(selectedResult.ActionKeywordAssigned) ? "" : selectedResult.ActionKeywordAssigned + " ";
|
||||
var selectedResultPossibleSuggestion = selectedResultActionKeyword + selectedResult.Title;
|
||||
|
||||
if (!selectedResultPossibleSuggestion.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase))
|
||||
return string.Empty;
|
||||
|
||||
// When user typed lower case and result title is uppercase, we still want to display suggestion
|
||||
return queryText + selectedResultPossibleSuggestion.Substring(queryText.Length);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception(nameof(QuerySuggestionBoxConverter), "fail to convert text for suggestion box", e);
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,9 @@
|
|||
xmlns:wox="clr-namespace:Wox"
|
||||
xmlns:vm="clr-namespace:Wox.ViewModel"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:converters="clr-namespace:Wox.Converters"
|
||||
mc:Ignorable="d"
|
||||
Title="Wox"
|
||||
Topmost="True"
|
||||
SizeToContent="Height"
|
||||
|
|
@ -25,6 +27,9 @@
|
|||
PreviewKeyDown="OnKeyDown"
|
||||
Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
d:DataContext="{d:DesignInstance vm:MainViewModel}">
|
||||
<Window.Resources>
|
||||
<converters:QuerySuggestionBoxConverter x:Key="QuerySuggestionBoxConverter"/>
|
||||
</Window.Resources>
|
||||
<Window.InputBindings>
|
||||
<KeyBinding Key="Escape" Command="{Binding EscCommand}"></KeyBinding>
|
||||
<KeyBinding Key="F1" Command="{Binding StartHelpCommand}"></KeyBinding>
|
||||
|
|
@ -55,29 +60,43 @@
|
|||
</Window.InputBindings>
|
||||
<Border Style="{DynamicResource WindowBorderStyle}" MouseDown="OnMouseDown" >
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBox Style="{DynamicResource QueryBoxStyle}"
|
||||
<Grid>
|
||||
<TextBox x:Name="QueryTextSuggestionBox"
|
||||
Style="{DynamicResource QueryBoxStyle}"
|
||||
Foreground="LightGray"
|
||||
IsEnabled="False">
|
||||
<TextBox.Text>
|
||||
<MultiBinding Converter="{StaticResource QuerySuggestionBoxConverter}">
|
||||
<Binding ElementName="QueryTextBox" Path="Text"/>
|
||||
<Binding ElementName="ResultListBox" Path="SelectedItem"/>
|
||||
</MultiBinding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
<TextBox x:Name="QueryTextBox"
|
||||
Style="{DynamicResource QueryBoxStyle}"
|
||||
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
PreviewDragOver="OnPreviewDragOver"
|
||||
TextChanged="OnTextChanged"
|
||||
AllowDrop="True"
|
||||
Visibility="Visible"
|
||||
x:Name="QueryTextBox">
|
||||
<TextBox.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Command="ApplicationCommands.Cut"/>
|
||||
<MenuItem Command="ApplicationCommands.Copy"/>
|
||||
<MenuItem Command="ApplicationCommands.Paste"/>
|
||||
<Separator />
|
||||
<MenuItem Header="Settings" Click="OnContextMenusForSettingsClick" />
|
||||
</ContextMenu>
|
||||
</TextBox.ContextMenu>
|
||||
</TextBox>
|
||||
Background="Transparent">
|
||||
<TextBox.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Command="ApplicationCommands.Cut"/>
|
||||
<MenuItem Command="ApplicationCommands.Copy"/>
|
||||
<MenuItem Command="ApplicationCommands.Paste"/>
|
||||
<Separator />
|
||||
<MenuItem Header="Settings" Click="OnContextMenusForSettingsClick" />
|
||||
</ContextMenu>
|
||||
</TextBox.ContextMenu>
|
||||
</TextBox>
|
||||
</Grid>
|
||||
<Line x:Name="ProgressBar" HorizontalAlignment="Right"
|
||||
Style="{DynamicResource PendingLineStyle}" Visibility="{Binding ProgressBarVisibility, Mode=TwoWay}"
|
||||
Y1="0" Y2="0" X2="100" Height="2" Width="752" StrokeThickness="1">
|
||||
</Line>
|
||||
<ContentControl>
|
||||
<wox:ResultListBox DataContext="{Binding Results}" PreviewMouseDown="OnPreviewMouseButtonDown" />
|
||||
<wox:ResultListBox x:Name="ResultListBox" DataContext="{Binding Results}" PreviewMouseDown="OnPreviewMouseButtonDown" />
|
||||
</ContentControl>
|
||||
<ContentControl>
|
||||
<wox:ResultListBox DataContext="{Binding ContextMenu}" PreviewMouseDown="OnPreviewMouseButtonDown" />
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
<Setter Property="Height" Value="46" />
|
||||
<Setter Property="Background" Value="#616161" />
|
||||
<Setter Property="Foreground" Value="#E3E0E3" />
|
||||
<Setter Property="CaretBrush" Value="#E3E0E3" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
|
||||
</Style>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
|
@ -210,7 +211,7 @@ namespace Wox.ViewModel
|
|||
Query();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// we need move cursor to end when we manually changed query
|
||||
/// but we don't want to move cursor to end when query is updated from TextBox
|
||||
|
|
@ -455,7 +456,6 @@ namespace Wox.ViewModel
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private Result ContextMenuTopMost(Result result)
|
||||
{
|
||||
Result menu;
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@
|
|||
<Compile Include="Converters\HighlightTextConverter.cs" />
|
||||
<Compile Include="Helper\SingletonWindowOpener.cs" />
|
||||
<Compile Include="PublicAPIInstance.cs" />
|
||||
<Compile Include="Converters\QuerySuggestionBoxConverter.cs" />
|
||||
<Compile Include="ReportWindow.xaml.cs" />
|
||||
<Compile Include="ResultListBox.xaml.cs">
|
||||
<DependentUpon>ResultListBox.xaml</DependentUpon>
|
||||
|
|
|
|||
Loading…
Reference in a new issue