From e66af0f605bf7ede314948302c0066b00e189481 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Tue, 30 Nov 2021 15:37:45 -0600 Subject: [PATCH] Add ControlPanelIcon Add Control Panel Icon to separate control panel setting and windows setting item Co-Authored-By: Dobin Park <6903107+onesounds@users.noreply.github.com> --- .../Classes/WindowsSetting.cs | 8 ++++++- .../Flow.Plugin.WindowsSettings.csproj | 7 ++---- .../Helper/ResultHelper.cs | 19 ++++++++------- .../Helper/TranslationHelper.cs | 2 +- .../Images/ControlPanel_Small.png | Bin 0 -> 2980 bytes .../Main.cs | 22 +++++++----------- 6 files changed, 28 insertions(+), 30 deletions(-) create mode 100644 Plugins/Flow.Launcher.Plugin.WindowsSettings/Images/ControlPanel_Small.png diff --git a/Plugins/Flow.Launcher.Plugin.WindowsSettings/Classes/WindowsSetting.cs b/Plugins/Flow.Launcher.Plugin.WindowsSettings/Classes/WindowsSetting.cs index be7cd44d3..35eb8cb45 100644 --- a/Plugins/Flow.Launcher.Plugin.WindowsSettings/Classes/WindowsSetting.cs +++ b/Plugins/Flow.Launcher.Plugin.WindowsSettings/Classes/WindowsSetting.cs @@ -37,10 +37,16 @@ namespace Flow.Plugin.WindowsSettings.Classes /// public string Command { get; set; } + private string type = string.Empty; + /// /// Gets or sets the type of the windows setting. /// public string Type { get; set; } + /// + /// Gets or sets the type display name of this setting. + /// + public string? DisplayType { get; set; } /// /// Gets or sets the alternative names of this setting. @@ -73,4 +79,4 @@ namespace Flow.Plugin.WindowsSettings.Classes /// public uint? DeprecatedInBuild { get; set; } } -} +} \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.WindowsSettings/Flow.Plugin.WindowsSettings.csproj b/Plugins/Flow.Launcher.Plugin.WindowsSettings/Flow.Plugin.WindowsSettings.csproj index e65a4c62e..d6dc20dd4 100644 --- a/Plugins/Flow.Launcher.Plugin.WindowsSettings/Flow.Plugin.WindowsSettings.csproj +++ b/Plugins/Flow.Launcher.Plugin.WindowsSettings/Flow.Plugin.WindowsSettings.csproj @@ -70,12 +70,9 @@ - + PreserveNewest - - - PreserveNewest - + diff --git a/Plugins/Flow.Launcher.Plugin.WindowsSettings/Helper/ResultHelper.cs b/Plugins/Flow.Launcher.Plugin.WindowsSettings/Helper/ResultHelper.cs index c5fd287bd..a273ea75d 100644 --- a/Plugins/Flow.Launcher.Plugin.WindowsSettings/Helper/ResultHelper.cs +++ b/Plugins/Flow.Launcher.Plugin.WindowsSettings/Helper/ResultHelper.cs @@ -27,12 +27,13 @@ namespace Flow.Plugin.WindowsSettings.Helper /// /// The original result list to convert. /// Query for specific result List - /// The path to the icon of each entry. + /// The path to the icon of each entry. /// A list with . internal static List GetResultList( in IEnumerable list, Query query, - string iconPath) + string windowsSettingIconPath, + string controlPanelIconPath) { var resultList = new List(); foreach (var entry in list) @@ -47,7 +48,7 @@ namespace Flow.Plugin.WindowsSettings.Helper if (nameMatch.IsSearchPrecisionScoreMet()) { - var settingResult = NewSettingResult(nameMatch.Score + highScore); + var settingResult = NewSettingResult(nameMatch.Score + highScore, entry.Type); settingResult.TitleHighlightData = nameMatch.MatchData; result = settingResult; } @@ -56,7 +57,7 @@ namespace Flow.Plugin.WindowsSettings.Helper var areaMatch = _api.FuzzySearch(query.Search, entry.Area); if (areaMatch.IsSearchPrecisionScoreMet()) { - var settingResult = NewSettingResult(areaMatch.Score + midScore); + var settingResult = NewSettingResult(areaMatch.Score + midScore, entry.Type); settingResult.SubTitleHighlightData = areaMatch.MatchData.Select(x => x + 6).ToList(); result = settingResult; } @@ -65,7 +66,7 @@ namespace Flow.Plugin.WindowsSettings.Helper result = entry.AltNames? .Select(altName => _api.FuzzySearch(query.Search, altName)) .Where(match => match.IsSearchPrecisionScoreMet()) - .Select(altNameMatch => NewSettingResult(altNameMatch.Score + midScore)) + .Select(altNameMatch => NewSettingResult(altNameMatch.Score + midScore, entry.Type)) .FirstOrDefault(); } @@ -79,7 +80,7 @@ namespace Flow.Plugin.WindowsSettings.Helper .SelectMany(x => x) .Contains(x, StringComparer.CurrentCultureIgnoreCase)) ) - result = NewSettingResult(midScore); + result = NewSettingResult(midScore, entry.Type); } } @@ -90,10 +91,10 @@ namespace Flow.Plugin.WindowsSettings.Helper resultList.Add(result); - Result NewSettingResult(int score) => new() + Result NewSettingResult(int score, string type) => new() { Action = _ => DoOpenSettingsAction(entry), - IcoPath = iconPath, + IcoPath = type == "AppSettingsApp" ? windowsSettingIconPath : controlPanelIconPath, SubTitle = $"{Resources.Area} \"{entry.Area}\" {Resources.SubtitlePreposition} {entry.Type}", Title = entry.Name + entry.glyph, ContextData = entry, @@ -150,7 +151,7 @@ namespace Flow.Plugin.WindowsSettings.Helper ProcessStartInfo processStartInfo; var command = entry.Command; - + command = Environment.ExpandEnvironmentVariables(command); if (command.Contains(' ')) diff --git a/Plugins/Flow.Launcher.Plugin.WindowsSettings/Helper/TranslationHelper.cs b/Plugins/Flow.Launcher.Plugin.WindowsSettings/Helper/TranslationHelper.cs index 529fae0a3..73ac76bf6 100644 --- a/Plugins/Flow.Launcher.Plugin.WindowsSettings/Helper/TranslationHelper.cs +++ b/Plugins/Flow.Launcher.Plugin.WindowsSettings/Helper/TranslationHelper.cs @@ -84,7 +84,7 @@ namespace Flow.Plugin.WindowsSettings.Helper { Area = area ?? settings.Area, Name = name ?? settings.Name, - Type = type ?? settings.Type, + DisplayType = type ?? settings.Type, AltNames = translatedAltNames }; diff --git a/Plugins/Flow.Launcher.Plugin.WindowsSettings/Images/ControlPanel_Small.png b/Plugins/Flow.Launcher.Plugin.WindowsSettings/Images/ControlPanel_Small.png new file mode 100644 index 0000000000000000000000000000000000000000..8a8a41aeb8f370ac29e8164a6e31f2133ffbff53 GIT binary patch literal 2980 zcmaJ@XH*ku7Y@P#QWQao)EE#HO)@DYCM2{3OjHm71sjqw!5~R62_~S@{5TZBP!z17 zSSTWjh@jLJg>{kQvMNQ222nw!3&JjJP}y&P?AbYI=6&Bg_qq4E?aU;2dTi3xFxG%T zAlh^q)l0Dg3%9ze;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Go8@7E%SqY>urMaFb@@-k-ugoF%n*XtLN3> zQWcHaD#Fq)Qx1mL=4|$E$VnR9ZXvf$syx+)^~0yeHhU&ieSUVO^i`C>E#cG|dmi?UDe%cq1>Hf26Lw!%(Qh{7h%dYJl^Zada}ZRbn@@IqW&voz86f_ zZ~EC{ZqnA{Vuy3pfGlm=)8t%ErlBm+w+#J^#-_vib*aJD@wc?#lfV9y zr{(W(O?h9z+PfyJBmUs1Ioekxm<>2(|JG?1H2YLd_Ttij?g5$l)?liz#r8pXI^D1+ zE#@H5k$3AVc#+S+4lpBJTnLJ#|2 zt-JIkbS_vqF)6z+0-@{RY;)15uIcreUYFFTcB5%hSG6EOb$H+*yJlN1X{z4f^PZc2 z^kZ2s(KMg;wtHln_Jyca{L7dCPK%5_g0Q&YLfe0p#4@>=bLnhC(Anb_Z{t@94!N0K zE4G8m2L*-8KMtsdzbd3p-t-#@;^&$^t*x1wD}@A(JH5SDYJ|M|Om3cV?w0&_GLrB* zOdfu!WsNsgKk{DljpLuZV|FbCwEgcT=Z|jcIe&jOlK1D`Q*W&(2lIoXhyCRaQN5=> zdi>hd;h=9Y5a6a#qFb)zfYUd{=Z=Q`p@MShlAo^(z1_`SQsJC>uiR?|W2BV4eP&O=_LU2ln z7##@M5Ph!v4!vjFj`lHfn##E+`P-wlWfr$>G=ksUFs&p)YxCa`x8PvE6rU>{$AI+K@Rlw%Q50zu)EA?^~`76;0v1lDl^G2bHuG4MwTysn=AV uGC?P>WmwV*UaXJ`U#q literal 0 HcmV?d00001 diff --git a/Plugins/Flow.Launcher.Plugin.WindowsSettings/Main.cs b/Plugins/Flow.Launcher.Plugin.WindowsSettings/Main.cs index 491bb903f..6afb3fb09 100644 --- a/Plugins/Flow.Launcher.Plugin.WindowsSettings/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.WindowsSettings/Main.cs @@ -18,16 +18,6 @@ namespace Flow.Plugin.WindowsSettings /// public sealed class Main : IPlugin, IContextMenu, IPluginI18n, IDisposable { - /// - /// The path to the symbol for a light theme. - /// - private const string _lightSymbol = "Images/WindowsSettings.light.png"; - - /// - /// The path to the symbol for a dark theme. - /// - private const string _darkSymbol = "Images/WindowsSettings.dark.png"; - /// /// The name of this assembly. /// @@ -39,9 +29,14 @@ namespace Flow.Plugin.WindowsSettings private PluginInitContext? _context; /// - /// The path to the icon for each result. + /// The path to the icon for windows setting result. /// - private string _defaultIconPath; + private const string windowSettingsIconPath = "Images/WindowsSettings.light.png"; + + /// + /// The path to the icon for control panel result. + /// + private const string controlPanelIconPath = "Images/ControlPanel_Small.png"; /// /// Indicate that the plugin is disposed. @@ -64,7 +59,6 @@ namespace Flow.Plugin.WindowsSettings public Main() { _assemblyName = Assembly.GetExecutingAssembly().GetName().Name ?? Name; - _defaultIconPath = _lightSymbol; } /// @@ -101,7 +95,7 @@ namespace Flow.Plugin.WindowsSettings /// A filtered list, can be empty when nothing was found. public List Query(Query query) { - var newList = ResultHelper.GetResultList(_translatedSettingList, query, _defaultIconPath); + var newList = ResultHelper.GetResultList(_translatedSettingList, query, windowSettingsIconPath, controlPanelIconPath); return newList;