From 796224d73369e55b278aa1be1a13f357b094e49c Mon Sep 17 00:00:00 2001 From: "Frederik “Freso” S. Olesen" Date: Mon, 6 Aug 2018 12:21:02 +0200 Subject: Add new "Open File" right-click dialog for Downloads This enables the user to directly open the downloaded archived/file which can be useful for e.g., inspection of what's inside or if they need to copy files from inside the archive to somewhere else. Saves a step compared to "Show in Folder" and then opening the file. --- src/downloadmanager.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/downloadmanager.cpp') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 33899f46..af32ee71 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -927,6 +927,31 @@ void DownloadManager::visitOnNexus(int index) } } +void DownloadManager::openFile(int index) +{ + if ((index < 0) || (index >= m_ActiveDownloads.size())) { + reportError(tr("VisitNexus: 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"open", ToWString(params).c_str(), nullptr, SW_SHOWNORMAL); + return; + } + else if (path.exists(getFileName(index) + ".unfinished")) { + params = params + QDir::toNativeSeparators(getFilePath(index)+".unfinished") + "\""; + + ::ShellExecuteW(nullptr, nullptr, L"open", ToWString(params).c_str(), nullptr, SW_SHOWNORMAL); + return; + } + + ::ShellExecuteW(nullptr, L"open", ToWString(QDir::toNativeSeparators(m_OutputDirectory)).c_str(), nullptr, nullptr, SW_SHOWNORMAL); + return; +} + void DownloadManager::openInDownloadsFolder(int index) { if ((index < 0) || (index >= m_ActiveDownloads.size())) { -- cgit v1.3.1