From c0afb197c21866008a2df16b6209f2f28c695aa9 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Mon, 1 Jul 2024 21:02:07 +1000 Subject: [PATCH] allow custom explorer profile's File Manager Path to replace with path greater flexibility with custom explorer profile --- .../UserSettings/Settings.cs | 9 +--- Flow.Launcher/PublicAPIInstance.cs | 44 ++++++------------- 2 files changed, 14 insertions(+), 39 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 7291017fb..125447d83 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -91,6 +91,7 @@ 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] @@ -131,14 +132,6 @@ 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 5470c2ddd..20b02ddee 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -25,7 +25,6 @@ using Flow.Launcher.Infrastructure.Storage; using System.Collections.Concurrent; using System.Diagnostics; using System.Collections.Specialized; -using Flow.Launcher.Infrastructure.UserSettings; namespace Flow.Launcher { @@ -229,39 +228,22 @@ namespace Flow.Launcher public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null) { - var customExplorerList = _settingsVM.Settings.CustomExplorerList; + using var explorer = new Process(); var explorerInfo = _settingsVM.Settings.CustomExplorer; - var qttabbarIndex = customExplorerList.FindIndex(e => e.Name.Equals("QTTABBAR", StringComparison.OrdinalIgnoreCase)); - var isQttabbarSelected = qttabbarIndex == _settingsVM.Settings.CustomExplorerIndex; - - if (isQttabbarSelected) + explorer.StartInfo = new ProcessStartInfo { - 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(); - } + FileName = explorerInfo.Path.Replace("%d", DirectoryPath), + 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)