Merge remote-tracking branch 'upstream/develop' into data-packs

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad
2025-04-29 09:15:11 +01:00
279 changed files with 9562 additions and 2103 deletions

View File

@@ -90,8 +90,15 @@ void TexturePackPage::downloadTexturePacks()
if (m_instance->typeName() != "Minecraft")
return; // this is a null instance or a legacy instance
ResourceDownload::TexturePackDownloadDialog mdownload(this, m_model, m_instance);
if (mdownload.exec()) {
m_downloadDialog = new ResourceDownload::TexturePackDownloadDialog(this, m_model, m_instance);
connect(this, &QObject::destroyed, m_downloadDialog, &QDialog::close);
connect(m_downloadDialog, &QDialog::finished, this, &TexturePackPage::downloadDialogFinished);
m_downloadDialog->open();
}
void TexturePackPage::downloadDialogFinished(int result)
{
if (result) {
auto tasks = new ConcurrentTask("Download Texture Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
connect(tasks, &Task::failed, [this, tasks](QString reason) {
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
@@ -109,8 +116,12 @@ void TexturePackPage::downloadTexturePacks()
tasks->deleteLater();
});
for (auto& task : mdownload.getTasks()) {
tasks->addTask(task);
if (m_downloadDialog) {
for (auto& task : m_downloadDialog->getTasks()) {
tasks->addTask(task);
}
} else {
qWarning() << "ResourceDownloadDialog vanished before we could collect tasks!";
}
ProgressDialog loadDialog(this);
@@ -119,6 +130,8 @@ void TexturePackPage::downloadTexturePacks()
m_model->update();
}
if (m_downloadDialog)
m_downloadDialog->deleteLater();
}
void TexturePackPage::updateTexturePacks()
@@ -241,34 +254,10 @@ void TexturePackPage::changeTexturePackVersion()
if (resource.metadata() == nullptr)
return;
ResourceDownload::TexturePackDownloadDialog mdownload(this, m_model, m_instance);
mdownload.setResourceMetadata(resource.metadata());
if (mdownload.exec()) {
auto tasks = new ConcurrentTask("Download Texture 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::TexturePackDownloadDialog(this, m_model, m_instance);
connect(this, &QObject::destroyed, m_downloadDialog, &QDialog::close);
connect(m_downloadDialog, &QDialog::finished, this, &TexturePackPage::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();
}