Respect console options (opening a console at all, automatically closing)

This commit is contained in:
Sky 2013-10-22 18:25:10 +01:00
parent 1d2183ea29
commit c65bab6efe
6 changed files with 29 additions and 12 deletions

View File

@ -14,7 +14,7 @@ ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) :
{ {
MultiMCPlatform::fixWM_CLASS(this); MultiMCPlatform::fixWM_CLASS(this);
ui->setupUi(this); ui->setupUi(this);
connect(mcproc, SIGNAL(ended()), this, SLOT(onEnded())); connect(mcproc, SIGNAL(ended(BaseInstance*)), this, SLOT(onEnded(BaseInstance*)));
} }
ConsoleWindow::~ConsoleWindow() ConsoleWindow::~ConsoleWindow()
@ -109,9 +109,14 @@ void ConsoleWindow::on_btnKillMinecraft_clicked()
r_u_sure.close(); r_u_sure.close();
} }
void ConsoleWindow::onEnded() void ConsoleWindow::onEnded(BaseInstance *instance)
{ {
ui->btnKillMinecraft->setEnabled(false); ui->btnKillMinecraft->setEnabled(false);
// TODO: Check why this doesn't work
if (!proc->exitCode()) this->close(); // TODO: Might need an option to forcefully close, even on an error
if(instance->settings().get("AutoCloseConsole").toBool())
{
// TODO: Check why this doesn't work
if (!proc->exitCode()) this->close();
}
} }

View File

@ -49,7 +49,7 @@ public slots:
private slots: private slots:
void on_closeButton_clicked(); void on_closeButton_clicked();
void on_btnKillMinecraft_clicked(); void on_btnKillMinecraft_clicked();
void onEnded(); void onEnded(BaseInstance *instance);
protected: protected:
void closeEvent(QCloseEvent *); void closeEvent(QCloseEvent *);

View File

@ -630,11 +630,18 @@ void MainWindow::launchInstance(BaseInstance *instance, LoginResponse response)
this->hide(); this->hide();
} }
console = new ConsoleWindow(proc); console = new ConsoleWindow(proc);
console->show();
connect(proc, SIGNAL(log(QString, MessageLevel::Enum)), console, connect(proc, SIGNAL(log(QString, MessageLevel::Enum)), console,
SLOT(write(QString, MessageLevel::Enum))); SLOT(write(QString, MessageLevel::Enum)));
connect(proc, SIGNAL(ended()), this, SLOT(instanceEnded())); connect(proc, SIGNAL(ended(BaseInstance*)), this, SLOT(instanceEnded(BaseInstance*)));
if (instance->settings().get("ShowConsole").toBool())
{
console->show();
}
proc->setLogin(response.username, response.session_id); proc->setLogin(response.username, response.session_id);
proc->launch(); proc->launch();
} }
@ -784,10 +791,15 @@ void MainWindow::on_actionEditInstNotes_triggered()
} }
} }
void MainWindow::instanceEnded() void MainWindow::instanceEnded(BaseInstance *instance)
{ {
this->show(); this->show();
ui->actionLaunchInstance->setEnabled(m_selectedInstance); ui->actionLaunchInstance->setEnabled(m_selectedInstance);
if (instance->settings().get("AutoCloseConsole").toBool())
{
console->close();
}
} }
void MainWindow::checkSetDefaultJava() void MainWindow::checkSetDefaultJava()

View File

@ -112,7 +112,7 @@ private slots:
void on_actionChangeInstLWJGLVersion_triggered(); void on_actionChangeInstLWJGLVersion_triggered();
void instanceEnded(); void instanceEnded(BaseInstance *instance);
void on_actionInstanceSettings_triggered(); void on_actionInstanceSettings_triggered();

View File

@ -138,7 +138,7 @@ void MinecraftProcess::finish(int code, ExitStatus status)
} }
} }
m_instance->cleanupAfterRun(); m_instance->cleanupAfterRun();
emit ended(); emit ended(m_instance);
} }
void MinecraftProcess::killMinecraft() void MinecraftProcess::killMinecraft()

View File

@ -67,7 +67,7 @@ signals:
/** /**
* @brief emitted when mc has finished and the PostLaunchCommand was run * @brief emitted when mc has finished and the PostLaunchCommand was run
*/ */
void ended(); void ended(BaseInstance*);
/** /**
* @brief emitted when we want to log something * @brief emitted when we want to log something