pollymc/application/pages/LegacyUpgradePage.cpp
2017-09-26 13:38:34 +02:00

43 lines
1.0 KiB
C++

#include "LegacyUpgradePage.h"
#include "ui_LegacyUpgradePage.h"
#include "minecraft/legacy/LegacyInstance.h"
#include "minecraft/legacy/LegacyUpgradeTask.h"
#include "MultiMC.h"
#include "FolderInstanceProvider.h"
#include "dialogs/CustomMessageBox.h"
#include "dialogs/ProgressDialog.h"
LegacyUpgradePage::LegacyUpgradePage(InstancePtr inst, QWidget *parent)
: QWidget(parent), ui(new Ui::LegacyUpgradePage), m_inst(inst)
{
ui->setupUi(this);
}
LegacyUpgradePage::~LegacyUpgradePage()
{
delete ui;
}
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"));
loadDialog.execWithTask(task);
}
void LegacyUpgradePage::on_upgradeButton_clicked()
{
std::unique_ptr<Task> task(MMC->folderProvider()->legacyUpgradeTask(m_inst));
runModalTask(task.get());
}
bool LegacyUpgradePage::shouldDisplay() const
{
return !m_inst->isRunning();
}