From 814a4b9455057744e3ac5fe86b1059f1f3100872 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Tue, 27 Jun 2023 22:34:34 +0300 Subject: [PATCH] Partial fix for displaying download progress of mods --- launcher/modManager/cdownloadmanager_moc.cpp | 6 +++--- launcher/modManager/cmodlistview_moc.cpp | 4 ++-- launcher/modManager/cmodmanager.cpp | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/launcher/modManager/cdownloadmanager_moc.cpp b/launcher/modManager/cdownloadmanager_moc.cpp index 80ea28cc0..a190bf757 100644 --- a/launcher/modManager/cdownloadmanager_moc.cpp +++ b/launcher/modManager/cdownloadmanager_moc.cpp @@ -62,10 +62,10 @@ CDownloadManager::FileEntry & CDownloadManager::getEntry(QNetworkReply * reply) void CDownloadManager::downloadFinished(QNetworkReply * reply) { FileEntry & file = getEntry(reply); - + QVariant possibleRedirectUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); QUrl qurl = possibleRedirectUrl.toUrl(); - + if(possibleRedirectUrl.isValid()) { QString filename; @@ -135,7 +135,7 @@ void CDownloadManager::downloadProgressChanged(qint64 bytesReceived, qint64 byte quint64 total = 0; for(auto & entry : currentDownloads) - total += entry.totalSize > 0 ? entry.totalSize : 0; + total += entry.totalSize > 0 ? entry.totalSize : entry.bytesReceived; quint64 received = 0; for(auto & entry : currentDownloads) diff --git a/launcher/modManager/cmodlistview_moc.cpp b/launcher/modManager/cmodlistview_moc.cpp index b3fa36236..16e852bca 100644 --- a/launcher/modManager/cmodlistview_moc.cpp +++ b/launcher/modManager/cmodlistview_moc.cpp @@ -603,8 +603,8 @@ void CModListView::downloadFile(QString file, QString url, QString description) void CModListView::downloadProgress(qint64 current, qint64 max) { // display progress, in kilobytes - ui->progressBar->setValue(current / 1024); ui->progressBar->setMaximum(max / 1024); + ui->progressBar->setValue(current / 1024); } void CModListView::downloadFinished(QStringList savedFiles, QStringList failedFiles, QStringList errors) @@ -680,7 +680,7 @@ void CModListView::installFiles(QStringList files) auto modjson = repodata[key].toMap().value("mod"); if(!modjson.isNull()) { - downloadFile(key + ".json", modjson.toString(), "mod json"); + downloadFile(key + ".json", modjson.toString(), "repository index"); } } } diff --git a/launcher/modManager/cmodmanager.cpp b/launcher/modManager/cmodmanager.cpp index 93f5fe69f..d76452ada 100644 --- a/launcher/modManager/cmodmanager.cpp +++ b/launcher/modManager/cmodmanager.cpp @@ -248,7 +248,6 @@ bool CModManager::doEnableMod(QString mod, bool on) modList->setModSettings(modSettings["activeMods"]); modList->modChanged(mod); - JsonUtils::JsonToFile(settingsPath(), modSettings); return true;