Skip to content

Commit a05e9f8

Browse files
committed
Use external plugin
1 parent b991cc8 commit a05e9f8

File tree

10 files changed

+92
-113
lines changed

10 files changed

+92
-113
lines changed

Flow.Launcher.Infrastructure/QuickSwitch/Interface/IQuickSwitchDialog.cs

Lines changed: 0 additions & 22 deletions
This file was deleted.

Flow.Launcher.Infrastructure/QuickSwitch/Interface/IQuickSwitchDialogWindow.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

Flow.Launcher.Infrastructure/QuickSwitch/Interface/IQuickSwitchDialogWindowTab.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

Flow.Launcher.Infrastructure/QuickSwitch/Interface/IQuickSwitchExplorer.cs

Lines changed: 0 additions & 24 deletions
This file was deleted.

Flow.Launcher.Infrastructure/QuickSwitch/Models/WindowsDialog.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Threading;
33
using Flow.Launcher.Infrastructure.Logger;
4-
using Flow.Launcher.Infrastructure.QuickSwitch.Interface;
4+
using Flow.Launcher.Plugins;
55
using Windows.Win32;
66
using Windows.Win32.Foundation;
77
using Windows.Win32.UI.WindowsAndMessaging;
@@ -21,7 +21,7 @@ internal class WindowsDialog : IQuickSwitchDialog
2121

2222
public string Name => "Windows";
2323

24-
public bool CheckDialogWindow(HWND hwnd)
24+
public bool CheckDialogWindow(IntPtr hwnd)
2525
{
2626
// Has it been checked?
2727
if (DialogWindow != null && DialogWindow.Handle == hwnd)
@@ -30,10 +30,10 @@ public bool CheckDialogWindow(HWND hwnd)
3030
}
3131

3232
// Is it a Win32 dialog box?
33-
if (GetClassName(hwnd) == WindowsDialogClassName)
33+
if (GetClassName(new(hwnd)) == WindowsDialogClassName)
3434
{
3535
// Is it a windows file dialog?
36-
var dialogType = GetFileDialogType(hwnd);
36+
var dialogType = GetFileDialogType(new(hwnd));
3737
if (dialogType != DialogType.Others)
3838
{
3939
DialogWindow = new WindowsDialogWindow(hwnd, dialogType);
@@ -82,15 +82,15 @@ private static DialogType GetFileDialogType(HWND handle)
8282

8383
internal class WindowsDialogWindow : IQuickSwitchDialogWindow
8484
{
85-
public HWND Handle { get; private set; } = HWND.Null;
85+
public IntPtr Handle { get; private set; } = IntPtr.Zero;
8686

8787
// After jumping folder, file editor handle of Save / SaveAs file dialogs cannot be found anymore
8888
// So we need to cache the current tab and use the original handle
8989
private IQuickSwitchDialogWindowTab _currentTab { get; set; } = null;
9090

9191
private readonly DialogType _dialogType;
9292

93-
public WindowsDialogWindow(HWND handle, DialogType dialogType)
93+
public WindowsDialogWindow(IntPtr handle, DialogType dialogType)
9494
{
9595
Handle = handle;
9696
_dialogType = dialogType;
@@ -111,7 +111,7 @@ internal class WindowsDialogTab : IQuickSwitchDialogWindowTab
111111
{
112112
#region Public Properties
113113

114-
public HWND Handle { get; private set; } = HWND.Null;
114+
public IntPtr Handle { get; private set; } = IntPtr.Zero;
115115

116116
#endregion
117117

@@ -133,7 +133,7 @@ internal class WindowsDialogTab : IQuickSwitchDialogWindowTab
133133

134134
#region Constructor
135135

136-
public WindowsDialogTab(HWND handle, DialogType dialogType)
136+
public WindowsDialogTab(IntPtr handle, DialogType dialogType)
137137
{
138138
Handle = handle;
139139
_dialogType = dialogType;
@@ -234,7 +234,7 @@ private bool GetPathControlEditor()
234234
{
235235
// Get the handle of the path editor
236236
// Must use PInvoke.FindWindowEx because PInvoke.GetDlgItem(Handle, 0x0000) will get another control
237-
_pathControl = PInvoke.FindWindowEx(Handle, HWND.Null, "WorkerW", null); // 0x0000
237+
_pathControl = PInvoke.FindWindowEx(new(Handle), HWND.Null, "WorkerW", null); // 0x0000
238238
_pathControl = PInvoke.FindWindowEx(_pathControl, HWND.Null, "ReBarWindow32", null); // 0xA005
239239
_pathControl = PInvoke.FindWindowEx(_pathControl, HWND.Null, "Address Band Root", null); // 0xA205
240240
_pathControl = PInvoke.FindWindowEx(_pathControl, HWND.Null, "msctls_progress32", null); // 0x0000
@@ -264,14 +264,14 @@ private bool GetFileEditor()
264264
if (_dialogType == DialogType.Open)
265265
{
266266
// Get the handle of the file name editor of Open file dialog
267-
_fileEditor = PInvoke.GetDlgItem(Handle, 0x047C); // ComboBoxEx32
267+
_fileEditor = PInvoke.GetDlgItem(new(Handle), 0x047C); // ComboBoxEx32
268268
_fileEditor = PInvoke.GetDlgItem(_fileEditor, 0x047C); // ComboBox
269269
_fileEditor = PInvoke.GetDlgItem(_fileEditor, 0x047C); // Edit
270270
}
271271
else
272272
{
273273
// Get the handle of the file name editor of Save / SaveAs file dialog
274-
_fileEditor = PInvoke.GetDlgItem(Handle, 0x0000); // DUIViewWndClassName
274+
_fileEditor = PInvoke.GetDlgItem(new(Handle), 0x0000); // DUIViewWndClassName
275275
_fileEditor = PInvoke.GetDlgItem(_fileEditor, 0x0000); // DirectUIHWND
276276
_fileEditor = PInvoke.GetDlgItem(_fileEditor, 0x0000); // FloatNotifySink
277277
_fileEditor = PInvoke.GetDlgItem(_fileEditor, 0x0000); // ComboBox
@@ -290,7 +290,7 @@ private bool GetFileEditor()
290290
private bool GetOpenButton()
291291
{
292292
// Get the handle of the open button
293-
_openButton = PInvoke.GetDlgItem(Handle, 0x0001); // Open/Save/SaveAs Button
293+
_openButton = PInvoke.GetDlgItem(new(Handle), 0x0001); // Open/Save/SaveAs Button
294294
if (_openButton == HWND.Null)
295295
{
296296
Log.Error(ClassName, "Failed to find open button handle");

Flow.Launcher.Infrastructure/QuickSwitch/Models/WindowsExplorer.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using System;
22
using System.Runtime.InteropServices;
3-
using Flow.Launcher.Infrastructure.QuickSwitch.Interface;
3+
using Flow.Launcher.Plugins;
44
using Windows.Win32;
5-
using Windows.Win32.Foundation;
65
using Windows.Win32.System.Com;
76
using Windows.Win32.UI.Shell;
87

@@ -11,20 +10,18 @@ namespace Flow.Launcher.Infrastructure.QuickSwitch.Models
1110
/// <summary>
1211
/// Class for handling Windows Explorer instances in QuickSwitch.
1312
/// </summary>
14-
internal class WindowsExplorer : IQuickSwitchExplorer
13+
public class WindowsExplorer : IQuickSwitchExplorer
1514
{
1615
private static readonly string ClassName = nameof(WindowsExplorer);
1716

1817
private static IWebBrowser2 _lastExplorerView = null;
1918
private static readonly object _lastExplorerViewLock = new();
2019

21-
public string Name => "Windows";
22-
23-
public bool CheckExplorerWindow(HWND foreground)
20+
public bool CheckExplorerWindow(IntPtr foreground)
2421
{
2522
var isExplorer = false;
2623
// Is it from Explorer?
27-
var processName = Win32Helper.GetProcessNameFromHwnd(foreground);
24+
var processName = Win32Helper.GetProcessNameFromHwnd(new(foreground));
2825
if (processName.ToLower() == "explorer.exe")
2926
{
3027
EnumerateShellWindows((shellWindow) =>
@@ -33,7 +30,7 @@ public bool CheckExplorerWindow(HWND foreground)
3330
{
3431
if (shellWindow is not IWebBrowser2 explorer) return true;
3532

36-
if (explorer.HWND != foreground.Value) return true;
33+
if (explorer.HWND != foreground) return true;
3734

3835
lock (_lastExplorerViewLock)
3936
{

Flow.Launcher.Infrastructure/QuickSwitch/QuickSwitch.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
using System.Windows.Threading;
77
using CommunityToolkit.Mvvm.DependencyInjection;
88
using Flow.Launcher.Infrastructure.Logger;
9-
using Flow.Launcher.Infrastructure.QuickSwitch.Interface;
109
using Flow.Launcher.Infrastructure.QuickSwitch.Models;
1110
using Flow.Launcher.Infrastructure.UserSettings;
11+
using Flow.Launcher.Plugins;
1212
using NHotkey;
1313
using Windows.Win32;
1414
using Windows.Win32.Foundation;
@@ -81,14 +81,6 @@ public static class QuickSwitch
8181

8282
#endregion
8383

84-
#region Supported Explorers & Dialogs Name
85-
86-
public static string[] SupportedExplorerNames => _quickSwitchExplorers.ConvertAll(explorer => explorer.Name).ToArray();
87-
88-
public static string[] SupportedDialogNames => _quickSwitchDialogs.ConvertAll(dialog => dialog.Name).ToArray();
89-
90-
#endregion
91-
9284
#region Initialize & Setup
9385

9486
public static void InitializeQuickSwitch()
@@ -308,7 +300,7 @@ private static async Task InvokeShowQuickSwitchWindowAsync(bool dialogWindowChan
308300
{
309301
if (_dialogWindow != null)
310302
{
311-
dialogWindowHandle = _dialogWindow.Handle;
303+
dialogWindowHandle = new(_dialogWindow.Handle);
312304
}
313305
}
314306

@@ -731,7 +723,7 @@ private static async Task<bool> JumpToPathAsync(IQuickSwitchDialogWindowTab dial
731723
{
732724
lock (_autoSwitchedDialogsLock)
733725
{
734-
_autoSwitchedDialogs.Add(dialogHandle);
726+
_autoSwitchedDialogs.Add(new(dialogHandle));
735727
}
736728
}
737729

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
3+
namespace Flow.Launcher.Plugins
4+
{
5+
/// <summary>
6+
/// Interface for handling file dialog instances in QuickSwitch.
7+
/// </summary>
8+
public interface IQuickSwitchDialog : IDisposable
9+
{
10+
/// <summary>
11+
///
12+
/// </summary>
13+
IQuickSwitchDialogWindow DialogWindow { get; }
14+
15+
bool CheckDialogWindow(IntPtr hwnd);
16+
}
17+
18+
public interface IQuickSwitchDialogWindow : IDisposable
19+
{
20+
IntPtr Handle { get; }
21+
22+
IQuickSwitchDialogWindowTab GetCurrentTab();
23+
}
24+
25+
public interface IQuickSwitchDialogWindowTab : IDisposable
26+
{
27+
IntPtr Handle { get; }
28+
29+
string GetCurrentFolder();
30+
31+
string GetCurrentFile();
32+
33+
bool JumpFolder(string path, bool auto);
34+
35+
bool JumpFile(string path);
36+
37+
bool Open();
38+
}
39+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
3+
namespace Flow.Launcher.Plugins
4+
{
5+
/// <summary>
6+
/// Interface for handling file explorer instances in QuickSwitch.
7+
/// </summary>
8+
public interface IQuickSwitchExplorer : IDisposable
9+
{
10+
/// <summary>
11+
/// Check if the foreground window is a Windows Explorer instance.
12+
/// </summary>
13+
/// <param name="foreground">
14+
/// The handle of the foreground window to check.
15+
/// </param>
16+
/// <returns>
17+
/// True if the foreground window is a Windows Explorer instance, otherwise false.
18+
/// </returns>
19+
bool CheckExplorerWindow(IntPtr foreground);
20+
21+
/// <summary>
22+
///
23+
/// </summary>
24+
void RemoveExplorerWindow();
25+
26+
/// <summary>
27+
///
28+
/// </summary>
29+
/// <returns></returns>
30+
string GetExplorerPath();
31+
}
32+
}

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,7 @@ public class QuickSwitchFileResultBehaviourData : DropdownDataGeneric<QuickSwitc
180180
public List<QuickSwitchFileResultBehaviourData> QuickSwitchFileResultBehaviours { get; } =
181181
DropdownDataGeneric<QuickSwitchFileResultBehaviours>.GetValues<QuickSwitchFileResultBehaviourData>("QuickSwitchFileResultBehaviour");
182182

183-
public string QuickSwitchSupportedExplorerDialogMessage =>
184-
string.Format(App.API.GetTranslation("QuickSwitchSupportedExplorerDialogMessage"),
185-
string.Join(", ", QuickSwitch.SupportedExplorerNames),
186-
string.Join(", ", QuickSwitch.SupportedDialogNames));
183+
public string QuickSwitchSupportedExplorerDialogMessage => string.Empty;
187184

188185
public int SearchDelayTimeValue
189186
{

0 commit comments

Comments
 (0)