fix: abort search if we're already trying to download a pack
Meaning we don't have to wait for the searches to finish in the background to finally start the modpack download, when we have already selected it -_- Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
83654a193e
commit
f26be00571
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -47,9 +47,12 @@ 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(); }
|
||||
|
||||
private slots:
|
||||
void requestFinished();
|
||||
void requestFailed(QString reason);
|
||||
@ -65,6 +68,8 @@ private:
|
||||
void requestLogo(QString file, QString url);
|
||||
|
||||
private:
|
||||
bool m_aborted = false;
|
||||
|
||||
QList<ModpacksCH::Modpack> modpacks;
|
||||
LogoMap m_logoMap;
|
||||
|
||||
|
@ -114,6 +114,12 @@ void FtbPage::openedImpl()
|
||||
suggestCurrent();
|
||||
}
|
||||
|
||||
void FtbPage::closedImpl()
|
||||
{
|
||||
if (listModel->isMakingRequest())
|
||||
listModel->abortRequest();
|
||||
}
|
||||
|
||||
void FtbPage::suggestCurrent()
|
||||
{
|
||||
if(!isOpened)
|
||||
|
@ -78,6 +78,7 @@ public:
|
||||
void retranslate() override;
|
||||
|
||||
void openedImpl() override;
|
||||
void closedImpl() override;
|
||||
|
||||
bool eventFilter(QObject * watched, QEvent * event) override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user