diff options
| author | 2022-02-06 20:46:22 -0600 | |
|---|---|---|
| committer | 2022-02-06 20:46:58 -0600 | |
| commit | ab93b4c66de04db92ada60d41975bb8c111a7f87 (patch) | |
| tree | 536350b66fc67f7eaf823097e9663316df275ece /src | |
| parent | yuzu: Add docked, GPU accuracy and adapting filter hotkeys (diff) | |
| download | yuzu-ab93b4c66de04db92ada60d41975bb8c111a7f87.tar.gz yuzu-ab93b4c66de04db92ada60d41975bb8c111a7f87.tar.xz yuzu-ab93b4c66de04db92ada60d41975bb8c111a7f87.zip | |
yuzu: Mute audio when in background
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 2 | ||||
| -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 | 18 | ||||
| -rw-r--r-- | src/yuzu/main.h | 1 | ||||
| -rw-r--r-- | src/yuzu/uisettings.h | 1 |
6 files changed, 27 insertions, 4 deletions
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 68facbce4..9ee7992e7 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -769,6 +769,7 @@ void Config::ReadUIValues() { | |||
| 769 | ReadBasicSetting(UISettings::values.callout_flags); | 769 | ReadBasicSetting(UISettings::values.callout_flags); |
| 770 | ReadBasicSetting(UISettings::values.show_console); | 770 | ReadBasicSetting(UISettings::values.show_console); |
| 771 | ReadBasicSetting(UISettings::values.pause_when_in_background); | 771 | ReadBasicSetting(UISettings::values.pause_when_in_background); |
| 772 | ReadBasicSetting(UISettings::values.mute_when_in_background); | ||
| 772 | ReadBasicSetting(UISettings::values.hide_mouse); | 773 | ReadBasicSetting(UISettings::values.hide_mouse); |
| 773 | 774 | ||
| 774 | qt_config->endGroup(); | 775 | qt_config->endGroup(); |
| @@ -1297,6 +1298,7 @@ void Config::SaveUIValues() { | |||
| 1297 | WriteBasicSetting(UISettings::values.callout_flags); | 1298 | WriteBasicSetting(UISettings::values.callout_flags); |
| 1298 | WriteBasicSetting(UISettings::values.show_console); | 1299 | WriteBasicSetting(UISettings::values.show_console); |
| 1299 | WriteBasicSetting(UISettings::values.pause_when_in_background); | 1300 | WriteBasicSetting(UISettings::values.pause_when_in_background); |
| 1301 | WriteBasicSetting(UISettings::values.mute_when_in_background); | ||
| 1300 | WriteBasicSetting(UISettings::values.hide_mouse); | 1302 | WriteBasicSetting(UISettings::values.hide_mouse); |
| 1301 | 1303 | ||
| 1302 | qt_config->endGroup(); | 1304 | qt_config->endGroup(); |
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index 566879317..978a29fe6 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp | |||
| @@ -46,6 +46,7 @@ void ConfigureGeneral::SetConfiguration() { | |||
| 46 | ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing.GetValue()); | 46 | ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing.GetValue()); |
| 47 | ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot.GetValue()); | 47 | ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot.GetValue()); |
| 48 | ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background.GetValue()); | 48 | ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background.GetValue()); |
| 49 | ui->toggle_background_mute->setChecked(UISettings::values.mute_when_in_background.GetValue()); | ||
| 49 | ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse.GetValue()); | 50 | ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse.GetValue()); |
| 50 | 51 | ||
| 51 | ui->toggle_speed_limit->setChecked(Settings::values.use_speed_limit.GetValue()); | 52 | ui->toggle_speed_limit->setChecked(Settings::values.use_speed_limit.GetValue()); |
| @@ -95,6 +96,7 @@ void ConfigureGeneral::ApplyConfiguration() { | |||
| 95 | UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); | 96 | UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); |
| 96 | UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked(); | 97 | UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked(); |
| 97 | UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked(); | 98 | UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked(); |
| 99 | UISettings::values.mute_when_in_background = ui->toggle_background_mute->isChecked(); | ||
| 98 | UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked(); | 100 | UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked(); |
| 99 | 101 | ||
| 100 | Settings::values.fps_cap.SetValue(ui->fps_cap->value()); | 102 | Settings::values.fps_cap.SetValue(ui->fps_cap->value()); |
diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui index 112dc72b3..bfc771135 100644 --- a/src/yuzu/configuration/configure_general.ui +++ b/src/yuzu/configuration/configure_general.ui | |||
| @@ -164,6 +164,13 @@ | |||
| 164 | </widget> | 164 | </widget> |
| 165 | </item> | 165 | </item> |
| 166 | <item> | 166 | <item> |
| 167 | <widget class="QCheckBox" name="toggle_background_mute"> | ||
| 168 | <property name="text"> | ||
| 169 | <string>Mute audio when in background</string> | ||
| 170 | </property> | ||
| 171 | </widget> | ||
| 172 | </item> | ||
| 173 | <item> | ||
| 167 | <widget class="QCheckBox" name="toggle_hide_mouse"> | 174 | <widget class="QCheckBox" name="toggle_hide_mouse"> |
| 168 | <property name="text"> | 175 | <property name="text"> |
| 169 | <string>Hide mouse on inactivity</string> | 176 | <string>Hide mouse on inactivity</string> |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 68cd9f6ea..cc5a8f65e 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -1034,14 +1034,14 @@ void GMainWindow::RestoreUIState() { | |||
| 1034 | } | 1034 | } |
| 1035 | 1035 | ||
| 1036 | void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { | 1036 | void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { |
| 1037 | if (!UISettings::values.pause_when_in_background) { | ||
| 1038 | return; | ||
| 1039 | } | ||
| 1040 | if (state != Qt::ApplicationHidden && state != Qt::ApplicationInactive && | 1037 | if (state != Qt::ApplicationHidden && state != Qt::ApplicationInactive && |
| 1041 | state != Qt::ApplicationActive) { | 1038 | state != Qt::ApplicationActive) { |
| 1042 | LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state); | 1039 | LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state); |
| 1043 | } | 1040 | } |
| 1044 | if (emulation_running) { | 1041 | if (!emulation_running) { |
| 1042 | return; | ||
| 1043 | } | ||
| 1044 | if (UISettings::values.pause_when_in_background) { | ||
| 1045 | if (emu_thread->IsRunning() && | 1045 | if (emu_thread->IsRunning() && |
| 1046 | (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { | 1046 | (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { |
| 1047 | auto_paused = true; | 1047 | auto_paused = true; |
| @@ -1051,6 +1051,16 @@ void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { | |||
| 1051 | OnStartGame(); | 1051 | OnStartGame(); |
| 1052 | } | 1052 | } |
| 1053 | } | 1053 | } |
| 1054 | if (UISettings::values.mute_when_in_background) { | ||
| 1055 | if (!Settings::values.audio_muted && | ||
| 1056 | (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { | ||
| 1057 | Settings::values.audio_muted = true; | ||
| 1058 | auto_muted = true; | ||
| 1059 | } else if (auto_muted && state == Qt::ApplicationActive) { | ||
| 1060 | Settings::values.audio_muted = false; | ||
| 1061 | auto_muted = false; | ||
| 1062 | } | ||
| 1063 | } | ||
| 1054 | } | 1064 | } |
| 1055 | 1065 | ||
| 1056 | void GMainWindow::ConnectWidgetEvents() { | 1066 | void GMainWindow::ConnectWidgetEvents() { |
diff --git a/src/yuzu/main.h b/src/yuzu/main.h index eb939bb29..6a35b9e3d 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h | |||
| @@ -372,6 +372,7 @@ private: | |||
| 372 | QString game_path; | 372 | QString game_path; |
| 373 | 373 | ||
| 374 | bool auto_paused = false; | 374 | bool auto_paused = false; |
| 375 | bool auto_muted = false; | ||
| 375 | QTimer mouse_hide_timer; | 376 | QTimer mouse_hide_timer; |
| 376 | 377 | ||
| 377 | // FS | 378 | // FS |
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index f7298ddad..06e8b46da 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h | |||
| @@ -73,6 +73,7 @@ struct Values { | |||
| 73 | Settings::BasicSetting<bool> confirm_before_closing{true, "confirmClose"}; | 73 | Settings::BasicSetting<bool> confirm_before_closing{true, "confirmClose"}; |
| 74 | Settings::BasicSetting<bool> first_start{true, "firstStart"}; | 74 | Settings::BasicSetting<bool> first_start{true, "firstStart"}; |
| 75 | Settings::BasicSetting<bool> pause_when_in_background{false, "pauseWhenInBackground"}; | 75 | Settings::BasicSetting<bool> pause_when_in_background{false, "pauseWhenInBackground"}; |
| 76 | Settings::BasicSetting<bool> mute_when_in_background{false, "muteWhenInBackground"}; | ||
| 76 | Settings::BasicSetting<bool> hide_mouse{true, "hideInactiveMouse"}; | 77 | Settings::BasicSetting<bool> hide_mouse{true, "hideInactiveMouse"}; |
| 77 | 78 | ||
| 78 | Settings::BasicSetting<bool> select_user_on_boot{false, "select_user_on_boot"}; | 79 | Settings::BasicSetting<bool> select_user_on_boot{false, "select_user_on_boot"}; |