Merge branch 'dev' into 240514ResizableWindow

This commit is contained in:
DB P 2024-05-28 10:06:03 +09:00 committed by GitHub
commit e39a7ed2be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 160 additions and 87 deletions

View file

@ -139,11 +139,20 @@ namespace Flow.Launcher.Core.Plugin
return Task.CompletedTask;
}
public virtual ValueTask DisposeAsync()
public virtual async ValueTask DisposeAsync()
{
RPC?.Dispose();
ErrorStream?.Dispose();
return ValueTask.CompletedTask;
try
{
await RPC.InvokeAsync("close");
}
catch (RemoteMethodNotFoundException e)
{
}
finally
{
RPC?.Dispose();
ErrorStream?.Dispose();
}
}
}
}

View file

@ -188,32 +188,16 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public bool AlwaysPreview { get; set; } = false;
public bool AlwaysStartEn { get; set; } = false;
private SearchPrecisionScore _querySearchPrecision = SearchPrecisionScore.Regular;
[JsonInclude, JsonConverter(typeof(JsonStringEnumConverter))]
public SearchPrecisionScore QuerySearchPrecision { get; private set; } = SearchPrecisionScore.Regular;
[JsonIgnore]
public string QuerySearchPrecisionString
public SearchPrecisionScore QuerySearchPrecision
{
get { return QuerySearchPrecision.ToString(); }
get => _querySearchPrecision;
set
{
try
{
var precisionScore = (SearchPrecisionScore)Enum
.Parse(typeof(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 = SearchPrecisionScore.Regular;
StringMatcher.Instance.UserSettingSearchPrecision = SearchPrecisionScore.Regular;
throw;
}
_querySearchPrecision = value;
if (StringMatcher.Instance != null)
StringMatcher.Instance.UserSettingSearchPrecision = value;
}
}

View file

@ -79,6 +79,9 @@
<system:String x:Key="hideNotifyIconToolTip">When the icon is hidden from the tray, the Settings menu can be opened by right-clicking on the search window.</system:String>
<system:String x:Key="querySearchPrecision">Query Search Precision</system:String>
<system:String x:Key="querySearchPrecisionToolTip">Changes minimum match score required for results.</system:String>
<system:String x:Key="SearchPrecisionNone">None</system:String>
<system:String x:Key="SearchPrecisionLow">Low</system:String>
<system:String x:Key="SearchPrecisionRegular">Regular</system:String>
<system:String x:Key="ShouldUsePinyin">Search with Pinyin</system:String>
<system:String x:Key="ShouldUsePinyinToolTip">Allows using Pinyin to search. Pinyin is the standard system of romanized spelling for translating Chinese.</system:String>
<system:String x:Key="AlwaysPreview">Always Preview</system:String>

View file

@ -1,5 +1,8 @@
<?xml version="1.0"?>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
<?xml version="1.0" ?>
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!-- MainWindow -->
<system:String x:Key="registerHotkeyFailed">Не удалось зарегистрировать сочетание клавиш &quot;{0}&quot;. Возможно, оно используется другой программой. Измените сочетание клавиш или закройте другую программу.</system:String>
<system:String x:Key="MessageBoxTitle">Flow Launcher</system:String>
@ -75,6 +78,9 @@
<system:String x:Key="hideNotifyIconToolTip">Когда значок скрыт в трее, меню настройки можно открыть, щёлкнув правой кнопкой мыши на окне поиска.</system:String>
<system:String x:Key="querySearchPrecision">Точность поиска запросов</system:String>
<system:String x:Key="querySearchPrecisionToolTip">Изменение минимального количества совпадений при поиске, необходимого для получения результатов.</system:String>
<system:String x:Key="SearchPrecisionNone">Нет</system:String>
<system:String x:Key="SearchPrecisionLow">Низкая</system:String>
<system:String x:Key="SearchPrecisionRegular">Обычная</system:String>
<system:String x:Key="ShouldUsePinyin">Поиск с использованием пиньинь</system:String>
<system:String x:Key="ShouldUsePinyinToolTip">Позволяет использовать пиньинь для поиска. Пиньинь - это стандартная система латинизированной орфографии для перевода китайского языка.</system:String>
<system:String x:Key="AlwaysPreview">Всегда предпросмотр</system:String>

View file

@ -8,7 +8,8 @@ namespace Flow.Launcher.SettingPages.ViewModels;
public class DropdownDataGeneric<TValue> : BaseModel where TValue : Enum
{
public string Display { get; set; }
public TValue Value { get; set; }
public TValue Value { get; private init; }
private string LocalizationKey { get; init; }
public static List<TR> GetValues<TR>(string keyPrefix) where TR : DropdownDataGeneric<TValue>, new()
{
@ -19,9 +20,17 @@ public class DropdownDataGeneric<TValue> : BaseModel where TValue : Enum
{
var key = keyPrefix + value;
var display = InternationalizationManager.Instance.GetTranslation(key);
data.Add(new TR { Display = display, Value = value });
data.Add(new TR { Display = display, Value = value, LocalizationKey = key });
}
return data;
}
public static void UpdateLabels<TR>(List<TR> options) where TR : DropdownDataGeneric<TValue>
{
foreach (var item in options)
{
item.Display = InternationalizationManager.Instance.GetTranslation(item.LocalizationKey);
}
}
}

View file

@ -24,13 +24,13 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
Settings = settings;
_updater = updater;
_portable = portable;
UpdateLastQueryModeDisplay();
UpdateEnumDropdownLocalizations();
}
public class SearchWindowScreen : DropdownDataGeneric<SearchWindowScreens> { }
public class SearchWindowAlign : DropdownDataGeneric<SearchWindowAligns> { }
// todo a better name?
public class LastQueryMode : DropdownDataGeneric<Infrastructure.UserSettings.LastQueryMode> { }
public class SearchWindowScreenData : DropdownDataGeneric<SearchWindowScreens> { }
public class SearchWindowAlignData : DropdownDataGeneric<SearchWindowAligns> { }
public class SearchPrecisionData : DropdownDataGeneric<SearchPrecisionScore> { }
public class LastQueryModeData : DropdownDataGeneric<LastQueryMode> { }
public bool StartFlowLauncherOnSystemStartup
{
@ -55,11 +55,14 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
}
public List<SearchWindowScreen> SearchWindowScreens =>
DropdownDataGeneric<SearchWindowScreens>.GetValues<SearchWindowScreen>("SearchWindowScreen");
public List<SearchWindowScreenData> SearchWindowScreens { get; } =
DropdownDataGeneric<SearchWindowScreens>.GetValues<SearchWindowScreenData>("SearchWindowScreen");
public List<SearchWindowAlign> SearchWindowAligns =>
DropdownDataGeneric<SearchWindowAligns>.GetValues<SearchWindowAlign>("SearchWindowAlign");
public List<SearchWindowAlignData> SearchWindowAligns { get; } =
DropdownDataGeneric<SearchWindowAligns>.GetValues<SearchWindowAlignData>("SearchWindowAlign");
public List<SearchPrecisionData> SearchPrecisionScores { get; } =
DropdownDataGeneric<SearchPrecisionScore>.GetValues<SearchPrecisionData>("SearchPrecision");
public List<int> ScreenNumbers
{
@ -98,29 +101,15 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
}
}
private List<LastQueryMode> _lastQueryModes = new();
public List<LastQueryModeData> LastQueryModes { get; } =
DropdownDataGeneric<LastQueryMode>.GetValues<LastQueryModeData>("LastQuery");
public List<LastQueryMode> LastQueryModes
private void UpdateEnumDropdownLocalizations()
{
get
{
if (_lastQueryModes.Count == 0)
{
_lastQueryModes =
DropdownDataGeneric<Infrastructure.UserSettings.LastQueryMode>
.GetValues<LastQueryMode>("LastQuery");
}
return _lastQueryModes;
}
}
private void UpdateLastQueryModeDisplay()
{
foreach (var item in LastQueryModes)
{
item.Display = InternationalizationManager.Instance.GetTranslation($"LastQuery{item.Value}");
}
DropdownDataGeneric<SearchWindowScreens>.UpdateLabels(SearchWindowScreens);
DropdownDataGeneric<SearchWindowAligns>.UpdateLabels(SearchWindowAligns);
DropdownDataGeneric<SearchPrecisionScore>.UpdateLabels(SearchPrecisionScores);
DropdownDataGeneric<LastQueryMode>.UpdateLabels(LastQueryModes);
}
public string Language
@ -133,7 +122,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
if (InternationalizationManager.Instance.PromptShouldUsePinyin(value))
ShouldUsePinyin = true;
UpdateLastQueryModeDisplay();
UpdateEnumDropdownLocalizations();
}
}
@ -143,12 +132,6 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
set => Settings.ShouldUsePinyin = value;
}
public List<string> QuerySearchPrecisionStrings => Enum
.GetValues(typeof(SearchPrecisionScore))
.Cast<SearchPrecisionScore>()
.Select(v => v.ToString())
.ToList();
public List<Language> Languages => InternationalizationManager.Instance.LoadAvailableLanguages();
public string AlwaysPreviewToolTip => string.Format(

View file

@ -30,19 +30,31 @@
TextAlignment="left" />
<cc:Card Title="{DynamicResource startFlowLauncherOnSystemStartup}" Icon="&#xe8fc;">
<ui:ToggleSwitch IsOn="{Binding StartFlowLauncherOnSystemStartup}" />
<ui:ToggleSwitch
IsOn="{Binding StartFlowLauncherOnSystemStartup}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}" />
</cc:Card>
<cc:Card Title="{DynamicResource hideOnStartup}" Icon="&#xed1a;">
<ui:ToggleSwitch IsOn="{Binding Settings.HideOnStartup}" />
<ui:ToggleSwitch
IsOn="{Binding Settings.HideOnStartup}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}" />
</cc:Card>
<cc:Card Title="{DynamicResource hideFlowLauncherWhenLoseFocus}" Margin="0 30 0 0">
<ui:ToggleSwitch IsOn="{Binding Settings.HideWhenDeactivated}" />
<ui:ToggleSwitch
IsOn="{Binding Settings.HideWhenDeactivated}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}" />
</cc:Card>
<cc:Card Title="{DynamicResource hideNotifyIcon}" Sub="{DynamicResource hideNotifyIconToolTip}">
<ui:ToggleSwitch IsOn="{Binding Settings.HideNotifyIcon}" />
<ui:ToggleSwitch
IsOn="{Binding Settings.HideNotifyIcon}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}" />
</cc:Card>
<cc:CardGroup Margin="0 30 0 0">
@ -111,7 +123,10 @@
Title="{DynamicResource ignoreHotkeysOnFullscreen}"
Icon="&#xe7fc;"
Sub="{DynamicResource ignoreHotkeysOnFullscreenToolTip}">
<ui:ToggleSwitch IsOn="{Binding Settings.IgnoreHotkeysOnFullscreen}" />
<ui:ToggleSwitch
IsOn="{Binding Settings.IgnoreHotkeysOnFullscreen}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}" />
</cc:Card>
<cc:Card
@ -119,29 +134,41 @@
Margin="0 30 0 0"
Icon="&#xe8a1;"
Sub="{DynamicResource AlwaysPreviewToolTip}">
<ui:ToggleSwitch IsOn="{Binding Settings.AlwaysPreview}" ToolTip="{Binding AlwaysPreviewToolTip}" />
<ui:ToggleSwitch
IsOn="{Binding Settings.AlwaysPreview}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}"
ToolTip="{Binding AlwaysPreviewToolTip}" />
</cc:Card>
<cc:Card
Title="{DynamicResource autoUpdates}"
Margin="0 30 0 0"
Icon="&#xecc5;">
<ui:ToggleSwitch IsOn="{Binding AutoUpdates}" />
<ui:ToggleSwitch
IsOn="{Binding AutoUpdates}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}" />
</cc:Card>
<cc:Card
Title="{DynamicResource portableMode}"
Icon="&#xe88e;"
Sub="{DynamicResource portableModeToolTIp}">
<ui:ToggleSwitch IsOn="{Binding PortableMode}" />
<ui:ToggleSwitch
IsOn="{Binding PortableMode}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}" />
</cc:Card>
<cc:CardGroup Margin="0 30 0 0">
<cc:Card Title="{DynamicResource querySearchPrecision}" Sub="{DynamicResource querySearchPrecisionToolTip}">
<ComboBox
MaxWidth="200"
ItemsSource="{Binding QuerySearchPrecisionStrings}"
SelectedItem="{Binding Settings.QuerySearchPrecisionString}" />
DisplayMemberPath="Display"
ItemsSource="{Binding SearchPrecisionScores}"
SelectedValue="{Binding Settings.QuerySearchPrecision}"
SelectedValuePath="Value" />
</cc:Card>
<cc:Card Title="{DynamicResource lastQueryMode}" Sub="{DynamicResource lastQueryModeToolTip}">
@ -211,14 +238,21 @@
Margin="0 30 0 0"
Icon="&#xe8d3;"
Sub="{DynamicResource typingStartEnTooltip}">
<ui:ToggleSwitch IsOn="{Binding Settings.AlwaysStartEn}" />
<ui:ToggleSwitch
IsOn="{Binding Settings.AlwaysStartEn}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}" />
</cc:Card>
<cc:Card
Title="{DynamicResource ShouldUsePinyin}"
Icon="&#xe98a;"
Sub="{DynamicResource ShouldUsePinyinToolTip}">
<ui:ToggleSwitch IsOn="{Binding Settings.ShouldUsePinyin}" ToolTip="{DynamicResource ShouldUsePinyinToolTip}" />
<ui:ToggleSwitch
IsOn="{Binding Settings.ShouldUsePinyin}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}"
ToolTip="{DynamicResource ShouldUsePinyinToolTip}" />
</cc:Card>
<cc:Card

View file

@ -63,10 +63,11 @@
SelectedValue="{Binding Settings.OpenResultModifiers}" />
</cc:Card>
<cc:Card
Title="{DynamicResource showOpenResultHotkey}"
Sub="{DynamicResource showOpenResultHotkeyToolTip}">
<ui:ToggleSwitch IsOn="{Binding Settings.ShowOpenResultHotkey}" />
<cc:Card Title="{DynamicResource showOpenResultHotkey}" Sub="{DynamicResource showOpenResultHotkeyToolTip}">
<ui:ToggleSwitch
IsOn="{Binding Settings.ShowOpenResultHotkey}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}" />
</cc:Card>
</cc:CardGroup>

View file

@ -33,7 +33,10 @@
<cc:CardGroup>
<cc:Card Title="{DynamicResource enableProxy}">
<ui:ToggleSwitch IsOn="{Binding Settings.Proxy.Enabled}" />
<ui:ToggleSwitch
IsOn="{Binding Settings.Proxy.Enabled}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}" />
</cc:Card>
<cc:Card Title="{DynamicResource server}">

View file

@ -32,6 +32,8 @@
<system:String x:Key="flowlauncher_plugin_program_index_PATH_tooltip">When enabled, Flow will load programs from the PATH environment variable</system:String>
<system:String x:Key="flowlauncher_plugin_program_enable_hidelnkpath">Hide app path</system:String>
<system:String x:Key="flowlauncher_plugin_program_enable_hidelnkpath_tooltip">For executable files such as UWP or lnk, hide the file path from being visible</system:String>
<system:String x:Key="flowlauncher_plugin_program_enable_hideuninstallers">Hide uninstallers</system:String>
<system:String x:Key="flowlauncher_plugin_program_enable_hideuninstallers_tooltip">Hides programs with common uninstaller names, such as unins000.exe</system:String>
<system:String x:Key="flowlauncher_plugin_program_enable_description">Search in Program Description</system:String>
<system:String x:Key="flowlauncher_plugin_program_enable_description_tooltip">Flow will search program's description</system:String>
<system:String x:Key="flowlauncher_plugin_program_suffixes_header">Suffixes</system:String>
@ -92,4 +94,4 @@
<system:String x:Key="flowlauncher_plugin_program_run_as_administrator_not_supported_message">This app is not intended to be run as administrator</system:String>
<system:String x:Key="flowlauncher_plugin_program_run_failed">Unable to run {0}</system:String>
</ResourceDictionary>
</ResourceDictionary>

View file

@ -11,6 +11,7 @@ using Flow.Launcher.Plugin.Program.Programs;
using Flow.Launcher.Plugin.Program.Views;
using Flow.Launcher.Plugin.Program.Views.Models;
using Microsoft.Extensions.Caching.Memory;
using Path = System.IO.Path;
using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch;
namespace Flow.Launcher.Plugin.Program
@ -33,6 +34,17 @@ namespace Flow.Launcher.Plugin.Program
private static readonly MemoryCacheOptions cacheOptions = new() { SizeLimit = 1560 };
private static MemoryCache cache = new(cacheOptions);
private static readonly string[] commonUninstallerNames =
{
"uninst.exe",
"unins000.exe",
"uninst000.exe",
"uninstall.exe"
};
// For cases when the uninstaller is named like "Uninstall Program Name.exe"
private const string CommonUninstallerPrefix = "uninstall";
private const string CommonUninstallerSuffix = ".exe";
static Main()
{
}
@ -52,6 +64,7 @@ namespace Flow.Launcher.Plugin.Program
.Concat(_uwps)
.AsParallel()
.WithCancellation(token)
.Where(HideUninstallersFilter)
.Where(p => p.Enabled)
.Select(p => p.Result(query.Search, Context.API))
.Where(r => r?.Score > 0)
@ -68,6 +81,16 @@ namespace Flow.Launcher.Plugin.Program
return result;
}
private bool HideUninstallersFilter(IProgram program)
{
if (!_settings.HideUninstallers) return true;
if (program is not Win32 win32) return true;
var fileName = Path.GetFileName(win32.ExecutablePath);
return !commonUninstallerNames.Contains(fileName, StringComparer.OrdinalIgnoreCase) &&
!(fileName.StartsWith(CommonUninstallerPrefix, StringComparison.OrdinalIgnoreCase) &&
fileName.EndsWith(CommonUninstallerSuffix, StringComparison.OrdinalIgnoreCase));
}
public async Task InitAsync(PluginInitContext context)
{
Context = context;

View file

@ -102,7 +102,7 @@ namespace Flow.Launcher.Plugin.Program
// CustomSuffixes no longer contains custom suffixes
// users has tweaked the settings
// or this function has been executed once
if (UseCustomSuffixes == true || ProgramSuffixes == null)
if (UseCustomSuffixes == true || ProgramSuffixes == null)
return;
var suffixes = ProgramSuffixes.ToList();
foreach(var item in BuiltinSuffixesStatus)
@ -117,6 +117,7 @@ namespace Flow.Launcher.Plugin.Program
public bool EnableStartMenuSource { get; set; } = true;
public bool EnableDescription { get; set; } = false;
public bool HideAppsPath { get; set; } = true;
public bool HideUninstallers { get; set; } = false;
public bool EnableRegistrySource { get; set; } = true;
public bool EnablePathSource { get; set; } = false;
public bool EnableUWP { get; set; } = true;

View file

@ -85,6 +85,11 @@
Content="{DynamicResource flowlauncher_plugin_program_enable_hidelnkpath}"
IsChecked="{Binding HideAppsPath}"
ToolTip="{DynamicResource flowlauncher_plugin_program_enable_hidelnkpath_tooltip}" />
<CheckBox
Margin="12 0 12 0"
Content="{DynamicResource flowlauncher_plugin_program_enable_hideuninstallers}"
IsChecked="{Binding HideUninstallers}"
ToolTip="{DynamicResource flowlauncher_plugin_program_enable_hideuninstallers_tooltip}" />
<CheckBox
Name="DescriptionEnabled"
Margin="12,0,12,0"

View file

@ -24,7 +24,7 @@ namespace Flow.Launcher.Plugin.Program.Views
private ListSortDirection _lastDirection;
// We do not save all program sources to settings, so using
// this as temporary holder for displaying all loaded programs sources.
// this as temporary holder for displaying all loaded programs sources.
internal static List<ProgramSource> ProgramSettingDisplayList { get; set; }
public bool EnableDescription
@ -47,6 +47,16 @@ namespace Flow.Launcher.Plugin.Program.Views
}
}
public bool HideUninstallers
{
get => _settings.HideUninstallers;
set
{
Main.ResetCache();
_settings.HideUninstallers = value;
}
}
public bool EnableRegistrySource
{
get => _settings.EnableRegistrySource;