Skip to content

Commit d7f4dac

Browse files
authored
Merge branch 'dev' into net7.0
2 parents 8d9501b + 1fd1a37 commit d7f4dac

File tree

5 files changed

+105
-12
lines changed

5 files changed

+105
-12
lines changed

.github/ISSUE_TEMPLATE/bug-report.yaml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,26 @@ body:
4141
- type: input
4242
attributes:
4343
label: Flow Launcher Version
44-
description: Go to "Settings" => "About".
45-
value: v1.8.3
44+
description: Go to "Settings" => "About". If you are using a prerelease version please append the build number.
45+
placeholder: "Example: 1.11.0"
46+
validations:
47+
required: true
4648

4749
- type: input
4850
attributes:
4951
label: Windows Build Number
50-
description: Run "ver" at CMD (command prompt).
51-
value: 10.0.19043.1288
52+
description: Run "ver" at CMD (command prompt) or go to Windows Settings -> Systems -> About.
53+
placeholder: "Example: 10.0.19043.1288"
54+
validations:
55+
required: true
56+
5257

5358
- type: textarea
5459
id: logs
5560
attributes:
5661
label: Error Log
5762
description: >
58-
Log file place:
59-
60-
- The latest version place: `%AppData%\FlowLauncher\Logs\<version>\<date>.txt`
61-
62-
- For portable mode: `%LocalAppData%\FlowLauncher\<App-Version>\UserData\Logs\<version>\<date>.txt`
63+
From flow type 'open log location' and find log file with the corresponding date containing the error info.
6364
value: >
6465
<details>
6566
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Runtime.InteropServices;
6+
7+
namespace Flow.Launcher.Infrastructure
8+
{
9+
public static class FileExplorerHelper
10+
{
11+
/// <summary>
12+
/// Gets the path of the file explorer that is currently in the foreground
13+
/// </summary>
14+
public static string GetActiveExplorerPath()
15+
{
16+
var explorerWindow = GetActiveExplorer();
17+
string locationUrl = explorerWindow?.LocationURL;
18+
return !string.IsNullOrEmpty(locationUrl) ? new Uri(locationUrl).LocalPath + "\\" : null;
19+
}
20+
21+
/// <summary>
22+
/// Gets the file explorer that is currently in the foreground
23+
/// </summary>
24+
private static dynamic GetActiveExplorer()
25+
{
26+
Type type = Type.GetTypeFromProgID("Shell.Application");
27+
if (type == null) return null;
28+
dynamic shell = Activator.CreateInstance(type);
29+
if (shell == null)
30+
{
31+
return null;
32+
}
33+
34+
var explorerWindows = new List<dynamic>();
35+
var openWindows = shell.Windows();
36+
for (int i = 0; i < openWindows.Count; i++)
37+
{
38+
var window = openWindows.Item(i);
39+
if (window == null) continue;
40+
41+
// find the desired window and make sure that it is indeed a file explorer
42+
// we don't want the Internet Explorer or the classic control panel
43+
// ToLower() is needed, because Windows can report the path as "C:\\Windows\\Explorer.EXE"
44+
if (Path.GetFileName((string)window.FullName)?.ToLower() == "explorer.exe")
45+
{
46+
explorerWindows.Add(window);
47+
}
48+
}
49+
50+
if (explorerWindows.Count == 0) return null;
51+
52+
var zOrders = GetZOrder(explorerWindows);
53+
54+
return explorerWindows.Zip(zOrders).MinBy(x => x.Second).First;
55+
}
56+
57+
[DllImport("user32.dll")]
58+
[return: MarshalAs(UnmanagedType.Bool)]
59+
private static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
60+
61+
private delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
62+
63+
/// <summary>
64+
/// Gets the z-order for one or more windows atomically with respect to each other. In Windows, smaller z-order is higher. If the window is not top level, the z order is returned as -1.
65+
/// </summary>
66+
private static IEnumerable<int> GetZOrder(List<dynamic> hWnds)
67+
{
68+
var z = new int[hWnds.Count];
69+
for (var i = 0; i < hWnds.Count; i++) z[i] = -1;
70+
71+
var index = 0;
72+
var numRemaining = hWnds.Count;
73+
EnumWindows((wnd, _) =>
74+
{
75+
var searchIndex = hWnds.FindIndex(x => x.HWND == wnd.ToInt32());
76+
if (searchIndex != -1)
77+
{
78+
z[searchIndex] = index;
79+
numRemaining--;
80+
if (numRemaining == 0) return false;
81+
}
82+
index++;
83+
return true;
84+
}, IntPtr.Zero);
85+
86+
return z;
87+
}
88+
}
89+
}

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,10 @@ public string QuerySearchPrecisionString
192192
public ObservableCollection<CustomShortcutModel> CustomShortcuts { get; set; } = new ObservableCollection<CustomShortcutModel>();
193193

194194
[JsonIgnore]
195-
public ObservableCollection<BuiltinShortcutModel> BuiltinShortcuts { get; set; } = new ObservableCollection<BuiltinShortcutModel>() {
196-
new BuiltinShortcutModel("{clipboard}", "shortcut_clipboard_description", Clipboard.GetText)
195+
public ObservableCollection<BuiltinShortcutModel> BuiltinShortcuts { get; set; } = new()
196+
{
197+
new BuiltinShortcutModel("{clipboard}", "shortcut_clipboard_description", Clipboard.GetText),
198+
new BuiltinShortcutModel("{active_explorer_path}", "shortcut_active_explorer_path", FileExplorerHelper.GetActiveExplorerPath)
197199
};
198200

199201
public bool DontPromptUpdateMsg { get; set; }

Flow.Launcher/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@
176176
<system:String x:Key="deleteCustomHotkeyWarning">Are you sure you want to delete {0} plugin hotkey?</system:String>
177177
<system:String x:Key="deleteCustomShortcutWarning">Are you sure you want to delete shortcut: {0} with expansion {1}?</system:String>
178178
<system:String x:Key="shortcut_clipboard_description">Get text from clipboard.</system:String>
179+
<system:String x:Key="shortcut_active_explorer_path">Get path from active explorer.</system:String>
179180
<system:String x:Key="queryWindowShadowEffect">Query window shadow effect</system:String>
180181
<system:String x:Key="shadowEffectCPUUsage">Shadow effect has a substantial usage of GPU. Not recommended if your computer performance is limited.</system:String>
181182
<system:String x:Key="windowWidthSize">Window Width Size</system:String>

Flow.Launcher/ViewModel/ResultViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private async Task<ImageSource> LoadImageInternalAsync(string imagePath, Result.
188188
{
189189
try
190190
{
191-
var image = await Task.Run(() => icon()).ConfigureAwait(false);
191+
var image = icon();
192192
return image;
193193
}
194194
catch (Exception e)

0 commit comments

Comments
 (0)