forked from Flow-Launcher/Flow.Launcher
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSettings.cs
More file actions
211 lines (154 loc) · 9.16 KB
/
Settings.cs
File metadata and controls
211 lines (154 loc) · 9.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
using Flow.Launcher.Plugin.Everything.Everything;
using Flow.Launcher.Plugin.Explorer.Search;
using Flow.Launcher.Plugin.Explorer.Search.Everything;
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Text.Json.Serialization;
using Flow.Launcher.Plugin.Explorer.Search.IProvider;
namespace Flow.Launcher.Plugin.Explorer
{
public class Settings
{
public int MaxResult { get; set; } = 100;
public ObservableCollection<AccessLink> QuickAccessLinks { get; set; } = new();
public ObservableCollection<AccessLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = new ObservableCollection<AccessLink>();
public string EditorPath { get; set; } = "";
public string FolderEditorPath { get; set; } = "";
public string ShellPath { get; set; } = "cmd";
public string ExcludedFileTypes { get; set; } = "";
public bool UseLocationAsWorkingDir { get; set; } = false;
public bool ShowInlinedWindowsContextMenu { get; set; } = false;
public string WindowsContextMenuIncludedItems { get; set; } = string.Empty;
public string WindowsContextMenuExcludedItems { get; set; } = string.Empty;
public bool DefaultOpenFolderInFileManager { get; set; } = false;
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
public bool SearchActionKeywordEnabled { get; set; } = true;
public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword;
public bool FileContentSearchKeywordEnabled { get; set; } = true;
public string PathSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
public bool PathSearchKeywordEnabled { get; set; }
public string IndexSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
public bool IndexSearchKeywordEnabled { get; set; }
public string QuickAccessActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
public bool QuickAccessKeywordEnabled { get; set; }
public bool WarnWindowsSearchServiceOff { get; set; } = true;
public bool ShowFileSizeInPreviewPanel { get; set; } = true;
public bool ShowCreatedDateInPreviewPanel { get; set; } = true;
public bool ShowModifiedDateInPreviewPanel { get; set; } = true;
public bool ShowFileAgeInPreviewPanel { get; set; } = false;
public string PreviewPanelDateFormat { get; set; } = "yyyy-MM-dd";
public string PreviewPanelTimeFormat { get; set; } = "HH:mm";
private EverythingSearchManager _everythingManagerInstance;
private WindowsIndexSearchManager _windowsIndexSearchManager;
#region SearchEngine
private EverythingSearchManager EverythingManagerInstance => _everythingManagerInstance ??= new EverythingSearchManager(this);
private WindowsIndexSearchManager WindowsIndexSearchManager => _windowsIndexSearchManager ??= new WindowsIndexSearchManager(this);
public IndexSearchEngineOption IndexSearchEngine { get; set; } = IndexSearchEngineOption.WindowsIndex;
[JsonIgnore]
public IIndexProvider IndexProvider => IndexSearchEngine switch
{
IndexSearchEngineOption.Everything => EverythingManagerInstance,
IndexSearchEngineOption.WindowsIndex => WindowsIndexSearchManager,
_ => throw new ArgumentOutOfRangeException(nameof(IndexSearchEngine))
};
public PathEnumerationEngineOption PathEnumerationEngine { get; set; } = PathEnumerationEngineOption.WindowsIndex;
[JsonIgnore]
public IPathIndexProvider PathEnumerator => PathEnumerationEngine switch
{
PathEnumerationEngineOption.Everything => EverythingManagerInstance,
PathEnumerationEngineOption.WindowsIndex => WindowsIndexSearchManager,
_ => throw new ArgumentOutOfRangeException(nameof(PathEnumerationEngine))
};
public ContentIndexSearchEngineOption ContentSearchEngine { get; set; } = ContentIndexSearchEngineOption.WindowsIndex;
[JsonIgnore]
public IContentIndexProvider ContentIndexProvider => ContentSearchEngine switch
{
ContentIndexSearchEngineOption.Everything => EverythingManagerInstance,
ContentIndexSearchEngineOption.WindowsIndex => WindowsIndexSearchManager,
_ => throw new ArgumentOutOfRangeException(nameof(ContentSearchEngine))
};
public enum PathEnumerationEngineOption
{
[Description("plugin_explorer_engine_windows_index")]
WindowsIndex,
[Description("plugin_explorer_engine_everything")]
Everything,
[Description("plugin_explorer_path_enumeration_engine_none")]
DirectEnumeration
}
public enum IndexSearchEngineOption
{
[Description("plugin_explorer_engine_windows_index")]
WindowsIndex,
[Description("plugin_explorer_engine_everything")]
Everything,
}
public enum ContentIndexSearchEngineOption
{
[Description("plugin_explorer_engine_windows_index")]
WindowsIndex,
[Description("plugin_explorer_engine_everything")]
Everything,
}
#endregion
#region Everything Settings
public string EverythingInstalledPath { get; set; }
[JsonIgnore]
public SortOption[] SortOptions { get; set; } = Enum.GetValues<SortOption>();
public SortOption SortOption { get; set; } = SortOption.NAME_ASCENDING;
public bool EnableEverythingContentSearch { get; set; } = false;
public bool EverythingEnabled => IndexSearchEngine == IndexSearchEngineOption.Everything ||
PathEnumerationEngine == PathEnumerationEngineOption.Everything ||
ContentSearchEngine == ContentIndexSearchEngineOption.Everything;
public bool EverythingSearchFullPath { get; set; } = false;
public bool EverythingEnableRunCount { get; set; } = true;
#endregion
internal enum ActionKeyword
{
SearchActionKeyword,
PathSearchActionKeyword,
FileContentSearchActionKeyword,
IndexSearchActionKeyword,
QuickAccessActionKeyword
}
internal string GetActionKeyword(ActionKeyword actionKeyword) => actionKeyword switch
{
ActionKeyword.SearchActionKeyword => SearchActionKeyword,
ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword,
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword,
ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword,
ActionKeyword.QuickAccessActionKeyword => QuickAccessActionKeyword,
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "ActionKeyWord property not found")
};
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,
ActionKeyword.QuickAccessActionKeyword => QuickAccessActionKeyword = keyword,
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "ActionKeyWord property not found")
};
internal bool GetActionKeywordEnabled(ActionKeyword actionKeyword) => actionKeyword switch
{
ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled,
ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled,
ActionKeyword.IndexSearchActionKeyword => IndexSearchKeywordEnabled,
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchKeywordEnabled,
ActionKeyword.QuickAccessActionKeyword => QuickAccessKeywordEnabled,
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "ActionKeyword enabled status not defined")
};
internal void SetActionKeywordEnabled(ActionKeyword actionKeyword, bool enable) => _ = actionKeyword switch
{
ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled = enable,
ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled = enable,
ActionKeyword.IndexSearchActionKeyword => IndexSearchKeywordEnabled = enable,
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchKeywordEnabled = enable,
ActionKeyword.QuickAccessActionKeyword => QuickAccessKeywordEnabled = enable,
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "ActionKeyword enabled status not defined")
};
}
}