diff --git a/Flow.Launcher/Converters/BoolToVisibilityConverter.cs b/Flow.Launcher/Converters/BoolToVisibilityConverter.cs index 0a5a5e338..ac3b2cfd0 100644 --- a/Flow.Launcher/Converters/BoolToVisibilityConverter.cs +++ b/Flow.Launcher/Converters/BoolToVisibilityConverter.cs @@ -8,13 +8,13 @@ namespace Flow.Launcher.Converters { public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture) { - return value switch + return (value, parameter) switch { - true when parameter is not null => Visibility.Collapsed, - _ when parameter is not null => Visibility.Visible, - - true => Visibility.Visible, - _ => Visibility.Collapsed + (true, not null) => Visibility.Collapsed, + (_, not null) => Visibility.Visible, + + (true, null) => Visibility.Visible, + (_, null) => Visibility.Collapsed }; } @@ -26,13 +26,13 @@ namespace Flow.Launcher.Converters { public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture) { - return value switch + return (value, parameter) switch { - true when parameter is not null => 0, - _ when parameter is not null => 5, - - true => 5, - _ => 0, + (true, not null) => 0, + (_, not null) => 5, + + (true, null) => 5, + (_, null) => 0 }; } diff --git a/Flow.Launcher/Converters/IconRadiusConverter.cs b/Flow.Launcher/Converters/IconRadiusConverter.cs index c64202eed..d0bdc9d1c 100644 --- a/Flow.Launcher/Converters/IconRadiusConverter.cs +++ b/Flow.Launcher/Converters/IconRadiusConverter.cs @@ -8,10 +8,10 @@ namespace Flow.Launcher.Converters { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { - if (values is not [double size, bool half]) + if (values is not [double size, bool isIconCircular]) throw new ArgumentException("IconRadiusConverter must have 2 parameters: [double, bool]"); - return half ? size / 2 : size; + return isIconCircular ? size / 2 : size; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { diff --git a/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs b/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs index a0f972ede..4a8c9e92b 100644 --- a/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs +++ b/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs @@ -12,6 +12,9 @@ namespace Flow.Launcher.Converters { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { + // values[0] is TextBox: The textbox displaying the autocomplete suggestion + // values[1] is ResultViewModel: Currently selected item in the list + // values[2] is string: Query text if ( values.Length != 3 || values[0] is not TextBox queryTextBox || @@ -26,7 +29,6 @@ namespace Flow.Launcher.Converters try { - var selectedResult = selectedItem.Result; var selectedResultActionKeyword = string.IsNullOrEmpty(selectedResult.ActionKeywordAssigned) ? "" : selectedResult.ActionKeywordAssigned + " "; var selectedResultPossibleSuggestion = selectedResultActionKeyword + selectedResult.Title; diff --git a/Flow.Launcher/Converters/TextConverter.cs b/Flow.Launcher/Converters/TextConverter.cs index 4fedbf778..c0b34d053 100644 --- a/Flow.Launcher/Converters/TextConverter.cs +++ b/Flow.Launcher/Converters/TextConverter.cs @@ -11,14 +11,19 @@ namespace Flow.Launcher.Converters public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var id = value?.ToString(); - return id switch + var translationKey = id switch { - PluginStoreItemViewModel.NewRelease => InternationalizationManager.Instance.GetTranslation("pluginStore_NewRelease"), - PluginStoreItemViewModel.RecentlyUpdated => InternationalizationManager.Instance.GetTranslation("pluginStore_RecentlyUpdated"), - PluginStoreItemViewModel.None => InternationalizationManager.Instance.GetTranslation("pluginStore_None"), - PluginStoreItemViewModel.Installed => InternationalizationManager.Instance.GetTranslation("pluginStore_Installed"), - _ => id + PluginStoreItemViewModel.NewRelease => "pluginStore_NewRelease", + PluginStoreItemViewModel.RecentlyUpdated => "pluginStore_RecentlyUpdated", + PluginStoreItemViewModel.None => "pluginStore_None", + PluginStoreItemViewModel.Installed => "pluginStore_Installed", + _ => null }; + + if (translationKey is null) + return id; + + return InternationalizationManager.Instance.GetTranslation(translationKey); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new InvalidOperationException();