update action keyword match logic

This commit is contained in:
Jeremy 2021-05-30 15:11:59 +10:00
parent e5fbfa24b4
commit 3bf3afc795
5 changed files with 12 additions and 57 deletions

View file

@ -63,13 +63,16 @@ namespace Flow.Launcher.Plugin.Explorer.Search
private bool ActionKeywordMatch(Query query, string allowedActionKeyword)
{
if (settings.EnabledIndexOnlySearchKeyword && (settings.IndexOnlySearchActionKeyword == Query.GlobalPluginWildcardSign || query.ActionKeyword == allowedActionKeyword))
return true;
if (query.ActionKeyword == settings.IndexOnlySearchActionKeyword)
return settings.IndexOnlySearchActionKeyword == allowedActionKeyword;
if (settings.EnabledPathSearchKeyword && (settings.PathSearchActionKeyword == Query.GlobalPluginWildcardSign || query.ActionKeyword == allowedActionKeyword))
return true;
if (query.ActionKeyword == settings.PathSearchActionKeyword)
return settings.PathSearchActionKeyword == allowedActionKeyword;
return settings.SearchActionKeyword == Query.GlobalPluginWildcardSign || query.ActionKeyword == allowedActionKeyword;
if (query.ActionKeyword == settings.SearchActionKeyword)
return settings.SearchActionKeyword == allowedActionKeyword;
return Query.GlobalPluginWildcardSign == allowedActionKeyword;
}
public async Task<List<Result>> PathSearchAsync(Query query, CancellationToken token = default)

View file

@ -23,10 +23,6 @@ namespace Flow.Launcher.Plugin.Explorer
public string PathSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
public bool EnabledPathSearchKeyword { get; set; }
public string IndexOnlySearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
public bool EnabledIndexOnlySearchKeyword { get; set; }
}
}

View file

@ -16,7 +16,6 @@
<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:" />
@ -24,9 +23,8 @@
Margin="10" Grid.Row="0" Width="105" Grid.Column="1"
VerticalAlignment="Center"
HorizontalAlignment="Left" />
<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">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="1">
<Button Click="OnConfirmButtonClick"
Margin="10 0 10 0" Width="80" Height="35"
Content="OK" />

View file

@ -33,17 +33,6 @@ namespace Flow.Launcher.Plugin.Explorer.Views
txtCurrentActionKeyword.Text = selectedActionKeyword.Keyword;
this.actionKeywordListView = actionKeywordListView;
// Search and File Content action keyword are not allowed to be disabled, they are the default search keywords.
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)
@ -88,30 +77,5 @@ 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;
}
}
}
}

View file

@ -49,19 +49,13 @@ namespace Flow.Launcher.Plugin.Explorer.Views
},
new ()
{
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"),
Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_path"),
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"),
Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_indexonlysearch"),
Keyword = this.viewModel.Settings.IndexOnlySearchActionKeyword,
KeywordProperty = ActionKeywordProperty.IndexOnlySearchActionKeyword
}