Merge pull request #2910 from FearlessTobi/port-4930
Port citra-emu/citra#4930: "Pause when in background"
This commit is contained in:
commit
b41692b69b
@ -716,6 +716,8 @@ void Config::ReadUIValues() {
|
|||||||
UISettings::values.callout_flags = ReadSetting(QStringLiteral("calloutFlags"), 0).toUInt();
|
UISettings::values.callout_flags = ReadSetting(QStringLiteral("calloutFlags"), 0).toUInt();
|
||||||
UISettings::values.show_console = ReadSetting(QStringLiteral("showConsole"), false).toBool();
|
UISettings::values.show_console = ReadSetting(QStringLiteral("showConsole"), false).toBool();
|
||||||
UISettings::values.profile_index = ReadSetting(QStringLiteral("profileIndex"), 0).toUInt();
|
UISettings::values.profile_index = ReadSetting(QStringLiteral("profileIndex"), 0).toUInt();
|
||||||
|
UISettings::values.pause_when_in_background =
|
||||||
|
ReadSetting(QStringLiteral("pauseWhenInBackground"), false).toBool();
|
||||||
|
|
||||||
ApplyDefaultProfileIfInputInvalid();
|
ApplyDefaultProfileIfInputInvalid();
|
||||||
|
|
||||||
@ -1124,6 +1126,8 @@ void Config::SaveUIValues() {
|
|||||||
WriteSetting(QStringLiteral("calloutFlags"), UISettings::values.callout_flags, 0);
|
WriteSetting(QStringLiteral("calloutFlags"), UISettings::values.callout_flags, 0);
|
||||||
WriteSetting(QStringLiteral("showConsole"), UISettings::values.show_console, false);
|
WriteSetting(QStringLiteral("showConsole"), UISettings::values.show_console, false);
|
||||||
WriteSetting(QStringLiteral("profileIndex"), UISettings::values.profile_index, 0);
|
WriteSetting(QStringLiteral("profileIndex"), UISettings::values.profile_index, 0);
|
||||||
|
WriteSetting(QStringLiteral("pauseWhenInBackground"),
|
||||||
|
UISettings::values.pause_when_in_background, false);
|
||||||
|
|
||||||
qt_config->endGroup();
|
qt_config->endGroup();
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ void ConfigureGeneral::SetConfiguration() {
|
|||||||
ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing);
|
ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing);
|
||||||
ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot);
|
ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot);
|
||||||
ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme));
|
ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme));
|
||||||
|
ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background);
|
||||||
|
|
||||||
ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit);
|
ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit);
|
||||||
ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked());
|
ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked());
|
||||||
@ -42,6 +43,7 @@ void ConfigureGeneral::ApplyConfiguration() {
|
|||||||
UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked();
|
UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked();
|
||||||
UISettings::values.theme =
|
UISettings::values.theme =
|
||||||
ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString();
|
ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString();
|
||||||
|
UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked();
|
||||||
|
|
||||||
Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked();
|
Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked();
|
||||||
Settings::values.frame_limit = ui->frame_limit->value();
|
Settings::values.frame_limit = ui->frame_limit->value();
|
||||||
|
@ -65,6 +65,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="toggle_background_pause">
|
||||||
|
<property name="text">
|
||||||
|
<string>Pause emulation when in background</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -675,6 +675,24 @@ void GMainWindow::RestoreUIState() {
|
|||||||
Debugger::ToggleConsole();
|
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() {
|
void GMainWindow::ConnectWidgetEvents() {
|
||||||
connect(game_list, &GameList::GameChosen, this, &GMainWindow::OnGameListLoadFile);
|
connect(game_list, &GameList::GameChosen, this, &GMainWindow::OnGameListLoadFile);
|
||||||
connect(game_list, &GameList::OpenDirectory, this, &GMainWindow::OnGameListOpenDirectory);
|
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
|
// After settings have been loaded by GMainWindow, apply the filter
|
||||||
main_window.show();
|
main_window.show();
|
||||||
|
|
||||||
|
QObject::connect(&app, &QGuiApplication::applicationStateChanged, &main_window,
|
||||||
|
&GMainWindow::OnAppFocusStateChanged);
|
||||||
|
|
||||||
Settings::LogSettings();
|
Settings::LogSettings();
|
||||||
|
|
||||||
int result = app.exec();
|
int result = app.exec();
|
||||||
|
@ -119,6 +119,7 @@ public slots:
|
|||||||
void SoftwareKeyboardGetText(const Core::Frontend::SoftwareKeyboardParameters& parameters);
|
void SoftwareKeyboardGetText(const Core::Frontend::SoftwareKeyboardParameters& parameters);
|
||||||
void SoftwareKeyboardInvokeCheckDialog(std::u16string error_message);
|
void SoftwareKeyboardInvokeCheckDialog(std::u16string error_message);
|
||||||
void WebBrowserOpenPage(std::string_view filename, std::string_view arguments);
|
void WebBrowserOpenPage(std::string_view filename, std::string_view arguments);
|
||||||
|
void OnAppFocusStateChanged(Qt::ApplicationState state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitializeWidgets();
|
void InitializeWidgets();
|
||||||
@ -244,6 +245,8 @@ private:
|
|||||||
// The path to the game currently running
|
// The path to the game currently running
|
||||||
QString game_path;
|
QString game_path;
|
||||||
|
|
||||||
|
bool auto_paused = false;
|
||||||
|
|
||||||
// FS
|
// FS
|
||||||
std::shared_ptr<FileSys::VfsFilesystem> vfs;
|
std::shared_ptr<FileSys::VfsFilesystem> vfs;
|
||||||
std::unique_ptr<FileSys::ManualContentProvider> provider;
|
std::unique_ptr<FileSys::ManualContentProvider> provider;
|
||||||
|
@ -58,6 +58,7 @@ struct Values {
|
|||||||
|
|
||||||
bool confirm_before_closing;
|
bool confirm_before_closing;
|
||||||
bool first_start;
|
bool first_start;
|
||||||
|
bool pause_when_in_background;
|
||||||
|
|
||||||
bool select_user_on_boot;
|
bool select_user_on_boot;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user