mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #449 from Flow-Launcher/ExplorerPathActionkeyword
Add specific keyword for path explore in explorer plugin
This commit is contained in:
commit
ad36f89345
15 changed files with 312 additions and 163 deletions
|
|
@ -252,6 +252,8 @@ namespace Flow.Launcher.Core.Plugin
|
||||||
|
|
||||||
public static bool ActionKeywordRegistered(string actionKeyword)
|
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
|
return actionKeyword != Query.GlobalPluginWildcardSign
|
||||||
&& NonGlobalPlugins.ContainsKey(actionKeyword);
|
&& NonGlobalPlugins.ContainsKey(actionKeyword);
|
||||||
}
|
}
|
||||||
|
|
@ -276,7 +278,7 @@ namespace Flow.Launcher.Core.Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// used to add action keyword for multiple action keyword plugin
|
/// used to remove action keyword for multiple action keyword plugin
|
||||||
/// e.g. web search
|
/// e.g. web search
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void RemoveActionKeyword(string id, string oldActionkeyword)
|
public static void RemoveActionKeyword(string id, string oldActionkeyword)
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,13 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
||||||
{
|
{
|
||||||
var settings = Plugins[metadata.ID];
|
var settings = Plugins[metadata.ID];
|
||||||
|
|
||||||
// TODO: Remove. This is one off for 1.2.0 release.
|
// TODO: Remove. This is backwards compatibility for 1.8.0 release.
|
||||||
// Introduced a new action keyword in Explorer, so need to update plugin setting in the UserData folder.
|
// Introduced two new action keywords 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.
|
|
||||||
if (metadata.ID == "572be03c74c642baae319fc283e561a8" && metadata.ActionKeywords.Count != settings.ActionKeywords.Count)
|
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))
|
if (string.IsNullOrEmpty(settings.Version))
|
||||||
settings.Version = metadata.Version;
|
settings.Version = metadata.Version;
|
||||||
|
|
|
||||||
|
|
@ -547,26 +547,9 @@ namespace Flow.Launcher.ViewModel
|
||||||
|
|
||||||
private void RemoveOldQueryResults(Query query)
|
private void RemoveOldQueryResults(Query query)
|
||||||
{
|
{
|
||||||
string lastKeyword = _lastQuery.ActionKeyword;
|
if (_lastQuery.ActionKeyword != query.ActionKeyword)
|
||||||
|
|
||||||
string keyword = query.ActionKeyword;
|
|
||||||
if (string.IsNullOrEmpty(lastKeyword))
|
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(keyword))
|
Results.Clear();
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,14 @@
|
||||||
<system:String x:Key="plugin_explorer_quickaccesslinks_header">Quick Access Links</system:String>
|
<system:String x:Key="plugin_explorer_quickaccesslinks_header">Quick Access Links</system:String>
|
||||||
<system:String x:Key="plugin_explorer_indexsearchexcludedpaths_header">Index Search Excluded Paths</system:String>
|
<system:String x:Key="plugin_explorer_indexsearchexcludedpaths_header">Index Search Excluded Paths</system:String>
|
||||||
<system:String x:Key="plugin_explorer_manageindexoptions">Indexing Options</system:String>
|
<system:String x:Key="plugin_explorer_manageindexoptions">Indexing Options</system:String>
|
||||||
<system:String x:Key="plugin_explorer_actionkeywordview_search">Search Activation:</system:String>
|
<system:String x:Key="plugin_explorer_actionkeywordview_search">Search:</system:String>
|
||||||
|
<system:String x:Key="plugin_explorer_actionkeywordview_pathsearch">Path Search:</system:String>
|
||||||
<system:String x:Key="plugin_explorer_actionkeywordview_filecontentsearch">File Content Search:</system:String>
|
<system:String x:Key="plugin_explorer_actionkeywordview_filecontentsearch">File Content Search:</system:String>
|
||||||
|
<system:String x:Key="plugin_explorer_actionkeywordview_indexsearch">Index Search:</system:String>
|
||||||
|
<system:String x:Key="plugin_explorer_actionkeyword_current">Current Action Keyword:</system:String>
|
||||||
|
<system:String x:Key="plugin_explorer_actionkeyword_done">Done</system:String>
|
||||||
|
<system:String x:Key="plugin_explorer_actionkeyword_enabled">Enabled</system:String>
|
||||||
|
<system:String x:Key="plugin_explorer_actionkeyword_enabled_tooltip">When disabled Flow will not execute this search option, and will additionally revert back to '*' to free up the action keyword</system:String>
|
||||||
|
|
||||||
<!--Plugin Infos-->
|
<!--Plugin Infos-->
|
||||||
<system:String x:Key="plugin_explorer_plugin_name">Explorer</system:String>
|
<system:String x:Key="plugin_explorer_plugin_name">Explorer</system:String>
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
<system:String x:Key="plugin_explorer_indexsearchexcludedpaths_header">索引搜索排除的路径</system:String>
|
<system:String x:Key="plugin_explorer_indexsearchexcludedpaths_header">索引搜索排除的路径</system:String>
|
||||||
<system:String x:Key="plugin_explorer_manageindexoptions">索引选项</system:String>
|
<system:String x:Key="plugin_explorer_manageindexoptions">索引选项</system:String>
|
||||||
<system:String x:Key="plugin_explorer_actionkeywordview_search">搜索激活:</system:String>
|
<system:String x:Key="plugin_explorer_actionkeywordview_search">搜索激活:</system:String>
|
||||||
|
<system:String x:Key="plugin_explorer_actionkeywordview_pathsearch">路径搜索激活:</system:String>
|
||||||
<system:String x:Key="plugin_explorer_actionkeywordview_filecontentsearch">文件内容搜索:</system:String>
|
<system:String x:Key="plugin_explorer_actionkeywordview_filecontentsearch">文件内容搜索:</system:String>
|
||||||
|
|
||||||
<!--Plugin Infos-->
|
<!--Plugin Infos-->
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ namespace Flow.Launcher.Plugin.Explorer
|
||||||
return new ExplorerSettings(viewModel);
|
return new ExplorerSettings(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task InitAsync(PluginInitContext context)
|
public Task InitAsync(PluginInitContext context)
|
||||||
{
|
{
|
||||||
Context = context;
|
Context = context;
|
||||||
|
|
||||||
|
|
@ -47,6 +47,8 @@ namespace Flow.Launcher.Plugin.Explorer
|
||||||
contextMenu = new ContextMenu(Context, Settings, viewModel);
|
contextMenu = new ContextMenu(Context, Settings, viewModel);
|
||||||
searchManager = new SearchManager(Settings, Context);
|
searchManager = new SearchManager(Settings, Context);
|
||||||
ResultManager.Init(Context);
|
ResultManager.Init(Context);
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Result> LoadContextMenus(Result selectedResult)
|
public List<Result> LoadContextMenus(Result selectedResult)
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
{
|
{
|
||||||
internal static bool IsEnvironmentVariableSearch(string search)
|
internal static bool IsEnvironmentVariableSearch(string search)
|
||||||
{
|
{
|
||||||
return LoadEnvironmentStringPaths().Count > 0
|
return search.StartsWith("%")
|
||||||
&& search.StartsWith("%")
|
|
||||||
&& search != "%%"
|
&& search != "%%"
|
||||||
&& !search.Contains("\\");
|
&& !search.Contains("\\") &&
|
||||||
|
LoadEnvironmentStringPaths().Count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Dictionary<string, string> LoadEnvironmentStringPaths()
|
internal static Dictionary<string, string> LoadEnvironmentStringPaths()
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
{
|
{
|
||||||
private static PathEqualityComparator instance;
|
private static PathEqualityComparator instance;
|
||||||
public static PathEqualityComparator Instance => instance ??= new PathEqualityComparator();
|
public static PathEqualityComparator Instance => instance ??= new PathEqualityComparator();
|
||||||
|
|
||||||
public bool Equals(Result x, Result y)
|
public bool Equals(Result x, Result y)
|
||||||
{
|
{
|
||||||
return x.SubTitle == y.SubTitle;
|
return x.SubTitle == y.SubTitle;
|
||||||
|
|
@ -39,21 +40,61 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
|
|
||||||
internal async Task<List<Result>> SearchAsync(Query query, CancellationToken token)
|
internal async Task<List<Result>> SearchAsync(Query query, CancellationToken token)
|
||||||
{
|
{
|
||||||
var results = new HashSet<Result>(PathEqualityComparator.Instance);
|
|
||||||
|
|
||||||
var querySearch = query.Search;
|
var querySearch = query.Search;
|
||||||
|
|
||||||
if (IsFileContentSearch(query.ActionKeyword))
|
if (IsFileContentSearch(query.ActionKeyword))
|
||||||
return await WindowsIndexFileContentSearchAsync(query, querySearch, token).ConfigureAwait(false);
|
return await WindowsIndexFileContentSearchAsync(query, querySearch, token).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var result = new HashSet<Result>(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<List<Result>> 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
|
// This allows the user to type the assigned action keyword and only see the list of quick folder links
|
||||||
if (string.IsNullOrEmpty(query.Search))
|
if (string.IsNullOrEmpty(query.Search))
|
||||||
return QuickAccess.AccessLinkListAll(query, settings.QuickAccessLinks);
|
return QuickAccess.AccessLinkListAll(query, settings.QuickAccessLinks);
|
||||||
|
|
||||||
|
var results = new HashSet<Result>(PathEqualityComparator.Instance);
|
||||||
|
|
||||||
var quickaccessLinks = QuickAccess.AccessLinkListMatched(query, settings.QuickAccessLinks);
|
var quickaccessLinks = QuickAccess.AccessLinkListMatched(query, settings.QuickAccessLinks);
|
||||||
|
|
||||||
if (quickaccessLinks.Count > 0)
|
results.UnionWith(quickaccessLinks);
|
||||||
results.UnionWith(quickaccessLinks);
|
|
||||||
|
|
||||||
var isEnvironmentVariable = EnvironmentVariables.IsEnvironmentVariableSearch(querySearch);
|
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\
|
// Query is a location path with a full environment variable, eg. %appdata%\somefolder\
|
||||||
var isEnvironmentVariablePath = querySearch[1..].Contains("%\\");
|
var isEnvironmentVariablePath = querySearch[1..].Contains("%\\");
|
||||||
|
|
||||||
if (!querySearch.IsLocationPathString() && !isEnvironmentVariablePath)
|
|
||||||
{
|
|
||||||
results.UnionWith(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token).ConfigureAwait(false));
|
|
||||||
|
|
||||||
return results.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
var locationPath = querySearch;
|
var locationPath = querySearch;
|
||||||
|
|
||||||
if (isEnvironmentVariablePath)
|
if (isEnvironmentVariablePath)
|
||||||
|
|
@ -99,7 +133,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
return results.ToList();
|
return results.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<List<Result>> WindowsIndexFileContentSearchAsync(Query query, string querySearchString, CancellationToken token)
|
private async Task<List<Result>> WindowsIndexFileContentSearchAsync(Query query, string querySearchString,
|
||||||
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
var queryConstructor = new QueryConstructor(settings);
|
var queryConstructor = new QueryConstructor(settings);
|
||||||
|
|
||||||
|
|
@ -107,11 +142,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
return new List<Result>();
|
return new List<Result>();
|
||||||
|
|
||||||
return await IndexSearch.WindowsIndexSearchAsync(querySearchString,
|
return await IndexSearch.WindowsIndexSearchAsync(querySearchString,
|
||||||
queryConstructor.CreateQueryHelper().ConnectionString,
|
queryConstructor.CreateQueryHelper().ConnectionString,
|
||||||
queryConstructor.QueryForFileContentSearch,
|
queryConstructor.QueryForFileContentSearch,
|
||||||
settings.IndexSearchExcludedSubdirectoryPaths,
|
settings.IndexSearchExcludedSubdirectoryPaths,
|
||||||
query,
|
query,
|
||||||
token).ConfigureAwait(false);
|
token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsFileContentSearch(string actionKeyword)
|
public bool IsFileContentSearch(string actionKeyword)
|
||||||
|
|
@ -138,28 +173,30 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
return await windowsIndexSearch(query, querySearchString, token);
|
return await windowsIndexSearch(query, querySearchString, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<List<Result>> WindowsIndexFilesAndFoldersSearchAsync(Query query, string querySearchString, CancellationToken token)
|
private async Task<List<Result>> WindowsIndexFilesAndFoldersSearchAsync(Query query, string querySearchString,
|
||||||
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
var queryConstructor = new QueryConstructor(settings);
|
var queryConstructor = new QueryConstructor(settings);
|
||||||
|
|
||||||
return await IndexSearch.WindowsIndexSearchAsync(querySearchString,
|
return await IndexSearch.WindowsIndexSearchAsync(querySearchString,
|
||||||
queryConstructor.CreateQueryHelper().ConnectionString,
|
queryConstructor.CreateQueryHelper().ConnectionString,
|
||||||
queryConstructor.QueryForAllFilesAndFolders,
|
queryConstructor.QueryForAllFilesAndFolders,
|
||||||
settings.IndexSearchExcludedSubdirectoryPaths,
|
settings.IndexSearchExcludedSubdirectoryPaths,
|
||||||
query,
|
query,
|
||||||
token).ConfigureAwait(false);
|
token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<List<Result>> WindowsIndexTopLevelFolderSearchAsync(Query query, string path, CancellationToken token)
|
private async Task<List<Result>> WindowsIndexTopLevelFolderSearchAsync(Query query, string path,
|
||||||
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
var queryConstructor = new QueryConstructor(settings);
|
var queryConstructor = new QueryConstructor(settings);
|
||||||
|
|
||||||
return await IndexSearch.WindowsIndexSearchAsync(path,
|
return await IndexSearch.WindowsIndexSearchAsync(path,
|
||||||
queryConstructor.CreateQueryHelper().ConnectionString,
|
queryConstructor.CreateQueryHelper().ConnectionString,
|
||||||
queryConstructor.QueryForTopLevelDirectorySearch,
|
queryConstructor.QueryForTopLevelDirectorySearch,
|
||||||
settings.IndexSearchExcludedSubdirectoryPaths,
|
settings.IndexSearchExcludedSubdirectoryPaths,
|
||||||
query,
|
query,
|
||||||
token).ConfigureAwait(false);
|
token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UseWindowsIndexForDirectorySearch(string locationPath)
|
private bool UseWindowsIndexForDirectorySearch(string locationPath)
|
||||||
|
|
@ -170,11 +207,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (settings.IndexSearchExcludedSubdirectoryPaths
|
if (settings.IndexSearchExcludedSubdirectoryPaths
|
||||||
.Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(pathToDirectory)
|
.Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(pathToDirectory)
|
||||||
.StartsWith(x.Path, StringComparison.OrdinalIgnoreCase)))
|
.StartsWith(x.Path, StringComparison.OrdinalIgnoreCase)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return IndexSearch.PathIsIndexed(pathToDirectory);
|
return IndexSearch.PathIsIndexed(pathToDirectory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
using Flow.Launcher.Plugin.Explorer.Search;
|
using Flow.Launcher.Plugin.Explorer.Search;
|
||||||
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
|
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
|
||||||
|
using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace Flow.Launcher.Plugin.Explorer
|
namespace Flow.Launcher.Plugin.Explorer
|
||||||
{
|
{
|
||||||
|
|
@ -18,7 +21,57 @@ namespace Flow.Launcher.Plugin.Explorer
|
||||||
public List<AccessLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = new List<AccessLink>();
|
public List<AccessLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = new List<AccessLink>();
|
||||||
|
|
||||||
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
|
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
|
||||||
|
public bool EnableSearchActionKeyword { get; set; } = true;
|
||||||
|
|
||||||
public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword;
|
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")
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -41,18 +41,15 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
|
||||||
Process.Start(psi);
|
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);
|
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;
|
internal bool IsNewActionKeywordGlobal(string newActionKeyword) => newActionKeyword == Query.GlobalPluginWildcardSign;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
ResizeMode="NoResize"
|
ResizeMode="NoResize"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
|
DataContext="{Binding RelativeSource={RelativeSource Self}}"
|
||||||
Title="Action Keyword Setting" Height="200" Width="500">
|
Title="Action Keyword Setting" Height="200" Width="500">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
|
@ -16,21 +17,24 @@
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="180" />
|
<ColumnDefinition Width="180" />
|
||||||
<ColumnDefinition />
|
<ColumnDefinition />
|
||||||
|
<ColumnDefinition />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<TextBlock Margin="20 10 10 10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center"
|
<TextBlock Margin="20 10 10 10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center"
|
||||||
HorizontalAlignment="Left" Text="Current Action Keyword:" />
|
HorizontalAlignment="Left" Text="{DynamicResource plugin_explorer_actionkeyword_current}" />
|
||||||
<TextBox Name="txtCurrentActionKeyword"
|
<TextBox Name="TxtCurrentActionKeyword"
|
||||||
Margin="10" Grid.Row="0" Width="105" Grid.Column="1"
|
Margin="10" Grid.Row="0" Width="105" Grid.Column="1"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
HorizontalAlignment="Left" />
|
HorizontalAlignment="Left"
|
||||||
|
Text="{Binding ActionKeyword}"
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="1">
|
PreviewKeyDown="TxtCurrentActionKeyword_OnKeyDown"/>
|
||||||
<Button Click="OnConfirmButtonClick"
|
<CheckBox Name="ChkActionKeywordEnabled" ToolTip="{DynamicResource plugin_explorer_actionkeyword_enabled_tooltip}"
|
||||||
Margin="10 0 10 0" Width="80" Height="35"
|
Margin="10" Grid.Row="0" Grid.Column="2" Content="{DynamicResource plugin_explorer_actionkeyword_enabled}"
|
||||||
Content="OK" />
|
Width="auto"
|
||||||
<Button Click="OnCancelButtonClick"
|
VerticalAlignment="Center" IsChecked="{Binding Enabled}"
|
||||||
Margin="10 0 10 0" Width="80" Height="35"
|
Visibility="{Binding Visible}"/>
|
||||||
Content="Cancel" />
|
<Button Name="DownButton"
|
||||||
</StackPanel>
|
Click="OnDoneButtonClick" Grid.Row="1" Grid.Column="2"
|
||||||
|
Margin="10 0 10 0" Width="80" Height="35"
|
||||||
|
Content="{DynamicResource plugin_explorer_actionkeyword_done}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|
@ -1,16 +1,10 @@
|
||||||
using Flow.Launcher.Plugin.Explorer.ViewModels;
|
using Flow.Launcher.Plugin.Explorer.ViewModels;
|
||||||
|
using ICSharpCode.SharpZipLib.Zip;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
|
|
||||||
namespace Flow.Launcher.Plugin.Explorer.Views
|
namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
{
|
{
|
||||||
|
|
@ -21,65 +15,102 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
{
|
{
|
||||||
private SettingsViewModel settingsViewModel;
|
private SettingsViewModel settingsViewModel;
|
||||||
|
|
||||||
private ActionKeywordView currentActionKeyword;
|
public ActionKeywordView CurrentActionKeyword { get; set; }
|
||||||
|
|
||||||
private List<ActionKeywordView> actionKeywordListView;
|
public string ActionKeyword
|
||||||
|
|
||||||
public ActionKeywordSetting(SettingsViewModel settingsViewModel, List<ActionKeywordView> actionKeywordListView, ActionKeywordView selectedActionKeyword)
|
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
get => _actionKeyword;
|
||||||
|
set
|
||||||
this.settingsViewModel = settingsViewModel;
|
{
|
||||||
|
// Set Enable to be true if user change ActionKeyword
|
||||||
currentActionKeyword = selectedActionKeyword;
|
if (Enabled is not null)
|
||||||
|
Enabled = true;
|
||||||
txtCurrentActionKeyword.Text = selectedActionKeyword.Keyword;
|
_actionKeyword = value;
|
||||||
|
}
|
||||||
this.actionKeywordListView = actionKeywordListView;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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))
|
CurrentActionKeyword = selectedActionKeyword;
|
||||||
return;
|
|
||||||
|
|
||||||
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();
|
Close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (CurrentActionKeyword.KeywordProperty == Settings.ActionKeyword.FileContentSearchActionKeyword
|
||||||
|
&& ActionKeyword == Query.GlobalPluginWildcardSign)
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settingsViewModel.IsNewActionKeywordGlobal(newActionKeyword)
|
var oldActionKeyword = CurrentActionKeyword.Keyword;
|
||||||
&& currentActionKeyword.Description
|
|
||||||
== settingsViewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_filecontentsearch"))
|
|
||||||
{
|
|
||||||
MessageBox.Show(settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));
|
|
||||||
|
|
||||||
return;
|
// == because of nullable
|
||||||
}
|
if (Enabled == false || !settingsViewModel.IsActionKeywordAlreadyAssigned(ActionKeyword))
|
||||||
|
|
||||||
if (!settingsViewModel.IsActionKeywordAlreadyAssigned(newActionKeyword))
|
|
||||||
{
|
{
|
||||||
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();
|
Close();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The keyword is not valid, so show message
|
||||||
MessageBox.Show(settingsViewModel.Context.API.GetTranslation("newActionKeywordsHasBeenAssigned"));
|
MessageBox.Show(settingsViewModel.Context.API.GetTranslation("newActionKeywordsHasBeenAssigned"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnCancelButtonClick(object sender, RoutedEventArgs e)
|
private void TxtCurrentActionKeyword_OnKeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
Close();
|
if (e.Key == Key.Enter)
|
||||||
|
{
|
||||||
return;
|
DownButton.Focus();
|
||||||
|
OnDoneButtonClick(sender, e);
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.Explorer.ViewModels"
|
xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.Explorer.ViewModels"
|
||||||
|
xmlns:views="clr-namespace:Flow.Launcher.Plugin.Explorer.Views"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450" d:DesignWidth="800">
|
d:DesignHeight="450" d:DesignWidth="800">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
|
|
@ -17,14 +18,17 @@
|
||||||
Text="{Binding Path, Mode=OneTime}"
|
Text="{Binding Path, Mode=OneTime}"
|
||||||
Margin="0,5,0,5" />
|
Margin="0,5,0,5" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
<DataTemplate x:Key="ListViewActionKeywords">
|
<DataTemplate x:Key="ListViewActionKeywords"
|
||||||
|
DataType="views:ActionKeywordView">
|
||||||
<Grid>
|
<Grid>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Description, Mode=OneTime}"
|
Text="{Binding Description, Mode=OneTime}"
|
||||||
|
Foreground="{Binding Color, Mode=OneWay}"
|
||||||
Margin="0,5,0,0" />
|
Margin="0,5,0,0" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Keyword, Mode=OneTime}"
|
Text="{Binding Keyword, Mode=OneTime}"
|
||||||
Margin="150,5,0,0" />
|
Foreground="{Binding Color, Mode=OneWay}"
|
||||||
|
Margin="250,5,0,0" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
|
|
|
||||||
|
|
@ -35,20 +35,20 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
|
|
||||||
actionKeywordsListView = new List<ActionKeywordView>
|
actionKeywordsListView = new List<ActionKeywordView>
|
||||||
{
|
{
|
||||||
new ActionKeywordView()
|
new(Settings.ActionKeyword.SearchActionKeyword,
|
||||||
{
|
viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_search")),
|
||||||
Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_search"),
|
new(Settings.ActionKeyword.FileContentSearchActionKeyword,
|
||||||
Keyword = this.viewModel.Settings.SearchActionKeyword
|
viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_filecontentsearch")),
|
||||||
},
|
new(Settings.ActionKeyword.PathSearchActionKeyword,
|
||||||
new ActionKeywordView()
|
viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_pathsearch")),
|
||||||
{
|
new(Settings.ActionKeyword.IndexSearchActionKeyword,
|
||||||
Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_filecontentsearch"),
|
viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_indexsearch"))
|
||||||
Keyword = this.viewModel.Settings.FileContentSearchActionKeyword
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
lbxActionKeywords.ItemsSource = actionKeywordsListView;
|
lbxActionKeywords.ItemsSource = actionKeywordsListView;
|
||||||
|
|
||||||
|
ActionKeywordView.Init(viewModel.Settings);
|
||||||
|
|
||||||
RefreshView();
|
RefreshView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,9 +71,9 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
&& btnEdit.Visibility == Visibility.Hidden)
|
&& btnEdit.Visibility == Visibility.Hidden)
|
||||||
btnEdit.Visibility = Visibility.Visible;
|
btnEdit.Visibility = Visibility.Visible;
|
||||||
|
|
||||||
if ((lbxAccessLinks.Items.Count == 0 && lbxExcludedPaths.Items.Count == 0)
|
if (lbxAccessLinks.Items.Count == 0 && lbxExcludedPaths.Items.Count == 0
|
||||||
&& btnDelete.Visibility == Visibility.Visible
|
&& btnDelete.Visibility == Visibility.Visible
|
||||||
&& btnEdit.Visibility == Visibility.Visible)
|
&& btnEdit.Visibility == Visibility.Visible)
|
||||||
{
|
{
|
||||||
btnDelete.Visibility = Visibility.Hidden;
|
btnDelete.Visibility = Visibility.Hidden;
|
||||||
btnEdit.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)
|
private void expActionKeywords_Collapsed(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!expActionKeywords.IsExpanded)
|
if (!expActionKeywords.IsExpanded)
|
||||||
expActionKeywords.Height = Double.NaN;
|
expActionKeywords.Height = double.NaN;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void expAccessLinks_Click(object sender, RoutedEventArgs e)
|
private void expAccessLinks_Click(object sender, RoutedEventArgs e)
|
||||||
|
|
@ -135,20 +135,20 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
|
|
||||||
if (expActionKeywords.IsExpanded)
|
if (expActionKeywords.IsExpanded)
|
||||||
expActionKeywords.IsExpanded = false;
|
expActionKeywords.IsExpanded = false;
|
||||||
|
|
||||||
RefreshView();
|
RefreshView();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void expAccessLinks_Collapsed(object sender, RoutedEventArgs e)
|
private void expAccessLinks_Collapsed(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!expAccessLinks.IsExpanded)
|
if (!expAccessLinks.IsExpanded)
|
||||||
expAccessLinks.Height = Double.NaN;
|
expAccessLinks.Height = double.NaN;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void expExcludedPaths_Click(object sender, RoutedEventArgs e)
|
private void expExcludedPaths_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (expExcludedPaths.IsExpanded)
|
if (expExcludedPaths.IsExpanded)
|
||||||
expAccessLinks.Height = Double.NaN;
|
expAccessLinks.Height = double.NaN;
|
||||||
|
|
||||||
if (expAccessLinks.IsExpanded)
|
if (expAccessLinks.IsExpanded)
|
||||||
expAccessLinks.IsExpanded = false;
|
expAccessLinks.IsExpanded = false;
|
||||||
|
|
@ -161,11 +161,12 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
|
|
||||||
private void btnDelete_Click(object sender, RoutedEventArgs e)
|
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)
|
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)
|
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 selectedActionKeyword = lbxActionKeywords.SelectedItem as ActionKeywordView;
|
||||||
|
|
||||||
var actionKeywordWindow = new ActionKeywordSetting(viewModel, actionKeywordsListView, selectedActionKeyword);
|
var actionKeywordWindow = new ActionKeywordSetting(viewModel,
|
||||||
|
selectedActionKeyword);
|
||||||
|
|
||||||
actionKeywordWindow.ShowDialog();
|
actionKeywordWindow.ShowDialog();
|
||||||
|
|
||||||
|
|
@ -199,7 +201,8 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var selectedRow = lbxAccessLinks.SelectedItem as AccessLink ?? lbxExcludedPaths.SelectedItem as AccessLink;
|
var selectedRow = lbxAccessLinks.SelectedItem as AccessLink ??
|
||||||
|
lbxExcludedPaths.SelectedItem as AccessLink;
|
||||||
|
|
||||||
if (selectedRow != null)
|
if (selectedRow != null)
|
||||||
{
|
{
|
||||||
|
|
@ -215,7 +218,8 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
|
|
||||||
if (expExcludedPaths.IsExpanded)
|
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;
|
link.Path = folderBrowserDialog.SelectedPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -235,10 +239,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
var folderBrowserDialog = new FolderBrowserDialog();
|
var folderBrowserDialog = new FolderBrowserDialog();
|
||||||
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
|
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
var newAccessLink = new AccessLink
|
var newAccessLink = new AccessLink {Path = folderBrowserDialog.SelectedPath};
|
||||||
{
|
|
||||||
Path = folderBrowserDialog.SelectedPath
|
|
||||||
};
|
|
||||||
|
|
||||||
AddAccessLink(newAccessLink);
|
AddAccessLink(newAccessLink);
|
||||||
}
|
}
|
||||||
|
|
@ -259,10 +260,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
{
|
{
|
||||||
if (Directory.Exists(s))
|
if (Directory.Exists(s))
|
||||||
{
|
{
|
||||||
var newFolderLink = new AccessLink
|
var newFolderLink = new AccessLink {Path = s};
|
||||||
{
|
|
||||||
Path = s
|
|
||||||
};
|
|
||||||
|
|
||||||
AddAccessLink(newFolderLink);
|
AddAccessLink(newFolderLink);
|
||||||
}
|
}
|
||||||
|
|
@ -275,7 +273,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
private void AddAccessLink(AccessLink newAccessLink)
|
private void AddAccessLink(AccessLink newAccessLink)
|
||||||
{
|
{
|
||||||
if (expAccessLinks.IsExpanded
|
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)
|
if (viewModel.Settings.QuickAccessLinks == null)
|
||||||
viewModel.Settings.QuickAccessLinks = new List<AccessLink>();
|
viewModel.Settings.QuickAccessLinks = new List<AccessLink>();
|
||||||
|
|
@ -313,8 +311,35 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
|
|
||||||
public class ActionKeywordView
|
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"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
{
|
{
|
||||||
"ID": "572be03c74c642baae319fc283e561a8",
|
"ID": "572be03c74c642baae319fc283e561a8",
|
||||||
"ActionKeywords": [
|
"ActionKeywords": [
|
||||||
"*",
|
"*",
|
||||||
"doc:"
|
"doc:",
|
||||||
|
"*",
|
||||||
|
"*"
|
||||||
],
|
],
|
||||||
"Name": "Explorer",
|
"Name": "Explorer",
|
||||||
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
|
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue