Backport new NetJob failure dialog from Octol1ttle's libcurl PR

Co-authored-by: Octol1ttle <l1ttleofficial@outlook.com>
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad 2025-11-23 17:23:36 +00:00 committed by Octol1ttle
parent c16a25faef
commit e6d7e5cdae
No known key found for this signature in database
GPG key ID: B77C34313AEE1FFF
5 changed files with 221 additions and 11 deletions

View file

@ -42,7 +42,7 @@
#if defined(LAUNCHER_APPLICATION)
#include "Application.h"
#include "settings/SettingsObject.h"
#include "ui/dialogs/CustomMessageBox.h"
#include "ui/dialogs/NetworkJobFailedDialog.h"
#endif
NetJob::NetJob(QString job_name, QNetworkAccessManager* network, int max_concurrent) : ConcurrentTask(job_name), m_network(network)
@ -164,23 +164,23 @@ void NetJob::emitFailed(QString reason)
if (APPLICATION_DYN && m_ask_retry && m_manual_try < APPLICATION->settings()->get("NumberOfManualRetries").toInt() && isOnline()) {
m_manual_try++;
auto response = CustomMessageBox::selectable(nullptr, "Confirm retry",
"The tasks failed.\n"
"Failed urls\n" +
getFailedFiles().join("\n\t") +
".\n"
"If this continues to happen please check the logs of the application.\n"
"Do you want to retry?",
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
->exec();
auto failed = getFailedActions();
auto dialog = NetworkJobFailedDialog(objectName(), m_try, m_done.size(), failed.size(), nullptr);
if (response == QMessageBox::Yes) {
int i = 0;
for (const auto& request : failed) {
dialog.addFailedRequest(i, request->url(), request->errorString());
++i;
}
if (dialog.exec() == QDialog::Accepted) {
m_try = 0;
executeNextSubTask();
return;
}
}
#endif
ConcurrentTask::emitFailed(reason);
}