mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 05:07:46 +02:00
fix: cover both usages of the download dialog
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
@ -85,9 +85,9 @@ void ResourcePackPage::downloadResourcePacks()
|
||||
return; // this is a null instance or a legacy instance
|
||||
|
||||
m_downloadDialog = new ResourceDownload::ResourcePackDownloadDialog(this, m_model, m_instance);
|
||||
m_downloadDialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(this, &QObject::destroyed, m_downloadDialog, &QDialog::close);
|
||||
connect(m_downloadDialog, &QDialog::finished, this, &ResourcePackPage::downloadDialogFinished);
|
||||
|
||||
m_downloadDialog->open();
|
||||
}
|
||||
|
||||
@ -125,6 +125,8 @@ void ResourcePackPage::downloadDialogFinished(int result)
|
||||
|
||||
m_model->update();
|
||||
}
|
||||
if (m_downloadDialog)
|
||||
m_downloadDialog->deleteLater();
|
||||
}
|
||||
|
||||
void ResourcePackPage::updateResourcePacks()
|
||||
@ -247,36 +249,10 @@ void ResourcePackPage::changeResourcePackVersion()
|
||||
if (resource.metadata() == nullptr)
|
||||
return;
|
||||
|
||||
auto mdownload = new ResourceDownload::ResourcePackDownloadDialog(this, m_model, m_instance);
|
||||
mdownload->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(this, &QObject::destroyed, mdownload, &QDialog::close);
|
||||
mdownload->setResourceMetadata(resource.metadata());
|
||||
if (mdownload->exec()) {
|
||||
auto tasks = new ConcurrentTask("Download Resource Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
|
||||
connect(tasks, &Task::failed, [this, tasks](QString reason) {
|
||||
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
||||
tasks->deleteLater();
|
||||
});
|
||||
connect(tasks, &Task::aborted, [this, tasks]() {
|
||||
CustomMessageBox::selectable(this, tr("Aborted"), tr("Download stopped by user."), QMessageBox::Information)->show();
|
||||
tasks->deleteLater();
|
||||
});
|
||||
connect(tasks, &Task::succeeded, [this, tasks]() {
|
||||
QStringList warnings = tasks->warnings();
|
||||
if (warnings.count())
|
||||
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
|
||||
m_downloadDialog = new ResourceDownload::ResourcePackDownloadDialog(this, m_model, m_instance);
|
||||
connect(this, &QObject::destroyed, m_downloadDialog, &QDialog::close);
|
||||
connect(m_downloadDialog, &QDialog::finished, this, &ResourcePackPage::downloadDialogFinished);
|
||||
|
||||
tasks->deleteLater();
|
||||
});
|
||||
|
||||
for (auto& task : mdownload->getTasks()) {
|
||||
tasks->addTask(task);
|
||||
}
|
||||
|
||||
ProgressDialog loadDialog(this);
|
||||
loadDialog.setSkipButton(true, tr("Abort"));
|
||||
loadDialog.execWithTask(tasks);
|
||||
|
||||
m_model->update();
|
||||
}
|
||||
m_downloadDialog->setResourceMetadata(resource.metadata());
|
||||
m_downloadDialog->open();
|
||||
}
|
||||
|
Reference in New Issue
Block a user