update manager

This commit is contained in:
fourtf 2018-06-22 10:22:25 +02:00
parent 5155039293
commit e534bdfeca

View file

@ -60,6 +60,7 @@ void UpdateManager::installUpdates()
"Failed while trying to download the update."); "Failed while trying to download the update.");
box->setAttribute(Qt::WA_DeleteOnClose); box->setAttribute(Qt::WA_DeleteOnClose);
box->show(); box->show();
box->raise();
}); });
return true; return true;
@ -109,6 +110,7 @@ void UpdateManager::checkForUpdates()
"temporarily or everything is broken."); "temporarily or everything is broken.");
box->setAttribute(Qt::WA_DeleteOnClose); box->setAttribute(Qt::WA_DeleteOnClose);
box->show(); box->show();
box->raise();
}); });
return; return;
} }
@ -118,16 +120,19 @@ void UpdateManager::checkForUpdates()
if (this->currentVersion_ != this->onlineVersion_) { if (this->currentVersion_ != this->onlineVersion_) {
this->setStatus_(UpdateAvailable); this->setStatus_(UpdateAvailable);
util::postToThread([this] {
QMessageBox *box = new QMessageBox(QMessageBox::Information, "Chatterino Update", QMessageBox *box =
new QMessageBox(QMessageBox::Information, "Chatterino Update",
"An update for chatterino is available.\n\nDo you " "An update for chatterino is available.\n\nDo you "
"want to download and install it?", "want to download and install it?",
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
box->setAttribute(Qt::WA_DeleteOnClose); box->setAttribute(Qt::WA_DeleteOnClose);
box->show(); box->show();
box->raise();
if (box->exec() == QMessageBox::Yes) { if (box->exec() == QMessageBox::Yes) {
util::postToThread([this] { this->installUpdates(); }); this->installUpdates();
} }
});
} else { } else {
this->setStatus_(NoUpdateAvailable); this->setStatus_(NoUpdateAvailable);
} }
@ -146,7 +151,7 @@ void UpdateManager::setStatus_(UpdateStatus status)
{ {
if (this->status_ != status) { if (this->status_ != status) {
this->status_ = status; this->status_ = status;
this->statusUpdated.invoke(status); util::postToThread([this, status] { this->statusUpdated.invoke(status); });
} }
} }