2017-09-16 22:09:05 +01:00
|
|
|
#include "LegacyUpgradePage.h"
|
|
|
|
#include "ui_LegacyUpgradePage.h"
|
|
|
|
|
2018-07-24 00:24:06 +01:00
|
|
|
#include "InstanceList.h"
|
2017-09-16 22:09:05 +01:00
|
|
|
#include "minecraft/legacy/LegacyInstance.h"
|
2017-09-26 12:38:34 +01:00
|
|
|
#include "minecraft/legacy/LegacyUpgradeTask.h"
|
2021-11-20 15:22:22 +00:00
|
|
|
#include "Application.h"
|
2017-09-26 12:38:34 +01:00
|
|
|
#include "dialogs/CustomMessageBox.h"
|
|
|
|
#include "dialogs/ProgressDialog.h"
|
2017-09-16 22:09:05 +01:00
|
|
|
|
2017-09-26 12:38:34 +01:00
|
|
|
LegacyUpgradePage::LegacyUpgradePage(InstancePtr inst, QWidget *parent)
|
2018-07-15 13:51:05 +01:00
|
|
|
: QWidget(parent), ui(new Ui::LegacyUpgradePage), m_inst(inst)
|
2017-09-16 22:09:05 +01:00
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
ui->setupUi(this);
|
2017-09-16 22:09:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
LegacyUpgradePage::~LegacyUpgradePage()
|
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
delete ui;
|
2017-09-16 22:09:05 +01:00
|
|
|
}
|
|
|
|
|
2017-09-26 12:38:34 +01:00
|
|
|
void LegacyUpgradePage::runModalTask(Task *task)
|
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
connect(task, &Task::failed, [this](QString reason)
|
|
|
|
{
|
|
|
|
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Warning)->show();
|
|
|
|
});
|
|
|
|
ProgressDialog loadDialog(this);
|
|
|
|
loadDialog.setSkipButton(true, tr("Abort"));
|
|
|
|
if(loadDialog.execWithTask(task) == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
m_container->requestClose();
|
|
|
|
}
|
2017-09-26 12:38:34 +01:00
|
|
|
}
|
|
|
|
|
2017-09-16 22:09:05 +01:00
|
|
|
void LegacyUpgradePage::on_upgradeButton_clicked()
|
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
QString newName = tr("%1 (Migrated)").arg(m_inst->name());
|
|
|
|
auto upgradeTask = new LegacyUpgradeTask(m_inst);
|
|
|
|
upgradeTask->setName(newName);
|
2021-11-20 15:22:22 +00:00
|
|
|
upgradeTask->setGroup(APPLICATION->instances()->getInstanceGroup(m_inst->id()));
|
2018-07-15 13:51:05 +01:00
|
|
|
upgradeTask->setIcon(m_inst->iconKey());
|
2021-11-20 15:22:22 +00:00
|
|
|
unique_qobject_ptr<Task> task(APPLICATION->instances()->wrapInstanceTask(upgradeTask));
|
2018-07-15 13:51:05 +01:00
|
|
|
runModalTask(task.get());
|
2017-09-16 22:09:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool LegacyUpgradePage::shouldDisplay() const
|
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
return !m_inst->isRunning();
|
2017-09-16 22:09:05 +01:00
|
|
|
}
|