mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
option to allow action keywords to be disabled
This commit is contained in:
parent
e9abaf3f6c
commit
995cf568ff
6 changed files with 97 additions and 19 deletions
|
|
@ -23,6 +23,7 @@
|
|||
<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) || ActionKeywordMatch(query, settings.SearchActionKeyword))
|
||||
if (ActionKeywordMatch(query, Settings.ActionKeyword.PathSearchActionKeyword) || ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword))
|
||||
{
|
||||
result.UnionWith(await PathSearchAsync(query, token).ConfigureAwait(false));
|
||||
}
|
||||
|
||||
if ((ActionKeywordMatch(query, settings.IndexOnlySearchActionKeyword) || ActionKeywordMatch(query, settings.SearchActionKeyword)) &&
|
||||
if ((ActionKeywordMatch(query, Settings.ActionKeyword.IndexOnlySearchActionKeyword) || ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword)) &&
|
||||
querySearch.Length > 0 &&
|
||||
!querySearch.IsLocationPathString())
|
||||
{
|
||||
|
|
@ -61,18 +61,21 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
return result.ToList();
|
||||
}
|
||||
|
||||
private bool ActionKeywordMatch(Query query, string allowedActionKeyword)
|
||||
private bool ActionKeywordMatch(Query query, Settings.ActionKeyword allowedActionKeyword)
|
||||
{
|
||||
if (query.ActionKeyword == settings.IndexOnlySearchActionKeyword)
|
||||
return settings.IndexOnlySearchActionKeyword == allowedActionKeyword;
|
||||
return Settings.ActionKeyword.IndexOnlySearchActionKeyword == allowedActionKeyword && settings.EnabledIndexOnlySearchKeyword;
|
||||
|
||||
if (query.ActionKeyword == settings.PathSearchActionKeyword)
|
||||
return settings.PathSearchActionKeyword == allowedActionKeyword;
|
||||
return Settings.ActionKeyword.PathSearchActionKeyword == allowedActionKeyword && settings.EnabledPathSearchKeyword;
|
||||
|
||||
if (query.ActionKeyword == settings.SearchActionKeyword)
|
||||
return settings.SearchActionKeyword == allowedActionKeyword;
|
||||
return Settings.ActionKeyword.SearchActionKeyword == allowedActionKeyword;
|
||||
|
||||
return Query.GlobalPluginWildcardSign == allowedActionKeyword;
|
||||
|
||||
return (Settings.ActionKeyword.IndexOnlySearchActionKeyword == allowedActionKeyword && settings.EnabledIndexOnlySearchKeyword)
|
||||
|| (Settings.ActionKeyword.PathSearchActionKeyword == allowedActionKeyword && settings.EnabledPathSearchKeyword)
|
||||
|| settings.SearchActionKeyword == Query.GlobalPluginWildcardSign;
|
||||
}
|
||||
|
||||
public async Task<List<Result>> PathSearchAsync(Query query, CancellationToken token = default)
|
||||
|
|
|
|||
|
|
@ -23,6 +23,18 @@ 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; }
|
||||
|
||||
internal enum ActionKeyword
|
||||
{
|
||||
SearchActionKeyword,
|
||||
PathSearchActionKeyword,
|
||||
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" />
|
||||
|
|
|
|||
|
|
@ -33,6 +33,17 @@ 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)
|
||||
|
|
@ -42,6 +53,24 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
if (string.IsNullOrEmpty(newActionKeyword))
|
||||
return;
|
||||
|
||||
if (currentActionKeyword.KeywordProperty == ActionKeywordProperty.IndexOnlySearchActionKeyword)
|
||||
{
|
||||
// reset to global so it does not take up an action keyword when disabled
|
||||
if (!currentActionKeyword.Enabled && newActionKeyword != Query.GlobalPluginWildcardSign)
|
||||
settingsViewModel.UpdateActionKeyword(currentActionKeyword.KeywordProperty, Query.GlobalPluginWildcardSign, currentActionKeyword.Keyword);
|
||||
|
||||
settings.EnabledIndexOnlySearchKeyword = currentActionKeyword.Enabled;
|
||||
}
|
||||
|
||||
if (currentActionKeyword.KeywordProperty == ActionKeywordProperty.PathSearchActionKeyword)
|
||||
{
|
||||
// reset to global so it does not take up an action keyword when disabled
|
||||
if (!currentActionKeyword.Enabled && newActionKeyword != Query.GlobalPluginWildcardSign)
|
||||
settingsViewModel.UpdateActionKeyword(currentActionKeyword.KeywordProperty, Query.GlobalPluginWildcardSign, currentActionKeyword.Keyword);
|
||||
|
||||
settings.EnabledPathSearchKeyword = currentActionKeyword.Enabled;
|
||||
}
|
||||
|
||||
if (newActionKeyword == currentActionKeyword.Keyword)
|
||||
{
|
||||
Close();
|
||||
|
|
@ -63,6 +92,15 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
|
||||
actionKeywordListView.FirstOrDefault(x => x.Description == currentActionKeyword.Description).Keyword = newActionKeyword;
|
||||
|
||||
// automatically help users set this to enabled if an action keyword is set and currently disabled
|
||||
if (currentActionKeyword.KeywordProperty == ActionKeywordProperty.IndexOnlySearchActionKeyword
|
||||
&& !settings.EnabledIndexOnlySearchKeyword)
|
||||
settings.EnabledIndexOnlySearchKeyword = true;
|
||||
|
||||
if (currentActionKeyword.KeywordProperty == ActionKeywordProperty.PathSearchActionKeyword
|
||||
&& !settings.EnabledPathSearchKeyword)
|
||||
settings.EnabledPathSearchKeyword = true;
|
||||
|
||||
Close();
|
||||
|
||||
return;
|
||||
|
|
@ -77,5 +115,14 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
|
||||
return;
|
||||
}
|
||||
private void OnActionKeywordEnabledChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
currentActionKeyword.Enabled = true;
|
||||
}
|
||||
|
||||
private void OnActionKeywordEnabledUnChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
currentActionKeyword.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,26 +38,36 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
new ()
|
||||
{
|
||||
Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_search"),
|
||||
Keyword = this.viewModel.Settings.SearchActionKeyword,
|
||||
KeywordProperty = ActionKeywordProperty.SearchActionKeyword
|
||||
Keyword = viewModel.Settings.SearchActionKeyword,
|
||||
KeywordProperty = ActionKeywordProperty.SearchActionKeyword,
|
||||
Enabled = true
|
||||
},
|
||||
new ()
|
||||
{
|
||||
Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_filecontentsearch"),
|
||||
Keyword = this.viewModel.Settings.FileContentSearchActionKeyword,
|
||||
KeywordProperty = ActionKeywordProperty.FileContentSearchActionKeyword
|
||||
Keyword = viewModel.Settings.FileContentSearchActionKeyword,
|
||||
KeywordProperty = ActionKeywordProperty.FileContentSearchActionKeyword,
|
||||
Enabled = true
|
||||
},
|
||||
new ()
|
||||
{
|
||||
Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_path"),
|
||||
Keyword = this.viewModel.Settings.PathSearchActionKeyword,
|
||||
KeywordProperty = ActionKeywordProperty.PathSearchActionKeyword
|
||||
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 = viewModel.Settings.PathSearchActionKeyword,
|
||||
KeywordProperty = ActionKeywordProperty.PathSearchActionKeyword,
|
||||
Enabled = viewModel.Settings.EnabledPathSearchKeyword
|
||||
},
|
||||
new ()
|
||||
{
|
||||
Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_indexonlysearch"),
|
||||
Keyword = this.viewModel.Settings.IndexOnlySearchActionKeyword,
|
||||
KeywordProperty = ActionKeywordProperty.IndexOnlySearchActionKeyword
|
||||
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 = viewModel.Settings.IndexOnlySearchActionKeyword,
|
||||
KeywordProperty = ActionKeywordProperty.IndexOnlySearchActionKeyword,
|
||||
Enabled = viewModel.Settings.EnabledIndexOnlySearchKeyword
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -330,6 +340,9 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
public string Description { get; set; }
|
||||
|
||||
public ActionKeywordProperty KeywordProperty { get; init; }
|
||||
|
||||
public string Keyword { get; set; }
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue