mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 04:37:30 +02:00
[fxcop] Wox.Infrastructure (#7590)
* CA1052: Static holder types should be Static or NotInheritable * CA1041: Provide ObsoleteAttribute message * CA1062: Validate arguments of public methods * CA1304: Specify CultureInfo / CA1305: Specify IFormatProvider / CA1307: Specify StringComparison for clarity * CA1802: Use Literals Where Appropriate * CA1820: Test for empty strings using string length * CA1707: Identifiers should not contain underscores * CA1805: Do not initialize unnecessarily. * CA1822: Mark members as static * CA2227: Collection properties should be read only * CA1054: URI parameters should not be strings * CA1031: Do not catch general exception types * CA1060: Move P/Invokes to NativeMethods class * CA1308: Normalize strings to uppercase * CA2000: Dispose objects before losing scope / CA2234: Pass System.Uri objects instead of strings * CA2234: Pass System.Uri objects instead of strings * CA1044: Properties should not be write only * CA1716: Identifiers should not match keywords * CA2007: Do not directly await a Task * CA2007: Do not directly await a Task (Suppressed) * CA5350: Do Not Use Weak Cryptographic Algorithms (Suppressed) * CA1724: Type names should not match namespaces (renamed Settings.cs to PowerToysRunSettings.cs) * CA1033: Interface methods should be callable by child types (Added sealed modifier to class) * CA1724: Type names should not match namespaces (Renamed Plugin.cs to RunPlugin.cs) * CA1724: Type names should not match namespaces (Renamed Http.cs to HttpClient.cs) * CA5364: Do not use deprecated security protocols (Remove unused code) * Enabled FxCopAnalyzer for Wox.Infrastructure * fixed comment * Addressed comments - Changed Ordinal to InvariantCulture - Added comments - Removed unused obsolete code - Removed unused method (CA2007: Do not directly await a Task) * Addressed comments - fixed justification for CA1031 suppression * Addressed comments - Fixed justification for CA1031 suppression in Wox.Core/Wox.Plugin
This commit is contained in:
@@ -0,0 +1,179 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Drawing;
|
||||
using ManagedCommon;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Infrastructure.UserSettings
|
||||
{
|
||||
public class PowerToysRunSettings : BaseModel
|
||||
{
|
||||
private string _hotkey = "Alt + Space";
|
||||
private string _previousHotkey = string.Empty;
|
||||
|
||||
public string PreviousHotkey
|
||||
{
|
||||
get
|
||||
{
|
||||
return _previousHotkey;
|
||||
}
|
||||
}
|
||||
|
||||
public string Hotkey
|
||||
{
|
||||
get
|
||||
{
|
||||
return _hotkey;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_hotkey != value)
|
||||
{
|
||||
_previousHotkey = _hotkey;
|
||||
_hotkey = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Language { get; set; } = "en";
|
||||
|
||||
public Theme Theme { get; set; } = Theme.System;
|
||||
|
||||
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; }
|
||||
|
||||
internal StringMatcher.SearchPrecisionScore QuerySearchPrecision { get; private set; } = StringMatcher.SearchPrecisionScore.Regular;
|
||||
|
||||
[JsonIgnore]
|
||||
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)
|
||||
{
|
||||
Wox.Plugin.Logger.Log.Exception("Failed to load QuerySearchPrecisionString value from Settings file", e, GetType());
|
||||
|
||||
QuerySearchPrecision = StringMatcher.SearchPrecisionScore.Regular;
|
||||
StringMatcher.Instance.UserSettingSearchPrecision = StringMatcher.SearchPrecisionScore.Regular;
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool AutoUpdates { get; set; }
|
||||
|
||||
public double WindowLeft { get; set; }
|
||||
|
||||
public double WindowTop { get; set; }
|
||||
|
||||
private int _maxResultsToShow = 4;
|
||||
|
||||
public int MaxResultsToShow
|
||||
{
|
||||
get
|
||||
{
|
||||
return _maxResultsToShow;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_maxResultsToShow != value)
|
||||
{
|
||||
_maxResultsToShow = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int ActivateTimes { get; set; }
|
||||
|
||||
// Order defaults to 0 or -1, so 1 will let this property appear last
|
||||
[JsonProperty(Order = 1)]
|
||||
public PluginSettings PluginSettings { get; set; } = new PluginSettings();
|
||||
|
||||
public ObservableCollection<CustomPluginHotkey> CustomPluginHotkeys { get; } = new ObservableCollection<CustomPluginHotkey>();
|
||||
|
||||
public bool DontPromptUpdateMsg { get; set; }
|
||||
|
||||
public bool EnableUpdateLog { get; set; }
|
||||
|
||||
public bool StartWoxOnSystemStartup { get; set; } = true;
|
||||
|
||||
public bool HideOnStartup { get; set; }
|
||||
|
||||
private bool _hideNotifyIcon;
|
||||
|
||||
public bool HideNotifyIcon
|
||||
{
|
||||
get
|
||||
{
|
||||
return _hideNotifyIcon;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_hideNotifyIcon = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool LeaveCmdOpen { get; set; }
|
||||
|
||||
public bool HideWhenDeactivated { get; set; } = true;
|
||||
|
||||
public bool ClearInputOnLaunch { get; set; }
|
||||
|
||||
public bool RememberLastLaunchLocation { get; set; }
|
||||
|
||||
public bool IgnoreHotkeysOnFullscreen { get; set; }
|
||||
|
||||
public bool UsePowerToysRunnerKeyboardHook { 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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user