2022-03-25 21:19:00 +00:00
|
|
|
using Flow.Launcher.Plugin.Everything.Everything;
|
2021-07-25 09:58:21 +00:00
|
|
|
using Flow.Launcher.Plugin.Explorer.Search;
|
2022-03-25 21:19:00 +00:00
|
|
|
using Flow.Launcher.Plugin.Explorer.Search.Everything;
|
2021-01-26 09:48:06 +00:00
|
|
|
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
|
2022-03-25 21:19:00 +00:00
|
|
|
using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex;
|
2021-06-02 01:10:24 +00:00
|
|
|
using System;
|
2020-05-11 13:15:15 +00:00
|
|
|
using System.Collections.Generic;
|
2022-07-01 04:56:15 +00:00
|
|
|
using System.Collections.ObjectModel;
|
2022-07-04 00:50:02 +00:00
|
|
|
using System.ComponentModel;
|
2022-03-25 21:19:00 +00:00
|
|
|
using System.Linq;
|
2022-03-28 20:28:18 +00:00
|
|
|
using System.Text.Json.Serialization;
|
2022-09-10 15:45:41 +00:00
|
|
|
using Flow.Launcher.Plugin.Explorer.Search.IProvider;
|
2020-05-11 13:15:15 +00:00
|
|
|
|
|
|
|
|
namespace Flow.Launcher.Plugin.Explorer
|
|
|
|
|
{
|
|
|
|
|
public class Settings
|
|
|
|
|
{
|
2020-05-24 22:14:21 +00:00
|
|
|
public int MaxResult { get; set; } = 100;
|
|
|
|
|
|
2022-07-04 00:50:02 +00:00
|
|
|
public ObservableCollection<AccessLink> QuickAccessLinks { get; set; } = new();
|
2020-06-02 10:12:14 +00:00
|
|
|
|
2022-07-04 00:50:02 +00:00
|
|
|
public ObservableCollection<AccessLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = new ObservableCollection<AccessLink>();
|
|
|
|
|
|
|
|
|
|
public string EditorPath { get; set; } = "";
|
|
|
|
|
|
2022-08-17 00:52:53 +00:00
|
|
|
public string ShellPath { get; set; } = "cmd";
|
2022-10-02 04:42:39 +00:00
|
|
|
|
2022-07-04 00:50:02 +00:00
|
|
|
|
|
|
|
|
public bool UseLocationAsWorkingDir { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
public bool ShowWindowsContextMenu { get; set; } = true;
|
2021-01-26 10:09:35 +00:00
|
|
|
|
2020-07-14 19:50:48 +00:00
|
|
|
|
|
|
|
|
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
|
2021-07-30 10:44:29 +00:00
|
|
|
|
2021-07-03 04:45:00 +00:00
|
|
|
public bool SearchActionKeywordEnabled { get; set; } = true;
|
2020-07-14 19:50:48 +00:00
|
|
|
|
2020-08-25 22:06:51 +00:00
|
|
|
public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword;
|
2021-05-22 09:23:25 +00:00
|
|
|
|
2021-09-01 11:10:52 +00:00
|
|
|
public bool FileContentSearchKeywordEnabled { get; set; } = true;
|
|
|
|
|
|
2021-05-22 09:23:25 +00:00
|
|
|
public string PathSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
|
2021-05-29 10:08:34 +00:00
|
|
|
|
2021-07-03 04:45:00 +00:00
|
|
|
public bool PathSearchKeywordEnabled { get; set; }
|
2021-05-30 09:28:18 +00:00
|
|
|
|
2021-06-05 04:07:13 +00:00
|
|
|
public string IndexSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
|
2021-05-30 09:28:18 +00:00
|
|
|
|
2021-09-01 12:05:19 +00:00
|
|
|
public bool IndexSearchKeywordEnabled { get; set; }
|
2021-05-30 09:28:18 +00:00
|
|
|
|
2021-07-30 10:44:29 +00:00
|
|
|
public string QuickAccessActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
|
|
|
|
|
|
|
|
|
|
public bool QuickAccessKeywordEnabled { get; set; }
|
|
|
|
|
|
2022-07-04 00:50:02 +00:00
|
|
|
|
2021-07-25 09:58:21 +00:00
|
|
|
public bool WarnWindowsSearchServiceOff { get; set; } = true;
|
|
|
|
|
|
2022-07-04 00:50:02 +00:00
|
|
|
private EverythingSearchManager _everythingManagerInstance;
|
|
|
|
|
private WindowsIndexSearchManager _windowsIndexSearchManager;
|
|
|
|
|
|
|
|
|
|
#region SearchEngine
|
|
|
|
|
|
|
|
|
|
private EverythingSearchManager EverythingManagerInstance => _everythingManagerInstance ??= new EverythingSearchManager(this);
|
|
|
|
|
private WindowsIndexSearchManager WindowsIndexSearchManager => _windowsIndexSearchManager ??= new WindowsIndexSearchManager(this);
|
|
|
|
|
|
|
|
|
|
|
2022-10-02 04:42:39 +00:00
|
|
|
public IndexSearchEngineOption IndexSearchEngine { get; set; } = IndexSearchEngineOption.WindowsIndex;
|
2022-03-28 20:28:18 +00:00
|
|
|
[JsonIgnore]
|
2022-07-04 00:50:02 +00:00
|
|
|
public IIndexProvider IndexProvider => IndexSearchEngine switch
|
|
|
|
|
{
|
|
|
|
|
IndexSearchEngineOption.Everything => EverythingManagerInstance,
|
|
|
|
|
IndexSearchEngineOption.WindowsIndex => WindowsIndexSearchManager,
|
|
|
|
|
_ => throw new ArgumentOutOfRangeException(nameof(IndexSearchEngine))
|
|
|
|
|
};
|
|
|
|
|
|
2022-10-02 04:42:39 +00:00
|
|
|
public PathEnumerationEngineOption PathEnumerationEngine { get; set; } = PathEnumerationEngineOption.WindowsIndex;
|
|
|
|
|
|
2022-03-28 20:28:18 +00:00
|
|
|
[JsonIgnore]
|
2022-09-10 15:45:41 +00:00
|
|
|
public IPathIndexProvider PathEnumerator => PathEnumerationEngine switch
|
2022-07-04 00:50:02 +00:00
|
|
|
{
|
|
|
|
|
PathEnumerationEngineOption.Everything => EverythingManagerInstance,
|
|
|
|
|
PathEnumerationEngineOption.WindowsIndex => WindowsIndexSearchManager,
|
|
|
|
|
_ => throw new ArgumentOutOfRangeException(nameof(PathEnumerationEngine))
|
|
|
|
|
};
|
2022-03-25 21:19:00 +00:00
|
|
|
|
2022-10-02 04:42:39 +00:00
|
|
|
public ContentIndexSearchEngineOption ContentSearchEngine { get; set; } = ContentIndexSearchEngineOption.WindowsIndex;
|
2022-03-28 20:28:18 +00:00
|
|
|
[JsonIgnore]
|
2022-07-04 00:50:02 +00:00
|
|
|
public IContentIndexProvider ContentIndexProvider => ContentSearchEngine switch
|
|
|
|
|
{
|
|
|
|
|
ContentIndexSearchEngineOption.Everything => EverythingManagerInstance,
|
|
|
|
|
ContentIndexSearchEngineOption.WindowsIndex => WindowsIndexSearchManager,
|
|
|
|
|
_ => throw new ArgumentOutOfRangeException(nameof(ContentSearchEngine))
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public enum PathEnumerationEngineOption
|
2022-03-25 21:19:00 +00:00
|
|
|
{
|
2022-07-04 00:50:02 +00:00
|
|
|
[Description("plugin_explorer_engine_windows_index")]
|
2022-03-25 21:19:00 +00:00
|
|
|
WindowsIndex,
|
2022-10-02 04:42:39 +00:00
|
|
|
[Description("plugin_explorer_engine_everything")]
|
|
|
|
|
Everything,
|
2022-07-04 00:50:02 +00:00
|
|
|
[Description("plugin_explorer_path_enumeration_engine_none")]
|
2022-11-28 23:54:06 +00:00
|
|
|
DirectEnumeration
|
2022-03-25 21:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum IndexSearchEngineOption
|
|
|
|
|
{
|
2022-10-02 04:42:39 +00:00
|
|
|
[Description("plugin_explorer_engine_windows_index")]
|
|
|
|
|
WindowsIndex,
|
2022-07-04 00:50:02 +00:00
|
|
|
[Description("plugin_explorer_engine_everything")]
|
2022-03-25 21:19:00 +00:00
|
|
|
Everything,
|
|
|
|
|
}
|
2022-07-04 00:50:02 +00:00
|
|
|
|
2022-03-28 20:28:18 +00:00
|
|
|
public enum ContentIndexSearchEngineOption
|
|
|
|
|
{
|
2022-10-02 04:42:39 +00:00
|
|
|
[Description("plugin_explorer_engine_windows_index")]
|
|
|
|
|
WindowsIndex,
|
2022-07-04 00:50:02 +00:00
|
|
|
[Description("plugin_explorer_engine_everything")]
|
2022-03-28 20:28:18 +00:00
|
|
|
Everything,
|
|
|
|
|
}
|
2022-07-04 00:50:02 +00:00
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2022-03-25 21:19:00 +00:00
|
|
|
|
2022-03-28 20:28:18 +00:00
|
|
|
#region Everything Settings
|
2022-07-04 00:50:02 +00:00
|
|
|
|
2022-03-25 21:19:00 +00:00
|
|
|
public string EverythingInstalledPath { get; set; }
|
|
|
|
|
|
2022-07-04 00:50:02 +00:00
|
|
|
[JsonIgnore]
|
2022-03-25 21:19:00 +00:00
|
|
|
public SortOption[] SortOptions { get; set; } = Enum.GetValues<SortOption>();
|
|
|
|
|
|
|
|
|
|
public SortOption SortOption { get; set; } = SortOption.NAME_ASCENDING;
|
2022-07-04 00:50:02 +00:00
|
|
|
|
2022-05-15 20:15:56 +00:00
|
|
|
public bool EnableEverythingContentSearch { get; set; } = false;
|
2022-03-25 21:19:00 +00:00
|
|
|
|
2022-10-02 04:42:39 +00:00
|
|
|
public bool EverythingEnabled => IndexSearchEngine == IndexSearchEngineOption.Everything ||
|
2022-08-17 01:32:49 +00:00
|
|
|
PathEnumerationEngine == PathEnumerationEngineOption.Everything ||
|
|
|
|
|
ContentSearchEngine == ContentIndexSearchEngineOption.Everything;
|
|
|
|
|
|
2022-03-25 21:19:00 +00:00
|
|
|
#endregion
|
|
|
|
|
|
2021-05-30 09:28:18 +00:00
|
|
|
internal enum ActionKeyword
|
|
|
|
|
{
|
|
|
|
|
SearchActionKeyword,
|
|
|
|
|
PathSearchActionKeyword,
|
|
|
|
|
FileContentSearchActionKeyword,
|
2021-07-30 10:44:29 +00:00
|
|
|
IndexSearchActionKeyword,
|
|
|
|
|
QuickAccessActionKeyword
|
2021-05-30 09:28:18 +00:00
|
|
|
}
|
2021-06-02 01:10:24 +00:00
|
|
|
|
|
|
|
|
internal string GetActionKeyword(ActionKeyword actionKeyword) => actionKeyword switch
|
|
|
|
|
{
|
|
|
|
|
ActionKeyword.SearchActionKeyword => SearchActionKeyword,
|
|
|
|
|
ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword,
|
|
|
|
|
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword,
|
2021-07-30 10:44:29 +00:00
|
|
|
ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword,
|
2021-09-15 11:15:33 +00:00
|
|
|
ActionKeyword.QuickAccessActionKeyword => QuickAccessActionKeyword,
|
2021-09-01 11:10:52 +00:00
|
|
|
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "ActionKeyWord property not found")
|
2021-06-02 01:10:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
internal void SetActionKeyword(ActionKeyword actionKeyword, string keyword) => _ = actionKeyword switch
|
|
|
|
|
{
|
|
|
|
|
ActionKeyword.SearchActionKeyword => SearchActionKeyword = keyword,
|
|
|
|
|
ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword = keyword,
|
|
|
|
|
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword = keyword,
|
2021-06-05 04:07:13 +00:00
|
|
|
ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword = keyword,
|
2021-07-30 10:44:29 +00:00
|
|
|
ActionKeyword.QuickAccessActionKeyword => QuickAccessActionKeyword = keyword,
|
2021-09-01 11:10:52 +00:00
|
|
|
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "ActionKeyWord property not found")
|
2021-06-02 01:10:24 +00:00
|
|
|
};
|
|
|
|
|
|
2021-09-01 11:10:52 +00:00
|
|
|
internal bool GetActionKeywordEnabled(ActionKeyword actionKeyword) => actionKeyword switch
|
2021-06-02 01:10:24 +00:00
|
|
|
{
|
2021-07-03 04:45:00 +00:00
|
|
|
ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled,
|
|
|
|
|
ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled,
|
2021-09-01 12:05:19 +00:00
|
|
|
ActionKeyword.IndexSearchActionKeyword => IndexSearchKeywordEnabled,
|
2021-09-01 11:10:52 +00:00
|
|
|
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchKeywordEnabled,
|
2021-07-30 10:44:29 +00:00
|
|
|
ActionKeyword.QuickAccessActionKeyword => QuickAccessKeywordEnabled,
|
2021-09-01 11:10:52 +00:00
|
|
|
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "ActionKeyword enabled status not defined")
|
2021-06-02 01:10:24 +00:00
|
|
|
};
|
|
|
|
|
|
2021-07-03 06:33:29 +00:00
|
|
|
internal void SetActionKeywordEnabled(ActionKeyword actionKeyword, bool enable) => _ = actionKeyword switch
|
2021-06-02 01:10:24 +00:00
|
|
|
{
|
2021-07-03 04:45:00 +00:00
|
|
|
ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled = enable,
|
|
|
|
|
ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled = enable,
|
2021-09-01 12:05:19 +00:00
|
|
|
ActionKeyword.IndexSearchActionKeyword => IndexSearchKeywordEnabled = enable,
|
2021-09-01 11:10:52 +00:00
|
|
|
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchKeywordEnabled = enable,
|
2021-07-30 10:44:29 +00:00
|
|
|
ActionKeyword.QuickAccessActionKeyword => QuickAccessKeywordEnabled = enable,
|
2021-09-01 11:10:52 +00:00
|
|
|
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "ActionKeyword enabled status not defined")
|
2021-06-02 01:10:24 +00:00
|
|
|
};
|
2020-05-11 13:15:15 +00:00
|
|
|
}
|
2022-09-10 15:45:41 +00:00
|
|
|
}
|