summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-12-07 03:57:40 +0100
committerPetr Mrázek <peterix@gmail.com>2013-12-07 03:57:40 +0100
commit220e07aef4a34dca9f31ae0c5bb994e5c594125d (patch)
tree70821c6dbe7e6c2f66f231dcb1bad62a763638d7 /gui
parent858916b951e92127c22503826b746d1e70c433f6 (diff)
parent7a6705030c36b2d6b94da1acd5bdf2311e4efeb7 (diff)
downloadMultiMC-220e07aef4a34dca9f31ae0c5bb994e5c594125d.tar
MultiMC-220e07aef4a34dca9f31ae0c5bb994e5c594125d.tar.gz
MultiMC-220e07aef4a34dca9f31ae0c5bb994e5c594125d.tar.lz
MultiMC-220e07aef4a34dca9f31ae0c5bb994e5c594125d.tar.xz
MultiMC-220e07aef4a34dca9f31ae0c5bb994e5c594125d.zip
Merge branch 'feature_updater' of github.com:MultiMC/MultiMC5 into feature_updater
Diffstat (limited to 'gui')
-rw-r--r--gui/MainWindow.cpp27
-rw-r--r--gui/MainWindow.h5
-rw-r--r--gui/dialogs/UpdateDialog.ui7
3 files changed, 31 insertions, 8 deletions
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp
index 618884ef..7ea5c291 100644
--- a/gui/MainWindow.cpp
+++ b/gui/MainWindow.cpp
@@ -439,20 +439,31 @@ void MainWindow::updateAvailable(QString repo, QString versionName, int versionI
QLOG_INFO() << "Update will be installed later.";
break;
case UPDATE_NOW:
- {
- QLOG_INFO() << "Installing update.";
- ProgressDialog updateDlg(this);
- DownloadUpdateTask updateTask(repo, versionId, &updateDlg);
- updateDlg.exec(&updateTask);
- }
+ downloadUpdates(repo, versionId);
break;
case UPDATE_ONEXIT:
- // TODO: Implement installing updates on exit.
- QLOG_INFO() << "Installing on exit is not implemented yet.";
+ downloadUpdates(repo, versionId, true);
break;
}
}
+void MainWindow::downloadUpdates(QString repo, int versionId, bool installOnExit)
+{
+ QLOG_INFO() << "Downloading updates.";
+ // TODO: If the user chooses to update on exit, we should download updates in the background.
+ // Doing so is a bit complicated, because we'd have to make sure it finished downloading before actually exiting MultiMC.
+ ProgressDialog updateDlg(this);
+ DownloadUpdateTask updateTask(repo, versionId, &updateDlg);
+ // If the task succeeds, install the updates.
+ if (updateDlg.exec(&updateTask))
+ {
+ if (installOnExit)
+ MMC->setUpdateOnExit(updateTask.updateFilesDir());
+ else
+ MMC->installUpdates(updateTask.updateFilesDir());
+ }
+}
+
void MainWindow::onCatToggled(bool state)
{
setCatBackground(state);
diff --git a/gui/MainWindow.h b/gui/MainWindow.h
index 1f498eca..b99c54ee 100644
--- a/gui/MainWindow.h
+++ b/gui/MainWindow.h
@@ -168,6 +168,11 @@ slots:
void changeActiveAccount();
void repopulateAccountsMenu();
+
+ /*!
+ * Runs the DownloadUpdateTask and installs updates.
+ */
+ void downloadUpdates(QString repo, int versionId, bool installOnExit=false);
protected:
bool eventFilter(QObject *obj, QEvent *ev);
diff --git a/gui/dialogs/UpdateDialog.ui b/gui/dialogs/UpdateDialog.ui
index f2361bd3..1fe65e62 100644
--- a/gui/dialogs/UpdateDialog.ui
+++ b/gui/dialogs/UpdateDialog.ui
@@ -42,6 +42,13 @@
</widget>
</item>
<item>
+ <widget class="QPushButton" name="btnUpdateOnExit">
+ <property name="text">
+ <string>Update after MultiMC closes</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QPushButton" name="btnUpdateLater">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">