diff --git a/gui/consolewindow.cpp b/gui/consolewindow.cpp index deeedd657..6ed4a0ec9 100644 --- a/gui/consolewindow.cpp +++ b/gui/consolewindow.cpp @@ -14,7 +14,7 @@ ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) : { MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); - connect(mcproc, SIGNAL(ended()), this, SLOT(onEnded())); + connect(mcproc, SIGNAL(ended(BaseInstance*)), this, SLOT(onEnded(BaseInstance*))); } ConsoleWindow::~ConsoleWindow() @@ -109,9 +109,14 @@ void ConsoleWindow::on_btnKillMinecraft_clicked() r_u_sure.close(); } -void ConsoleWindow::onEnded() +void ConsoleWindow::onEnded(BaseInstance *instance) { 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(); + } } diff --git a/gui/consolewindow.h b/gui/consolewindow.h index 6a6c9e50c..e8790c92a 100644 --- a/gui/consolewindow.h +++ b/gui/consolewindow.h @@ -49,7 +49,7 @@ public slots: private slots: void on_closeButton_clicked(); void on_btnKillMinecraft_clicked(); - void onEnded(); + void onEnded(BaseInstance *instance); protected: void closeEvent(QCloseEvent *); diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index cce16a934..608dacd5f 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -630,11 +630,18 @@ void MainWindow::launchInstance(BaseInstance *instance, LoginResponse response) this->hide(); } + console = new ConsoleWindow(proc); - console->show(); + connect(proc, SIGNAL(log(QString, MessageLevel::Enum)), console, 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->launch(); } @@ -784,10 +791,15 @@ void MainWindow::on_actionEditInstNotes_triggered() } } -void MainWindow::instanceEnded() +void MainWindow::instanceEnded(BaseInstance *instance) { this->show(); ui->actionLaunchInstance->setEnabled(m_selectedInstance); + + if (instance->settings().get("AutoCloseConsole").toBool()) + { + console->close(); + } } void MainWindow::checkSetDefaultJava() diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 4490d474f..941fbcca1 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -112,7 +112,7 @@ private slots: void on_actionChangeInstLWJGLVersion_triggered(); - void instanceEnded(); + void instanceEnded(BaseInstance *instance); void on_actionInstanceSettings_triggered(); diff --git a/logic/MinecraftProcess.cpp b/logic/MinecraftProcess.cpp index 06b7a1f1b..ff122628a 100644 --- a/logic/MinecraftProcess.cpp +++ b/logic/MinecraftProcess.cpp @@ -138,7 +138,7 @@ void MinecraftProcess::finish(int code, ExitStatus status) } } m_instance->cleanupAfterRun(); - emit ended(); + emit ended(m_instance); } void MinecraftProcess::killMinecraft() @@ -193,4 +193,4 @@ MessageLevel::Enum MinecraftProcess::getLevel(const QString &line, MessageLevel: if (line.contains("[DEBUG]")) level = MessageLevel::Debug; return level; -} \ No newline at end of file +} diff --git a/logic/MinecraftProcess.h b/logic/MinecraftProcess.h index a1dfa23f6..812559d54 100644 --- a/logic/MinecraftProcess.h +++ b/logic/MinecraftProcess.h @@ -67,7 +67,7 @@ signals: /** * @brief emitted when mc has finished and the PostLaunchCommand was run */ - void ended(); + void ended(BaseInstance*); /** * @brief emitted when we want to log something