summaryrefslogtreecommitdiff
path: root/src/downloadmanager.cpp
diff options
context:
space:
mode:
authorAl <gabriel.cortesi@outlook.com>2019-05-26 12:24:02 +0200
committerGitHub <noreply@github.com>2019-05-26 12:24:02 +0200
commit2caa688e5581849441b1c96e4a2d357e9241f74a (patch)
treec99b83f84f4be692663be4256e9ec955f4258e7e /src/downloadmanager.cpp
parent2d58ad346c9e8840d3864080d62999e686962a76 (diff)
parent21185182c6551d053cccdcf087e0c219a3785cf8 (diff)
Merge pull request #731 from isanae/filetree-dds-preview-630
Add preview to filetree, some refactoring
Diffstat (limited to 'src/downloadmanager.cpp')
-rw-r--r--src/downloadmanager.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index d4a6c37f..648b102a 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -1041,14 +1041,14 @@ void DownloadManager::openFile(int index)
reportError(tr("OpenFile: invalid download index %1").arg(index));
return;
}
+
QDir path = QDir(m_OutputDirectory);
if (path.exists(getFileName(index))) {
-
- ::ShellExecuteW(nullptr, L"open", ToWString(QDir::toNativeSeparators(getFilePath(index))).c_str(), nullptr, nullptr, SW_SHOWNORMAL);
+ shell::OpenFile(getFilePath(index));
return;
}
- ::ShellExecuteW(nullptr, L"explore", ToWString(QDir::toNativeSeparators(m_OutputDirectory)).c_str(), nullptr, nullptr, SW_SHOWNORMAL);
+ shell::ExploreFile(m_OutputDirectory);
return;
}
@@ -1058,23 +1058,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)) {
+ shell::ExploreFile(path);
return;
}
+ else {
+ const auto unfinished = path + ".unfinished";
+ if (QFile::exists(unfinished)) {
+ shell::ExploreFile(unfinished);
+ return;
+ }
+ }
- ::ShellExecuteW(nullptr, L"explore", ToWString(QDir::toNativeSeparators(m_OutputDirectory)).c_str(), nullptr, nullptr, SW_SHOWNORMAL);
- return;
+ shell::ExploreFile(m_OutputDirectory);
}