Force Oracle run on new install/update (#3497)

* Force Oracle run on new install/update

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* Add settings option to disable such a check

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>
This commit is contained in:
Zach H 2019-01-14 01:11:05 -05:00 committed by GitHub
parent 273d5d89b7
commit 41bfbf2e83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 75 additions and 5 deletions

View file

@ -317,9 +317,9 @@ void MainWindow::actAbout()
void MainWindow::actTips()
{
if (tip != NULL) {
if (tip != nullptr) {
delete tip;
tip = NULL;
tip = nullptr;
}
tip = new DlgTipOfTheDay();
if (tip->successfulInit) {
@ -828,13 +828,30 @@ MainWindow::MainWindow(QWidget *parent)
if (tip->successfulInit && settingsCache->getShowTipsOnStartup() && tip->newTipsAvailable) {
tip->show();
}
// Only run the check updater if the user wants it (defaults to on)
if (settingsCache->getNotifyAboutNewVersion()) {
auto versionUpdater = new MainUpdateHelper();
connect(versionUpdater, SIGNAL(newVersionDetected(QString)), this, SLOT(alertForcedOracleRun(QString)));
QtConcurrent::run(versionUpdater, &MainUpdateHelper::testForNewVersion);
}
}
void MainWindow::alertForcedOracleRun(const QString &newVersion)
{
settingsCache->setClientVersion(newVersion);
QMessageBox::information(this, tr("New Version"),
tr("Congratulations on updating to Cockatrice %1!\n"
"Oracle will now launch to update your card database.")
.arg(newVersion));
actCheckCardUpdates();
}
MainWindow::~MainWindow()
{
if (tip != NULL) {
if (tip != nullptr) {
delete tip;
tip = NULL;
tip = nullptr;
}
if (trayIcon) {
trayIcon->hide();
@ -1271,3 +1288,10 @@ void MainWindow::promptForgotPasswordReset()
dlg.getPlayerName(), dlg.getToken(), dlg.getPassword());
}
}
void MainUpdateHelper::testForNewVersion()
{
if (settingsCache->getClientVersion() != VERSION_STRING) {
emit newVersionDetected(VERSION_STRING);
}
}