aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/ui')
-rw-r--r--launcher/ui/dialogs/NewInstanceDialog.cpp8
-rw-r--r--launcher/ui/dialogs/ProgressDialog.cpp5
-rw-r--r--launcher/ui/pages/modplatform/ftb/FtbListModel.cpp11
-rw-r--r--launcher/ui/pages/modplatform/ftb/FtbListModel.h6
-rw-r--r--launcher/ui/pages/modplatform/ftb/FtbPage.cpp8
-rw-r--r--launcher/ui/pages/modplatform/ftb/FtbPage.h1
6 files changed, 36 insertions, 3 deletions
diff --git a/launcher/ui/dialogs/NewInstanceDialog.cpp b/launcher/ui/dialogs/NewInstanceDialog.cpp
index d203795a..df182f09 100644
--- a/launcher/ui/dialogs/NewInstanceDialog.cpp
+++ b/launcher/ui/dialogs/NewInstanceDialog.cpp
@@ -139,6 +139,10 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, const QString
void NewInstanceDialog::reject()
{
APPLICATION->settings()->set("NewInstanceGeometry", saveGeometry().toBase64());
+
+ // This is just so that the pages get the close() call and can react to it, if needed.
+ m_container->prepareToClose();
+
QDialog::reject();
}
@@ -146,6 +150,10 @@ void NewInstanceDialog::accept()
{
APPLICATION->settings()->set("NewInstanceGeometry", saveGeometry().toBase64());
importIconNow();
+
+ // This is just so that the pages get the close() call and can react to it, if needed.
+ m_container->prepareToClose();
+
QDialog::accept();
}
diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp
index 258a32e4..68dd4d17 100644
--- a/launcher/ui/dialogs/ProgressDialog.cpp
+++ b/launcher/ui/dialogs/ProgressDialog.cpp
@@ -25,6 +25,7 @@ ProgressDialog::ProgressDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Pr
{
ui->setupUi(this);
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
+ setAttribute(Qt::WidgetAttribute::WA_QuitOnClose, true);
setSkipButton(false);
changeProgress(0, 100);
}
@@ -67,7 +68,7 @@ int ProgressDialog::execWithTask(Task* task)
return QDialog::DialogCode::Accepted;
}
- QDialog::DialogCode result;
+ QDialog::DialogCode result {};
if (handleImmediateResult(result)) {
return result;
}
@@ -80,7 +81,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] { QDialog::reject(); });
+ connect(task, &Task::aborted, this, &ProgressDialog::hide);
connect(task, &Task::abortStatusChanged, ui->skipButton, &QPushButton::setEnabled);
m_is_multi_step = task->isMultiStep();
diff --git a/launcher/ui/pages/modplatform/ftb/FtbListModel.cpp b/launcher/ui/pages/modplatform/ftb/FtbListModel.cpp
index ad15b6e6..3a149944 100644
--- a/launcher/ui/pages/modplatform/ftb/FtbListModel.cpp
+++ b/launcher/ui/pages/modplatform/ftb/FtbListModel.cpp
@@ -103,6 +103,8 @@ void ListModel::getLogo(const QString &logo, const QString &logoUrl, LogoCallbac
void ListModel::request()
{
+ m_aborted = false;
+
beginResetModel();
modpacks.clear();
endResetModel();
@@ -117,6 +119,12 @@ void ListModel::request()
QObject::connect(netJob, &NetJob::failed, this, &ListModel::requestFailed);
}
+void ListModel::abortRequest()
+{
+ m_aborted = jobPtr->abort();
+ jobPtr.reset();
+}
+
void ListModel::requestFinished()
{
jobPtr.reset();
@@ -162,6 +170,9 @@ void ListModel::requestPack()
void ListModel::packRequestFinished()
{
+ if (!jobPtr || m_aborted)
+ return;
+
jobPtr.reset();
remainingPacks.removeOne(currentPack);
diff --git a/launcher/ui/pages/modplatform/ftb/FtbListModel.h b/launcher/ui/pages/modplatform/ftb/FtbListModel.h
index 314cb789..d7a120f0 100644
--- a/launcher/ui/pages/modplatform/ftb/FtbListModel.h
+++ b/launcher/ui/pages/modplatform/ftb/FtbListModel.h
@@ -47,9 +47,13 @@ public:
QVariant data(const QModelIndex &index, int role) const override;
void request();
+ void abortRequest();
void getLogo(const QString &logo, const QString &logoUrl, LogoCallback callback);
+ [[nodiscard]] bool isMakingRequest() const { return jobPtr.get(); }
+ [[nodiscard]] bool wasAborted() const { return m_aborted; }
+
private slots:
void requestFinished();
void requestFailed(QString reason);
@@ -65,6 +69,8 @@ private:
void requestLogo(QString file, QString url);
private:
+ bool m_aborted = false;
+
QList<ModpacksCH::Modpack> modpacks;
LogoMap m_logoMap;
diff --git a/launcher/ui/pages/modplatform/ftb/FtbPage.cpp b/launcher/ui/pages/modplatform/ftb/FtbPage.cpp
index 8975d74e..34a3d1c0 100644
--- a/launcher/ui/pages/modplatform/ftb/FtbPage.cpp
+++ b/launcher/ui/pages/modplatform/ftb/FtbPage.cpp
@@ -105,7 +105,7 @@ void FtbPage::retranslate()
void FtbPage::openedImpl()
{
- if(!initialised)
+ if(!initialised || listModel->wasAborted())
{
listModel->request();
initialised = true;
@@ -114,6 +114,12 @@ void FtbPage::openedImpl()
suggestCurrent();
}
+void FtbPage::closedImpl()
+{
+ if (listModel->isMakingRequest())
+ listModel->abortRequest();
+}
+
void FtbPage::suggestCurrent()
{
if(!isOpened)
diff --git a/launcher/ui/pages/modplatform/ftb/FtbPage.h b/launcher/ui/pages/modplatform/ftb/FtbPage.h
index 90c8e7fd..631ae7f5 100644
--- a/launcher/ui/pages/modplatform/ftb/FtbPage.h
+++ b/launcher/ui/pages/modplatform/ftb/FtbPage.h
@@ -78,6 +78,7 @@ public:
void retranslate() override;
void openedImpl() override;
+ void closedImpl() override;
bool eventFilter(QObject * watched, QEvent * event) override;