diff options
Diffstat (limited to '')
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 4 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_general.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_general.ui | 7 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 21 | ||||
| -rw-r--r-- | src/yuzu/main.h | 3 | ||||
| -rw-r--r-- | src/yuzu/uisettings.h | 1 |
6 files changed, 38 insertions, 0 deletions
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 92d9fb161..0cc3688c2 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -705,6 +705,8 @@ void Config::ReadUIValues() { | |||
| 705 | UISettings::values.callout_flags = ReadSetting(QStringLiteral("calloutFlags"), 0).toUInt(); | 705 | UISettings::values.callout_flags = ReadSetting(QStringLiteral("calloutFlags"), 0).toUInt(); |
| 706 | UISettings::values.show_console = ReadSetting(QStringLiteral("showConsole"), false).toBool(); | 706 | UISettings::values.show_console = ReadSetting(QStringLiteral("showConsole"), false).toBool(); |
| 707 | UISettings::values.profile_index = ReadSetting(QStringLiteral("profileIndex"), 0).toUInt(); | 707 | UISettings::values.profile_index = ReadSetting(QStringLiteral("profileIndex"), 0).toUInt(); |
| 708 | UISettings::values.pause_when_in_background = | ||
| 709 | ReadSetting(QStringLiteral("pauseWhenInBackground"), false).toBool(); | ||
| 708 | 710 | ||
| 709 | ApplyDefaultProfileIfInputInvalid(); | 711 | ApplyDefaultProfileIfInputInvalid(); |
| 710 | 712 | ||
| @@ -1103,6 +1105,8 @@ void Config::SaveUIValues() { | |||
| 1103 | WriteSetting(QStringLiteral("calloutFlags"), UISettings::values.callout_flags, 0); | 1105 | WriteSetting(QStringLiteral("calloutFlags"), UISettings::values.callout_flags, 0); |
| 1104 | WriteSetting(QStringLiteral("showConsole"), UISettings::values.show_console, false); | 1106 | WriteSetting(QStringLiteral("showConsole"), UISettings::values.show_console, false); |
| 1105 | WriteSetting(QStringLiteral("profileIndex"), UISettings::values.profile_index, 0); | 1107 | WriteSetting(QStringLiteral("profileIndex"), UISettings::values.profile_index, 0); |
| 1108 | WriteSetting(QStringLiteral("pauseWhenInBackground"), | ||
| 1109 | UISettings::values.pause_when_in_background, false); | ||
| 1106 | 1110 | ||
| 1107 | qt_config->endGroup(); | 1111 | qt_config->endGroup(); |
| 1108 | } | 1112 | } |
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index 98bc9b391..34e1d7fea 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp | |||
| @@ -31,6 +31,7 @@ void ConfigureGeneral::SetConfiguration() { | |||
| 31 | ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing); | 31 | ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing); |
| 32 | ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot); | 32 | ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot); |
| 33 | ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme)); | 33 | ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme)); |
| 34 | ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background); | ||
| 34 | 35 | ||
| 35 | ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit); | 36 | ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit); |
| 36 | ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked()); | 37 | ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked()); |
| @@ -42,6 +43,7 @@ void ConfigureGeneral::ApplyConfiguration() { | |||
| 42 | UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked(); | 43 | UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked(); |
| 43 | UISettings::values.theme = | 44 | UISettings::values.theme = |
| 44 | ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString(); | 45 | ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString(); |
| 46 | UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked(); | ||
| 45 | 47 | ||
| 46 | Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked(); | 48 | Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked(); |
| 47 | Settings::values.frame_limit = ui->frame_limit->value(); | 49 | Settings::values.frame_limit = ui->frame_limit->value(); |
diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui index 0bb91d64b..26b3486ff 100644 --- a/src/yuzu/configuration/configure_general.ui +++ b/src/yuzu/configuration/configure_general.ui | |||
| @@ -65,6 +65,13 @@ | |||
| 65 | </property> | 65 | </property> |
| 66 | </widget> | 66 | </widget> |
| 67 | </item> | 67 | </item> |
| 68 | <item> | ||
| 69 | <widget class="QCheckBox" name="toggle_background_pause"> | ||
| 70 | <property name="text"> | ||
| 71 | <string>Pause emulation when in background</string> | ||
| 72 | </property> | ||
| 73 | </widget> | ||
| 74 | </item> | ||
| 68 | </layout> | 75 | </layout> |
| 69 | </item> | 76 | </item> |
| 70 | </layout> | 77 | </layout> |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 2d82df739..757d42a3a 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -675,6 +675,24 @@ void GMainWindow::RestoreUIState() { | |||
| 675 | Debugger::ToggleConsole(); | 675 | Debugger::ToggleConsole(); |
| 676 | } | 676 | } |
| 677 | 677 | ||
| 678 | void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { | ||
| 679 | if (!UISettings::values.pause_when_in_background) { | ||
| 680 | return; | ||
| 681 | } | ||
| 682 | if (state != Qt::ApplicationHidden && state != Qt::ApplicationInactive && | ||
| 683 | state != Qt::ApplicationActive) { | ||
| 684 | LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state); | ||
| 685 | } | ||
| 686 | if (ui.action_Pause->isEnabled() && | ||
| 687 | (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { | ||
| 688 | auto_paused = true; | ||
| 689 | OnPauseGame(); | ||
| 690 | } else if (ui.action_Start->isEnabled() && auto_paused && state == Qt::ApplicationActive) { | ||
| 691 | auto_paused = false; | ||
| 692 | OnStartGame(); | ||
| 693 | } | ||
| 694 | } | ||
| 695 | |||
| 678 | void GMainWindow::ConnectWidgetEvents() { | 696 | void GMainWindow::ConnectWidgetEvents() { |
| 679 | connect(game_list, &GameList::GameChosen, this, &GMainWindow::OnGameListLoadFile); | 697 | connect(game_list, &GameList::GameChosen, this, &GMainWindow::OnGameListLoadFile); |
| 680 | connect(game_list, &GameList::OpenDirectory, this, &GMainWindow::OnGameListOpenDirectory); | 698 | connect(game_list, &GameList::OpenDirectory, this, &GMainWindow::OnGameListOpenDirectory); |
| @@ -2311,6 +2329,9 @@ int main(int argc, char* argv[]) { | |||
| 2311 | // After settings have been loaded by GMainWindow, apply the filter | 2329 | // After settings have been loaded by GMainWindow, apply the filter |
| 2312 | main_window.show(); | 2330 | main_window.show(); |
| 2313 | 2331 | ||
| 2332 | QObject::connect(&app, &QGuiApplication::applicationStateChanged, &main_window, | ||
| 2333 | &GMainWindow::OnAppFocusStateChanged); | ||
| 2334 | |||
| 2314 | Settings::LogSettings(); | 2335 | Settings::LogSettings(); |
| 2315 | 2336 | ||
| 2316 | int result = app.exec(); | 2337 | int result = app.exec(); |
diff --git a/src/yuzu/main.h b/src/yuzu/main.h index e942d1248..fd4b9ccf5 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h | |||
| @@ -119,6 +119,7 @@ public slots: | |||
| 119 | void SoftwareKeyboardGetText(const Core::Frontend::SoftwareKeyboardParameters& parameters); | 119 | void SoftwareKeyboardGetText(const Core::Frontend::SoftwareKeyboardParameters& parameters); |
| 120 | void SoftwareKeyboardInvokeCheckDialog(std::u16string error_message); | 120 | void SoftwareKeyboardInvokeCheckDialog(std::u16string error_message); |
| 121 | void WebBrowserOpenPage(std::string_view filename, std::string_view arguments); | 121 | void WebBrowserOpenPage(std::string_view filename, std::string_view arguments); |
| 122 | void OnAppFocusStateChanged(Qt::ApplicationState state); | ||
| 122 | 123 | ||
| 123 | private: | 124 | private: |
| 124 | void InitializeWidgets(); | 125 | void InitializeWidgets(); |
| @@ -244,6 +245,8 @@ private: | |||
| 244 | // The path to the game currently running | 245 | // The path to the game currently running |
| 245 | QString game_path; | 246 | QString game_path; |
| 246 | 247 | ||
| 248 | bool auto_paused = false; | ||
| 249 | |||
| 247 | // FS | 250 | // FS |
| 248 | std::shared_ptr<FileSys::VfsFilesystem> vfs; | 251 | std::shared_ptr<FileSys::VfsFilesystem> vfs; |
| 249 | std::unique_ptr<FileSys::ManualContentProvider> provider; | 252 | std::unique_ptr<FileSys::ManualContentProvider> provider; |
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index c57290006..84824caae 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h | |||
| @@ -58,6 +58,7 @@ struct Values { | |||
| 58 | 58 | ||
| 59 | bool confirm_before_closing; | 59 | bool confirm_before_closing; |
| 60 | bool first_start; | 60 | bool first_start; |
| 61 | bool pause_when_in_background; | ||
| 61 | 62 | ||
| 62 | bool select_user_on_boot; | 63 | bool select_user_on_boot; |
| 63 | 64 | ||