Browse Source

Refactor

adaptive-webui-19844
Chocobo1 8 years ago
parent
commit
bb956b8453
  1. 17
      src/base/utils/misc.cpp

17
src/base/utils/misc.cpp

@ -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…
Cancel
Save