mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-11 00:17:59 -05:00
yuzu: Pause when in background
Co-Authored-By: Vitor K <vitor-k@users.noreply.github.com>
This commit is contained in:
@ -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);
|
||||
@ -2311,6 +2329,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();
|
||||
|
Reference in New Issue
Block a user