mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-13 16:53:08 -07:00
Refactor
This commit is contained in:
parent
8742d7aa45
commit
bb956b8453
1 changed files with 48 additions and 55 deletions
|
@ -572,8 +572,12 @@ void Utils::Misc::openPath(const QString &absolutePath)
|
||||||
void Utils::Misc::openFolderSelect(const QString &absolutePath)
|
void Utils::Misc::openFolderSelect(const QString &absolutePath)
|
||||||
{
|
{
|
||||||
const QString path = Utils::Fs::fromNativePath(absolutePath);
|
const QString path = Utils::Fs::fromNativePath(absolutePath);
|
||||||
|
// If the item to select doesn't exist, try to open its parent
|
||||||
|
if (!QFileInfo(path).exists()) {
|
||||||
|
openPath(path.left(path.lastIndexOf("/")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if (QFileInfo(path).exists()) {
|
|
||||||
// Syntax is: explorer /select, "C:\Folder1\Folder2\file_to_select"
|
// Syntax is: explorer /select, "C:\Folder1\Folder2\file_to_select"
|
||||||
// Dir separators MUST be win-style slashes
|
// Dir separators MUST be win-style slashes
|
||||||
|
|
||||||
|
@ -603,13 +607,7 @@ void Utils::Misc::openFolderSelect(const QString &absolutePath)
|
||||||
::CloseHandle(processInfo.hProcess);
|
::CloseHandle(processInfo.hProcess);
|
||||||
::CloseHandle(processInfo.hThread);
|
::CloseHandle(processInfo.hThread);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
// If the item to select doesn't exist, try to open its parent
|
|
||||||
openPath(path.left(path.lastIndexOf("/")));
|
|
||||||
}
|
|
||||||
#elif defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
|
#elif defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
|
||||||
if (QFileInfo(path).exists()) {
|
|
||||||
QProcess proc;
|
QProcess proc;
|
||||||
proc.start("xdg-mime", QStringList() << "query" << "default" << "inode/directory");
|
proc.start("xdg-mime", QStringList() << "query" << "default" << "inode/directory");
|
||||||
proc.waitForFinished();
|
proc.waitForFinished();
|
||||||
|
@ -626,11 +624,6 @@ void Utils::Misc::openFolderSelect(const QString &absolutePath)
|
||||||
else
|
else
|
||||||
// "caja" manager can't pinpoint the file, see: https://github.com/qbittorrent/qBittorrent/issues/5003
|
// "caja" manager can't pinpoint the file, see: https://github.com/qbittorrent/qBittorrent/issues/5003
|
||||||
openPath(path.left(path.lastIndexOf("/")));
|
openPath(path.left(path.lastIndexOf("/")));
|
||||||
}
|
|
||||||
else {
|
|
||||||
// If the item to select doesn't exist, try to open its parent
|
|
||||||
openPath(path.left(path.lastIndexOf("/")));
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
openPath(path.left(path.lastIndexOf("/")));
|
openPath(path.left(path.lastIndexOf("/")));
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue