diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs
index 94ceb242e..8d2c6df24 100644
--- a/Flow.Launcher.Core/Plugin/PluginManager.cs
+++ b/Flow.Launcher.Core/Plugin/PluginManager.cs
@@ -252,6 +252,8 @@ namespace Flow.Launcher.Core.Plugin
public static bool ActionKeywordRegistered(string actionKeyword)
{
+ // this method is only checking for action keywords (defined as not '*') registration
+ // hence the actionKeyword != Query.GlobalPluginWildcardSign logic
return actionKeyword != Query.GlobalPluginWildcardSign
&& NonGlobalPlugins.ContainsKey(actionKeyword);
}
@@ -276,7 +278,7 @@ namespace Flow.Launcher.Core.Plugin
}
///
- /// used to add action keyword for multiple action keyword plugin
+ /// used to remove action keyword for multiple action keyword plugin
/// e.g. web search
///
public static void RemoveActionKeyword(string id, string oldActionkeyword)
diff --git a/Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs b/Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs
index dd768afb4..abce8b41e 100644
--- a/Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs
+++ b/Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs
@@ -16,11 +16,13 @@ namespace Flow.Launcher.Infrastructure.UserSettings
{
var settings = Plugins[metadata.ID];
- // TODO: Remove. This is one off for 1.2.0 release.
- // Introduced a new action keyword in Explorer, so need to update plugin setting in the UserData folder.
- // This kind of plugin meta update should be handled by a dedicated method trigger by version bump.
+ // TODO: Remove. This is backwards compatibility for 1.8.0 release.
+ // Introduced two new action keywords in Explorer, so need to update plugin setting in the UserData folder.
if (metadata.ID == "572be03c74c642baae319fc283e561a8" && metadata.ActionKeywords.Count != settings.ActionKeywords.Count)
- settings.ActionKeywords = metadata.ActionKeywords;
+ {
+ settings.ActionKeywords.Add(Query.GlobalPluginWildcardSign); // for index search
+ settings.ActionKeywords.Add(Query.GlobalPluginWildcardSign); // for path search
+ }
if (string.IsNullOrEmpty(settings.Version))
settings.Version = metadata.Version;
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index abe8d681b..4ee15b46d 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -547,26 +547,9 @@ namespace Flow.Launcher.ViewModel
private void RemoveOldQueryResults(Query query)
{
- string lastKeyword = _lastQuery.ActionKeyword;
-
- string keyword = query.ActionKeyword;
- if (string.IsNullOrEmpty(lastKeyword))
+ if (_lastQuery.ActionKeyword != query.ActionKeyword)
{
- if (!string.IsNullOrEmpty(keyword))
- {
- Results.KeepResultsFor(PluginManager.NonGlobalPlugins[keyword].Metadata);
- }
- }
- else
- {
- if (string.IsNullOrEmpty(keyword))
- {
- Results.KeepResultsExcept(PluginManager.NonGlobalPlugins[lastKeyword].Metadata);
- }
- else if (lastKeyword != keyword)
- {
- Results.KeepResultsFor(PluginManager.NonGlobalPlugins[keyword].Metadata);
- }
+ Results.Clear();
}
}
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
index 9ba0da3f6..a989327be 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
@@ -19,8 +19,14 @@
Quick Access Links
Index Search Excluded Paths
Indexing Options
- Search Activation:
+ Search:
+ Path Search:
File Content Search:
+ Index Search:
+ Current Action Keyword:
+ Done
+ Enabled
+ When disabled Flow will not execute this search option, and will additionally revert back to '*' to free up the action keyword
Explorer
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/zh-cn.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/zh-cn.xaml
index c4a2322b2..dac6e908b 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/zh-cn.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/zh-cn.xaml
@@ -20,6 +20,7 @@
索引搜索排除的路径
索引选项
搜索激活:
+ 路径搜索激活:
文件内容搜索:
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs
index 8204e755c..92b7c95a0 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs
@@ -28,7 +28,7 @@ namespace Flow.Launcher.Plugin.Explorer
return new ExplorerSettings(viewModel);
}
- public async Task InitAsync(PluginInitContext context)
+ public Task InitAsync(PluginInitContext context)
{
Context = context;
@@ -47,6 +47,8 @@ namespace Flow.Launcher.Plugin.Explorer
contextMenu = new ContextMenu(Context, Settings, viewModel);
searchManager = new SearchManager(Settings, Context);
ResultManager.Init(Context);
+
+ return Task.CompletedTask;
}
public List LoadContextMenus(Result selectedResult)
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs
index 1e9815cb9..595ac3610 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs
@@ -10,10 +10,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search
{
internal static bool IsEnvironmentVariableSearch(string search)
{
- return LoadEnvironmentStringPaths().Count > 0
- && search.StartsWith("%")
+ return search.StartsWith("%")
&& search != "%%"
- && !search.Contains("\\");
+ && !search.Contains("\\") &&
+ LoadEnvironmentStringPaths().Count > 0;
}
internal static Dictionary LoadEnvironmentStringPaths()
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs
index e9b4b0fc1..6f3996b0d 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs
@@ -26,6 +26,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
{
private static PathEqualityComparator instance;
public static PathEqualityComparator Instance => instance ??= new PathEqualityComparator();
+
public bool Equals(Result x, Result y)
{
return x.SubTitle == y.SubTitle;
@@ -39,21 +40,61 @@ namespace Flow.Launcher.Plugin.Explorer.Search
internal async Task> SearchAsync(Query query, CancellationToken token)
{
- var results = new HashSet(PathEqualityComparator.Instance);
-
var querySearch = query.Search;
if (IsFileContentSearch(query.ActionKeyword))
return await WindowsIndexFileContentSearchAsync(query, querySearch, token).ConfigureAwait(false);
+ var result = new HashSet(PathEqualityComparator.Instance);
+
+ if (ActionKeywordMatch(query, Settings.ActionKeyword.PathSearchActionKeyword) ||
+ ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword))
+ {
+ result.UnionWith(await PathSearchAsync(query, token).ConfigureAwait(false));
+ }
+
+ if ((ActionKeywordMatch(query, Settings.ActionKeyword.IndexSearchActionKeyword) ||
+ ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword)) &&
+ querySearch.Length > 0 &&
+ !querySearch.IsLocationPathString())
+ {
+ result.UnionWith(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token)
+ .ConfigureAwait(false));
+ }
+
+ return result.ToList();
+ }
+
+ private bool ActionKeywordMatch(Query query, Settings.ActionKeyword allowedActionKeyword)
+ {
+ var keyword = query.ActionKeyword.Length == 0 ? Query.GlobalPluginWildcardSign : query.ActionKeyword;
+
+ return allowedActionKeyword switch
+ {
+ Settings.ActionKeyword.SearchActionKeyword => settings.EnableSearchActionKeyword &&
+ keyword == settings.SearchActionKeyword,
+ Settings.ActionKeyword.PathSearchActionKeyword => settings.EnabledPathSearchKeyword &&
+ keyword == settings.PathSearchActionKeyword,
+ Settings.ActionKeyword.FileContentSearchActionKeyword => keyword ==
+ settings.FileContentSearchActionKeyword,
+ Settings.ActionKeyword.IndexSearchActionKeyword => settings.EnabledIndexOnlySearchKeyword &&
+ keyword == settings.IndexSearchActionKeyword
+ };
+ }
+
+ public async Task> PathSearchAsync(Query query, CancellationToken token = default)
+ {
+ var querySearch = query.Search;
+
// This allows the user to type the assigned action keyword and only see the list of quick folder links
if (string.IsNullOrEmpty(query.Search))
return QuickAccess.AccessLinkListAll(query, settings.QuickAccessLinks);
+ var results = new HashSet(PathEqualityComparator.Instance);
+
var quickaccessLinks = QuickAccess.AccessLinkListMatched(query, settings.QuickAccessLinks);
- if (quickaccessLinks.Count > 0)
- results.UnionWith(quickaccessLinks);
+ results.UnionWith(quickaccessLinks);
var isEnvironmentVariable = EnvironmentVariables.IsEnvironmentVariableSearch(querySearch);
@@ -63,13 +104,6 @@ namespace Flow.Launcher.Plugin.Explorer.Search
// Query is a location path with a full environment variable, eg. %appdata%\somefolder\
var isEnvironmentVariablePath = querySearch[1..].Contains("%\\");
- if (!querySearch.IsLocationPathString() && !isEnvironmentVariablePath)
- {
- results.UnionWith(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token).ConfigureAwait(false));
-
- return results.ToList();
- }
-
var locationPath = querySearch;
if (isEnvironmentVariablePath)
@@ -99,7 +133,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search
return results.ToList();
}
- private async Task> WindowsIndexFileContentSearchAsync(Query query, string querySearchString, CancellationToken token)
+ private async Task> WindowsIndexFileContentSearchAsync(Query query, string querySearchString,
+ CancellationToken token)
{
var queryConstructor = new QueryConstructor(settings);
@@ -107,11 +142,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search
return new List();
return await IndexSearch.WindowsIndexSearchAsync(querySearchString,
- queryConstructor.CreateQueryHelper().ConnectionString,
- queryConstructor.QueryForFileContentSearch,
- settings.IndexSearchExcludedSubdirectoryPaths,
- query,
- token).ConfigureAwait(false);
+ queryConstructor.CreateQueryHelper().ConnectionString,
+ queryConstructor.QueryForFileContentSearch,
+ settings.IndexSearchExcludedSubdirectoryPaths,
+ query,
+ token).ConfigureAwait(false);
}
public bool IsFileContentSearch(string actionKeyword)
@@ -138,28 +173,30 @@ namespace Flow.Launcher.Plugin.Explorer.Search
return await windowsIndexSearch(query, querySearchString, token);
}
- private async Task> WindowsIndexFilesAndFoldersSearchAsync(Query query, string querySearchString, CancellationToken token)
+ private async Task> WindowsIndexFilesAndFoldersSearchAsync(Query query, string querySearchString,
+ CancellationToken token)
{
var queryConstructor = new QueryConstructor(settings);
return await IndexSearch.WindowsIndexSearchAsync(querySearchString,
- queryConstructor.CreateQueryHelper().ConnectionString,
- queryConstructor.QueryForAllFilesAndFolders,
- settings.IndexSearchExcludedSubdirectoryPaths,
- query,
- token).ConfigureAwait(false);
+ queryConstructor.CreateQueryHelper().ConnectionString,
+ queryConstructor.QueryForAllFilesAndFolders,
+ settings.IndexSearchExcludedSubdirectoryPaths,
+ query,
+ token).ConfigureAwait(false);
}
- private async Task> WindowsIndexTopLevelFolderSearchAsync(Query query, string path, CancellationToken token)
+ private async Task> WindowsIndexTopLevelFolderSearchAsync(Query query, string path,
+ CancellationToken token)
{
var queryConstructor = new QueryConstructor(settings);
return await IndexSearch.WindowsIndexSearchAsync(path,
- queryConstructor.CreateQueryHelper().ConnectionString,
- queryConstructor.QueryForTopLevelDirectorySearch,
- settings.IndexSearchExcludedSubdirectoryPaths,
- query,
- token).ConfigureAwait(false);
+ queryConstructor.CreateQueryHelper().ConnectionString,
+ queryConstructor.QueryForTopLevelDirectorySearch,
+ settings.IndexSearchExcludedSubdirectoryPaths,
+ query,
+ token).ConfigureAwait(false);
}
private bool UseWindowsIndexForDirectorySearch(string locationPath)
@@ -170,11 +207,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search
return false;
if (settings.IndexSearchExcludedSubdirectoryPaths
- .Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(pathToDirectory)
- .StartsWith(x.Path, StringComparison.OrdinalIgnoreCase)))
+ .Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(pathToDirectory)
+ .StartsWith(x.Path, StringComparison.OrdinalIgnoreCase)))
return false;
return IndexSearch.PathIsIndexed(pathToDirectory);
}
}
-}
+}
\ No newline at end of file
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
index a8eac986d..bd6fe7e20 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
@@ -1,6 +1,9 @@
using Flow.Launcher.Plugin.Explorer.Search;
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
+using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption;
+using System;
using System.Collections.Generic;
+using System.IO;
namespace Flow.Launcher.Plugin.Explorer
{
@@ -18,7 +21,57 @@ namespace Flow.Launcher.Plugin.Explorer
public List IndexSearchExcludedSubdirectoryPaths { get; set; } = new List();
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
+ public bool EnableSearchActionKeyword { get; set; } = true;
public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword;
+
+ public string PathSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
+
+ public bool EnabledPathSearchKeyword { get; set; }
+
+ public string IndexSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
+
+ public bool EnabledIndexOnlySearchKeyword { get; set; }
+
+ internal enum ActionKeyword
+ {
+ SearchActionKeyword,
+ PathSearchActionKeyword,
+ FileContentSearchActionKeyword,
+ IndexSearchActionKeyword
+ }
+
+ internal string GetActionKeyword(ActionKeyword actionKeyword) => actionKeyword switch
+ {
+ ActionKeyword.SearchActionKeyword => SearchActionKeyword,
+ ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword,
+ ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword,
+ ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword
+ };
+
+ internal void SetActionKeyword(ActionKeyword actionKeyword, string keyword) => _ = actionKeyword switch
+ {
+ ActionKeyword.SearchActionKeyword => SearchActionKeyword = keyword,
+ ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword = keyword,
+ ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword = keyword,
+ ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword = keyword,
+ _ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property")
+ };
+
+ internal bool? GetActionKeywordEnable(ActionKeyword actionKeyword) => actionKeyword switch
+ {
+ ActionKeyword.SearchActionKeyword => EnableSearchActionKeyword,
+ ActionKeyword.PathSearchActionKeyword => EnabledPathSearchKeyword,
+ ActionKeyword.IndexSearchActionKeyword => EnabledIndexOnlySearchKeyword,
+ _ => null
+ };
+
+ internal void SetActionKeywordEnable(ActionKeyword actionKeyword, bool enable) => _ = actionKeyword switch
+ {
+ ActionKeyword.SearchActionKeyword => EnableSearchActionKeyword = enable,
+ ActionKeyword.PathSearchActionKeyword => EnabledPathSearchKeyword = enable,
+ ActionKeyword.IndexSearchActionKeyword => EnabledIndexOnlySearchKeyword = enable,
+ _ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property")
+ };
}
}
\ No newline at end of file
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
index 92932bf4c..77ec5457b 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
@@ -41,18 +41,15 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
Process.Start(psi);
}
- internal void UpdateActionKeyword(string newActionKeyword, string oldActionKeyword)
+ internal void UpdateActionKeyword(Settings.ActionKeyword modifiedActionKeyword, string newActionKeyword, string oldActionKeyword)
{
PluginManager.ReplaceActionKeyword(Context.CurrentPluginMetadata.ID, oldActionKeyword, newActionKeyword);
-
- if (Settings.FileContentSearchActionKeyword == oldActionKeyword)
- Settings.FileContentSearchActionKeyword = newActionKeyword;
-
- if (Settings.SearchActionKeyword == oldActionKeyword)
- Settings.SearchActionKeyword = newActionKeyword;
}
- internal bool IsActionKeywordAlreadyAssigned(string newActionKeyword) => PluginManager.ActionKeywordRegistered(newActionKeyword);
+ internal bool IsActionKeywordAlreadyAssigned(string newActionKeyword)
+ {
+ return PluginManager.ActionKeywordRegistered(newActionKeyword);
+ }
internal bool IsNewActionKeywordGlobal(string newActionKeyword) => newActionKeyword == Query.GlobalPluginWildcardSign;
}
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml
index 0e1c7e872..19ff624b0 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml
@@ -7,6 +7,7 @@
mc:Ignorable="d"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
+ DataContext="{Binding RelativeSource={RelativeSource Self}}"
Title="Action Keyword Setting" Height="200" Width="500">
@@ -16,21 +17,24 @@
+
-
+
-
-
-
-
-
+ HorizontalAlignment="Left"
+ Text="{Binding ActionKeyword}"
+ PreviewKeyDown="TxtCurrentActionKeyword_OnKeyDown"/>
+
+
-
+
\ No newline at end of file
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs
index 2957283ad..18703e5ea 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs
@@ -1,16 +1,10 @@
-using Flow.Launcher.Plugin.Explorer.ViewModels;
+using Flow.Launcher.Plugin.Explorer.ViewModels;
+using ICSharpCode.SharpZipLib.Zip;
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
{
@@ -21,65 +15,102 @@ namespace Flow.Launcher.Plugin.Explorer.Views
{
private SettingsViewModel settingsViewModel;
- private ActionKeywordView currentActionKeyword;
+ public ActionKeywordView CurrentActionKeyword { get; set; }
- private List actionKeywordListView;
-
- public ActionKeywordSetting(SettingsViewModel settingsViewModel, List actionKeywordListView, ActionKeywordView selectedActionKeyword)
+ public string ActionKeyword
{
- InitializeComponent();
-
- this.settingsViewModel = settingsViewModel;
-
- currentActionKeyword = selectedActionKeyword;
-
- txtCurrentActionKeyword.Text = selectedActionKeyword.Keyword;
-
- this.actionKeywordListView = actionKeywordListView;
+ get => _actionKeyword;
+ set
+ {
+ // Set Enable to be true if user change ActionKeyword
+ if (Enabled is not null)
+ Enabled = true;
+ _actionKeyword = value;
+ }
}
- private void OnConfirmButtonClick(object sender, RoutedEventArgs e)
+ public bool? Enabled { get; set; }
+
+ private string _actionKeyword;
+
+ public Visibility Visible =>
+ CurrentActionKeyword.Enabled is not null ? Visibility.Visible : Visibility.Collapsed;
+
+ public ActionKeywordSetting(SettingsViewModel settingsViewModel,
+ ActionKeywordView selectedActionKeyword)
{
- var newActionKeyword = txtCurrentActionKeyword.Text;
+ this.settingsViewModel = settingsViewModel;
- if (string.IsNullOrEmpty(newActionKeyword))
- return;
+ CurrentActionKeyword = selectedActionKeyword;
- if (newActionKeyword == currentActionKeyword.Keyword)
+ ActionKeyword = selectedActionKeyword.Keyword;
+ Enabled = selectedActionKeyword.Enabled;
+
+ InitializeComponent();
+
+ TxtCurrentActionKeyword.Focus();
+ }
+
+ private void OnDoneButtonClick(object sender, RoutedEventArgs e)
+ {
+ if (string.IsNullOrEmpty(ActionKeyword))
+ ActionKeyword = Query.GlobalPluginWildcardSign;
+
+ if (CurrentActionKeyword.Keyword == ActionKeyword && CurrentActionKeyword.Enabled == Enabled)
{
Close();
+ return;
+ }
+
+
+ if (CurrentActionKeyword.KeywordProperty == Settings.ActionKeyword.FileContentSearchActionKeyword
+ && ActionKeyword == Query.GlobalPluginWildcardSign)
+ {
+ MessageBox.Show(
+ settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));
return;
}
- if (settingsViewModel.IsNewActionKeywordGlobal(newActionKeyword)
- && currentActionKeyword.Description
- == settingsViewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_filecontentsearch"))
- {
- MessageBox.Show(settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));
+ var oldActionKeyword = CurrentActionKeyword.Keyword;
- return;
- }
-
- if (!settingsViewModel.IsActionKeywordAlreadyAssigned(newActionKeyword))
+ // == because of nullable
+ if (Enabled == false || !settingsViewModel.IsActionKeywordAlreadyAssigned(ActionKeyword))
{
- settingsViewModel.UpdateActionKeyword(newActionKeyword, currentActionKeyword.Keyword);
+ // Update View Data
+ CurrentActionKeyword.Keyword = Enabled == true ? ActionKeyword : Query.GlobalPluginWildcardSign;
+ CurrentActionKeyword.Enabled = Enabled;
- actionKeywordListView.Where(x => x.Description == currentActionKeyword.Description).FirstOrDefault().Keyword = newActionKeyword;
+ switch (Enabled)
+ {
+ // reset to global so it does not take up an action keyword when disabled
+ // not for null Enable plugin
+ case false when oldActionKeyword != Query.GlobalPluginWildcardSign:
+ settingsViewModel.UpdateActionKeyword(CurrentActionKeyword.KeywordProperty,
+ Query.GlobalPluginWildcardSign, oldActionKeyword);
+ break;
+ default:
+ settingsViewModel.UpdateActionKeyword(CurrentActionKeyword.KeywordProperty,
+ CurrentActionKeyword.Keyword, oldActionKeyword);
+ break;
+ }
Close();
-
return;
}
+ // The keyword is not valid, so show message
MessageBox.Show(settingsViewModel.Context.API.GetTranslation("newActionKeywordsHasBeenAssigned"));
}
- private void OnCancelButtonClick(object sender, RoutedEventArgs e)
+ private void TxtCurrentActionKeyword_OnKeyDown(object sender, KeyEventArgs e)
{
- Close();
-
- return;
+ if (e.Key == Key.Enter)
+ {
+ DownButton.Focus();
+ OnDoneButtonClick(sender, e);
+ e.Handled = true;
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
index b4795ec8b..50171a363 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
@@ -4,6 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.Explorer.ViewModels"
+ xmlns:views="clr-namespace:Flow.Launcher.Plugin.Explorer.Views"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
@@ -17,14 +18,17 @@
Text="{Binding Path, Mode=OneTime}"
Margin="0,5,0,5" />
-
+
+ Foreground="{Binding Color, Mode=OneWay}"
+ Margin="250,5,0,0" />
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs
index 26f169c92..ffd5b618a 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs
@@ -35,20 +35,20 @@ namespace Flow.Launcher.Plugin.Explorer.Views
actionKeywordsListView = new List
{
- new ActionKeywordView()
- {
- Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_search"),
- Keyword = this.viewModel.Settings.SearchActionKeyword
- },
- new ActionKeywordView()
- {
- Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_filecontentsearch"),
- Keyword = this.viewModel.Settings.FileContentSearchActionKeyword
- }
+ new(Settings.ActionKeyword.SearchActionKeyword,
+ viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_search")),
+ new(Settings.ActionKeyword.FileContentSearchActionKeyword,
+ viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_filecontentsearch")),
+ new(Settings.ActionKeyword.PathSearchActionKeyword,
+ viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_pathsearch")),
+ new(Settings.ActionKeyword.IndexSearchActionKeyword,
+ viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_indexsearch"))
};
lbxActionKeywords.ItemsSource = actionKeywordsListView;
+ ActionKeywordView.Init(viewModel.Settings);
+
RefreshView();
}
@@ -71,9 +71,9 @@ namespace Flow.Launcher.Plugin.Explorer.Views
&& btnEdit.Visibility == Visibility.Hidden)
btnEdit.Visibility = Visibility.Visible;
- if ((lbxAccessLinks.Items.Count == 0 && lbxExcludedPaths.Items.Count == 0)
- && btnDelete.Visibility == Visibility.Visible
- && btnEdit.Visibility == Visibility.Visible)
+ if (lbxAccessLinks.Items.Count == 0 && lbxExcludedPaths.Items.Count == 0
+ && btnDelete.Visibility == Visibility.Visible
+ && btnEdit.Visibility == Visibility.Visible)
{
btnDelete.Visibility = Visibility.Hidden;
btnEdit.Visibility = Visibility.Hidden;
@@ -122,7 +122,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
private void expActionKeywords_Collapsed(object sender, RoutedEventArgs e)
{
if (!expActionKeywords.IsExpanded)
- expActionKeywords.Height = Double.NaN;
+ expActionKeywords.Height = double.NaN;
}
private void expAccessLinks_Click(object sender, RoutedEventArgs e)
@@ -135,20 +135,20 @@ namespace Flow.Launcher.Plugin.Explorer.Views
if (expActionKeywords.IsExpanded)
expActionKeywords.IsExpanded = false;
-
+
RefreshView();
}
private void expAccessLinks_Collapsed(object sender, RoutedEventArgs e)
{
if (!expAccessLinks.IsExpanded)
- expAccessLinks.Height = Double.NaN;
+ expAccessLinks.Height = double.NaN;
}
private void expExcludedPaths_Click(object sender, RoutedEventArgs e)
{
if (expExcludedPaths.IsExpanded)
- expAccessLinks.Height = Double.NaN;
+ expAccessLinks.Height = double.NaN;
if (expAccessLinks.IsExpanded)
expAccessLinks.IsExpanded = false;
@@ -161,11 +161,12 @@ namespace Flow.Launcher.Plugin.Explorer.Views
private void btnDelete_Click(object sender, RoutedEventArgs e)
{
- var selectedRow = lbxAccessLinks.SelectedItem as AccessLink?? lbxExcludedPaths.SelectedItem as AccessLink;
+ var selectedRow = lbxAccessLinks.SelectedItem as AccessLink ?? lbxExcludedPaths.SelectedItem as AccessLink;
if (selectedRow != null)
{
- string msg = string.Format(viewModel.Context.API.GetTranslation("plugin_explorer_delete_folder_link"), selectedRow.Path);
+ string msg = string.Format(viewModel.Context.API.GetTranslation("plugin_explorer_delete_folder_link"),
+ selectedRow.Path);
if (MessageBox.Show(msg, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
@@ -191,7 +192,8 @@ namespace Flow.Launcher.Plugin.Explorer.Views
{
var selectedActionKeyword = lbxActionKeywords.SelectedItem as ActionKeywordView;
- var actionKeywordWindow = new ActionKeywordSetting(viewModel, actionKeywordsListView, selectedActionKeyword);
+ var actionKeywordWindow = new ActionKeywordSetting(viewModel,
+ selectedActionKeyword);
actionKeywordWindow.ShowDialog();
@@ -199,7 +201,8 @@ namespace Flow.Launcher.Plugin.Explorer.Views
}
else
{
- var selectedRow = lbxAccessLinks.SelectedItem as AccessLink ?? lbxExcludedPaths.SelectedItem as AccessLink;
+ var selectedRow = lbxAccessLinks.SelectedItem as AccessLink ??
+ lbxExcludedPaths.SelectedItem as AccessLink;
if (selectedRow != null)
{
@@ -215,7 +218,8 @@ namespace Flow.Launcher.Plugin.Explorer.Views
if (expExcludedPaths.IsExpanded)
{
- var link = viewModel.Settings.IndexSearchExcludedSubdirectoryPaths.First(x => x.Path == selectedRow.Path);
+ var link = viewModel.Settings.IndexSearchExcludedSubdirectoryPaths.First(x =>
+ x.Path == selectedRow.Path);
link.Path = folderBrowserDialog.SelectedPath;
}
}
@@ -235,10 +239,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
var folderBrowserDialog = new FolderBrowserDialog();
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
- var newAccessLink = new AccessLink
- {
- Path = folderBrowserDialog.SelectedPath
- };
+ var newAccessLink = new AccessLink {Path = folderBrowserDialog.SelectedPath};
AddAccessLink(newAccessLink);
}
@@ -259,10 +260,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
{
if (Directory.Exists(s))
{
- var newFolderLink = new AccessLink
- {
- Path = s
- };
+ var newFolderLink = new AccessLink {Path = s};
AddAccessLink(newFolderLink);
}
@@ -275,7 +273,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
private void AddAccessLink(AccessLink newAccessLink)
{
if (expAccessLinks.IsExpanded
- && !viewModel.Settings.QuickAccessLinks.Any(x => x.Path == newAccessLink.Path))
+ && !viewModel.Settings.QuickAccessLinks.Any(x => x.Path == newAccessLink.Path))
{
if (viewModel.Settings.QuickAccessLinks == null)
viewModel.Settings.QuickAccessLinks = new List();
@@ -313,8 +311,35 @@ namespace Flow.Launcher.Plugin.Explorer.Views
public class ActionKeywordView
{
- public string Description { get; set; }
+ private static Settings _settings;
- public string Keyword { get; set; }
+ public static void Init(Settings settings)
+ {
+ _settings = settings;
+ }
+
+ internal ActionKeywordView(Settings.ActionKeyword actionKeyword, string description)
+ {
+ KeywordProperty = actionKeyword;
+ Description = description;
+ }
+
+ public string Description { get; private init; }
+ public string Color => Enabled ?? true ? "Black" : "Gray";
+
+ internal Settings.ActionKeyword KeywordProperty { get; }
+
+ public string Keyword
+ {
+ get => _settings.GetActionKeyword(KeywordProperty);
+ set => _settings.SetActionKeyword(KeywordProperty, value);
+ }
+
+ public bool? Enabled
+ {
+ get => _settings.GetActionKeywordEnable(KeywordProperty);
+ set => _settings.SetActionKeywordEnable(KeywordProperty,
+ value ?? throw new ArgumentException("Unexpected null value"));
+ }
}
-}
+}
\ No newline at end of file
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json b/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json
index 6be1ed95d..0b46f9fd7 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json
@@ -1,8 +1,10 @@
{
"ID": "572be03c74c642baae319fc283e561a8",
"ActionKeywords": [
- "*",
- "doc:"
+ "*",
+ "doc:",
+ "*",
+ "*"
],
"Name": "Explorer",
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",