mirror of
https://github.com/citra-emu/citra-canary.git
synced 2024-12-23 23:35:28 +00:00
Pause on unfocused first draft
This is a MVP, still needs one or more configuration option(s) and review of the code style.
This commit is contained in:
parent
d6f2bc8c04
commit
23405b4ce1
|
@ -499,6 +499,17 @@ void GMainWindow::RestoreUIState() {
|
|||
statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked());
|
||||
}
|
||||
|
||||
void GMainWindow::OnLoseFocus(Qt::ApplicationState state) {
|
||||
if (ui.action_Pause->isEnabled() &&
|
||||
(state == Qt::ApplicationSuspended ||
|
||||
state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) {
|
||||
OnPauseGame();
|
||||
}
|
||||
if (ui.action_Start->isEnabled() && state == Qt::ApplicationActive) {
|
||||
OnStartGame();
|
||||
}
|
||||
}
|
||||
|
||||
void GMainWindow::ConnectWidgetEvents() {
|
||||
connect(game_list, &GameList::GameChosen, this, &GMainWindow::OnGameListLoadFile);
|
||||
connect(game_list, &GameList::OpenDirectory, this, &GMainWindow::OnGameListOpenDirectory);
|
||||
|
@ -2013,6 +2024,10 @@ int main(int argc, char* argv[]) {
|
|||
Core::System::GetInstance().RegisterSoftwareKeyboard(std::make_shared<QtKeyboard>(main_window));
|
||||
|
||||
main_window.show();
|
||||
|
||||
QObject::connect(&app, &QGuiApplication::applicationStateChanged, &main_window,
|
||||
&GMainWindow::OnLoseFocus);
|
||||
|
||||
int result = app.exec();
|
||||
detached_tasks.WaitForAllTasks();
|
||||
return result;
|
||||
|
|
|
@ -68,6 +68,8 @@ public:
|
|||
GameList* game_list;
|
||||
std::unique_ptr<DiscordRPC::DiscordInterface> discord_rpc;
|
||||
|
||||
public slots:
|
||||
void OnLoseFocus(Qt::ApplicationState state);
|
||||
signals:
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue