diff options
author | german77 <juangerman-13@hotmail.com> | 2022-02-07 03:46:22 +0100 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2022-02-07 03:46:58 +0100 |
commit | ab93b4c66de04db92ada60d41975bb8c111a7f87 (patch) | |
tree | 536350b66fc67f7eaf823097e9663316df275ece | |
parent | yuzu: Add docked, GPU accuracy and adapting filter hotkeys (diff) | |
download | yuzu-ab93b4c66de04db92ada60d41975bb8c111a7f87.tar yuzu-ab93b4c66de04db92ada60d41975bb8c111a7f87.tar.gz yuzu-ab93b4c66de04db92ada60d41975bb8c111a7f87.tar.bz2 yuzu-ab93b4c66de04db92ada60d41975bb8c111a7f87.tar.lz yuzu-ab93b4c66de04db92ada60d41975bb8c111a7f87.tar.xz yuzu-ab93b4c66de04db92ada60d41975bb8c111a7f87.tar.zst yuzu-ab93b4c66de04db92ada60d41975bb8c111a7f87.zip |
-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() { ReadBasicSetting(UISettings::values.callout_flags); ReadBasicSetting(UISettings::values.show_console); ReadBasicSetting(UISettings::values.pause_when_in_background); + ReadBasicSetting(UISettings::values.mute_when_in_background); ReadBasicSetting(UISettings::values.hide_mouse); qt_config->endGroup(); @@ -1297,6 +1298,7 @@ void Config::SaveUIValues() { WriteBasicSetting(UISettings::values.callout_flags); WriteBasicSetting(UISettings::values.show_console); WriteBasicSetting(UISettings::values.pause_when_in_background); + WriteBasicSetting(UISettings::values.mute_when_in_background); WriteBasicSetting(UISettings::values.hide_mouse); 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() { ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing.GetValue()); ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot.GetValue()); ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background.GetValue()); + ui->toggle_background_mute->setChecked(UISettings::values.mute_when_in_background.GetValue()); ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse.GetValue()); ui->toggle_speed_limit->setChecked(Settings::values.use_speed_limit.GetValue()); @@ -95,6 +96,7 @@ void ConfigureGeneral::ApplyConfiguration() { UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked(); UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked(); + UISettings::values.mute_when_in_background = ui->toggle_background_mute->isChecked(); UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked(); 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 @@ </widget> </item> <item> + <widget class="QCheckBox" name="toggle_background_mute"> + <property name="text"> + <string>Mute audio when in background</string> + </property> + </widget> + </item> + <item> <widget class="QCheckBox" name="toggle_hide_mouse"> <property name="text"> <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() { } 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 (emulation_running) { + if (!emulation_running) { + return; + } + if (UISettings::values.pause_when_in_background) { if (emu_thread->IsRunning() && (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { auto_paused = true; @@ -1051,6 +1051,16 @@ void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { OnStartGame(); } } + if (UISettings::values.mute_when_in_background) { + if (!Settings::values.audio_muted && + (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { + Settings::values.audio_muted = true; + auto_muted = true; + } else if (auto_muted && state == Qt::ApplicationActive) { + Settings::values.audio_muted = false; + auto_muted = false; + } + } } 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: QString game_path; bool auto_paused = false; + bool auto_muted = false; QTimer mouse_hide_timer; // 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 { Settings::BasicSetting<bool> confirm_before_closing{true, "confirmClose"}; Settings::BasicSetting<bool> first_start{true, "firstStart"}; Settings::BasicSetting<bool> pause_when_in_background{false, "pauseWhenInBackground"}; + Settings::BasicSetting<bool> mute_when_in_background{false, "muteWhenInBackground"}; Settings::BasicSetting<bool> hide_mouse{true, "hideInactiveMouse"}; Settings::BasicSetting<bool> select_user_on_boot{false, "select_user_on_boot"}; |