diff options
| author | bunnei <bunneidev@gmail.com> | 2019-10-09 21:36:51 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-09 21:36:51 -0400 |
| commit | b41692b69b778ce553c03461e4c66d9a3f58175e (patch) | |
| tree | 787ece68a43190ba17020afe9f57c024b831e534 /src/yuzu/main.cpp | |
| parent | d46e523fda089ffb5b4c8bead77f551c26b062d6 (diff) | |
| parent | b89fb6e1be43f5334d9ca2f5119aaee4a43c9c5b (diff) | |
Merge pull request #2910 from FearlessTobi/port-4930
Port citra-emu/citra#4930: "Pause when in background"
Diffstat (limited to 'src/yuzu/main.cpp')
| -rw-r--r-- | src/yuzu/main.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 451e4a4d6..d6bb18d24 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -675,6 +675,24 @@ void GMainWindow::RestoreUIState() { Debugger::ToggleConsole(); } +void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { + if (!UISettings::values.pause_when_in_background) { + return; + } + if (state != Qt::ApplicationHidden && state != Qt::ApplicationInactive && + state != Qt::ApplicationActive) { + LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state); + } + if (ui.action_Pause->isEnabled() && + (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { + auto_paused = true; + OnPauseGame(); + } else if (ui.action_Start->isEnabled() && auto_paused && state == Qt::ApplicationActive) { + auto_paused = false; + OnStartGame(); + } +} + void GMainWindow::ConnectWidgetEvents() { connect(game_list, &GameList::GameChosen, this, &GMainWindow::OnGameListLoadFile); connect(game_list, &GameList::OpenDirectory, this, &GMainWindow::OnGameListOpenDirectory); @@ -2320,6 +2338,9 @@ int main(int argc, char* argv[]) { // After settings have been loaded by GMainWindow, apply the filter main_window.show(); + QObject::connect(&app, &QGuiApplication::applicationStateChanged, &main_window, + &GMainWindow::OnAppFocusStateChanged); + Settings::LogSettings(); int result = app.exec(); |
