Skip to content

Commit 661b8cf

Browse files
authored
Merge pull request #621 from Flow-Launcher/add_quickaccess_actionkeyword
Add Quick Access action keyword for Explorer
2 parents f3398c5 + dd6b8f8 commit 661b8cf

File tree

7 files changed

+66
-31
lines changed

7 files changed

+66
-31
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: 21 additions & 14 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)
@@ -78,24 +91,18 @@ private bool ActionKeywordMatch(Query query, Settings.ActionKeyword allowedActio
7891
Settings.ActionKeyword.FileContentSearchActionKeyword => Settings.FileContentSearchKeywordEnabled &&
7992
keyword == Settings.FileContentSearchActionKeyword,
8093
Settings.ActionKeyword.IndexSearchActionKeyword => Settings.IndexSearchKeywordEnabled &&
81-
keyword == Settings.IndexSearchActionKeyword
94+
keyword == Settings.IndexSearchActionKeyword,
95+
Settings.ActionKeyword.QuickAccessActionKeyword => Settings.QuickAccessKeywordEnabled &&
96+
keyword == Settings.QuickAccessActionKeyword
8297
};
8398
}
8499

85100
public async Task<List<Result>> PathSearchAsync(Query query, CancellationToken token = default)
86101
{
87102
var querySearch = query.Search;
88103

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-
93104
var results = new HashSet<Result>(PathEqualityComparator.Instance);
94105

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

101108
if (isEnvironmentVariable)

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class Settings
1919
public List<AccessLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = new List<AccessLink>();
2020

2121
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
22+
2223
public bool SearchActionKeywordEnabled { get; set; } = true;
2324

2425
public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword;
@@ -33,14 +34,19 @@ public class Settings
3334

3435
public bool IndexSearchKeywordEnabled { 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
@@ -49,6 +55,7 @@ internal enum ActionKeyword
4955
ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword,
5056
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword,
5157
ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword,
58+
ActionKeyword.QuickAccessActionKeyword => QuickAccessActionKeyword,
5259
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "ActionKeyWord property not found")
5360
};
5461

@@ -58,6 +65,7 @@ internal enum ActionKeyword
5865
ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword = keyword,
5966
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword = keyword,
6067
ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword = keyword,
68+
ActionKeyword.QuickAccessActionKeyword => QuickAccessActionKeyword = keyword,
6169
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "ActionKeyWord property not found")
6270
};
6371

@@ -67,6 +75,7 @@ internal enum ActionKeyword
6775
ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled,
6876
ActionKeyword.IndexSearchActionKeyword => IndexSearchKeywordEnabled,
6977
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchKeywordEnabled,
78+
ActionKeyword.QuickAccessActionKeyword => QuickAccessKeywordEnabled,
7079
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "ActionKeyword enabled status not defined")
7180
};
7281

@@ -76,6 +85,7 @@ internal enum ActionKeyword
7685
ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled = enable,
7786
ActionKeyword.IndexSearchActionKeyword => IndexSearchKeywordEnabled = enable,
7887
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchKeywordEnabled = enable,
88+
ActionKeyword.QuickAccessActionKeyword => QuickAccessKeywordEnabled = enable,
7989
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "ActionKeyword enabled status not defined")
8090
};
8191
}

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,16 @@ private void OnDoneButtonClick(object sender, RoutedEventArgs e)
5959
}
6060

6161

62-
if (CurrentActionKeyword.KeywordProperty == Settings.ActionKeyword.FileContentSearchActionKeyword
63-
&& ActionKeyword == Query.GlobalPluginWildcardSign)
64-
{
65-
MessageBox.Show(
66-
settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));
67-
68-
return;
69-
}
62+
if (ActionKeyword == Query.GlobalPluginWildcardSign)
63+
switch (CurrentActionKeyword.KeywordProperty)
64+
{
65+
case Settings.ActionKeyword.FileContentSearchActionKeyword:
66+
MessageBox.Show(settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));
67+
return;
68+
case Settings.ActionKeyword.QuickAccessActionKeyword:
69+
MessageBox.Show(settingsViewModel.Context.API.GetTranslation("plugin_explorer_quickaccess_globalActionKeywordInvalid"));
70+
return;
71+
}
7072

7173
var oldActionKeyword = CurrentActionKeyword.Keyword;
7274

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.5",
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)