fix: simplify abort handling and add missing emits

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow
2022-07-28 15:58:04 -03:00
parent 4b0ceea894
commit 6541570969
16 changed files with 85 additions and 16 deletions

View File

@ -1656,6 +1656,10 @@ void MainWindow::runModalTask(Task *task)
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
}
});
connect(task, &Task::aborted, [this]
{
CustomMessageBox::selectable(this, tr("Task aborted"), tr("The task has been aborted by the user."), QMessageBox::Information)->show();
});
ProgressDialog loadDialog(this);
loadDialog.setSkipButton(true, tr("Abort"));
loadDialog.execWithTask(task);

View File

@ -43,8 +43,7 @@ void ProgressDialog::setSkipButton(bool present, QString label)
void ProgressDialog::on_skipButton_clicked(bool checked)
{
Q_UNUSED(checked);
if (task->abort())
QDialog::reject();
task->abort();
}
ProgressDialog::~ProgressDialog()
@ -81,7 +80,7 @@ int ProgressDialog::execWithTask(Task* task)
connect(task, &Task::stepStatus, this, &ProgressDialog::changeStatus);
connect(task, &Task::progress, this, &ProgressDialog::changeProgress);
connect(task, &Task::aborted, [this] { onTaskFailed(tr("Aborted by user")); });
connect(task, &Task::aborted, [this] { QDialog::reject(); });
m_is_multi_step = task->isMultiStep();
if (!m_is_multi_step) {

View File

@ -146,6 +146,7 @@ void Page::openedImpl()
{
connect(ftbFetchTask.get(), &PackFetchTask::finished, this, &Page::ftbPackDataDownloadSuccessfully);
connect(ftbFetchTask.get(), &PackFetchTask::failed, this, &Page::ftbPackDataDownloadFailed);
connect(ftbFetchTask.get(), &PackFetchTask::aborted, this, &Page::ftbPackDataDownloadAborted);
connect(ftbFetchTask.get(), &PackFetchTask::privateFileDownloadFinished, this, &Page::ftbPrivatePackDataDownloadSuccessfully);
connect(ftbFetchTask.get(), &PackFetchTask::privateFileDownloadFailed, this, &Page::ftbPrivatePackDataDownloadFailed);
@ -220,7 +221,12 @@ void Page::ftbPackDataDownloadSuccessfully(ModpackList publicPacks, ModpackList
void Page::ftbPackDataDownloadFailed(QString reason)
{
//TODO: Display the error
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
}
void Page::ftbPackDataDownloadAborted()
{
CustomMessageBox::selectable(this, tr("Task aborted"), tr("The task has been aborted by the user."), QMessageBox::Information)->show();
}
void Page::ftbPrivatePackDataDownloadSuccessfully(Modpack pack)

View File

@ -95,6 +95,7 @@ private:
private slots:
void ftbPackDataDownloadSuccessfully(ModpackList publicPacks, ModpackList thirdPartyPacks);
void ftbPackDataDownloadFailed(QString reason);
void ftbPackDataDownloadAborted();
void ftbPrivatePackDataDownloadSuccessfully(Modpack pack);
void ftbPrivatePackDataDownloadFailed(QString reason, QString packCode);