Skip to content

Commit 86fe664

Browse files
committed
add option to remove warning msg and install Everything plugin
1 parent 44d8666 commit 86fe664

File tree

4 files changed

+60
-23
lines changed

4 files changed

+60
-23
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
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>
1313
<system:String x:Key="plugin_explorer_windowsSearchServiceNotRunning">The required service for Windows Index Search does not appear to be running</system:String>
1414
<system:String x:Key="plugin_explorer_windowsSearchServiceFix">To fix this, start the Windows Search service. Select here to remove this warning</system:String>
15+
<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>
16+
<system:String x:Key="plugin_explorer_alternative_title">Explorer Alternative</system:String>
1517

1618
<!--Controls-->
1719
<system:String x:Key="plugin_explorer_delete">Delete</system:String>

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ public class SearchManager
1414
{
1515
internal static PluginInitContext Context;
1616

17-
private readonly Settings settings;
17+
internal static Settings Settings;
1818

1919
public SearchManager(Settings settings, PluginInitContext context)
2020
{
2121
Context = context;
22-
this.settings = settings;
22+
Settings = settings;
2323
}
2424

2525
private class PathEqualityComparator : IEqualityComparer<Result>
@@ -71,14 +71,14 @@ private bool ActionKeywordMatch(Query query, Settings.ActionKeyword allowedActio
7171

7272
return allowedActionKeyword switch
7373
{
74-
Settings.ActionKeyword.SearchActionKeyword => settings.SearchActionKeywordEnabled &&
75-
keyword == settings.SearchActionKeyword,
76-
Settings.ActionKeyword.PathSearchActionKeyword => settings.PathSearchKeywordEnabled &&
77-
keyword == settings.PathSearchActionKeyword,
74+
Settings.ActionKeyword.SearchActionKeyword => Settings.SearchActionKeywordEnabled &&
75+
keyword == Settings.SearchActionKeyword,
76+
Settings.ActionKeyword.PathSearchActionKeyword => Settings.PathSearchKeywordEnabled &&
77+
keyword == Settings.PathSearchActionKeyword,
7878
Settings.ActionKeyword.FileContentSearchActionKeyword => keyword ==
79-
settings.FileContentSearchActionKeyword,
80-
Settings.ActionKeyword.IndexSearchActionKeyword => settings.IndexOnlySearchKeywordEnabled &&
81-
keyword == settings.IndexSearchActionKeyword
79+
Settings.FileContentSearchActionKeyword,
80+
Settings.ActionKeyword.IndexSearchActionKeyword => Settings.IndexOnlySearchKeywordEnabled &&
81+
keyword == Settings.IndexSearchActionKeyword
8282
};
8383
}
8484

@@ -88,11 +88,11 @@ public async Task<List<Result>> PathSearchAsync(Query query, CancellationToken t
8888

8989
// This allows the user to type the assigned action keyword and only see the list of quick folder links
9090
if (string.IsNullOrEmpty(query.Search))
91-
return QuickAccess.AccessLinkListAll(query, settings.QuickAccessLinks);
91+
return QuickAccess.AccessLinkListAll(query, Settings.QuickAccessLinks);
9292

9393
var results = new HashSet<Result>(PathEqualityComparator.Instance);
9494

95-
var quickaccessLinks = QuickAccess.AccessLinkListMatched(query, settings.QuickAccessLinks);
95+
var quickaccessLinks = QuickAccess.AccessLinkListMatched(query, Settings.QuickAccessLinks);
9696

9797
results.UnionWith(quickaccessLinks);
9898

@@ -136,7 +136,7 @@ public async Task<List<Result>> PathSearchAsync(Query query, CancellationToken t
136136
private async Task<List<Result>> WindowsIndexFileContentSearchAsync(Query query, string querySearchString,
137137
CancellationToken token)
138138
{
139-
var queryConstructor = new QueryConstructor(settings);
139+
var queryConstructor = new QueryConstructor(Settings);
140140

141141
if (string.IsNullOrEmpty(querySearchString))
142142
return new List<Result>();
@@ -145,14 +145,14 @@ private async Task<List<Result>> WindowsIndexFileContentSearchAsync(Query query,
145145
querySearchString,
146146
queryConstructor.CreateQueryHelper,
147147
queryConstructor.QueryForFileContentSearch,
148-
settings.IndexSearchExcludedSubdirectoryPaths,
148+
Settings.IndexSearchExcludedSubdirectoryPaths,
149149
query,
150150
token).ConfigureAwait(false);
151151
}
152152

153153
public bool IsFileContentSearch(string actionKeyword)
154154
{
155-
return actionKeyword == settings.FileContentSearchActionKeyword;
155+
return actionKeyword == Settings.FileContentSearchActionKeyword;
156156
}
157157

158158
private List<Result> DirectoryInfoClassSearch(Query query, string querySearch, CancellationToken token)
@@ -177,26 +177,26 @@ public async Task<List<Result>> TopLevelDirectorySearchBehaviourAsync(
177177
private async Task<List<Result>> WindowsIndexFilesAndFoldersSearchAsync(Query query, string querySearchString,
178178
CancellationToken token)
179179
{
180-
var queryConstructor = new QueryConstructor(settings);
180+
var queryConstructor = new QueryConstructor(Settings);
181181

182182
return await IndexSearch.WindowsIndexSearchAsync(
183183
querySearchString,
184184
queryConstructor.CreateQueryHelper,
185185
queryConstructor.QueryForAllFilesAndFolders,
186-
settings.IndexSearchExcludedSubdirectoryPaths,
186+
Settings.IndexSearchExcludedSubdirectoryPaths,
187187
query,
188188
token).ConfigureAwait(false);
189189
}
190190

191191
private async Task<List<Result>> WindowsIndexTopLevelFolderSearchAsync(Query query, string path,
192192
CancellationToken token)
193193
{
194-
var queryConstructor = new QueryConstructor(settings);
194+
var queryConstructor = new QueryConstructor(Settings);
195195

196196
return await IndexSearch.WindowsIndexSearchAsync(path,
197197
queryConstructor.CreateQueryHelper,
198198
queryConstructor.QueryForTopLevelDirectorySearch,
199-
settings.IndexSearchExcludedSubdirectoryPaths,
199+
Settings.IndexSearchExcludedSubdirectoryPaths,
200200
query,
201201
token).ConfigureAwait(false);
202202
}
@@ -205,10 +205,10 @@ private bool UseWindowsIndexForDirectorySearch(string locationPath)
205205
{
206206
var pathToDirectory = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath);
207207

208-
if (!settings.UseWindowsIndexForDirectorySearch)
208+
if (!Settings.UseWindowsIndexForDirectorySearch)
209209
return false;
210210

211-
if (settings.IndexSearchExcludedSubdirectoryPaths
211+
if (Settings.IndexSearchExcludedSubdirectoryPaths
212212
.Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(pathToDirectory)
213213
.StartsWith(x.Path, StringComparison.OrdinalIgnoreCase)))
214214
return false;

Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
using System;
44
using System.Collections.Generic;
55
using System.Data.OleDb;
6+
using System.Linq;
67
using System.Runtime.InteropServices;
78
using System.Text.RegularExpressions;
89
using System.Threading;
910
using System.Threading.Tasks;
11+
using System.Windows;
1012

1113
namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
1214
{
@@ -107,12 +109,43 @@ await ExecuteWindowsIndexSearchAsync(constructedQuery, queryHelper().ConnectionS
107109
catch (COMException)
108110
{
109111
// Occurs because the Windows Indexing (WSearch) is turned off in services and unable to be used by Explorer plugin
112+
if (!SearchManager.Settings.WarnWindowsSearchServiceOff)
113+
return new List<Result>();
114+
115+
var api = SearchManager.Context.API;
116+
110117
return new List<Result>
111118
{
112119
new Result
113120
{
114-
Title = SearchManager.Context.API.GetTranslation("plugin_explorer_windowsSearchServiceNotRunning"),
115-
SubTitle = SearchManager.Context.API.GetTranslation("plugin_explorer_windowsSearchServiceFix"),
121+
Title = api.GetTranslation("plugin_explorer_windowsSearchServiceNotRunning"),
122+
SubTitle = api.GetTranslation("plugin_explorer_windowsSearchServiceFix"),
123+
Action = c =>
124+
{
125+
SearchManager.Settings.WarnWindowsSearchServiceOff = false;
126+
127+
if (MessageBox.Show(string.Format(api.GetTranslation("plugin_explorer_alternative"), Environment.NewLine),
128+
api.GetTranslation("plugin_explorer_alternative_title"),
129+
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
130+
{
131+
var pluginsManagerPlugins= api.GetAllPlugins().FirstOrDefault(x => x.Metadata.ID == "9f8f9b14-2518-4907-b211-35ab6290dee7");
132+
133+
api.ChangeQuery(string.Format("{0} install everything", pluginsManagerPlugins.Metadata.ActionKeywords[0]));
134+
}
135+
else
136+
{
137+
// Clears the warning message because same query string will not alter the displayed result list
138+
api.ChangeQuery(string.Empty);
139+
140+
api.ChangeQuery(query.RawQuery);
141+
}
142+
143+
var mainWindow = Application.Current.MainWindow;
144+
mainWindow.Visibility = Visibility.Visible;
145+
mainWindow.Focus();
146+
147+
return false;
148+
},
116149
IcoPath = Constants.ExplorerIconImagePath
117150
}
118151
};

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Flow.Launcher.Plugin.Explorer.Search;
1+
using Flow.Launcher.Plugin.Explorer.Search;
22
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
33
using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption;
44
using System;
@@ -33,6 +33,8 @@ public class Settings
3333

3434
public bool IndexOnlySearchKeywordEnabled { get; set; }
3535

36+
public bool WarnWindowsSearchServiceOff { get; set; } = true;
37+
3638
internal enum ActionKeyword
3739
{
3840
SearchActionKeyword,

0 commit comments

Comments
 (0)