Add Exception handling for qttabbar

This commit is contained in:
DB p 2024-06-25 16:35:32 +09:00
parent 79c9d9fc3b
commit 7a5fc1c534
2 changed files with 40 additions and 14 deletions

View file

@ -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
}
};

View file

@ -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)