summaryrefslogtreecommitdiff
path: root/src/downloadmanager.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-05-25 03:10:37 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2019-05-25 03:10:37 -0400
commitebb855dc1421e89813a1f4a74a4963d76aba9747 (patch)
tree83fddf2d4d62ac8d35930a7c04dcf4e02c194079 /src/downloadmanager.cpp
parent9a014db4b3a64dc93450dff8afe980db3694c595 (diff)
ExploreFile() will select the file in explorer when the path is a file
replaced more ShellExecute() calls with ExploreFile()
Diffstat (limited to 'src/downloadmanager.cpp')
-rw-r--r--src/downloadmanager.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index 78162f11..686092b5 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -1037,7 +1037,7 @@ void DownloadManager::openFile(int index)
return;
}
- ::ShellExecuteW(nullptr, L"explore", ToWString(QDir::toNativeSeparators(m_OutputDirectory)).c_str(), nullptr, nullptr, SW_SHOWNORMAL);
+ ExploreFile(m_OutputDirectory);
return;
}
@@ -1047,23 +1047,22 @@ void DownloadManager::openInDownloadsFolder(int index)
reportError(tr("OpenFileInDownloadsFolder: invalid download index %1").arg(index));
return;
}
- QString params = "/select,\"";
- QDir path = QDir(m_OutputDirectory);
- if (path.exists(getFileName(index))) {
- params = params + QDir::toNativeSeparators(getFilePath(index)) + "\"";
- ::ShellExecuteW(nullptr, nullptr, L"explorer", ToWString(params).c_str(), nullptr, SW_SHOWNORMAL);
- return;
- }
- else if (path.exists(getFileName(index) + ".unfinished")) {
- params = params + QDir::toNativeSeparators(getFilePath(index)+".unfinished") + "\"";
+ const auto path = getFilePath(index);
- ::ShellExecuteW(nullptr, nullptr, L"explorer", ToWString(params).c_str(), nullptr, SW_SHOWNORMAL);
+ if (QFile::exists(path)) {
+ ExploreFile(path);
return;
}
+ else {
+ const auto unfinished = path + ".unfinished";
+ if (QFile::exists(unfinished)) {
+ ExploreFile(unfinished);
+ return;
+ }
+ }
- ::ShellExecuteW(nullptr, L"explore", ToWString(QDir::toNativeSeparators(m_OutputDirectory)).c_str(), nullptr, nullptr, SW_SHOWNORMAL);
- return;
+ ExploreFile(m_OutputDirectory);
}