diff options
author | Andrew <forkk@forkk.net> | 2013-12-06 12:59:58 -0600 |
---|---|---|
committer | Andrew <forkk@forkk.net> | 2013-12-06 12:59:58 -0600 |
commit | 6ac94ddcb6f64ffae3948bed778bccc33a92f0fd (patch) | |
tree | 31cb30a051772bb49339514b79acf07ae9661c95 /gui/MainWindow.cpp | |
parent | e90f1a27569ac6b9e9782646c9de92fc9534b1d2 (diff) | |
download | MultiMC-6ac94ddcb6f64ffae3948bed778bccc33a92f0fd.tar MultiMC-6ac94ddcb6f64ffae3948bed778bccc33a92f0fd.tar.gz MultiMC-6ac94ddcb6f64ffae3948bed778bccc33a92f0fd.tar.lz MultiMC-6ac94ddcb6f64ffae3948bed778bccc33a92f0fd.tar.xz MultiMC-6ac94ddcb6f64ffae3948bed778bccc33a92f0fd.zip |
Finish implementing update installation.
Also add the option to update on exit.
Diffstat (limited to 'gui/MainWindow.cpp')
-rw-r--r-- | gui/MainWindow.cpp | 27 |
1 files changed, 19 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); |