Pause in background guard clause and unused flag

This commit is contained in:
vitor-k 2019-09-15 01:08:12 -03:00
parent 66b1e419c3
commit 05b1cfc63b
2 changed files with 12 additions and 12 deletions

View file

@ -32,7 +32,7 @@
<item>
<widget class="QCheckBox" name="toggle_background_pause">
<property name="text">
<string>Pause emulation when on background</string>
<string>Pause emulation when in background</string>
</property>
</widget>
</item>

View file

@ -500,17 +500,17 @@ void GMainWindow::RestoreUIState() {
}
void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) {
if (UISettings::values.pause_when_in_background) {
if (ui.action_Pause->isEnabled() &&
(state == Qt::ApplicationSuspended ||
state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) {
auto_paused = true;
OnPauseGame();
}
if (ui.action_Start->isEnabled() && auto_paused && state == Qt::ApplicationActive) {
auto_paused = false;
OnStartGame();
}
if (!UISettings::values.pause_when_in_background) {
return;
}
if (ui.action_Pause->isEnabled() &&
(state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) {
auto_paused = true;
OnPauseGame();
}
if (ui.action_Start->isEnabled() && auto_paused && state == Qt::ApplicationActive) {
auto_paused = false;
OnStartGame();
}
}