From 7a5fc1c534e90e7af1e3a3cdbb5696c5fb31766a Mon Sep 17 00:00:00 2001 From: DB p Date: Tue, 25 Jun 2024 16:35:32 +0900 Subject: [PATCH] Add Exception handling for qttabbar --- .../UserSettings/Settings.cs | 9 +++- Flow.Launcher/PublicAPIInstance.cs | 45 +++++++++++++------ 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 0c7de10fd..5e66eaff9 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -91,7 +91,6 @@ namespace Flow.Launcher.Infrastructure.UserSettings public double? SettingWindowTop { get; set; } = null; public double? SettingWindowLeft { get; set; } = null; public System.Windows.WindowState SettingWindowState { get; set; } = WindowState.Normal; - public int CustomExplorerIndex { get; set; } = 0; [JsonIgnore] @@ -132,6 +131,14 @@ namespace Flow.Launcher.Infrastructure.UserSettings Path = "Files", DirectoryArgument = "-select \"%d\"", FileArgument = "-select \"%f\"" + }, + new() + { + Name = "QTTabBar", + Path = "Explorer", + DirectoryArgument = "\"%d\"", + FileArgument = "\"%f\"", + Editable = false } }; diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index b49bf39d3..c35dcc2ba 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -25,6 +25,7 @@ using Flow.Launcher.Infrastructure.Storage; using System.Collections.Concurrent; using System.Diagnostics; using System.Collections.Specialized; +using Flow.Launcher.Infrastructure.UserSettings; namespace Flow.Launcher { @@ -228,21 +229,39 @@ namespace Flow.Launcher public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null) { - using var explorer = new Process(); + var customExplorerList = _settingsVM.Settings.CustomExplorerList; var explorerInfo = _settingsVM.Settings.CustomExplorer; - explorer.StartInfo = new ProcessStartInfo + + var qttabbarIndex = customExplorerList.FindIndex(e => e.Name.Equals("QTTABBAR", StringComparison.OrdinalIgnoreCase)); + var isQttabbarSelected = qttabbarIndex >= 0 && _settingsVM.Settings.CustomExplorerIndex == qttabbarIndex; + + if (isQttabbarSelected) { - FileName = explorerInfo.Path, - UseShellExecute = true, - Arguments = FileNameOrFilePath is null - ? explorerInfo.DirectoryArgument.Replace("%d", DirectoryPath) - : explorerInfo.FileArgument - .Replace("%d", DirectoryPath) - .Replace("%f", - Path.IsPathRooted(FileNameOrFilePath) ? FileNameOrFilePath : Path.Combine(DirectoryPath, FileNameOrFilePath) - ) - }; - explorer.Start(); + Process.Start(new ProcessStartInfo + { + FileName = DirectoryPath, + UseShellExecute = true, + Verb = "open", + Arguments = FileNameOrFilePath + }); + } + else + { + using var explorer = new Process(); + explorer.StartInfo = new ProcessStartInfo + { + FileName = explorerInfo.Path, + UseShellExecute = true, + Arguments = FileNameOrFilePath is null + ? explorerInfo.DirectoryArgument.Replace("%d", DirectoryPath) + : explorerInfo.FileArgument + .Replace("%d", DirectoryPath) + .Replace("%f", + Path.IsPathRooted(FileNameOrFilePath) ? FileNameOrFilePath : Path.Combine(DirectoryPath, FileNameOrFilePath) + ) + }; + explorer.Start(); + } } private void OpenUri(Uri uri, bool? inPrivate = null)