summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/yuzu/configuration/config.cpp2
-rw-r--r--src/yuzu/configuration/configure_general.cpp2
-rw-r--r--src/yuzu/configuration/configure_general.ui7
-rw-r--r--src/yuzu/main.cpp18
-rw-r--r--src/yuzu/main.h1
-rw-r--r--src/yuzu/uisettings.h1
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"};