diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs
index d83c767dd44..3c2d6589ece 100644
--- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs
+++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs
@@ -177,32 +177,16 @@ public CustomBrowserViewModel CustomBrowser
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;
}
}
diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml
index 070c290cdfb..3d5bd99c78c 100644
--- a/Flow.Launcher/Languages/en.xaml
+++ b/Flow.Launcher/Languages/en.xaml
@@ -77,6 +77,9 @@
When the icon is hidden from the tray, the Settings menu can be opened by right-clicking on the search window.
Query Search Precision
Changes minimum match score required for results.
+ None
+ Low
+ Regular
Search with Pinyin
Allows using Pinyin to search. Pinyin is the standard system of romanized spelling for translating Chinese.
Always Preview
diff --git a/Flow.Launcher/Languages/ru.xaml b/Flow.Launcher/Languages/ru.xaml
index 08da8599140..739252da79f 100644
--- a/Flow.Launcher/Languages/ru.xaml
+++ b/Flow.Launcher/Languages/ru.xaml
@@ -1,5 +1,8 @@
-
-
+
+
Не удалось зарегистрировать сочетание клавиш "{0}". Возможно, оно используется другой программой. Измените сочетание клавиш или закройте другую программу.
Flow Launcher
@@ -75,6 +78,9 @@
Когда значок скрыт в трее, меню настройки можно открыть, щёлкнув правой кнопкой мыши на окне поиска.
Точность поиска запросов
Изменение минимального количества совпадений при поиске, необходимого для получения результатов.
+ Нет
+ Низкая
+ Обычная
Поиск с использованием пиньинь
Позволяет использовать пиньинь для поиска. Пиньинь - это стандартная система латинизированной орфографии для перевода китайского языка.
Всегда предпросмотр
diff --git a/Flow.Launcher/SettingPages/ViewModels/DropdownDataGeneric.cs b/Flow.Launcher/SettingPages/ViewModels/DropdownDataGeneric.cs
index 025c73f85df..15a81443645 100644
--- a/Flow.Launcher/SettingPages/ViewModels/DropdownDataGeneric.cs
+++ b/Flow.Launcher/SettingPages/ViewModels/DropdownDataGeneric.cs
@@ -8,7 +8,8 @@ namespace Flow.Launcher.SettingPages.ViewModels;
public class DropdownDataGeneric : 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 GetValues
(string keyPrefix) where TR : DropdownDataGeneric, new()
{
@@ -19,9 +20,17 @@ public class DropdownDataGeneric : 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(List
options) where TR : DropdownDataGeneric
+ {
+ foreach (var item in options)
+ {
+ item.Display = InternationalizationManager.Instance.GetTranslation(item.LocalizationKey);
+ }
+ }
}
diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs
index a9718a0ac19..37f18edb950 100644
--- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs
+++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs
@@ -24,13 +24,13 @@ public SettingsPaneGeneralViewModel(Settings settings, Updater updater, IPortabl
Settings = settings;
_updater = updater;
_portable = portable;
- UpdateLastQueryModeDisplay();
+ UpdateEnumDropdownLocalizations();
}
- public class SearchWindowScreen : DropdownDataGeneric { }
- public class SearchWindowAlign : DropdownDataGeneric { }
- // todo a better name?
- public class LastQueryMode : DropdownDataGeneric { }
+ public class SearchWindowScreenData : DropdownDataGeneric { }
+ public class SearchWindowAlignData : DropdownDataGeneric { }
+ public class SearchPrecisionData : DropdownDataGeneric { }
+ public class LastQueryModeData : DropdownDataGeneric { }
public bool StartFlowLauncherOnSystemStartup
{
@@ -55,11 +55,14 @@ public bool StartFlowLauncherOnSystemStartup
}
- public List SearchWindowScreens =>
- DropdownDataGeneric.GetValues("SearchWindowScreen");
+ public List SearchWindowScreens { get; } =
+ DropdownDataGeneric.GetValues("SearchWindowScreen");
- public List SearchWindowAligns =>
- DropdownDataGeneric.GetValues("SearchWindowAlign");
+ public List SearchWindowAligns { get; } =
+ DropdownDataGeneric.GetValues("SearchWindowAlign");
+
+ public List SearchPrecisionScores { get; } =
+ DropdownDataGeneric.GetValues("SearchPrecision");
public List ScreenNumbers
{
@@ -98,29 +101,15 @@ public bool PortableMode
}
}
- private List _lastQueryModes = new();
+ public List LastQueryModes { get; } =
+ DropdownDataGeneric.GetValues("LastQuery");
- public List LastQueryModes
+ private void UpdateEnumDropdownLocalizations()
{
- get
- {
- if (_lastQueryModes.Count == 0)
- {
- _lastQueryModes =
- DropdownDataGeneric
- .GetValues("LastQuery");
- }
-
- return _lastQueryModes;
- }
- }
-
- private void UpdateLastQueryModeDisplay()
- {
- foreach (var item in LastQueryModes)
- {
- item.Display = InternationalizationManager.Instance.GetTranslation($"LastQuery{item.Value}");
- }
+ DropdownDataGeneric.UpdateLabels(SearchWindowScreens);
+ DropdownDataGeneric.UpdateLabels(SearchWindowAligns);
+ DropdownDataGeneric.UpdateLabels(SearchPrecisionScores);
+ DropdownDataGeneric.UpdateLabels(LastQueryModes);
}
public string Language
@@ -133,7 +122,7 @@ public string Language
if (InternationalizationManager.Instance.PromptShouldUsePinyin(value))
ShouldUsePinyin = true;
- UpdateLastQueryModeDisplay();
+ UpdateEnumDropdownLocalizations();
}
}
@@ -143,12 +132,6 @@ public bool ShouldUsePinyin
set => Settings.ShouldUsePinyin = value;
}
- public List QuerySearchPrecisionStrings => Enum
- .GetValues(typeof(SearchPrecisionScore))
- .Cast()
- .Select(v => v.ToString())
- .ToList();
-
public List Languages => InternationalizationManager.Instance.LoadAvailableLanguages();
public IEnumerable MaxResultsRange => Enumerable.Range(2, 16);
diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml
index c13f7f86947..03a3bb7093a 100644
--- a/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml
+++ b/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml
@@ -162,8 +162,10 @@
Sub="{DynamicResource querySearchPrecisionToolTip}">
+ DisplayMemberPath="Display"
+ ItemsSource="{Binding SearchPrecisionScores}"
+ SelectedValue="{Binding Settings.QuerySearchPrecision}"
+ SelectedValuePath="Value" />