summaryrefslogtreecommitdiffstats
path: root/application/InstanceWindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'application/InstanceWindow.cpp')
-rw-r--r--application/InstanceWindow.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/application/InstanceWindow.cpp b/application/InstanceWindow.cpp
index dd643f47..2e876fea 100644
--- a/application/InstanceWindow.cpp
+++ b/application/InstanceWindow.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2013-2017 MultiMC Contributors
+/* Copyright 2013-2018 MultiMC Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -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);
}
@@ -72,7 +73,7 @@ InstanceWindow::InstanceWindow(InstancePtr instance, QWidget *parent)
m_launchOfflineButton = new QPushButton();
horizontalLayout->addWidget(m_launchOfflineButton);
m_launchOfflineButton->setText(tr("Launch Offline"));
- setKillButton(m_instance->isRunning());
+ updateLaunchButtons();
connect(m_launchOfflineButton, SIGNAL(clicked(bool)), SLOT(on_btnLaunchMinecraftOffline_clicked()));
m_closeButton = new QPushButton();
@@ -115,14 +116,21 @@ void InstanceWindow::on_instanceStatusChanged(BaseInstance::Status, BaseInstance
}
}
-void InstanceWindow::setKillButton(bool kill)
+void InstanceWindow::updateLaunchButtons()
{
- if(kill)
+ if(m_instance->isRunning())
{
m_launchOfflineButton->setEnabled(false);
m_killButton->setText(tr("Kill"));
m_killButton->setToolTip(tr("Kill the running instance"));
}
+ else if(!m_instance->canLaunch())
+ {
+ m_launchOfflineButton->setEnabled(false);
+ m_killButton->setText(tr("Launch"));
+ m_killButton->setToolTip(tr("Launch the instance"));
+ m_killButton->setEnabled(false);
+ }
else
{
m_launchOfflineButton->setEnabled(true);
@@ -141,9 +149,9 @@ void InstanceWindow::on_InstanceLaunchTask_changed(std::shared_ptr<LaunchTask> p
m_proc = proc;
}
-void InstanceWindow::on_RunningState_changed(bool running)
+void InstanceWindow::on_RunningState_changed(bool)
{
- setKillButton(running);
+ updateLaunchButtons();
m_container->refreshContainer();
}
@@ -206,3 +214,13 @@ void InstanceWindow::refreshContainer()
InstanceWindow::~InstanceWindow()
{
}
+
+bool InstanceWindow::requestClose()
+{
+ if(m_container->prepareToClose())
+ {
+ close();
+ return true;
+ }
+ return false;
+}