diff options
author | Petr Mrázek <peterix@gmail.com> | 2017-04-07 00:27:24 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2017-04-07 00:27:24 +0200 |
commit | 795889d934e8f4ebe89be1a49a3417fd98e89be1 (patch) | |
tree | c5b0d30d425003c4b88e84a2908e63eb5ed797b9 /application/widgets/VersionSelectWidget.cpp | |
parent | 160b5033a79e6b5ee9f3e2a001b96c677f41ddcb (diff) | |
parent | 8e58d61150b0bdbe9eb91065d36342f3004fe97b (diff) | |
download | PrismLauncher-795889d934e8f4ebe89be1a49a3417fd98e89be1.tar.gz PrismLauncher-795889d934e8f4ebe89be1a49a3417fd98e89be1.tar.bz2 PrismLauncher-795889d934e8f4ebe89be1a49a3417fd98e89be1.zip |
Merge branch 'feature/meta' into develop
Diffstat (limited to 'application/widgets/VersionSelectWidget.cpp')
-rw-r--r-- | application/widgets/VersionSelectWidget.cpp | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/application/widgets/VersionSelectWidget.cpp b/application/widgets/VersionSelectWidget.cpp index 18284a91..1696d9d1 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) @@ -178,4 +168,4 @@ void VersionSelectWidget::setExactFilter(BaseVersionList::ModelRoles role, QStri void VersionSelectWidget::setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter) { m_proxyModel->setFilter(role, filter, false); -}
\ No newline at end of file +} |