2017-09-17 02:39:05 +05:30
|
|
|
#include "LegacyUpgradePage.h"
|
|
|
|
#include "ui_LegacyUpgradePage.h"
|
|
|
|
|
|
|
|
#include "minecraft/legacy/LegacyInstance.h"
|
2017-09-26 17:08:34 +05:30
|
|
|
#include "minecraft/legacy/LegacyUpgradeTask.h"
|
|
|
|
#include "MultiMC.h"
|
|
|
|
#include "FolderInstanceProvider.h"
|
|
|
|
#include "dialogs/CustomMessageBox.h"
|
|
|
|
#include "dialogs/ProgressDialog.h"
|
2017-09-17 02:39:05 +05:30
|
|
|
|
2017-09-26 17:08:34 +05:30
|
|
|
LegacyUpgradePage::LegacyUpgradePage(InstancePtr inst, QWidget *parent)
|
2017-09-17 02:39:05 +05:30
|
|
|
: QWidget(parent), ui(new Ui::LegacyUpgradePage), m_inst(inst)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
LegacyUpgradePage::~LegacyUpgradePage()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2017-09-26 17:08:34 +05:30
|
|
|
void LegacyUpgradePage::runModalTask(Task *task)
|
|
|
|
{
|
|
|
|
connect(task, &Task::failed, [this](QString reason)
|
|
|
|
{
|
|
|
|
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Warning)->show();
|
|
|
|
});
|
|
|
|
ProgressDialog loadDialog(this);
|
|
|
|
loadDialog.setSkipButton(true, tr("Abort"));
|
2017-09-26 22:34:37 +05:30
|
|
|
if(loadDialog.execWithTask(task) == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
m_container->requestClose();
|
|
|
|
}
|
2017-09-26 17:08:34 +05:30
|
|
|
}
|
|
|
|
|
2017-09-17 02:39:05 +05:30
|
|
|
void LegacyUpgradePage::on_upgradeButton_clicked()
|
|
|
|
{
|
2017-09-26 17:08:34 +05:30
|
|
|
std::unique_ptr<Task> task(MMC->folderProvider()->legacyUpgradeTask(m_inst));
|
|
|
|
runModalTask(task.get());
|
2017-09-17 02:39:05 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
bool LegacyUpgradePage::shouldDisplay() const
|
|
|
|
{
|
|
|
|
return !m_inst->isRunning();
|
|
|
|
}
|