diff options
| author | Al12rs <gabriel.cortesi@outlook.com> | 2018-07-16 20:56:47 +0200 |
|---|---|---|
| committer | Al12rs <gabriel.cortesi@outlook.com> | 2018-07-16 20:56:47 +0200 |
| commit | 2524d65441e99cbb14037144b8af60e1d25e1179 (patch) | |
| tree | aba253edda27662b694d44d8377f968209ebe6c6 /src | |
| parent | 5efddbd5156f914de9406775f06111b899060177 (diff) | |
Added "Open in Folder" option to downloads tab.
Diffstat (limited to 'src')
| -rw-r--r-- | src/downloadlistwidget.cpp | 10 | ||||
| -rw-r--r-- | src/downloadlistwidget.h | 2 | ||||
| -rw-r--r-- | src/downloadlistwidgetcompact.cpp | 9 | ||||
| -rw-r--r-- | src/downloadlistwidgetcompact.h | 2 | ||||
| -rw-r--r-- | src/downloadmanager.cpp | 25 | ||||
| -rw-r--r-- | src/downloadmanager.h | 2 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 1 |
7 files changed, 49 insertions, 2 deletions
diff --git a/src/downloadlistwidget.cpp b/src/downloadlistwidget.cpp index 5ab5d397..0ef408fb 100644 --- a/src/downloadlistwidget.cpp +++ b/src/downloadlistwidget.cpp @@ -272,6 +272,10 @@ void DownloadListWidgetDelegate::issueVisitOnNexus() emit visitOnNexus(m_ContextRow);
}
+void DownloadListWidgetDelegate::issueOpenInDownloadsFolder()
+{
+ emit openInDownloadsFolder(m_ContextRow);
+}
void DownloadListWidgetDelegate::issueCancel()
{
@@ -352,6 +356,8 @@ bool DownloadListWidgetDelegate::editorEvent(QEvent *event, QAbstractItemModel * }else {
menu.addAction(tr("Visit on Nexus"), this,SLOT(issueVisitOnNexus()));
}
+
+ menu.addAction(tr("Show in Folder"), this, SLOT(issueOpenInDownloadsFolder()));
menu.addSeparator();
@@ -364,9 +370,11 @@ bool DownloadListWidgetDelegate::editorEvent(QEvent *event, QAbstractItemModel * } else if (state == DownloadManager::STATE_DOWNLOADING){
menu.addAction(tr("Cancel"), this, SLOT(issueCancel()));
menu.addAction(tr("Pause"), this, SLOT(issuePause()));
+ menu.addAction(tr("Show in Folder"), this, SLOT(issueOpenInDownloadsFolder()));
} else if ((state == DownloadManager::STATE_PAUSED) || (state == DownloadManager::STATE_ERROR) || (state == DownloadManager::STATE_PAUSING)) {
- menu.addAction(tr("Remove"), this, SLOT(issueDelete()));
+ menu.addAction(tr("Delete"), this, SLOT(issueDelete()));
menu.addAction(tr("Resume"), this, SLOT(issueResume()));
+ menu.addAction(tr("Show in Folder"), this, SLOT(issueOpenInDownloadsFolder()));
}
menu.addSeparator();
diff --git a/src/downloadlistwidget.h b/src/downloadlistwidget.h index e2746f3a..4dcbea99 100644 --- a/src/downloadlistwidget.h +++ b/src/downloadlistwidget.h @@ -72,6 +72,7 @@ signals: void pauseDownload(int index);
void resumeDownload(int index);
void visitOnNexus(int index);
+ void openInDownloadsFolder(int index);
protected:
@@ -92,6 +93,7 @@ private slots: void issueRestoreToView();
void issueRestoreToViewAll();
void issueVisitOnNexus();
+ void issueOpenInDownloadsFolder();
void issueCancel();
void issuePause();
void issueResume();
diff --git a/src/downloadlistwidgetcompact.cpp b/src/downloadlistwidgetcompact.cpp index 99cbd7cb..1d1805ef 100644 --- a/src/downloadlistwidgetcompact.cpp +++ b/src/downloadlistwidgetcompact.cpp @@ -226,6 +226,11 @@ void DownloadListWidgetCompactDelegate::issueVisitOnNexus() emit visitOnNexus(m_ContextIndex.row());
}
+void DownloadListWidgetCompactDelegate::issueOpenInDownloadsFolder()
+{
+ emit openInDownloadsFolder(m_ContextIndex.row());
+}
+
void DownloadListWidgetCompactDelegate::issueRestoreToView()
{
emit restoreDownload(m_ContextIndex.row());
@@ -317,6 +322,7 @@ bool DownloadListWidgetCompactDelegate::editorEvent(QEvent *event, QAbstractItem }else {
menu.addAction(tr("Visit on Nexus"), this, SLOT(issueVisitOnNexus()));
}
+ menu.addAction(tr("Show in Folder"), this, SLOT(issueOpenInDownloadsFolder()));
menu.addSeparator();
menu.addAction(tr("Delete"), this, SLOT(issueDelete()));
if (hidden) {
@@ -327,11 +333,12 @@ bool DownloadListWidgetCompactDelegate::editorEvent(QEvent *event, QAbstractItem } else if (state == DownloadManager::STATE_DOWNLOADING){
menu.addAction(tr("Cancel"), this, SLOT(issueCancel()));
menu.addAction(tr("Pause"), this, SLOT(issuePause()));
+ menu.addAction(tr("Show in Folder"), this, SLOT(issueOpenInDownloadsFolder()));
} else if ((state == DownloadManager::STATE_PAUSED) || (state == DownloadManager::STATE_ERROR) || (state == DownloadManager::STATE_PAUSING)) {
menu.addAction(tr("Remove"), this, SLOT(issueDelete()));
menu.addAction(tr("Resume"), this, SLOT(issueResume()));
+ menu.addAction(tr("Show in Folder"), this, SLOT(issueOpenInDownloadsFolder()));
}
-
menu.addSeparator();
}
menu.addAction(tr("Delete Installed..."), this, SLOT(issueDeleteCompleted()));
diff --git a/src/downloadlistwidgetcompact.h b/src/downloadlistwidgetcompact.h index 28a376eb..c25b7e99 100644 --- a/src/downloadlistwidgetcompact.h +++ b/src/downloadlistwidgetcompact.h @@ -70,6 +70,7 @@ signals: void pauseDownload(int index);
void resumeDownload(int index);
void visitOnNexus(int index);
+ void openInDownloadsFolder(int index);
protected:
@@ -90,6 +91,7 @@ private slots: void issueRestoreToView();
void issueRestoreToViewAll();
void issueVisitOnNexus();
+ void issueOpenInDownloadsFolder();
void issueCancel();
void issuePause();
void issueResume();
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 9761fee4..1a2934a5 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -911,6 +911,31 @@ void DownloadManager::visitOnNexus(int index) }
}
+void DownloadManager::openInDownloadsFolder(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"explorer", 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"explorer", ToWString(params).c_str(), nullptr, SW_SHOWNORMAL);
+ return;
+ }
+
+ ::ShellExecuteW(nullptr, L"explore", ToWString(QDir::toNativeSeparators(m_OutputDirectory)).c_str(), nullptr, nullptr, SW_SHOWNORMAL);
+ return;
+}
+
int DownloadManager::numTotalDownloads() const
{
diff --git a/src/downloadmanager.h b/src/downloadmanager.h index fa3764b7..514402ee 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -438,6 +438,8 @@ public slots: void visitOnNexus(int index);
+ void openInDownloadsFolder(int index);
+
void nxmDescriptionAvailable(QString gameName, int modID, QVariant userData, QVariant resultData, int requestID);
void nxmFilesAvailable(QString gameName, int modID, QVariant userData, QVariant resultData, int requestID);
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fc666a49..436d4d26 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4242,6 +4242,7 @@ void MainWindow::updateDownloadListDelegate() connect(ui->downloadView->itemDelegate(), SIGNAL(installDownload(int)), &m_OrganizerCore, SLOT(installDownload(int)));
connect(ui->downloadView->itemDelegate(), SIGNAL(queryInfo(int)), m_OrganizerCore.downloadManager(), SLOT(queryInfo(int)));
connect(ui->downloadView->itemDelegate(), SIGNAL(visitOnNexus(int)), m_OrganizerCore.downloadManager(), SLOT(visitOnNexus(int)));
+ connect(ui->downloadView->itemDelegate(), SIGNAL(openInDownloadsFolder(int)), m_OrganizerCore.downloadManager(), SLOT(openInDownloadsFolder(int)));
connect(ui->downloadView->itemDelegate(), SIGNAL(removeDownload(int, bool)), m_OrganizerCore.downloadManager(), SLOT(removeDownload(int, bool)));
connect(ui->downloadView->itemDelegate(), SIGNAL(restoreDownload(int)), m_OrganizerCore.downloadManager(), SLOT(restoreDownload(int)));
connect(ui->downloadView->itemDelegate(), SIGNAL(cancelDownload(int)), m_OrganizerCore.downloadManager(), SLOT(cancelDownload(int)));
|
