Merge branch 'develop' of github.com:MultiMC/MultiMC5 into develop

Conflicts:
	CMakeLists.txt
	gui/MainWindow.cpp
This commit is contained in:
Petr Mrázek
2013-12-10 07:22:22 +01:00
123 changed files with 45872 additions and 69 deletions

View File

@ -59,6 +59,7 @@
#include "gui/dialogs/CopyInstanceDialog.h"
#include "gui/dialogs/AccountListDialog.h"
#include "gui/dialogs/AccountSelectDialog.h"
#include "gui/dialogs/UpdateDialog.h"
#include "gui/dialogs/EditAccountDialog.h"
#include "gui/ConsoleWindow.h"
@ -69,6 +70,12 @@
#include "logic/lists/IconList.h"
#include "logic/lists/JavaVersionList.h"
#include "logic/auth/flows/AuthenticateTask.h"
#include "logic/auth/flows/RefreshTask.h"
#include "logic/auth/flows/ValidateTask.h"
#include "logic/updater/DownloadUpdateTask.h"
#include "logic/BaseInstance.h"
#include "logic/InstanceFactory.h"
#include "logic/MinecraftProcess.h"
@ -80,6 +87,7 @@
#include "logic/LegacyInstance.h"
#include "logic/assets/AssetsUtils.h"
#include <logic/updater/UpdateChecker.h>
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
@ -161,7 +169,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
connect(MMC->instances().get(), SIGNAL(dataIsInvalid()), SLOT(selectionBad()));
m_statusLeft = new QLabel(tr("Instance type"), this);
m_statusRight = new QLabel(tr("Assets information"), this);
m_statusRight = new QLabel(this);
m_statusRight->setAlignment(Qt::AlignRight);
statusBar()->addPermanentWidget(m_statusLeft, 1);
statusBar()->addPermanentWidget(m_statusRight, 0);
@ -232,6 +240,13 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
{
MMC->lwjgllist()->loadList();
}
// set up the updater object.
auto updater = MMC->updateChecker();
QObject::connect(updater.get(), &UpdateChecker::updateAvailable, this, &MainWindow::updateAvailable);
// if automatic update checks are allowed, start one.
if(MMC->settings()->get("AutoUpdate").toBool())
on_actionCheckUpdate_triggered();
}
const QString currentInstanceId = MMC->settings()->get("SelectedInstance").toString();
@ -406,6 +421,41 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *ev)
return QMainWindow::eventFilter(obj, ev);
}
void MainWindow::updateAvailable(QString repo, QString versionName, int versionId)
{
UpdateDialog dlg;
UpdateAction action = (UpdateAction) dlg.exec();
switch(action)
{
case UPDATE_LATER:
QLOG_INFO() << "Update will be installed later.";
break;
case UPDATE_NOW:
downloadUpdates(repo, versionId);
break;
case UPDATE_ONEXIT:
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);
@ -593,6 +643,8 @@ void MainWindow::on_actionConfig_Folder_triggered()
void MainWindow::on_actionCheckUpdate_triggered()
{
auto updater = MMC->updateChecker();
updater->checkForUpdate();
}
void MainWindow::on_actionSettings_triggered()