Skip to content

Commit 7a5fc1c

Browse files
committed
Add Exception handling for qttabbar
1 parent 79c9d9f commit 7a5fc1c

File tree

2 files changed

+40
-14
lines changed

2 files changed

+40
-14
lines changed

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public string Theme
9191
public double? SettingWindowTop { get; set; } = null;
9292
public double? SettingWindowLeft { get; set; } = null;
9393
public System.Windows.WindowState SettingWindowState { get; set; } = WindowState.Normal;
94-
9594
public int CustomExplorerIndex { get; set; } = 0;
9695

9796
[JsonIgnore]
@@ -132,6 +131,14 @@ public CustomExplorerViewModel CustomExplorer
132131
Path = "Files",
133132
DirectoryArgument = "-select \"%d\"",
134133
FileArgument = "-select \"%f\""
134+
},
135+
new()
136+
{
137+
Name = "QTTabBar",
138+
Path = "Explorer",
139+
DirectoryArgument = "\"%d\"",
140+
FileArgument = "\"%f\"",
141+
Editable = false
135142
}
136143
};
137144

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using System.Collections.Concurrent;
2626
using System.Diagnostics;
2727
using System.Collections.Specialized;
28+
using Flow.Launcher.Infrastructure.UserSettings;
2829

2930
namespace Flow.Launcher
3031
{
@@ -228,21 +229,39 @@ public void SavePluginSettings()
228229

229230
public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null)
230231
{
231-
using var explorer = new Process();
232+
var customExplorerList = _settingsVM.Settings.CustomExplorerList;
232233
var explorerInfo = _settingsVM.Settings.CustomExplorer;
233-
explorer.StartInfo = new ProcessStartInfo
234+
235+
var qttabbarIndex = customExplorerList.FindIndex(e => e.Name.Equals("QTTABBAR", StringComparison.OrdinalIgnoreCase));
236+
var isQttabbarSelected = qttabbarIndex >= 0 && _settingsVM.Settings.CustomExplorerIndex == qttabbarIndex;
237+
238+
if (isQttabbarSelected)
234239
{
235-
FileName = explorerInfo.Path,
236-
UseShellExecute = true,
237-
Arguments = FileNameOrFilePath is null
238-
? explorerInfo.DirectoryArgument.Replace("%d", DirectoryPath)
239-
: explorerInfo.FileArgument
240-
.Replace("%d", DirectoryPath)
241-
.Replace("%f",
242-
Path.IsPathRooted(FileNameOrFilePath) ? FileNameOrFilePath : Path.Combine(DirectoryPath, FileNameOrFilePath)
243-
)
244-
};
245-
explorer.Start();
240+
Process.Start(new ProcessStartInfo
241+
{
242+
FileName = DirectoryPath,
243+
UseShellExecute = true,
244+
Verb = "open",
245+
Arguments = FileNameOrFilePath
246+
});
247+
}
248+
else
249+
{
250+
using var explorer = new Process();
251+
explorer.StartInfo = new ProcessStartInfo
252+
{
253+
FileName = explorerInfo.Path,
254+
UseShellExecute = true,
255+
Arguments = FileNameOrFilePath is null
256+
? explorerInfo.DirectoryArgument.Replace("%d", DirectoryPath)
257+
: explorerInfo.FileArgument
258+
.Replace("%d", DirectoryPath)
259+
.Replace("%f",
260+
Path.IsPathRooted(FileNameOrFilePath) ? FileNameOrFilePath : Path.Combine(DirectoryPath, FileNameOrFilePath)
261+
)
262+
};
263+
explorer.Start();
264+
}
246265
}
247266

248267
private void OpenUri(Uri uri, bool? inPrivate = null)

0 commit comments

Comments
 (0)