Merge branch 'feature/close_after_launch' into develop
This commit is contained in:
commit
fcc4420cfe
@ -717,6 +717,8 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
// pastebin URL
|
// pastebin URL
|
||||||
m_settings->registerSetting("PastebinURL", "https://0x0.st");
|
m_settings->registerSetting("PastebinURL", "https://0x0.st");
|
||||||
|
|
||||||
|
m_settings->registerSetting("CloseAfterLaunch", false);
|
||||||
|
|
||||||
// Init page provider
|
// Init page provider
|
||||||
{
|
{
|
||||||
m_globalSettingsProvider = std::make_shared<GenericPageProvider>(tr("Settings"));
|
m_globalSettingsProvider = std::make_shared<GenericPageProvider>(tr("Settings"));
|
||||||
|
@ -25,6 +25,19 @@
|
|||||||
|
|
||||||
LauncherPartLaunch::LauncherPartLaunch(LaunchTask *parent) : LaunchStep(parent)
|
LauncherPartLaunch::LauncherPartLaunch(LaunchTask *parent) : LaunchStep(parent)
|
||||||
{
|
{
|
||||||
|
if (APPLICATION->settings()->get("CloseAfterLaunch").toBool())
|
||||||
|
{
|
||||||
|
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(".*Setting user.+", QRegularExpression::CaseInsensitiveOption)).length() != 0)
|
||||||
|
{
|
||||||
|
APPLICATION->closeAllWindows();
|
||||||
|
disconnect(*connection);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
connect(&m_process, &LoggedProcess::log, this, &LauncherPartLaunch::logLines);
|
connect(&m_process, &LoggedProcess::log, this, &LauncherPartLaunch::logLines);
|
||||||
connect(&m_process, &LoggedProcess::stateChanged, this, &LauncherPartLaunch::on_state);
|
connect(&m_process, &LoggedProcess::stateChanged, this, &LauncherPartLaunch::on_state);
|
||||||
}
|
}
|
||||||
@ -155,6 +168,8 @@ void LauncherPartLaunch::on_state(LoggedProcess::State state)
|
|||||||
}
|
}
|
||||||
case LoggedProcess::Finished:
|
case LoggedProcess::Finished:
|
||||||
{
|
{
|
||||||
|
if (APPLICATION->settings()->get("CloseAfterLaunch").toBool())
|
||||||
|
APPLICATION->showMainWindow();
|
||||||
m_parent->setPid(-1);
|
m_parent->setPid(-1);
|
||||||
// if the exit code wasn't 0, report this as a crash
|
// if the exit code wasn't 0, report this as a crash
|
||||||
auto exitCode = m_process.exitCode();
|
auto exitCode = m_process.exitCode();
|
||||||
|
@ -71,6 +71,9 @@ void MinecraftPage::applySettings()
|
|||||||
s->set("ShowGameTime", ui->showGameTime->isChecked());
|
s->set("ShowGameTime", ui->showGameTime->isChecked());
|
||||||
s->set("ShowGlobalGameTime", ui->showGlobalGameTime->isChecked());
|
s->set("ShowGlobalGameTime", ui->showGlobalGameTime->isChecked());
|
||||||
s->set("RecordGameTime", ui->recordGameTime->isChecked());
|
s->set("RecordGameTime", ui->recordGameTime->isChecked());
|
||||||
|
|
||||||
|
// Miscellaneous
|
||||||
|
s->set("CloseAfterLaunch", ui->closeAfterLaunchCheck->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftPage::loadSettings()
|
void MinecraftPage::loadSettings()
|
||||||
@ -88,4 +91,6 @@ void MinecraftPage::loadSettings()
|
|||||||
ui->showGameTime->setChecked(s->get("ShowGameTime").toBool());
|
ui->showGameTime->setChecked(s->get("ShowGameTime").toBool());
|
||||||
ui->showGlobalGameTime->setChecked(s->get("ShowGlobalGameTime").toBool());
|
ui->showGlobalGameTime->setChecked(s->get("ShowGlobalGameTime").toBool());
|
||||||
ui->recordGameTime->setChecked(s->get("RecordGameTime").toBool());
|
ui->recordGameTime->setChecked(s->get("RecordGameTime").toBool());
|
||||||
|
|
||||||
|
ui->closeAfterLaunchCheck->setChecked(s->get("CloseAfterLaunch").toBool());
|
||||||
}
|
}
|
||||||
|
@ -164,6 +164,25 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Miscellaneous</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="closeAfterLaunchCheck">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>PolyMC will automatically reopen when the game crashes or exits.</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Close PolyMC after game window opens</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacerMinecraft">
|
<spacer name="verticalSpacerMinecraft">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -184,7 +203,6 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>tabWidget</tabstop>
|
|
||||||
<tabstop>maximizedCheckBox</tabstop>
|
<tabstop>maximizedCheckBox</tabstop>
|
||||||
<tabstop>windowWidthSpinBox</tabstop>
|
<tabstop>windowWidthSpinBox</tabstop>
|
||||||
<tabstop>windowHeightSpinBox</tabstop>
|
<tabstop>windowHeightSpinBox</tabstop>
|
||||||
|
Loading…
Reference in New Issue
Block a user