NOISSUE more work on Legacy migration

This commit is contained in:
Petr Mrázek 2017-09-20 23:38:31 +02:00
parent 9a6c2b0e2c
commit ba3cbb7330
14 changed files with 149 additions and 12 deletions

View file

@ -72,7 +72,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 +115,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 +148,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();
}