diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index 730803f6d..2ac531ec5 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -440,6 +440,54 @@ void DownloadManager::refreshList()
}
}
+void DownloadManager::queryDownloadListInfo()
+{
+ TimeThis tt("DownloadManager::queryDownloadListInfos()");
+
+ log::info("Retrieving data from every download (if possible)...");
+
+ int incompleteInfos = 0;
+
+ // Just go through all active downloads to query infos
+ for (size_t i = 0; i < m_ActiveDownloads.size(); i++) {
+ if (isInfoIncomplete(i)) {
+ incompleteInfos++;
+ }
+ }
+
+ if (incompleteInfos <= 5) {
+ // Fetch metadata for incomplete download infos
+ startDisableDirWatcher();
+ for (size_t i = 0; i < m_ActiveDownloads.size(); i++) {
+ if (isInfoIncomplete(i)) {
+ queryInfoMd5(i);
+ }
+ }
+ endDisableDirWatcher();
+ } else {
+
+ // Warn the user if the number of incomplete infos is over 5
+ QString message = tr("There are %1 incomplete download meta files.\n\n"
+ "Do you want to fetch all incomplete metadata?\n"
+ "API uses will be consumed, and Mod Organizer may stutter.");
+ message = message.arg(incompleteInfos);
+ if (QMessageBox::question(m_ParentWidget, tr("Incomplete Download Infos"), message,
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
+ // Fetch metadata for incomplete download infos
+ startDisableDirWatcher();
+ for (size_t i = 0; i < m_ActiveDownloads.size(); i++) {
+ if (isInfoIncomplete(i)) {
+ queryInfoMd5(i);
+ }
+ }
+ endDisableDirWatcher();
+ }
+ return;
+ }
+
+ log::info("Metadata has been retrieved successfully!");
+}
+
bool DownloadManager::addDownload(const QStringList& URLs, QString gameName, int modID,
int fileID, const ModRepositoryFileInfo* fileInfo)
{
diff --git a/src/downloadmanager.h b/src/downloadmanager.h
index 1e7a626ee..549ac29ae 100644
--- a/src/downloadmanager.h
+++ b/src/downloadmanager.h
@@ -402,6 +402,11 @@ class DownloadManager : public QObject
*/
void refreshList();
+ /**
+ * @brief Query infos for every download in the list
+ */
+ void queryDownloadListInfo();
+
public: // IDownloadManager interface:
int startDownloadURLs(const QStringList& urls);
int startDownloadNexusFile(int modID, int fileID);
diff --git a/src/downloadstab.cpp b/src/downloadstab.cpp
index bf3ea9ad0..25dfa8e48 100644
--- a/src/downloadstab.cpp
+++ b/src/downloadstab.cpp
@@ -5,8 +5,9 @@
#include "ui_mainwindow.h"
DownloadsTab::DownloadsTab(OrganizerCore& core, Ui::MainWindow* mwui)
- : m_core(core), ui{mwui->btnRefreshDownloads, mwui->downloadView,
- mwui->showHiddenBox, mwui->downloadFilterEdit}
+ : m_core(core),
+ ui{mwui->btnRefreshDownloads, mwui->btnQueryDownloadsInfo, mwui->downloadView,
+ mwui->showHiddenBox, mwui->downloadFilterEdit}
{
DownloadList* sourceModel = new DownloadList(m_core, ui.list);
@@ -26,6 +27,9 @@ DownloadsTab::DownloadsTab(OrganizerCore& core, Ui::MainWindow* mwui)
connect(ui.refresh, &QPushButton::clicked, [&] {
refresh();
});
+ connect(ui.queryInfos, &QPushButton::clicked, [&] {
+ queryInfos();
+ });
connect(ui.list, SIGNAL(installDownload(int)), &m_core, SLOT(installDownload(int)));
connect(ui.list, SIGNAL(queryInfo(int)), m_core.downloadManager(),
SLOT(queryInfo(int)));
@@ -80,6 +84,11 @@ void DownloadsTab::refresh()
m_core.downloadManager()->refreshList();
}
+void DownloadsTab::queryInfos()
+{
+ m_core.downloadManager()->queryDownloadListInfo();
+}
+
void DownloadsTab::resumeDownload(int downloadIndex)
{
m_core.loggedInAction(ui.list, [this, downloadIndex] {
diff --git a/src/downloadstab.h b/src/downloadstab.h
index f0b85d918..1676ec761 100644
--- a/src/downloadstab.h
+++ b/src/downloadstab.h
@@ -23,6 +23,7 @@ class DownloadsTab : public QObject
struct DownloadsTabUi
{
QPushButton* refresh;
+ QPushButton* queryInfos;
DownloadListView* list;
QCheckBox* showHidden;
QLineEdit* filter;
@@ -33,6 +34,12 @@ class DownloadsTab : public QObject
MOBase::FilterWidget m_filter;
void refresh();
+
+ /**
+ * @brief Handle click on the "Query infos" button
+ **/
+ void queryInfos();
+
void resumeDownload(int downloadIndex);
};
diff --git a/src/mainwindow.ui b/src/mainwindow.ui
index c2ce37b32..227486cf0 100644
--- a/src/mainwindow.ui
+++ b/src/mainwindow.ui
@@ -1326,6 +1326,26 @@
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::ContextMenuPolicy::DefaultContextMenu
+
+
+ Query Metadata
+
+
+
+ :/MO/gui/resources/system-search.png:/MO/gui/resources/system-search.png
+
+
+
-