Skip to content

Commit 9981fab

Browse files
authored
Merge branch 'dev' into 250412-ImportThemePreset
2 parents b2a3782 + 5cc3124 commit 9981fab

File tree

31 files changed

+158
-163
lines changed

31 files changed

+158
-163
lines changed

Flow.Launcher.Infrastructure/Image/ImageLoader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ private static async ValueTask<ImageResult> LoadInternalAsync(string path, bool
171171
}
172172
catch (System.Exception e2)
173173
{
174-
Log.Exception(ClassName, $"|ImageLoader.Load|Failed to get thumbnail for {path} on first try", e);
175-
Log.Exception(ClassName, $"|ImageLoader.Load|Failed to get thumbnail for {path} on second try", e2);
174+
Log.Exception(ClassName, $"Failed to get thumbnail for {path} on first try", e);
175+
Log.Exception(ClassName, $"Failed to get thumbnail for {path} on second try", e2);
176176

177177
ImageSource image = ImageCache[Constant.MissingImgIcon, false];
178178
ImageCache[path, false] = image;

Flow.Launcher.Infrastructure/Image/ThumbnailReader.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Flow.Launcher.Infrastructure.Image
1313
{
1414
/// <summary>
15-
/// Subclass of <see cref="Windows.Win32.UI.Shell.SIIGBF"/>
15+
/// Subclass of <see cref="SIIGBF"/>
1616
/// </summary>
1717
[Flags]
1818
public enum ThumbnailOptions
@@ -31,7 +31,9 @@ public class WindowsThumbnailProvider
3131

3232
private static readonly Guid GUID_IShellItem = typeof(IShellItem).GUID;
3333

34-
private static readonly HRESULT S_ExtractionFailed = (HRESULT)0x8004B200;
34+
private static readonly HRESULT S_EXTRACTIONFAILED = (HRESULT)0x8004B200;
35+
36+
private static readonly HRESULT S_PATHNOTFOUND = (HRESULT)0x8004B205;
3537

3638
public static BitmapSource GetThumbnail(string fileName, int width, int height, ThumbnailOptions options)
3739
{
@@ -79,16 +81,22 @@ private static unsafe HBITMAP GetHBitmap(string fileName, int width, int height,
7981
{
8082
imageFactory.GetImage(size, (SIIGBF)options, &hBitmap);
8183
}
82-
catch (COMException ex) when (ex.HResult == S_ExtractionFailed && options == ThumbnailOptions.ThumbnailOnly)
84+
catch (COMException ex) when (options == ThumbnailOptions.ThumbnailOnly &&
85+
(ex.HResult == S_PATHNOTFOUND || ex.HResult == S_EXTRACTIONFAILED))
8386
{
84-
// Fallback to IconOnly if ThumbnailOnly fails
87+
// Fallback to IconOnly if extraction fails or files cannot be found
8588
imageFactory.GetImage(size, (SIIGBF)ThumbnailOptions.IconOnly, &hBitmap);
8689
}
8790
catch (FileNotFoundException) when (options == ThumbnailOptions.ThumbnailOnly)
8891
{
8992
// Fallback to IconOnly if files cannot be found
9093
imageFactory.GetImage(size, (SIIGBF)ThumbnailOptions.IconOnly, &hBitmap);
9194
}
95+
catch (System.Exception ex)
96+
{
97+
// Handle other exceptions
98+
throw new InvalidOperationException("Failed to get thumbnail", ex);
99+
}
92100
}
93101
finally
94102
{

Flow.Launcher.Infrastructure/Win32Helper.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -365,21 +365,10 @@ public static unsafe void SwitchToEnglishKeyboardLayout(bool backupPrevious)
365365
// No installed English layout found
366366
if (enHKL == HKL.Null) return;
367367

368-
// When application is exiting, the Application.Current will be null
369-
if (Application.Current == null) return;
370-
371-
// Get the FL main window
372-
var hwnd = GetWindowHandle(Application.Current.MainWindow, true);
368+
// Get the foreground window
369+
var hwnd = PInvoke.GetForegroundWindow();
373370
if (hwnd == HWND.Null) return;
374371

375-
// Check if the FL main window is the current foreground window
376-
if (!IsForegroundWindow(hwnd))
377-
{
378-
var result = PInvoke.SetForegroundWindow(hwnd);
379-
// If we cannot set the foreground window, we can use the foreground window and switch the layout
380-
if (!result) hwnd = PInvoke.GetForegroundWindow();
381-
}
382-
383372
// Get the current foreground window thread ID
384373
var threadId = PInvoke.GetWindowThreadProcessId(hwnd);
385374
if (threadId == 0) throw new Win32Exception(Marshal.GetLastWin32Error());

Flow.Launcher.Plugin/Result.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ public string BadgeIcoPath
128128
/// <summary>
129129
/// Delegate to load an icon for this result.
130130
/// </summary>
131-
public IconDelegate Icon { get; set; }
131+
public IconDelegate Icon = null;
132132

133133
/// <summary>
134134
/// Delegate to load an icon for the badge of this result.
135135
/// </summary>
136-
public IconDelegate BadgeIcon { get; set; }
136+
public IconDelegate BadgeIcon = null;
137137

138138
/// <summary>
139139
/// Information for Glyph Icon (Prioritized than IcoPath/Icon if user enable Glyph Icons)

Flow.Launcher/HotkeyControl.xaml.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#nullable enable
2-
3-
using System.Collections.ObjectModel;
1+
using System.Collections.ObjectModel;
42
using System.Threading.Tasks;
53
using System.Windows;
64
using System.Windows.Input;
@@ -9,6 +7,8 @@
97
using Flow.Launcher.Infrastructure.Hotkey;
108
using Flow.Launcher.Infrastructure.UserSettings;
119

10+
#nullable enable
11+
1212
namespace Flow.Launcher
1313
{
1414
public partial class HotkeyControl
@@ -242,7 +242,11 @@ private async Task OpenHotkeyDialogAsync()
242242
HotKeyMapper.RemoveHotkey(Hotkey);
243243
}
244244

245-
var dialog = new HotkeyControlDialog(Hotkey, DefaultHotkey, WindowTitle);
245+
var dialog = new HotkeyControlDialog(Hotkey, DefaultHotkey, WindowTitle)
246+
{
247+
Owner = Window.GetWindow(this)
248+
};
249+
246250
await dialog.ShowAsync();
247251
switch (dialog.ResultType)
248252
{

Flow.Launcher/Msg.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ private void fadeOutStoryboard_Completed(object sender, EventArgs e)
5959
Close();
6060
}
6161

62+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "VSTHRD100:Avoid async void methods", Justification = "<Pending>")]
6263
public async void Show(string title, string subTitle, string iconPath)
6364
{
6465
tbTitle.Text = title;

Flow.Launcher/ReportWindow.xaml.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ namespace Flow.Launcher
1515
{
1616
internal partial class ReportWindow
1717
{
18-
private static readonly string ClassName = nameof(ReportWindow);
19-
2018
public ReportWindow(Exception exception)
2119
{
2220
InitializeComponent();

Flow.Launcher/SettingPages/ViewModels/SettingsPanePluginsViewModel.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Windows;
66
using CommunityToolkit.Mvvm.Input;
77
using Flow.Launcher.Core.Plugin;
8-
using Flow.Launcher.Infrastructure;
98
using Flow.Launcher.Infrastructure.UserSettings;
109
using Flow.Launcher.Plugin;
1110
using Flow.Launcher.ViewModel;
@@ -112,10 +111,11 @@ public SettingsPanePluginsViewModel(Settings settings)
112111
.ToList();
113112

114113
[RelayCommand]
115-
private async Task OpenHelperAsync()
114+
private async Task OpenHelperAsync(Button button)
116115
{
117116
var helpDialog = new ContentDialog()
118117
{
118+
Owner = Window.GetWindow(button),
119119
Content = new StackPanel
120120
{
121121
Children =
@@ -146,7 +146,6 @@ private async Task OpenHelperAsync()
146146
}
147147
}
148148
},
149-
150149
PrimaryButtonText = (string)Application.Current.Resources["commonOK"],
151150
CornerRadius = new CornerRadius(8),
152151
Style = (Style)Application.Current.Resources["ContentDialog"]

Flow.Launcher/SettingPages/Views/SettingsPanePlugins.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
Height="34"
5858
Margin="0 0 20 0"
5959
Command="{Binding OpenHelperCommand}"
60+
CommandParameter="{Binding RelativeSource={RelativeSource Self}}"
6061
Content="&#xe9ce;"
6162
FontFamily="{DynamicResource SymbolThemeFontFamily}"
6263
FontSize="14" />

Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using System.Windows.Navigation;
1+
using System.Windows.Navigation;
22
using CommunityToolkit.Mvvm.DependencyInjection;
33
using Flow.Launcher.SettingPages.ViewModels;
4-
using Page = ModernWpf.Controls.Page;
54
using Flow.Launcher.Infrastructure.UserSettings;
5+
using Page = ModernWpf.Controls.Page;
66

77
namespace Flow.Launcher.SettingPages.Views;
88

0 commit comments

Comments
 (0)