mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
keep search activation, enable and disable path and index search
This commit is contained in:
parent
e4a15b453b
commit
7e799b5625
8 changed files with 88 additions and 23 deletions
|
|
@ -22,6 +22,8 @@
|
|||
<system:String x:Key="plugin_explorer_actionkeywordview_search">Index Search Activation:</system:String>
|
||||
<system:String x:Key="plugin_explorer_actionkeywordview_path">Path Explore Activation:</system:String>
|
||||
<system:String x:Key="plugin_explorer_actionkeywordview_filecontentsearch">File Content Search:</system:String>
|
||||
<system:String x:Key="plugin_explorer_actionkeywordview_indexonlysearch">Index Only Search:</system:String>
|
||||
<system:String x:Key="plugin_explorer_actionkeywordview_brackets_disabled">(Disabled)</system:String>
|
||||
|
||||
<!--Plugin Infos-->
|
||||
<system:String x:Key="plugin_explorer_plugin_name">Explorer</system:String>
|
||||
|
|
|
|||
|
|
@ -46,12 +46,12 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
|
||||
var result = new HashSet<Result>(PathEqualityComparator.Instance);
|
||||
|
||||
if (ActionKeywordMatch(query, settings.PathSearchActionKeyword))
|
||||
if (ActionKeywordMatch(query, settings.PathSearchActionKeyword) || ActionKeywordMatch(query, settings.SearchActionKeyword))
|
||||
{
|
||||
result.UnionWith(await PathSearchAsync(query, token).ConfigureAwait(false));
|
||||
}
|
||||
|
||||
if (ActionKeywordMatch(query, settings.SearchActionKeyword) &&
|
||||
if ((ActionKeywordMatch(query, settings.IndexOnlySearchActionKeyword) || ActionKeywordMatch(query, settings.SearchActionKeyword)) &&
|
||||
querySearch.Length > 0 &&
|
||||
!querySearch.IsLocationPathString())
|
||||
{
|
||||
|
|
@ -61,10 +61,15 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
return result.ToList();
|
||||
}
|
||||
|
||||
private bool ActionKeywordMatch(Query query, string actionKeyword)
|
||||
private bool ActionKeywordMatch(Query query, string allowedActionKeyword)
|
||||
{
|
||||
return query.ActionKeyword == actionKeyword ||
|
||||
query.ActionKeyword.Length == 0 && actionKeyword == Query.GlobalPluginWildcardSign;
|
||||
if (settings.EnabledIndexOnlySearchKeyword && (settings.IndexOnlySearchActionKeyword == Query.GlobalPluginWildcardSign || query.ActionKeyword == allowedActionKeyword))
|
||||
return true;
|
||||
|
||||
if (settings.EnabledPathSearchKeyword && (settings.PathSearchActionKeyword == Query.GlobalPluginWildcardSign || query.ActionKeyword == allowedActionKeyword))
|
||||
return true;
|
||||
|
||||
return settings.SearchActionKeyword == Query.GlobalPluginWildcardSign || query.ActionKeyword == allowedActionKeyword;
|
||||
}
|
||||
|
||||
public async Task<List<Result>> PathSearchAsync(Query query, CancellationToken token = default)
|
||||
|
|
|
|||
|
|
@ -22,5 +22,11 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword;
|
||||
|
||||
public string PathSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
|
||||
|
||||
public bool EnabledPathSearchKeyword { get; set; }
|
||||
|
||||
public string IndexOnlySearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
|
||||
|
||||
public bool EnabledIndexOnlySearchKeyword { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -59,6 +59,9 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
|
|||
case ActionKeywordProperty.FileContentSearchActionKeyword:
|
||||
Settings.FileContentSearchActionKeyword = newActionKeyword;
|
||||
break;
|
||||
case ActionKeywordProperty.IndexOnlySearchActionKeyword:
|
||||
Settings.IndexOnlySearchActionKeyword = newActionKeyword;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -71,6 +74,7 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
|
|||
{
|
||||
SearchActionKeyword,
|
||||
PathSearchActionKeyword,
|
||||
FileContentSearchActionKeyword
|
||||
FileContentSearchActionKeyword,
|
||||
IndexOnlySearchActionKeyword
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="180" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Margin="20 10 10 10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left" Text="Current Action Keyword:" />
|
||||
|
|
@ -23,8 +24,9 @@
|
|||
Margin="10" Grid.Row="0" Width="105" Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left" />
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="1">
|
||||
<CheckBox Name="chkActionKeywordEnabled" Margin="10" Grid.Row="0" Grid.Column="2" Content="Enabled" Width="auto"
|
||||
VerticalAlignment="Center" Checked="OnActionKeywordEnabledChecked" Unchecked="OnActionKeywordEnabledUnChecked"/>
|
||||
<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.ColumnSpan="2" Margin="100 92 0 0" Grid.RowSpan="2">
|
||||
<Button Click="OnConfirmButtonClick"
|
||||
Margin="10 0 10 0" Width="80" Height="35"
|
||||
Content="OK" />
|
||||
|
|
|
|||
|
|
@ -1,16 +1,7 @@
|
|||
using Flow.Launcher.Plugin.Explorer.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Explorer.Views
|
||||
{
|
||||
|
|
@ -23,20 +14,36 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
|
||||
private ActionKeywordView currentActionKeyword;
|
||||
|
||||
|
||||
private List<ActionKeywordView> actionKeywordListView;
|
||||
|
||||
public ActionKeywordSetting(SettingsViewModel settingsViewModel, List<ActionKeywordView> actionKeywordListView, ActionKeywordView selectedActionKeyword)
|
||||
private Settings settings;
|
||||
|
||||
public ActionKeywordSetting(SettingsViewModel settingsViewModel,
|
||||
List<ActionKeywordView> actionKeywordListView,
|
||||
ActionKeywordView selectedActionKeyword, Settings settings)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.settingsViewModel = settingsViewModel;
|
||||
|
||||
this.settings = settings;
|
||||
|
||||
currentActionKeyword = selectedActionKeyword;
|
||||
|
||||
txtCurrentActionKeyword.Text = selectedActionKeyword.Keyword;
|
||||
|
||||
this.actionKeywordListView = actionKeywordListView;
|
||||
|
||||
// Search and File Content action keyword are not allowed to be disabled, they are the default search keyword.
|
||||
if (currentActionKeyword.KeywordProperty == ActionKeywordProperty.SearchActionKeyword
|
||||
|| currentActionKeyword.KeywordProperty == ActionKeywordProperty.FileContentSearchActionKeyword)
|
||||
chkActionKeywordEnabled.Visibility = Visibility.Collapsed;
|
||||
|
||||
if (currentActionKeyword.KeywordProperty == ActionKeywordProperty.IndexOnlySearchActionKeyword)
|
||||
chkActionKeywordEnabled.IsChecked = this.settings.EnabledIndexOnlySearchKeyword;
|
||||
|
||||
if (currentActionKeyword.KeywordProperty == ActionKeywordProperty.PathSearchActionKeyword)
|
||||
chkActionKeywordEnabled.IsChecked = this.settings.EnabledPathSearchKeyword;
|
||||
}
|
||||
|
||||
private void OnConfirmButtonClick(object sender, RoutedEventArgs e)
|
||||
|
|
@ -81,5 +88,30 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
|
||||
return;
|
||||
}
|
||||
private void OnActionKeywordEnabledChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (currentActionKeyword.KeywordProperty == ActionKeywordProperty.IndexOnlySearchActionKeyword)
|
||||
settings.EnabledIndexOnlySearchKeyword = true;
|
||||
|
||||
if (currentActionKeyword.KeywordProperty == ActionKeywordProperty.PathSearchActionKeyword)
|
||||
settings.EnabledPathSearchKeyword = true;
|
||||
}
|
||||
|
||||
private void OnActionKeywordEnabledUnChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (currentActionKeyword.Keyword == settings.IndexOnlySearchActionKeyword)
|
||||
{
|
||||
settings.EnabledIndexOnlySearchKeyword = false;
|
||||
// reset to global so it does not take up an action keyword when disabled
|
||||
settings.IndexOnlySearchActionKeyword = Query.GlobalPluginWildcardSign;
|
||||
}
|
||||
|
||||
if (currentActionKeyword.Keyword == settings.PathSearchActionKeyword)
|
||||
{
|
||||
settings.EnabledPathSearchKeyword = false;
|
||||
// reset to global so it does not take up an action keyword when disabled
|
||||
settings.PathSearchActionKeyword = Query.GlobalPluginWildcardSign;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,9 +49,21 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
},
|
||||
new ()
|
||||
{
|
||||
Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_path"),
|
||||
Description = viewModel.Settings.EnabledPathSearchKeyword
|
||||
? viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_path")
|
||||
: viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_path")
|
||||
+ " " + viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_brackets_disabled"),
|
||||
Keyword = this.viewModel.Settings.PathSearchActionKeyword,
|
||||
KeywordProperty = ActionKeywordProperty.PathSearchActionKeyword
|
||||
},
|
||||
new ()
|
||||
{
|
||||
Description = viewModel.Settings.EnabledIndexOnlySearchKeyword
|
||||
? viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_indexonlysearch")
|
||||
: viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_indexonlysearch")
|
||||
+ " " + viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_brackets_disabled"),
|
||||
Keyword = this.viewModel.Settings.IndexOnlySearchActionKeyword,
|
||||
KeywordProperty = ActionKeywordProperty.IndexOnlySearchActionKeyword
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -199,7 +211,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
{
|
||||
var selectedActionKeyword = lbxActionKeywords.SelectedItem as ActionKeywordView;
|
||||
|
||||
var actionKeywordWindow = new ActionKeywordSetting(viewModel, actionKeywordsListView, selectedActionKeyword);
|
||||
var actionKeywordWindow = new ActionKeywordSetting(viewModel, actionKeywordsListView, selectedActionKeyword, viewModel.Settings);
|
||||
|
||||
actionKeywordWindow.ShowDialog();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
{
|
||||
"ID": "572be03c74c642baae319fc283e561a8",
|
||||
"ActionKeywords": [
|
||||
"*",
|
||||
"doc:"
|
||||
"*",
|
||||
"doc:",
|
||||
"*",
|
||||
"*"
|
||||
],
|
||||
"Name": "Explorer",
|
||||
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
|
||||
|
|
|
|||
Loading…
Reference in a new issue