diff options
Diffstat (limited to 'application/pages')
-rw-r--r-- | application/pages/LegacyUpgradePage.cpp | 21 | ||||
-rw-r--r-- | application/pages/LegacyUpgradePage.h | 12 |
2 files changed, 27 insertions, 6 deletions
diff --git a/application/pages/LegacyUpgradePage.cpp b/application/pages/LegacyUpgradePage.cpp index 14cb916d..c1ad0146 100644 --- a/application/pages/LegacyUpgradePage.cpp +++ b/application/pages/LegacyUpgradePage.cpp @@ -2,8 +2,13 @@ #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(LegacyInstance *inst, QWidget *parent) +LegacyUpgradePage::LegacyUpgradePage(InstancePtr inst, QWidget *parent) : QWidget(parent), ui(new Ui::LegacyUpgradePage), m_inst(inst) { ui->setupUi(this); @@ -14,9 +19,21 @@ 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() { - // now what? + std::unique_ptr<Task> task(MMC->folderProvider()->legacyUpgradeTask(m_inst)); + runModalTask(task.get()); } bool LegacyUpgradePage::shouldDisplay() const diff --git a/application/pages/LegacyUpgradePage.h b/application/pages/LegacyUpgradePage.h index 4731bb82..5de958c4 100644 --- a/application/pages/LegacyUpgradePage.h +++ b/application/pages/LegacyUpgradePage.h @@ -20,6 +20,7 @@ #include "minecraft/legacy/LegacyInstance.h" #include "pages/BasePage.h" #include <MultiMC.h> +#include "tasks/Task.h" namespace Ui { @@ -31,7 +32,7 @@ class LegacyUpgradePage : public QWidget, public BasePage Q_OBJECT public: - explicit LegacyUpgradePage(LegacyInstance *inst, QWidget *parent = 0); + explicit LegacyUpgradePage(InstancePtr inst, QWidget *parent = 0); virtual ~LegacyUpgradePage(); virtual QString displayName() const override { @@ -50,11 +51,14 @@ public: return "Legacy-upgrade"; } virtual bool shouldDisplay() const override; -private -slots: + +private slots: void on_upgradeButton_clicked(); private: + void runModalTask(Task *task); + +private: Ui::LegacyUpgradePage *ui; - LegacyInstance *m_inst; + InstancePtr m_inst; }; |