NOISSUE Legacy migration success now closes the instance window

This commit is contained in:
Petr Mrázek 2017-09-26 19:04:37 +02:00
parent 719f112f64
commit 1a38587877
10 changed files with 41 additions and 19 deletions

View File

@ -48,6 +48,7 @@ InstanceWindow::InstanceWindow(InstancePtr instance, QWidget *parent)
{
auto provider = std::make_shared<InstancePageProvider>(m_instance);
m_container = new PageContainer(provider, "console", this);
m_container->setParentContainer(this);
setCentralWidget(m_container);
}
@ -213,3 +214,13 @@ void InstanceWindow::refreshContainer()
InstanceWindow::~InstanceWindow()
{
}
bool InstanceWindow::requestClose()
{
if(m_container->prepareToClose())
{
close();
return true;
}
return false;
}

View File

@ -40,6 +40,9 @@ public:
// save all settings and changes (prepare for launch)
bool saveAll();
// request closing the window (from a page)
bool requestClose() override;
signals:
void isClosing();

View File

@ -33,11 +33,15 @@ public:
virtual QString helpPage() const { return QString(); }
virtual void opened() {}
virtual void closed() {}
virtual void setParentContainer(BasePageContainer *) {};
virtual void setParentContainer(BasePageContainer * container)
{
m_container = container;
};
public:
int stackIndex = -1;
int listIndex = -1;
protected:
BasePageContainer * m_container = nullptr;
};
typedef std::shared_ptr<BasePage> BasePagePtr;

View File

@ -6,4 +6,5 @@ public:
virtual ~BasePageContainer(){};
virtual bool selectPage(QString pageId) = 0;
virtual void refreshContainer() = 0;
virtual bool requestClose() = 0;
};

View File

@ -27,7 +27,10 @@ void LegacyUpgradePage::runModalTask(Task *task)
});
ProgressDialog loadDialog(this);
loadDialog.setSkipButton(true, tr("Abort"));
loadDialog.execWithTask(task);
if(loadDialog.execWithTask(task) == QDialog::Accepted)
{
m_container->requestClose();
}
}
void LegacyUpgradePage::on_upgradeButton_clicked()

View File

@ -218,7 +218,7 @@ void LogPage::on_btnClear_clicked()
if(!m_model)
return;
m_model->clear();
m_parentContainer->refreshContainer();
m_container->refreshContainer();
}
void LogPage::on_btnBottom_clicked()
@ -262,8 +262,3 @@ void LogPage::findActivated()
ui->searchBar->selectAll();
}
}
void LogPage::setParentContainer(BasePageContainer * container)
{
m_parentContainer = container;
}

View File

@ -54,7 +54,6 @@ public:
return "Minecraft-Logs";
}
virtual bool shouldDisplay() const override;
virtual void setParentContainer(BasePageContainer *) override;
private slots:
void on_btnPaste_clicked();
@ -77,7 +76,6 @@ private:
InstancePtr m_instance;
std::shared_ptr<LaunchTask> m_process;
BasePageContainer * m_parentContainer;
LogFormatProxyModel * m_proxy;
shared_qobject_ptr <LogModel> m_model;
};

View File

@ -98,11 +98,6 @@ bool VersionPage::shouldDisplay() const
return !m_inst->isRunning();
}
void VersionPage::setParentContainer(BasePageContainer * container)
{
m_container = container;
}
VersionPage::VersionPage(MinecraftInstance *inst, QWidget *parent)
: QWidget(parent), ui(new Ui::VersionPage), m_inst(inst)
{

View File

@ -48,8 +48,6 @@ public:
}
virtual bool shouldDisplay() const override;
virtual void setParentContainer(BasePageContainer *) override;
private slots:
void on_forgeBtn_clicked();
void on_liteloaderBtn_clicked();
@ -85,7 +83,6 @@ private:
std::shared_ptr<MinecraftProfile> m_profile;
MinecraftInstance *m_inst;
int currentIdx = 0;
BasePageContainer * m_container = nullptr;
public slots:
void versionCurrent(const QModelIndex &current, const QModelIndex &previous);

View File

@ -47,9 +47,23 @@ public:
*/
bool prepareToClose();
/* request close - used by individual pages */
bool requestClose() override
{
if(m_container)
{
return m_container->requestClose();
}
return false;
}
virtual bool selectPage(QString pageId) override;
void refreshContainer() override;
virtual void setParentContainer(BasePageContainer * container)
{
m_container = container;
};
private:
void createUI();
@ -60,6 +74,7 @@ slots:
void help();
private:
BasePageContainer * m_container = nullptr;
BasePage * m_currentPage = 0;
QSortFilterProxyModel *m_proxyModel;
PageModel *m_model;