diff options
author | Petr Mrázek <peterix@gmail.com> | 2017-09-26 13:38:34 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2017-09-26 13:38:34 +0200 |
commit | 2b998bb8cc8e83efafb20ed2fbe1a245d4d5ec5f (patch) | |
tree | 392872160002aa12c95a9f9239300aa12e80b368 /application | |
parent | eac892965e152519a6d7278504e7d4118aa7c01f (diff) | |
download | MultiMC-2b998bb8cc8e83efafb20ed2fbe1a245d4d5ec5f.tar MultiMC-2b998bb8cc8e83efafb20ed2fbe1a245d4d5ec5f.tar.gz MultiMC-2b998bb8cc8e83efafb20ed2fbe1a245d4d5ec5f.tar.lz MultiMC-2b998bb8cc8e83efafb20ed2fbe1a245d4d5ec5f.tar.xz MultiMC-2b998bb8cc8e83efafb20ed2fbe1a245d4d5ec5f.zip |
NOISSUE implement LEgacy instance migration
Diffstat (limited to 'application')
-rw-r--r-- | application/InstancePageProvider.h | 2 | ||||
-rw-r--r-- | application/pages/LegacyUpgradePage.cpp | 21 | ||||
-rw-r--r-- | application/pages/LegacyUpgradePage.h | 12 |
3 files changed, 28 insertions, 7 deletions
diff --git a/application/InstancePageProvider.h b/application/InstancePageProvider.h index 1f5a6aef..b13ce93d 100644 --- a/application/InstancePageProvider.h +++ b/application/InstancePageProvider.h @@ -49,7 +49,7 @@ public: std::shared_ptr<LegacyInstance> legacy = std::dynamic_pointer_cast<LegacyInstance>(inst); if(legacy) { - values.append(new LegacyUpgradePage(legacy.get())); + values.append(new LegacyUpgradePage(legacy)); values.append(new NotesPage(legacy.get())); values.append(new WorldListPage(legacy.get(), legacy->worldList(), "worlds", "worlds", tr("Worlds"), "Worlds")); values.append(new ScreenshotsPage(FS::PathCombine(legacy->minecraftRoot(), "screenshots"))); 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; }; |