Merge pull request #11990 from german77/audio

yuzu: Save mute when in background setting
This commit is contained in:
liamwhite 2023-11-13 09:13:12 -05:00 committed by GitHub
commit 247d66a680
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 13 deletions

View File

@ -203,6 +203,8 @@ const char* TranslateCategory(Category category) {
case Category::Ui: case Category::Ui:
case Category::UiGeneral: case Category::UiGeneral:
return "UI"; return "UI";
case Category::UiAudio:
return "UiAudio";
case Category::UiLayout: case Category::UiLayout:
return "UiLayout"; return "UiLayout";
case Category::UiGameList: case Category::UiGameList:

View File

@ -153,7 +153,7 @@ struct Values {
true, true,
true}; true};
Setting<bool, false> audio_muted{ Setting<bool, false> audio_muted{
linkage, false, "audio_muted", Category::Audio, Specialization::Default, false, true}; linkage, false, "audio_muted", Category::Audio, Specialization::Default, true, true};
Setting<bool, false> dump_audio_commands{ Setting<bool, false> dump_audio_commands{
linkage, false, "dump_audio_commands", Category::Audio, Specialization::Default, false}; linkage, false, "dump_audio_commands", Category::Audio, Specialization::Default, false};

View File

@ -32,6 +32,7 @@ enum class Category : u32 {
AddOns, AddOns,
Controls, Controls,
Ui, Ui,
UiAudio,
UiGeneral, UiGeneral,
UiLayout, UiLayout,
UiGameList, UiGameList,

View File

@ -360,6 +360,7 @@ void Config::ReadAudioValues() {
qt_config->beginGroup(QStringLiteral("Audio")); qt_config->beginGroup(QStringLiteral("Audio"));
ReadCategory(Settings::Category::Audio); ReadCategory(Settings::Category::Audio);
ReadCategory(Settings::Category::UiAudio);
qt_config->endGroup(); qt_config->endGroup();
} }
@ -900,6 +901,7 @@ void Config::SaveAudioValues() {
qt_config->beginGroup(QStringLiteral("Audio")); qt_config->beginGroup(QStringLiteral("Audio"));
WriteCategory(Settings::Category::Audio); WriteCategory(Settings::Category::Audio);
WriteCategory(Settings::Category::UiAudio);
qt_config->endGroup(); qt_config->endGroup();
} }

View File

@ -38,17 +38,21 @@ void ConfigureAudio::Setup(const ConfigurationShared::Builder& builder) {
std::map<u32, QWidget*> hold; std::map<u32, QWidget*> hold;
auto push = [&](Settings::Category category) { auto push_settings = [&](Settings::Category category) {
for (auto* setting : Settings::values.linkage.by_category[category]) { for (auto* setting : Settings::values.linkage.by_category[category]) {
settings.push_back(setting); settings.push_back(setting);
} }
};
auto push_ui_settings = [&](Settings::Category category) {
for (auto* setting : UISettings::values.linkage.by_category[category]) { for (auto* setting : UISettings::values.linkage.by_category[category]) {
settings.push_back(setting); settings.push_back(setting);
} }
}; };
push(Settings::Category::Audio); push_settings(Settings::Category::Audio);
push(Settings::Category::SystemAudio); push_settings(Settings::Category::SystemAudio);
push_ui_settings(Settings::Category::UiAudio);
for (auto* setting : settings) { for (auto* setting : settings) {
auto* widget = builder.BuildWidget(setting, apply_funcs); auto* widget = builder.BuildWidget(setting, apply_funcs);

View File

@ -1064,12 +1064,6 @@ void GMainWindow::InitializeWidgets() {
volume_slider->setObjectName(QStringLiteral("volume_slider")); volume_slider->setObjectName(QStringLiteral("volume_slider"));
volume_slider->setMaximum(200); volume_slider->setMaximum(200);
volume_slider->setPageStep(5); volume_slider->setPageStep(5);
connect(volume_slider, &QSlider::valueChanged, this, [this](int percentage) {
Settings::values.audio_muted = false;
const auto volume = static_cast<u8>(percentage);
Settings::values.volume.SetValue(volume);
UpdateVolumeUI();
});
volume_popup->layout()->addWidget(volume_slider); volume_popup->layout()->addWidget(volume_slider);
volume_button = new VolumeButton(); volume_button = new VolumeButton();
@ -1077,6 +1071,12 @@ void GMainWindow::InitializeWidgets() {
volume_button->setFocusPolicy(Qt::NoFocus); volume_button->setFocusPolicy(Qt::NoFocus);
volume_button->setCheckable(true); volume_button->setCheckable(true);
UpdateVolumeUI(); UpdateVolumeUI();
connect(volume_slider, &QSlider::valueChanged, this, [this](int percentage) {
Settings::values.audio_muted = false;
const auto volume = static_cast<u8>(percentage);
Settings::values.volume.SetValue(volume);
UpdateVolumeUI();
});
connect(volume_button, &QPushButton::clicked, this, [&] { connect(volume_button, &QPushButton::clicked, this, [&] {
UpdateVolumeUI(); UpdateVolumeUI();
volume_popup->setVisible(!volume_popup->isVisible()); volume_popup->setVisible(!volume_popup->isVisible());

View File

@ -109,9 +109,13 @@ struct Values {
Settings::Specialization::Default, Settings::Specialization::Default,
true, true,
true}; true};
Setting<bool> mute_when_in_background{ Setting<bool> mute_when_in_background{linkage,
linkage, false, "muteWhenInBackground", Category::Audio, Settings::Specialization::Default, false,
true, true}; "muteWhenInBackground",
Category::UiAudio,
Settings::Specialization::Default,
true,
true};
Setting<bool> hide_mouse{ Setting<bool> hide_mouse{
linkage, true, "hideInactiveMouse", Category::UiGeneral, Settings::Specialization::Default, linkage, true, "hideInactiveMouse", Category::UiGeneral, Settings::Specialization::Default,
true, true}; true, true};