Skip to content

Commit 6978b65

Browse files
committed
add Quick Access action keyword
1 parent 309ee29 commit 6978b65

File tree

7 files changed

+70
-30
lines changed

7 files changed

+70
-30
lines changed

Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using Flow.Launcher.Plugin;
33

44
namespace Flow.Launcher.Infrastructure.UserSettings
@@ -15,13 +15,24 @@ public void UpdatePluginSettings(List<PluginMetadata> metadatas)
1515
if (Plugins.ContainsKey(metadata.ID))
1616
{
1717
var settings = Plugins[metadata.ID];
18-
19-
// TODO: Remove. This is backwards compatibility for 1.8.0 release.
20-
// Introduced two new action keywords in Explorer, so need to update plugin setting in the UserData folder.
18+
2119
if (metadata.ID == "572be03c74c642baae319fc283e561a8" && metadata.ActionKeywords.Count != settings.ActionKeywords.Count)
2220
{
23-
settings.ActionKeywords.Add(Query.GlobalPluginWildcardSign); // for index search
24-
settings.ActionKeywords.Add(Query.GlobalPluginWildcardSign); // for path search
21+
// TODO: Remove. This is backwards compatibility for Explorer 1.8.0 release.
22+
// Introduced two new action keywords in Explorer, so need to update plugin setting in the UserData folder.
23+
if (settings.Version.CompareTo("1.8.0") < 0)
24+
{
25+
settings.ActionKeywords.Add(Query.GlobalPluginWildcardSign); // for index search
26+
settings.ActionKeywords.Add(Query.GlobalPluginWildcardSign); // for path search
27+
settings.ActionKeywords.Add(Query.GlobalPluginWildcardSign); // for quick access action keyword
28+
}
29+
30+
// TODO: Remove. This is backwards compatibility for Explorer 1.9.0 release.
31+
// Introduced a new action keywords in Explorer since 1.8.0, so need to update plugin setting in the UserData folder.
32+
if (settings.Version.CompareTo("1.8.0") > 0)
33+
{
34+
settings.ActionKeywords.Add(Query.GlobalPluginWildcardSign); // for quick access action keyword
35+
}
2536
}
2637

2738
if (string.IsNullOrEmpty(settings.Version))

Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<system:String x:Key="plugin_explorer_deletefilefoldersuccess">Deletion successful</system:String>
1111
<system:String x:Key="plugin_explorer_deletefilefoldersuccess_detail">Successfully deleted the {0}</system:String>
1212
<system:String x:Key="plugin_explorer_globalActionKeywordInvalid">Assigning the global action keyword could bring up too many results during search. Please choose a specific action keyword</system:String>
13+
<system:String x:Key="plugin_explorer_quickaccess_globalActionKeywordInvalid">Quick Access can not be set to the global action keyword when enabled. Please choose a specific action keyword</system:String>
1314
<system:String x:Key="plugin_explorer_windowsSearchServiceNotRunning">The required service for Windows Index Search does not appear to be running</system:String>
1415
<system:String x:Key="plugin_explorer_windowsSearchServiceFix">To fix this, start the Windows Search service. Select here to remove this warning</system:String>
1516
<system:String x:Key="plugin_explorer_alternative">The warning message has been switched off. As an alternative for searching files and folders, would you like to install Everything plugin?{0}{0}Select 'Yes' to install Everything plugin, or 'No' to return</system:String>
@@ -27,6 +28,7 @@
2728
<system:String x:Key="plugin_explorer_actionkeywordview_pathsearch">Path Search:</system:String>
2829
<system:String x:Key="plugin_explorer_actionkeywordview_filecontentsearch">File Content Search:</system:String>
2930
<system:String x:Key="plugin_explorer_actionkeywordview_indexsearch">Index Search:</system:String>
31+
<system:String x:Key="plugin_explorer_actionkeywordview_quickaccess">Quick Access:</system:String>
3032
<system:String x:Key="plugin_explorer_actionkeyword_current">Current Action Keyword:</system:String>
3133
<system:String x:Key="plugin_explorer_actionkeyword_done">Done</system:String>
3234
<system:String x:Key="plugin_explorer_actionkeyword_enabled">Enabled</system:String>

Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,40 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok
4242
{
4343
var querySearch = query.Search;
4444

45+
var results = new HashSet<Result>(PathEqualityComparator.Instance);
46+
47+
// This allows the user to type the below action keywords and see/search the list of quick folder links
48+
if (ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword)
49+
|| ActionKeywordMatch(query, Settings.ActionKeyword.QuickAccessActionKeyword)
50+
|| ActionKeywordMatch(query, Settings.ActionKeyword.PathSearchActionKeyword))
51+
{
52+
if (string.IsNullOrEmpty(query.Search))
53+
return QuickAccess.AccessLinkListAll(query, Settings.QuickAccessLinks);
54+
55+
var quickaccessLinks = QuickAccess.AccessLinkListMatched(query, Settings.QuickAccessLinks);
56+
57+
results.UnionWith(quickaccessLinks);
58+
}
59+
4560
if (IsFileContentSearch(query.ActionKeyword))
4661
return await WindowsIndexFileContentSearchAsync(query, querySearch, token).ConfigureAwait(false);
4762

48-
var result = new HashSet<Result>(PathEqualityComparator.Instance);
49-
5063
if (ActionKeywordMatch(query, Settings.ActionKeyword.PathSearchActionKeyword) ||
5164
ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword))
5265
{
53-
result.UnionWith(await PathSearchAsync(query, token).ConfigureAwait(false));
66+
results.UnionWith(await PathSearchAsync(query, token).ConfigureAwait(false));
5467
}
5568

5669
if ((ActionKeywordMatch(query, Settings.ActionKeyword.IndexSearchActionKeyword) ||
5770
ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword)) &&
5871
querySearch.Length > 0 &&
5972
!querySearch.IsLocationPathString())
6073
{
61-
result.UnionWith(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token)
74+
results.UnionWith(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token)
6275
.ConfigureAwait(false));
6376
}
6477

65-
return result.ToList();
78+
return results.ToList();
6679
}
6780

6881
private bool ActionKeywordMatch(Query query, Settings.ActionKeyword allowedActionKeyword)
@@ -75,27 +88,20 @@ private bool ActionKeywordMatch(Query query, Settings.ActionKeyword allowedActio
7588
keyword == Settings.SearchActionKeyword,
7689
Settings.ActionKeyword.PathSearchActionKeyword => Settings.PathSearchKeywordEnabled &&
7790
keyword == Settings.PathSearchActionKeyword,
78-
Settings.ActionKeyword.FileContentSearchActionKeyword => keyword ==
79-
Settings.FileContentSearchActionKeyword,
91+
Settings.ActionKeyword.FileContentSearchActionKeyword => keyword == Settings.FileContentSearchActionKeyword,
8092
Settings.ActionKeyword.IndexSearchActionKeyword => Settings.IndexOnlySearchKeywordEnabled &&
81-
keyword == Settings.IndexSearchActionKeyword
93+
keyword == Settings.IndexSearchActionKeyword,
94+
Settings.ActionKeyword.QuickAccessActionKeyword => Settings.QuickAccessKeywordEnabled &&
95+
keyword == Settings.QuickAccessActionKeyword
8296
};
8397
}
8498

8599
public async Task<List<Result>> PathSearchAsync(Query query, CancellationToken token = default)
86100
{
87101
var querySearch = query.Search;
88102

89-
// This allows the user to type the assigned action keyword and only see the list of quick folder links
90-
if (string.IsNullOrEmpty(query.Search))
91-
return QuickAccess.AccessLinkListAll(query, Settings.QuickAccessLinks);
92-
93103
var results = new HashSet<Result>(PathEqualityComparator.Instance);
94104

95-
var quickaccessLinks = QuickAccess.AccessLinkListMatched(query, Settings.QuickAccessLinks);
96-
97-
results.UnionWith(quickaccessLinks);
98-
99105
var isEnvironmentVariable = EnvironmentVariables.IsEnvironmentVariableSearch(querySearch);
100106

101107
if (isEnvironmentVariable)

Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class Settings
2121
public List<AccessLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = new List<AccessLink>();
2222

2323
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
24+
2425
public bool SearchActionKeywordEnabled { get; set; } = true;
2526

2627
public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword;
@@ -33,22 +34,28 @@ public class Settings
3334

3435
public bool IndexOnlySearchKeywordEnabled { get; set; }
3536

37+
public string QuickAccessActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
38+
39+
public bool QuickAccessKeywordEnabled { get; set; }
40+
3641
public bool WarnWindowsSearchServiceOff { get; set; } = true;
3742

3843
internal enum ActionKeyword
3944
{
4045
SearchActionKeyword,
4146
PathSearchActionKeyword,
4247
FileContentSearchActionKeyword,
43-
IndexSearchActionKeyword
48+
IndexSearchActionKeyword,
49+
QuickAccessActionKeyword
4450
}
4551

4652
internal string GetActionKeyword(ActionKeyword actionKeyword) => actionKeyword switch
4753
{
4854
ActionKeyword.SearchActionKeyword => SearchActionKeyword,
4955
ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword,
5056
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword,
51-
ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword
57+
ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword,
58+
ActionKeyword.QuickAccessActionKeyword => QuickAccessActionKeyword
5259
};
5360

5461
internal void SetActionKeyword(ActionKeyword actionKeyword, string keyword) => _ = actionKeyword switch
@@ -57,6 +64,7 @@ internal enum ActionKeyword
5764
ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword = keyword,
5865
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword = keyword,
5966
ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword = keyword,
67+
ActionKeyword.QuickAccessActionKeyword => QuickAccessActionKeyword = keyword,
6068
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property")
6169
};
6270

@@ -65,6 +73,7 @@ internal enum ActionKeyword
6573
ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled,
6674
ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled,
6775
ActionKeyword.IndexSearchActionKeyword => IndexOnlySearchKeywordEnabled,
76+
ActionKeyword.QuickAccessActionKeyword => QuickAccessKeywordEnabled,
6877
_ => null
6978
};
7079

@@ -73,6 +82,7 @@ internal enum ActionKeyword
7382
ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled = enable,
7483
ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled = enable,
7584
ActionKeyword.IndexSearchActionKeyword => IndexOnlySearchKeywordEnabled = enable,
85+
ActionKeyword.QuickAccessActionKeyword => QuickAccessKeywordEnabled = enable,
7686
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property")
7787
};
7888
}

Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,19 @@ private void OnDoneButtonClick(object sender, RoutedEventArgs e)
6363
}
6464

6565

66-
if (CurrentActionKeyword.KeywordProperty == Settings.ActionKeyword.FileContentSearchActionKeyword
67-
&& ActionKeyword == Query.GlobalPluginWildcardSign)
66+
if (ActionKeyword == Query.GlobalPluginWildcardSign
67+
&& (CurrentActionKeyword.KeywordProperty == Settings.ActionKeyword.FileContentSearchActionKeyword
68+
|| CurrentActionKeyword.KeywordProperty == Settings.ActionKeyword.QuickAccessActionKeyword))
6869
{
69-
MessageBox.Show(
70-
settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));
70+
switch (CurrentActionKeyword.KeywordProperty)
71+
{
72+
case Settings.ActionKeyword.FileContentSearchActionKeyword:
73+
MessageBox.Show(settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));
74+
break;
75+
case Settings.ActionKeyword.QuickAccessActionKeyword:
76+
MessageBox.Show(settingsViewModel.Context.API.GetTranslation("plugin_explorer_quickaccess_globalActionKeywordInvalid"));
77+
break;
78+
}
7179

7280
return;
7381
}

Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ public ExplorerSettings(SettingsViewModel viewModel)
4242
new(Settings.ActionKeyword.PathSearchActionKeyword,
4343
viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_pathsearch")),
4444
new(Settings.ActionKeyword.IndexSearchActionKeyword,
45-
viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_indexsearch"))
45+
viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_indexsearch")),
46+
new(Settings.ActionKeyword.QuickAccessActionKeyword,
47+
viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_quickaccess"))
4648
};
4749

4850
lbxActionKeywords.ItemsSource = actionKeywordsListView;

Plugins/Flow.Launcher.Plugin.Explorer/plugin.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
"*",
55
"doc:",
66
"*",
7+
"*",
78
"*"
89
],
910
"Name": "Explorer",
1011
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
1112
"Author": "Jeremy Wu",
12-
"Version": "1.8.2",
13+
"Version": "1.9.0",
1314
"Language": "csharp",
1415
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
1516
"ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll",

0 commit comments

Comments
 (0)