summaryrefslogtreecommitdiffstats
path: root/application/widgets
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-03-19 23:58:54 +0100
committerPetr Mrázek <peterix@gmail.com>2017-04-07 00:20:02 +0200
commitf557c1367994a61935fa0e8d0b1b67688d2692d0 (patch)
tree8eff9809b158cd1e65ba0eadc2b1c140b78c4e8b /application/widgets
parent2660418d58efb33cd3a0ab8ed9d48c359c076905 (diff)
downloadMultiMC-f557c1367994a61935fa0e8d0b1b67688d2692d0.tar
MultiMC-f557c1367994a61935fa0e8d0b1b67688d2692d0.tar.gz
MultiMC-f557c1367994a61935fa0e8d0b1b67688d2692d0.tar.lz
MultiMC-f557c1367994a61935fa0e8d0b1b67688d2692d0.tar.xz
MultiMC-f557c1367994a61935fa0e8d0b1b67688d2692d0.zip
NOISSUE stuff and things happened. Maybe.
Diffstat (limited to 'application/widgets')
-rw-r--r--application/widgets/VersionSelectWidget.cpp44
-rw-r--r--application/widgets/VersionSelectWidget.h5
2 files changed, 20 insertions, 29 deletions
diff --git a/application/widgets/VersionSelectWidget.cpp b/application/widgets/VersionSelectWidget.cpp
index 18284a91..a4eb428b 100644
--- a/application/widgets/VersionSelectWidget.cpp
+++ b/application/widgets/VersionSelectWidget.cpp
@@ -80,52 +80,42 @@ void VersionSelectWidget::initialize()
void VersionSelectWidget::closeEvent(QCloseEvent * event)
{
- if(loadTask)
- {
- loadTask->abort();
- loadTask->deleteLater();
- loadTask = nullptr;
- }
QWidget::closeEvent(event);
}
void VersionSelectWidget::loadList()
{
- if(loadTask)
+ auto newTask = m_vlist->getLoadTask();
+ if (!newTask)
{
return;
}
- loadTask = m_vlist->getLoadTask();
- if (!loadTask)
+ loadTask = newTask.get();
+ connect(loadTask, &Task::succeeded, this, &VersionSelectWidget::onTaskSucceeded);
+ connect(loadTask, &Task::failed, this, &VersionSelectWidget::onTaskFailed);
+ connect(loadTask, &Task::progress, this, &VersionSelectWidget::changeProgress);
+ if(!loadTask->isRunning())
{
- return;
+ loadTask->start();
}
- connect(loadTask, &Task::finished, this, &VersionSelectWidget::onTaskFinished);
- connect(loadTask, &Task::progress, this, &VersionSelectWidget::changeProgress);
- loadTask->start();
sneakyProgressBar->setHidden(false);
}
-void VersionSelectWidget::onTaskFinished()
+void VersionSelectWidget::onTaskSucceeded()
{
- if (!loadTask->successful())
- {
- CustomMessageBox::selectable(this, tr("Error"),
- tr("List update failed:\n%1").arg(loadTask->failReason()),
- QMessageBox::Warning)->show();
- if (m_proxyModel->rowCount() == 0)
- {
- listView->setEmptyMode(VersionListView::ErrorString);
- }
- }
- else if (m_proxyModel->rowCount() == 0)
+ if (m_proxyModel->rowCount() == 0)
{
listView->setEmptyMode(VersionListView::String);
}
sneakyProgressBar->setHidden(true);
- loadTask->deleteLater();
- loadTask = nullptr;
preselect();
+ loadTask = nullptr;
+}
+
+void VersionSelectWidget::onTaskFailed(const QString& reason)
+{
+ CustomMessageBox::selectable(this, tr("Error"), tr("List update failed:\n%1").arg(reason), QMessageBox::Warning)->show();
+ onTaskSucceeded();
}
void VersionSelectWidget::changeProgress(qint64 current, qint64 total)
diff --git a/application/widgets/VersionSelectWidget.h b/application/widgets/VersionSelectWidget.h
index 0fc9f2e6..66e512ac 100644
--- a/application/widgets/VersionSelectWidget.h
+++ b/application/widgets/VersionSelectWidget.h
@@ -55,7 +55,8 @@ protected:
virtual void closeEvent ( QCloseEvent* );
private slots:
- void onTaskFinished();
+ void onTaskSucceeded();
+ void onTaskFailed(const QString &reason);
void changeProgress(qint64 current, qint64 total);
void currentRowChanged(const QModelIndex &current, const QModelIndex &);
@@ -66,7 +67,7 @@ private:
BaseVersionList *m_vlist = nullptr;
VersionProxyModel *m_proxyModel = nullptr;
int resizeOnColumn = 0;
- Task * loadTask = nullptr;
+ Task * loadTask;
bool preselectedAlready = false;
private: