Finish implementing update installation.
Also add the option to update on exit.
This commit is contained in:
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -41,6 +41,13 @@
|
||||
</property>
|
||||
</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">
|
||||
|
Reference in New Issue
Block a user