mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
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>
This commit is contained in:
parent
1990a7edfd
commit
e66af0f605
6 changed files with 28 additions and 30 deletions
|
|
@ -37,10 +37,16 @@ namespace Flow.Plugin.WindowsSettings.Classes
|
|||
/// </summary>
|
||||
public string Command { get; set; }
|
||||
|
||||
private string type = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the windows setting.
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the type display name of this setting.
|
||||
/// </summary>
|
||||
public string? DisplayType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the alternative names of this setting.
|
||||
|
|
@ -73,4 +79,4 @@ namespace Flow.Plugin.WindowsSettings.Classes
|
|||
/// </summary>
|
||||
public uint? DeprecatedInBuild { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -70,12 +70,9 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Images\WindowsSettings.dark.png">
|
||||
<Content Include="Images\*.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Images\WindowsSettings.light.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
|
||||
|
|
|
|||
|
|
@ -27,12 +27,13 @@ namespace Flow.Plugin.WindowsSettings.Helper
|
|||
/// </summary>
|
||||
/// <param name="list">The original result list to convert.</param>
|
||||
/// <param name="query">Query for specific result List</param>
|
||||
/// <param name="iconPath">The path to the icon of each entry.</param>
|
||||
/// <param name="windowsSettingIconPath">The path to the icon of each entry.</param>
|
||||
/// <returns>A list with <see cref="Result"/>.</returns>
|
||||
internal static List<Result> GetResultList(
|
||||
in IEnumerable<WindowsSetting> list,
|
||||
Query query,
|
||||
string iconPath)
|
||||
string windowsSettingIconPath,
|
||||
string controlPanelIconPath)
|
||||
{
|
||||
var resultList = new List<Result>();
|
||||
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(' '))
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
|
|
@ -18,16 +18,6 @@ namespace Flow.Plugin.WindowsSettings
|
|||
/// </summary>
|
||||
public sealed class Main : IPlugin, IContextMenu, IPluginI18n, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The path to the symbol for a light theme.
|
||||
/// </summary>
|
||||
private const string _lightSymbol = "Images/WindowsSettings.light.png";
|
||||
|
||||
/// <summary>
|
||||
/// The path to the symbol for a dark theme.
|
||||
/// </summary>
|
||||
private const string _darkSymbol = "Images/WindowsSettings.dark.png";
|
||||
|
||||
/// <summary>
|
||||
/// The name of this assembly.
|
||||
/// </summary>
|
||||
|
|
@ -39,9 +29,14 @@ namespace Flow.Plugin.WindowsSettings
|
|||
private PluginInitContext? _context;
|
||||
|
||||
/// <summary>
|
||||
/// The path to the icon for each result.
|
||||
/// The path to the icon for windows setting result.
|
||||
/// </summary>
|
||||
private string _defaultIconPath;
|
||||
private const string windowSettingsIconPath = "Images/WindowsSettings.light.png";
|
||||
|
||||
/// <summary>
|
||||
/// The path to the icon for control panel result.
|
||||
/// </summary>
|
||||
private const string controlPanelIconPath = "Images/ControlPanel_Small.png";
|
||||
|
||||
/// <summary>
|
||||
/// Indicate that the plugin is disposed.
|
||||
|
|
@ -64,7 +59,6 @@ namespace Flow.Plugin.WindowsSettings
|
|||
public Main()
|
||||
{
|
||||
_assemblyName = Assembly.GetExecutingAssembly().GetName().Name ?? Name;
|
||||
_defaultIconPath = _lightSymbol;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -101,7 +95,7 @@ namespace Flow.Plugin.WindowsSettings
|
|||
/// <returns>A filtered list, can be empty when nothing was found.</returns>
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
var newList = ResultHelper.GetResultList(_translatedSettingList, query, _defaultIconPath);
|
||||
var newList = ResultHelper.GetResultList(_translatedSettingList, query, windowSettingsIconPath, controlPanelIconPath);
|
||||
return newList;
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue