/ src / modules / launcher / Wox.Infrastructure / UserSettings / PowerToysRunSettings.cs
PowerToysRunSettings.cs
  1  // Copyright (c) Microsoft Corporation
  2  // The Microsoft Corporation licenses this file to you under the MIT license.
  3  // See the LICENSE file in the project root for more information.
  4  
  5  using System.Text.Json.Serialization;
  6  
  7  using ManagedCommon;
  8  using Wox.Plugin;
  9  
 10  namespace Wox.Infrastructure.UserSettings
 11  {
 12      public class PowerToysRunSettings : BaseModel
 13      {
 14          private string _hotkey = "Alt + Space";
 15          private string _previousHotkey = string.Empty;
 16  
 17          public string PreviousHotkey
 18          {
 19              get
 20              {
 21                  return _previousHotkey;
 22              }
 23          }
 24  
 25          public string Hotkey
 26          {
 27              get
 28              {
 29                  return _hotkey;
 30              }
 31  
 32              set
 33              {
 34                  if (_hotkey != value)
 35                  {
 36                      _previousHotkey = _hotkey;
 37                      _hotkey = value;
 38                      OnPropertyChanged(nameof(Hotkey));
 39                  }
 40              }
 41          }
 42  
 43          private bool _useCentralizedKeyboardHook;
 44  
 45          public bool UseCentralizedKeyboardHook
 46          {
 47              get
 48              {
 49                  return _useCentralizedKeyboardHook;
 50              }
 51  
 52              set
 53              {
 54                  if (_useCentralizedKeyboardHook != value)
 55                  {
 56                      _useCentralizedKeyboardHook = value;
 57                      OnPropertyChanged(nameof(UseCentralizedKeyboardHook));
 58                  }
 59              }
 60          }
 61  
 62          private bool _searchQueryResultsWithDelay = true;
 63  
 64          public bool SearchQueryResultsWithDelay
 65          {
 66              get
 67              {
 68                  return _searchQueryResultsWithDelay;
 69              }
 70  
 71              set
 72              {
 73                  if (_searchQueryResultsWithDelay != value)
 74                  {
 75                      _searchQueryResultsWithDelay = value;
 76                      OnPropertyChanged(nameof(SearchQueryResultsWithDelay));
 77                  }
 78              }
 79          }
 80  
 81          private int _searchInputDelay = 150;
 82  
 83          private int _searchInputDelayFast = 30;
 84  
 85          private int _searchClickedItemWeight = 5;
 86  
 87          private bool _searchQueryTuningEnabled;
 88  
 89          private bool _searchWaitForSlowResults;
 90  
 91          public int SearchInputDelayFast
 92          {
 93              get
 94              {
 95                  return _searchInputDelayFast;
 96              }
 97  
 98              set
 99              {
100                  if (_searchInputDelayFast != value)
101                  {
102                      _searchInputDelayFast = value;
103                      OnPropertyChanged(nameof(SearchInputDelayFast));
104                  }
105              }
106          }
107  
108          public int SearchInputDelay
109          {
110              get
111              {
112                  return _searchInputDelay;
113              }
114  
115              set
116              {
117                  if (_searchInputDelay != value)
118                  {
119                      _searchInputDelay = value;
120                      OnPropertyChanged(nameof(SearchInputDelay));
121                  }
122              }
123          }
124  
125          public bool SearchQueryTuningEnabled
126          {
127              get
128              {
129                  return _searchQueryTuningEnabled;
130              }
131  
132              set
133              {
134                  if (_searchQueryTuningEnabled != value)
135                  {
136                      _searchQueryTuningEnabled = value;
137                      OnPropertyChanged(nameof(SearchQueryTuningEnabled));
138                  }
139              }
140          }
141  
142          public bool SearchWaitForSlowResults
143          {
144              get
145              {
146                  return _searchWaitForSlowResults;
147              }
148  
149              set
150              {
151                  if (_searchWaitForSlowResults != value)
152                  {
153                      _searchWaitForSlowResults = value;
154                      OnPropertyChanged(nameof(_searchWaitForSlowResults));
155                  }
156              }
157          }
158  
159          public int SearchClickedItemWeight
160          {
161              get
162              {
163                  return _searchClickedItemWeight;
164              }
165  
166              set
167              {
168                  if (_searchClickedItemWeight != value)
169                  {
170                      _searchClickedItemWeight = value;
171                      OnPropertyChanged(nameof(SearchClickedItemWeight));
172                  }
173              }
174          }
175  
176          public Theme Theme { get; set; } = Theme.System;
177  
178          public StartupPosition StartupPosition { get; set; } = StartupPosition.Cursor;
179  
180          public bool PTRunNonDelayedSearchInParallel { get; set; } = true;
181  
182          public string PTRunStartNewSearchAction { get; set; }
183  
184          public bool PTRSearchQueryFastResultsWithDelay { get; set; }
185  
186          /// <summary>
187          /// Gets or sets a value indicating whether when false Alphabet static service will always return empty results
188          /// </summary>
189          public bool ShouldUsePinyin { get; set; }
190  
191          internal StringMatcher.SearchPrecisionScore QuerySearchPrecision { get; private set; } = StringMatcher.SearchPrecisionScore.Regular;
192  
193          public double WindowLeft { get; set; }
194  
195          public double WindowTop { get; set; }
196  
197          private int _maxResultsToShow = 4;
198  
199          public int MaxResultsToShow
200          {
201              get
202              {
203                  return _maxResultsToShow;
204              }
205  
206              set
207              {
208                  if (_maxResultsToShow != value)
209                  {
210                      _maxResultsToShow = value;
211                      OnPropertyChanged(nameof(MaxResultsToShow));
212                  }
213              }
214          }
215  
216          private int _activeTimes;
217  
218          public int ActivateTimes
219          {
220              get => _activeTimes;
221              set
222              {
223                  if (_activeTimes != value)
224                  {
225                      _activeTimes = value;
226                      OnPropertyChanged(nameof(ActivateTimes));
227                  }
228              }
229          }
230  
231          public bool HideWhenDeactivated { get; set; } = true;
232  
233          public bool ClearInputOnLaunch { get; set; }
234  
235          public bool TabSelectsContextButtons { get; set; }
236  
237          public bool RememberLastLaunchLocation { get; set; }
238  
239          public enum ShowPluginsOverviewMode
240          {
241              All,
242              NonGlobal,
243              None,
244          }
245  
246          private ShowPluginsOverviewMode _showPluginsOverview = ShowPluginsOverviewMode.All;
247  
248          public ShowPluginsOverviewMode ShowPluginsOverview
249          {
250              get => _showPluginsOverview;
251              set
252              {
253                  if (_showPluginsOverview != value)
254                  {
255                      _showPluginsOverview = value;
256                      OnPropertyChanged(nameof(ShowPluginsOverview));
257                  }
258              }
259          }
260  
261          public int TitleFontSize { get; set; } = 16;
262  
263          public bool IgnoreHotkeysOnFullscreen { get; set; }
264  
265          public bool StartedFromPowerToysRunner { get; set; }
266  
267          public bool GenerateThumbnailsFromFiles { get; set; } = true;
268  
269          [JsonConverter(typeof(JsonStringEnumConverter))]
270          public LastQueryMode LastQueryMode { get; set; } = LastQueryMode.Selected;
271      }
272  
273      public enum LastQueryMode
274      {
275          Selected,
276          Empty,
277          Preserved,
278      }
279  }