Close after Launch setting

This commit is contained in:
swirl
2022-01-29 19:04:44 -05:00
parent 5abb97362f
commit 0065a29901
6 changed files with 36 additions and 0 deletions

View File

@ -25,6 +25,19 @@
LauncherPartLaunch::LauncherPartLaunch(LaunchTask *parent) : LaunchStep(parent)
{
if (APPLICATION->settings()->get("CloseAfterLaunch").toBoolean())
{
std::shared_ptr<QMetaObject::Connection> connection{new QMetaObject::Connection};
*connection = connect(&m_process, &LoggedProcess::log, this, [=](QStringList lines, MessageLevel::Enum level) {
qDebug() << lines;
if (lines.filter(QRegularExpression(".+Backend library: LWJGL version.+")).length() != 0)
{
APPLICATION->closeAllWindows();
disconnect(*connection);
}
});
}
connect(&m_process, &LoggedProcess::log, this, &LauncherPartLaunch::logLines);
connect(&m_process, &LoggedProcess::stateChanged, this, &LauncherPartLaunch::on_state);
}
@ -155,6 +168,8 @@ void LauncherPartLaunch::on_state(LoggedProcess::State state)
}
case LoggedProcess::Finished:
{
if (APPLICATION->settings()->get("CloseAfterLaunch").toBoolean())
APPLICATION->showMainWindow();
m_parent->setPid(-1);
// if the exit code wasn't 0, report this as a crash
auto exitCode = m_process.exitCode();