mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-29 18:22:47 +01:00
yuzu: Mute audio when in background
This commit is contained in:
parent
49eb78497b
commit
ab93b4c66d
6 changed files with 27 additions and 4 deletions
|
@ -769,6 +769,7 @@ void Config::ReadUIValues() {
|
||||||
ReadBasicSetting(UISettings::values.callout_flags);
|
ReadBasicSetting(UISettings::values.callout_flags);
|
||||||
ReadBasicSetting(UISettings::values.show_console);
|
ReadBasicSetting(UISettings::values.show_console);
|
||||||
ReadBasicSetting(UISettings::values.pause_when_in_background);
|
ReadBasicSetting(UISettings::values.pause_when_in_background);
|
||||||
|
ReadBasicSetting(UISettings::values.mute_when_in_background);
|
||||||
ReadBasicSetting(UISettings::values.hide_mouse);
|
ReadBasicSetting(UISettings::values.hide_mouse);
|
||||||
|
|
||||||
qt_config->endGroup();
|
qt_config->endGroup();
|
||||||
|
@ -1297,6 +1298,7 @@ void Config::SaveUIValues() {
|
||||||
WriteBasicSetting(UISettings::values.callout_flags);
|
WriteBasicSetting(UISettings::values.callout_flags);
|
||||||
WriteBasicSetting(UISettings::values.show_console);
|
WriteBasicSetting(UISettings::values.show_console);
|
||||||
WriteBasicSetting(UISettings::values.pause_when_in_background);
|
WriteBasicSetting(UISettings::values.pause_when_in_background);
|
||||||
|
WriteBasicSetting(UISettings::values.mute_when_in_background);
|
||||||
WriteBasicSetting(UISettings::values.hide_mouse);
|
WriteBasicSetting(UISettings::values.hide_mouse);
|
||||||
|
|
||||||
qt_config->endGroup();
|
qt_config->endGroup();
|
||||||
|
|
|
@ -46,6 +46,7 @@ void ConfigureGeneral::SetConfiguration() {
|
||||||
ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing.GetValue());
|
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_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_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_hide_mouse->setChecked(UISettings::values.hide_mouse.GetValue());
|
||||||
|
|
||||||
ui->toggle_speed_limit->setChecked(Settings::values.use_speed_limit.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.confirm_before_closing = ui->toggle_check_exit->isChecked();
|
||||||
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.pause_when_in_background = ui->toggle_background_pause->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();
|
UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked();
|
||||||
|
|
||||||
Settings::values.fps_cap.SetValue(ui->fps_cap->value());
|
Settings::values.fps_cap.SetValue(ui->fps_cap->value());
|
||||||
|
|
|
@ -163,6 +163,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="toggle_background_mute">
|
||||||
|
<property name="text">
|
||||||
|
<string>Mute audio when in background</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="toggle_hide_mouse">
|
<widget class="QCheckBox" name="toggle_hide_mouse">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
|
@ -1034,14 +1034,14 @@ void GMainWindow::RestoreUIState() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) {
|
void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) {
|
||||||
if (!UISettings::values.pause_when_in_background) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (state != Qt::ApplicationHidden && state != Qt::ApplicationInactive &&
|
if (state != Qt::ApplicationHidden && state != Qt::ApplicationInactive &&
|
||||||
state != Qt::ApplicationActive) {
|
state != Qt::ApplicationActive) {
|
||||||
LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state);
|
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() &&
|
if (emu_thread->IsRunning() &&
|
||||||
(state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) {
|
(state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) {
|
||||||
auto_paused = true;
|
auto_paused = true;
|
||||||
|
@ -1051,6 +1051,16 @@ void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) {
|
||||||
OnStartGame();
|
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() {
|
void GMainWindow::ConnectWidgetEvents() {
|
||||||
|
|
|
@ -372,6 +372,7 @@ private:
|
||||||
QString game_path;
|
QString game_path;
|
||||||
|
|
||||||
bool auto_paused = false;
|
bool auto_paused = false;
|
||||||
|
bool auto_muted = false;
|
||||||
QTimer mouse_hide_timer;
|
QTimer mouse_hide_timer;
|
||||||
|
|
||||||
// FS
|
// FS
|
||||||
|
|
|
@ -73,6 +73,7 @@ struct Values {
|
||||||
Settings::BasicSetting<bool> confirm_before_closing{true, "confirmClose"};
|
Settings::BasicSetting<bool> confirm_before_closing{true, "confirmClose"};
|
||||||
Settings::BasicSetting<bool> first_start{true, "firstStart"};
|
Settings::BasicSetting<bool> first_start{true, "firstStart"};
|
||||||
Settings::BasicSetting<bool> pause_when_in_background{false, "pauseWhenInBackground"};
|
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> hide_mouse{true, "hideInactiveMouse"};
|
||||||
|
|
||||||
Settings::BasicSetting<bool> select_user_on_boot{false, "select_user_on_boot"};
|
Settings::BasicSetting<bool> select_user_on_boot{false, "select_user_on_boot"};
|
||||||
|
|
Loading…
Reference in a new issue