2017-09-16 21:09:05 +00:00
|
|
|
#include "LegacyUpgradePage.h"
|
|
|
|
#include "ui_LegacyUpgradePage.h"
|
|
|
|
|
|
|
|
#include "minecraft/legacy/LegacyInstance.h"
|
2017-09-26 11:38:34 +00:00
|
|
|
#include "minecraft/legacy/LegacyUpgradeTask.h"
|
|
|
|
#include "MultiMC.h"
|
|
|
|
#include "FolderInstanceProvider.h"
|
|
|
|
#include "dialogs/CustomMessageBox.h"
|
|
|
|
#include "dialogs/ProgressDialog.h"
|
2017-09-16 21:09:05 +00:00
|
|
|
|
2017-09-26 11:38:34 +00:00
|
|
|
LegacyUpgradePage::LegacyUpgradePage(InstancePtr inst, QWidget *parent)
|
2017-09-16 21:09:05 +00:00
|
|
|
: QWidget(parent), ui(new Ui::LegacyUpgradePage), m_inst(inst)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
LegacyUpgradePage::~LegacyUpgradePage()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2017-09-26 11:38:34 +00:00
|
|
|
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 17:04:37 +00:00
|
|
|
if(loadDialog.execWithTask(task) == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
m_container->requestClose();
|
|
|
|
}
|
2017-09-26 11:38:34 +00:00
|
|
|
}
|
|
|
|
|
2017-09-16 21:09:05 +00:00
|
|
|
void LegacyUpgradePage::on_upgradeButton_clicked()
|
|
|
|
{
|
2018-03-19 01:36:12 +00:00
|
|
|
QString newName = tr("%1 (Migrated)").arg(m_inst->name());
|
|
|
|
auto upgradeTask = new LegacyUpgradeTask(m_inst);
|
|
|
|
upgradeTask->setName(newName);
|
|
|
|
upgradeTask->setGroup(m_inst->group());
|
|
|
|
upgradeTask->setIcon(m_inst->iconKey());
|
|
|
|
std::unique_ptr<Task> task(MMC->folderProvider()->wrapInstanceTask(upgradeTask));
|
2017-09-26 11:38:34 +00:00
|
|
|
runModalTask(task.get());
|
2017-09-16 21:09:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool LegacyUpgradePage::shouldDisplay() const
|
|
|
|
{
|
|
|
|
return !m_inst->isRunning();
|
|
|
|
}
|