Qt: add gui audio volume setting

This commit is contained in:
Megamouse 2026-03-20 01:27:57 +01:00
parent 33f8deffbe
commit 40229adb14
7 changed files with 78 additions and 2 deletions

View file

@ -17,6 +17,7 @@ namespace gui
{
QString stylesheet;
bool custom_stylesheet_active = false;
f32 volume = 1.0f;
QString get_savestate_list_column_name(savestate_list_columns col)
{

View file

@ -13,6 +13,7 @@ namespace gui
{
extern QString stylesheet;
extern bool custom_stylesheet_active;
extern f32 volume;
enum custom_roles
{
@ -139,6 +140,8 @@ namespace gui
const QColor gl_icon_color = QColor(240, 240, 240, 255);
const gui_save gui_volume = gui_save(main_window, "guiVolume", 1.0f);
const gui_save rg_freeze = gui_save(main_window, "recentGamesFrozen", false);
const gui_save rg_entries = gui_save(main_window, "recentGamesNames", QVariant::fromValue(q_pair_list()));

View file

@ -3663,6 +3663,8 @@ void main_window::ConfigureGuiFromSettings()
m_recent_game.entries = gui_settings::Var2List(m_gui_settings->GetValue(gui::rg_entries));
m_recent_save.entries = gui_settings::Var2List(m_gui_settings->GetValue(gui::rs_entries));
gui::volume = std::clamp(m_gui_settings->GetValue(gui::gui_volume).toFloat() * 100.0f, 0.0f, 100.0f);
const auto update_recent_games_menu = [this](bool is_savestate)
{
recent_game_wrapper& rgw = is_savestate ? m_recent_save : m_recent_game;

View file

@ -1,7 +1,9 @@
#include "stdafx.h"
#include "Emu/System.h"
#include "Emu/system_config.h"
#include "Emu/Audio/audio_utils.h"
#include "qt_video_source.h"
#include "gui_settings.h"
#include "Loader/ISO.h"
@ -267,7 +269,14 @@ void qt_video_source::start_audio()
}
}
audio.output->setVolume(g_cfg.audio.volume.get() / 100.0f);
f32 volume = gui::volume;
if (m_audio_instance_index == qt_audio_instance::emu_index)
{
volume = audio::get_volume();
}
audio.output->setVolume(std::clamp(volume, 0.0f, 1.0f));
audio.player->play();
audio.source = this;
}

View file

@ -2186,6 +2186,16 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
m_gui_settings->SetValue(gui::nav_global, checked);
});
// Audio
SubscribeTooltip(ui->gb_gui_volume, tooltips.settings.gui_volume);
connect(ui->guiVolume, &QSlider::valueChanged, [this](int value)
{
ui->guiVolumeLabel->setText(tr("User Interface: %0 %", "GUI volume").arg(value));
gui::volume = std::clamp(value / 100.0f, 0.0f, 1.0f);
m_gui_settings->SetValue(gui::gui_volume, gui::volume);
});
ui->guiVolume->setValue(std::clamp(m_gui_settings->GetValue(gui::gui_volume).toFloat() * 100.0f, 0.0f, 100.0f));
// Discord:
SubscribeTooltip(ui->useRichPresence, tooltips.settings.use_rich_presence);
SubscribeTooltip(ui->discordState, tooltips.settings.discord_state);

View file

@ -513,7 +513,7 @@
</item>
<item>
<widget class="QWidget" name="widget_gpu_4" native="true">
<layout class="QHBoxLayout" name="widget_gpu_4_layout" stretch="1,1">
<layout class="QHBoxLayout" name="widget_gpu_4_layout" stretch="1">
<property name="leftMargin">
<number>0</number>
</property>
@ -3980,6 +3980,56 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_gui_volume">
<property name="title">
<string>Volume</string>
</property>
<layout class="QVBoxLayout" name="gb_gui_volume_layout">
<item>
<widget class="QWidget" name="gui_volume" native="true">
<layout class="QVBoxLayout" name="layout_gui_volume">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="guiVolumeLabel">
<property name="text">
<string>GUI: 0%</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="guiVolume">
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TickPosition::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>50</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="guiTabSpacerMiddle">
<property name="orientation">

View file

@ -228,6 +228,7 @@ public:
const QString uuid = tr("This is the ID used for hardware statistics.\nIt should only be reset if you change your hardware configuration or if you copied RPCS3 to another PC.");
const QString pad_navigation = tr("Use the game pad that is configured for player 1 to navigate in the GUI.");
const QString global_navigation = tr("Keep control over pad navigation if RPCS3 is not the active window.");
const QString gui_volume = tr("Set the audio volume of the user interface. This does not affect the ingame audio.");
// input