diff options
| author | 2023-11-13 09:13:12 -0500 | |
|---|---|---|
| committer | 2023-11-13 09:13:12 -0500 | |
| commit | 247d66a680abd437164da98d2dcd1b39726faafc (patch) | |
| tree | e4e1a688d4ef645b3c1faccd01204b7e9e44d16f /src | |
| parent | Merge pull request #12014 from t895/shrink-logo (diff) | |
| parent | yuzu: Make mute audio persistent (diff) | |
| download | yuzu-247d66a680abd437164da98d2dcd1b39726faafc.tar.gz yuzu-247d66a680abd437164da98d2dcd1b39726faafc.tar.xz yuzu-247d66a680abd437164da98d2dcd1b39726faafc.zip | |
Merge pull request #11990 from german77/audio
yuzu: Save mute when in background setting
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/settings.cpp | 2 | ||||
| -rw-r--r-- | src/common/settings.h | 2 | ||||
| -rw-r--r-- | src/common/settings_common.h | 1 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_audio.cpp | 10 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 12 | ||||
| -rw-r--r-- | src/yuzu/uisettings.h | 10 |
7 files changed, 26 insertions, 13 deletions
diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 98b43e49c..51717be06 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp | |||
| @@ -203,6 +203,8 @@ const char* TranslateCategory(Category category) { | |||
| 203 | case Category::Ui: | 203 | case Category::Ui: |
| 204 | case Category::UiGeneral: | 204 | case Category::UiGeneral: |
| 205 | return "UI"; | 205 | return "UI"; |
| 206 | case Category::UiAudio: | ||
| 207 | return "UiAudio"; | ||
| 206 | case Category::UiLayout: | 208 | case Category::UiLayout: |
| 207 | return "UiLayout"; | 209 | return "UiLayout"; |
| 208 | case Category::UiGameList: | 210 | case Category::UiGameList: |
diff --git a/src/common/settings.h b/src/common/settings.h index 9317075f7..e899f1ae6 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -153,7 +153,7 @@ struct Values { | |||
| 153 | true, | 153 | true, |
| 154 | true}; | 154 | true}; |
| 155 | Setting<bool, false> audio_muted{ | 155 | Setting<bool, false> audio_muted{ |
| 156 | linkage, false, "audio_muted", Category::Audio, Specialization::Default, false, true}; | 156 | linkage, false, "audio_muted", Category::Audio, Specialization::Default, true, true}; |
| 157 | Setting<bool, false> dump_audio_commands{ | 157 | Setting<bool, false> dump_audio_commands{ |
| 158 | linkage, false, "dump_audio_commands", Category::Audio, Specialization::Default, false}; | 158 | linkage, false, "dump_audio_commands", Category::Audio, Specialization::Default, false}; |
| 159 | 159 | ||
diff --git a/src/common/settings_common.h b/src/common/settings_common.h index 1800ab10d..7943223eb 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h | |||
| @@ -32,6 +32,7 @@ enum class Category : u32 { | |||
| 32 | AddOns, | 32 | AddOns, |
| 33 | Controls, | 33 | Controls, |
| 34 | Ui, | 34 | Ui, |
| 35 | UiAudio, | ||
| 35 | UiGeneral, | 36 | UiGeneral, |
| 36 | UiLayout, | 37 | UiLayout, |
| 37 | UiGameList, | 38 | UiGameList, |
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index baa3e55f3..42bbb2964 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -360,6 +360,7 @@ void Config::ReadAudioValues() { | |||
| 360 | qt_config->beginGroup(QStringLiteral("Audio")); | 360 | qt_config->beginGroup(QStringLiteral("Audio")); |
| 361 | 361 | ||
| 362 | ReadCategory(Settings::Category::Audio); | 362 | ReadCategory(Settings::Category::Audio); |
| 363 | ReadCategory(Settings::Category::UiAudio); | ||
| 363 | 364 | ||
| 364 | qt_config->endGroup(); | 365 | qt_config->endGroup(); |
| 365 | } | 366 | } |
| @@ -900,6 +901,7 @@ void Config::SaveAudioValues() { | |||
| 900 | qt_config->beginGroup(QStringLiteral("Audio")); | 901 | qt_config->beginGroup(QStringLiteral("Audio")); |
| 901 | 902 | ||
| 902 | WriteCategory(Settings::Category::Audio); | 903 | WriteCategory(Settings::Category::Audio); |
| 904 | WriteCategory(Settings::Category::UiAudio); | ||
| 903 | 905 | ||
| 904 | qt_config->endGroup(); | 906 | qt_config->endGroup(); |
| 905 | } | 907 | } |
diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index 81dd51ad3..9b6ef47a7 100644 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp | |||
| @@ -38,17 +38,21 @@ void ConfigureAudio::Setup(const ConfigurationShared::Builder& builder) { | |||
| 38 | 38 | ||
| 39 | std::map<u32, QWidget*> hold; | 39 | std::map<u32, QWidget*> hold; |
| 40 | 40 | ||
| 41 | auto push = [&](Settings::Category category) { | 41 | auto push_settings = [&](Settings::Category category) { |
| 42 | for (auto* setting : Settings::values.linkage.by_category[category]) { | 42 | for (auto* setting : Settings::values.linkage.by_category[category]) { |
| 43 | settings.push_back(setting); | 43 | settings.push_back(setting); |
| 44 | } | 44 | } |
| 45 | }; | ||
| 46 | |||
| 47 | auto push_ui_settings = [&](Settings::Category category) { | ||
| 45 | for (auto* setting : UISettings::values.linkage.by_category[category]) { | 48 | for (auto* setting : UISettings::values.linkage.by_category[category]) { |
| 46 | settings.push_back(setting); | 49 | settings.push_back(setting); |
| 47 | } | 50 | } |
| 48 | }; | 51 | }; |
| 49 | 52 | ||
| 50 | push(Settings::Category::Audio); | 53 | push_settings(Settings::Category::Audio); |
| 51 | push(Settings::Category::SystemAudio); | 54 | push_settings(Settings::Category::SystemAudio); |
| 55 | push_ui_settings(Settings::Category::UiAudio); | ||
| 52 | 56 | ||
| 53 | for (auto* setting : settings) { | 57 | for (auto* setting : settings) { |
| 54 | auto* widget = builder.BuildWidget(setting, apply_funcs); | 58 | auto* widget = builder.BuildWidget(setting, apply_funcs); |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index d2a054eaa..f077d7f9c 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -1064,12 +1064,6 @@ void GMainWindow::InitializeWidgets() { | |||
| 1064 | volume_slider->setObjectName(QStringLiteral("volume_slider")); | 1064 | volume_slider->setObjectName(QStringLiteral("volume_slider")); |
| 1065 | volume_slider->setMaximum(200); | 1065 | volume_slider->setMaximum(200); |
| 1066 | volume_slider->setPageStep(5); | 1066 | volume_slider->setPageStep(5); |
| 1067 | connect(volume_slider, &QSlider::valueChanged, this, [this](int percentage) { | ||
| 1068 | Settings::values.audio_muted = false; | ||
| 1069 | const auto volume = static_cast<u8>(percentage); | ||
| 1070 | Settings::values.volume.SetValue(volume); | ||
| 1071 | UpdateVolumeUI(); | ||
| 1072 | }); | ||
| 1073 | volume_popup->layout()->addWidget(volume_slider); | 1067 | volume_popup->layout()->addWidget(volume_slider); |
| 1074 | 1068 | ||
| 1075 | volume_button = new VolumeButton(); | 1069 | volume_button = new VolumeButton(); |
| @@ -1077,6 +1071,12 @@ void GMainWindow::InitializeWidgets() { | |||
| 1077 | volume_button->setFocusPolicy(Qt::NoFocus); | 1071 | volume_button->setFocusPolicy(Qt::NoFocus); |
| 1078 | volume_button->setCheckable(true); | 1072 | volume_button->setCheckable(true); |
| 1079 | UpdateVolumeUI(); | 1073 | UpdateVolumeUI(); |
| 1074 | connect(volume_slider, &QSlider::valueChanged, this, [this](int percentage) { | ||
| 1075 | Settings::values.audio_muted = false; | ||
| 1076 | const auto volume = static_cast<u8>(percentage); | ||
| 1077 | Settings::values.volume.SetValue(volume); | ||
| 1078 | UpdateVolumeUI(); | ||
| 1079 | }); | ||
| 1080 | connect(volume_button, &QPushButton::clicked, this, [&] { | 1080 | connect(volume_button, &QPushButton::clicked, this, [&] { |
| 1081 | UpdateVolumeUI(); | 1081 | UpdateVolumeUI(); |
| 1082 | volume_popup->setVisible(!volume_popup->isVisible()); | 1082 | volume_popup->setVisible(!volume_popup->isVisible()); |
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index 77d992c54..3485a6347 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h | |||
| @@ -109,9 +109,13 @@ struct Values { | |||
| 109 | Settings::Specialization::Default, | 109 | Settings::Specialization::Default, |
| 110 | true, | 110 | true, |
| 111 | true}; | 111 | true}; |
| 112 | Setting<bool> mute_when_in_background{ | 112 | Setting<bool> mute_when_in_background{linkage, |
| 113 | linkage, false, "muteWhenInBackground", Category::Audio, Settings::Specialization::Default, | 113 | false, |
| 114 | true, true}; | 114 | "muteWhenInBackground", |
| 115 | Category::UiAudio, | ||
| 116 | Settings::Specialization::Default, | ||
| 117 | true, | ||
| 118 | true}; | ||
| 115 | Setting<bool> hide_mouse{ | 119 | Setting<bool> hide_mouse{ |
| 116 | linkage, true, "hideInactiveMouse", Category::UiGeneral, Settings::Specialization::Default, | 120 | linkage, true, "hideInactiveMouse", Category::UiGeneral, Settings::Specialization::Default, |
| 117 | true, true}; | 121 | true, true}; |