Skip to content

Commit bb03dfe

Browse files
committed
More code cleanup & improvements
1 parent 60166c1 commit bb03dfe

15 files changed

Lines changed: 68 additions & 69 deletions

Flow.Launcher.Core/Plugin/QueryBuilder.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,18 @@ public static class QueryBuilder
3131

3232
string actionKeyword, search;
3333
string possibleActionKeyword = terms[0];
34-
string[] searchTerms;
3534

3635
if (nonGlobalPlugins.TryGetValue(possibleActionKeyword, out var pluginPair) && !pluginPair.Metadata.Disabled)
3736
{
3837
// use non global plugin for query
3938
actionKeyword = possibleActionKeyword;
4039
search = terms.Length > 1 ? trimmedQuery[(actionKeyword.Length + 1)..].TrimStart() : string.Empty;
41-
searchTerms = terms[1..];
4240
}
4341
else
4442
{
4543
// non action keyword
4644
actionKeyword = string.Empty;
4745
search = trimmedQuery.TrimStart();
48-
searchTerms = terms;
4946
}
5047

5148
return new Query()

Flow.Launcher/Converters/BoolToVisibilityConverter.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
using System.Globalization;
1+
using System;
2+
using System.Globalization;
23
using System.Windows;
34
using System.Windows.Data;
45

56
namespace Flow.Launcher.Converters;
67

78
public class BoolToVisibilityConverter : IValueConverter
89
{
9-
public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture)
10+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
1011
{
1112
return (value, parameter) switch
1213
{
@@ -18,13 +19,14 @@ public object Convert(object value, System.Type targetType, object parameter, Cu
1819
};
1920
}
2021

21-
public object ConvertBack(object value, System.Type targetType, object parameter, CultureInfo culture) => throw new System.InvalidOperationException();
22+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
23+
=> throw new InvalidOperationException();
2224
}
2325

2426
public class SplitterConverter : IValueConverter
2527
/* Prevents the dragging part of the preview area from working when preview is turned off. */
2628
{
27-
public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture)
29+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
2830
{
2931
return (value, parameter) switch
3032
{
@@ -36,5 +38,5 @@ public object Convert(object value, System.Type targetType, object parameter, Cu
3638
};
3739
}
3840

39-
public object ConvertBack(object value, System.Type targetType, object parameter, CultureInfo culture) => throw new System.InvalidOperationException();
41+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new InvalidOperationException();
4042
}

Flow.Launcher/Converters/BorderClipConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
1919
}
2020

2121
Path myPath = new Path();
22-
if (width < Double.Epsilon || height < Double.Epsilon)
22+
if (width < double.Epsilon || height < double.Epsilon)
2323
{
2424
return Geometry.Empty;
2525
}

Flow.Launcher/Converters/StringToKeyBindingConverter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ namespace Flow.Launcher.Converters;
77

88
public class StringToKeyBindingConverter : IValueConverter
99
{
10-
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
10+
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
1111
{
1212
if (parameter is not string mode || value is not string hotkeyStr)
1313
return null;
1414

1515
var converter = new KeyGestureConverter();
16-
var key = (KeyGesture)converter.ConvertFromString(hotkeyStr);
16+
var key = (KeyGesture?)converter.ConvertFromString(hotkeyStr);
1717
return mode switch
1818
{
1919
"key" => key?.Key,

Flow.Launcher/Flow.Launcher.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
1313
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1414
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
15+
<Nullable>enable</Nullable>
1516
</PropertyGroup>
1617

1718
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

Flow.Launcher/Helper/HotKeyMapper.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1-
using Flow.Launcher.Infrastructure.Hotkey;
1+
using System;
2+
using ChefKeys;
3+
using CommunityToolkit.Mvvm.DependencyInjection;
4+
using Flow.Launcher.Infrastructure.Hotkey;
25
using Flow.Launcher.Infrastructure.UserSettings;
3-
using System;
6+
using Flow.Launcher.ViewModel;
47
using NHotkey;
58
using NHotkey.Wpf;
6-
using Flow.Launcher.ViewModel;
7-
using ChefKeys;
8-
using CommunityToolkit.Mvvm.DependencyInjection;
99

1010
namespace Flow.Launcher.Helper;
1111

1212
internal static class HotKeyMapper
1313
{
1414
private static readonly string ClassName = nameof(HotKeyMapper);
1515

16+
#pragma warning disable CS8618
1617
private static Settings _settings;
1718
private static MainViewModel _mainViewModel;
19+
#pragma warning restore CS8618
1820

1921
internal static void Initialize()
2022
{
2123
_mainViewModel = Ioc.Default.GetRequiredService<MainViewModel>();
22-
_settings = Ioc.Default.GetService<Settings>();
24+
_settings = Ioc.Default.GetRequiredService<Settings>();
2325

2426
SetHotkey(_settings.Hotkey, OnToggleHotkey);
2527
LoadCustomPluginHotkey();
2628
}
2729

28-
internal static void OnToggleHotkey(object sender, HotkeyEventArgs args)
30+
internal static void OnToggleHotkey(object? sender, HotkeyEventArgs args)
2931
{
3032
if (!_mainViewModel.ShouldIgnoreHotkeys())
3133
_mainViewModel.ToggleFlowLauncher();

Flow.Launcher/Helper/SingleInstance.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static class SingleInstance<TApplication> where TApplication : Applicatio
4242
/// <summary>
4343
/// Application mutex.
4444
/// </summary>
45-
internal static Mutex SingleInstanceMutex { get; set; }
45+
internal static Mutex? SingleInstanceMutex { get; set; }
4646

4747
#endregion
4848

Flow.Launcher/Helper/WpfHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Flow.Launcher.Helper;
55

66
public static class WpfHelper
77
{
8-
public static T FindVisualChild<T>(DependencyObject dep) where T : DependencyObject
8+
public static T? FindVisualChild<T>(DependencyObject dep) where T : DependencyObject
99
{
1010
if (dep is null)
1111
return null;

Flow.Launcher/HotkeyControl.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ private void RefreshHotkeyInterface(string hotkey)
215215
private static bool CheckHotkeyAvailability(HotkeyModel hotkey, bool validateKeyGesture) =>
216216
hotkey.Validate(validateKeyGesture) && HotKeyMapper.CheckAvailability(hotkey);
217217

218-
public string EmptyHotkey => Localize.none();
218+
public static string EmptyHotkey => Localize.none();
219219

220220
public ObservableCollection<string> KeysToDisplay { get; set; } = new();
221221

@@ -308,7 +308,7 @@ private void SetKeysToDisplay(HotkeyModel? hotkey)
308308
}
309309
}
310310

311-
public void SetHotkey(string? keyStr, bool triggerValidate = true)
311+
public void SetHotkey(string keyStr, bool triggerValidate = true)
312312
{
313313
SetHotkey(new HotkeyModel(keyStr), triggerValidate);
314314
}

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ private void QueryTextBox_TextChanged1(object sender, TextChangedEventArgs e)
775775
{
776776
var textBox = (TextBox)sender;
777777
_viewModel.QueryText = textBox.Text;
778-
_viewModel.Query(false);
778+
_viewModel.Query();
779779
}
780780

781781
#endregion

0 commit comments

Comments
 (0)