Add option to enable pause when on background

This commit is contained in:
vitor-k 2019-09-13 23:01:12 -03:00
parent 7224ec57f6
commit 356fd60520
5 changed files with 23 additions and 9 deletions

View file

@ -500,15 +500,17 @@ void GMainWindow::RestoreUIState() {
}
void GMainWindow::OnLoseFocus(Qt::ApplicationState state) {
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_on_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();
}
}
}