2017-09-17 02:39:05 +05:30
|
|
|
#include "LegacyUpgradePage.h"
|
|
|
|
#include "ui_LegacyUpgradePage.h"
|
|
|
|
|
2018-07-24 04:54:06 +05:30
|
|
|
#include "InstanceList.h"
|
2017-09-17 02:39:05 +05:30
|
|
|
#include "minecraft/legacy/LegacyInstance.h"
|
2017-09-26 17:08:34 +05:30
|
|
|
#include "minecraft/legacy/LegacyUpgradeTask.h"
|
|
|
|
#include "MultiMC.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)
|
2018-07-15 18:21:05 +05:30
|
|
|
: QWidget(parent), ui(new Ui::LegacyUpgradePage), m_inst(inst)
|
2017-09-17 02:39:05 +05:30
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
ui->setupUi(this);
|
2017-09-17 02:39:05 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
LegacyUpgradePage::~LegacyUpgradePage()
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
delete ui;
|
2017-09-17 02:39:05 +05:30
|
|
|
}
|
|
|
|
|
2017-09-26 17:08:34 +05:30
|
|
|
void LegacyUpgradePage::runModalTask(Task *task)
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
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 17:08:34 +05:30
|
|
|
}
|
|
|
|
|
2017-09-17 02:39:05 +05:30
|
|
|
void LegacyUpgradePage::on_upgradeButton_clicked()
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
QString newName = tr("%1 (Migrated)").arg(m_inst->name());
|
|
|
|
auto upgradeTask = new LegacyUpgradeTask(m_inst);
|
|
|
|
upgradeTask->setName(newName);
|
2018-07-31 05:24:08 +05:30
|
|
|
upgradeTask->setGroup(MMC->instances()->getInstanceGroup(m_inst->id()));
|
2018-07-15 18:21:05 +05:30
|
|
|
upgradeTask->setIcon(m_inst->iconKey());
|
2018-07-24 04:54:06 +05:30
|
|
|
std::unique_ptr<Task> task(MMC->instances()->wrapInstanceTask(upgradeTask));
|
2018-07-15 18:21:05 +05:30
|
|
|
runModalTask(task.get());
|
2017-09-17 02:39:05 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
bool LegacyUpgradePage::shouldDisplay() const
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
return !m_inst->isRunning();
|
2017-09-17 02:39:05 +05:30
|
|
|
}
|