mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-15 20:19:17 +08:00
07310c7714
* fix typo * make function obsolete it is not used in the code * rewrite the function that converts chinese chars to pinyin 1. Only difference in this rewrite is instead of returning 2D array, return as a combined single string of all the possible pinyin combination. Since fuzzy search does character matching, this shouldn't be a problem. 2. Added a function that returns a custom language converter. In this case Pinyin converter. New converters can be added. * Use new language converter param + strip out ScoreForPinyin method * update * Change parameter name * fix failing tests * WIP * Remove todo There should be some distinction between score after precision filter and actual raw score derived from FuzzySearch. Although so far RawScore is used in testing, but it seems to describe the structure. Originally it was to avoid assigning score directly as it would be hard to reason about that output of FuzzySearch score is. * Add constructors, remove default to enforce required properties * remove setting rawscore in SearchPrecision * Change method name to reflect intention * Change parameter name + update comment * update * Remove params comment Co-authored-by: theClueless <14300910+theClueless@users.noreply.github.com>
116 lines
4.0 KiB
C#
116 lines
4.0 KiB
C#
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.Drawing;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Converters;
|
|
using Wox.Plugin;
|
|
|
|
namespace Wox.Infrastructure.UserSettings
|
|
{
|
|
public class Settings : BaseModel
|
|
{
|
|
public string Hotkey { get; set; } = "Alt + Space";
|
|
public string Language { get; set; } = "en";
|
|
public string Theme { get; set; } = "Dark";
|
|
public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name;
|
|
public string QueryBoxFontStyle { get; set; }
|
|
public string QueryBoxFontWeight { get; set; }
|
|
public string QueryBoxFontStretch { get; set; }
|
|
public string ResultFont { get; set; } = FontFamily.GenericSansSerif.Name;
|
|
public string ResultFontStyle { get; set; }
|
|
public string ResultFontWeight { get; set; }
|
|
public string ResultFontStretch { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// when false Alphabet static service will always return empty results
|
|
/// </summary>
|
|
public bool ShouldUsePinyin { get; set; } = true;
|
|
|
|
|
|
internal StringMatcher.SearchPrecisionScore QuerySearchPrecision { get; private set; } = StringMatcher.SearchPrecisionScore.Regular;
|
|
|
|
public string QuerySearchPrecisionString
|
|
{
|
|
get { return QuerySearchPrecision.ToString(); }
|
|
set
|
|
{
|
|
try
|
|
{
|
|
var precisionScore = (StringMatcher.SearchPrecisionScore)Enum
|
|
.Parse(typeof(StringMatcher.SearchPrecisionScore), value);
|
|
|
|
QuerySearchPrecision = precisionScore;
|
|
StringMatcher.Instance.UserSettingSearchPrecision = precisionScore;
|
|
}
|
|
catch (ArgumentException e)
|
|
{
|
|
Logger.Log.Exception(nameof(Settings), "Failed to load QuerySearchPrecisionString value from Settings file", e);
|
|
|
|
QuerySearchPrecision = StringMatcher.SearchPrecisionScore.Regular;
|
|
StringMatcher.Instance.UserSettingSearchPrecision = StringMatcher.SearchPrecisionScore.Regular;
|
|
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
|
|
public bool AutoUpdates { get; set; } = false;
|
|
|
|
public double WindowLeft { get; set; }
|
|
public double WindowTop { get; set; }
|
|
public int MaxResultsToShow { get; set; } = 6;
|
|
public int ActivateTimes { get; set; }
|
|
|
|
// Order defaults to 0 or -1, so 1 will let this property appear last
|
|
[JsonProperty(Order = 1)]
|
|
public PluginsSettings PluginSettings { get; set; } = new PluginsSettings();
|
|
public ObservableCollection<CustomPluginHotkey> CustomPluginHotkeys { get; set; } = new ObservableCollection<CustomPluginHotkey>();
|
|
|
|
[Obsolete]
|
|
public double Opacity { get; set; } = 1;
|
|
|
|
[Obsolete]
|
|
public OpacityMode OpacityMode { get; set; } = OpacityMode.Normal;
|
|
|
|
public bool DontPromptUpdateMsg { get; set; }
|
|
public bool EnableUpdateLog { get; set; }
|
|
|
|
public bool StartWoxOnSystemStartup { get; set; } = true;
|
|
public bool HideOnStartup { get; set; }
|
|
bool _hideNotifyIcon { get; set; }
|
|
public bool HideNotifyIcon
|
|
{
|
|
get { return _hideNotifyIcon; }
|
|
set
|
|
{
|
|
_hideNotifyIcon = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
public bool LeaveCmdOpen { get; set; }
|
|
public bool HideWhenDeactive { get; set; } = true;
|
|
public bool RememberLastLaunchLocation { get; set; }
|
|
public bool IgnoreHotkeysOnFullscreen { get; set; }
|
|
|
|
public HttpProxy Proxy { get; set; } = new HttpProxy();
|
|
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public LastQueryMode LastQueryMode { get; set; } = LastQueryMode.Selected;
|
|
}
|
|
|
|
public enum LastQueryMode
|
|
{
|
|
Selected,
|
|
Empty,
|
|
Preserved
|
|
}
|
|
|
|
[Obsolete]
|
|
public enum OpacityMode
|
|
{
|
|
Normal = 0,
|
|
LayeredWindow = 1,
|
|
DWM = 2
|
|
}
|
|
} |