configure_audio: Port to support both per-game and global modes
This commit is contained in:
@@ -23,6 +23,10 @@ ConfigureAudio::ConfigureAudio(QWidget* parent)
|
||||
|
||||
connect(ui->volume_slider, &QSlider::valueChanged, this,
|
||||
&ConfigureAudio::setVolumeIndicatorText);
|
||||
connect(ui->volume_slider, &QSlider::valueChanged, this, [this]() {
|
||||
if (!ui->volume_checkbox->isHidden())
|
||||
ui->volume_checkbox->setChecked(true);
|
||||
});
|
||||
|
||||
this->setConfiguration();
|
||||
connect(ui->output_sink_combo_box,
|
||||
@@ -35,6 +39,31 @@ ConfigureAudio::ConfigureAudio(QWidget* parent)
|
||||
|
||||
ConfigureAudio::~ConfigureAudio() = default;
|
||||
|
||||
void ConfigureAudio::setPerGame(bool per_game) {
|
||||
ui->toggle_audio_stretching->setTristate(per_game);
|
||||
ui->output_sink_checkbox->setHidden(!per_game);
|
||||
ui->audio_device_checkbox->setHidden(!per_game);
|
||||
ui->volume_checkbox->setHidden(!per_game);
|
||||
}
|
||||
|
||||
void ConfigureAudio::loadValuesChange(const PerGameValuesChange& change) {
|
||||
ui->toggle_audio_stretching->setCheckState(
|
||||
change.enable_audio_stretching
|
||||
? (Settings::values->enable_audio_stretching ? Qt::Checked : Qt::Unchecked)
|
||||
: Qt::PartiallyChecked);
|
||||
ui->output_sink_checkbox->setChecked(change.sink_id);
|
||||
ui->audio_device_checkbox->setChecked(change.audio_device_id);
|
||||
ui->volume_checkbox->setChecked(change.volume);
|
||||
}
|
||||
|
||||
void ConfigureAudio::mergeValuesChange(PerGameValuesChange& change) {
|
||||
change.enable_audio_stretching =
|
||||
ui->toggle_audio_stretching->checkState() != Qt::PartiallyChecked;
|
||||
change.sink_id = ui->output_sink_checkbox->isChecked();
|
||||
change.audio_device_id = ui->audio_device_checkbox->isChecked();
|
||||
change.volume = ui->volume_checkbox->isChecked();
|
||||
}
|
||||
|
||||
void ConfigureAudio::setConfiguration() {
|
||||
setOutputSinkFromSinkID();
|
||||
|
||||
@@ -43,15 +72,15 @@ void ConfigureAudio::setConfiguration() {
|
||||
|
||||
setAudioDeviceFromDeviceID();
|
||||
|
||||
ui->toggle_audio_stretching->setChecked(Settings::values.enable_audio_stretching);
|
||||
ui->volume_slider->setValue(Settings::values.volume * ui->volume_slider->maximum());
|
||||
ui->toggle_audio_stretching->setChecked(Settings::values->enable_audio_stretching);
|
||||
ui->volume_slider->setValue(Settings::values->volume * ui->volume_slider->maximum());
|
||||
setVolumeIndicatorText(ui->volume_slider->sliderPosition());
|
||||
}
|
||||
|
||||
void ConfigureAudio::setOutputSinkFromSinkID() {
|
||||
int new_sink_index = 0;
|
||||
|
||||
const QString sink_id = QString::fromStdString(Settings::values.sink_id);
|
||||
const QString sink_id = QString::fromStdString(Settings::values->sink_id);
|
||||
for (int index = 0; index < ui->output_sink_combo_box->count(); index++) {
|
||||
if (ui->output_sink_combo_box->itemText(index) == sink_id) {
|
||||
new_sink_index = index;
|
||||
@@ -65,7 +94,7 @@ void ConfigureAudio::setOutputSinkFromSinkID() {
|
||||
void ConfigureAudio::setAudioDeviceFromDeviceID() {
|
||||
int new_device_index = -1;
|
||||
|
||||
const QString device_id = QString::fromStdString(Settings::values.audio_device_id);
|
||||
const QString device_id = QString::fromStdString(Settings::values->audio_device_id);
|
||||
for (int index = 0; index < ui->audio_device_combo_box->count(); index++) {
|
||||
if (ui->audio_device_combo_box->itemText(index) == device_id) {
|
||||
new_device_index = index;
|
||||
@@ -81,14 +110,14 @@ void ConfigureAudio::setVolumeIndicatorText(int percentage) {
|
||||
}
|
||||
|
||||
void ConfigureAudio::applyConfiguration() {
|
||||
Settings::values.sink_id =
|
||||
Settings::values->sink_id =
|
||||
ui->output_sink_combo_box->itemText(ui->output_sink_combo_box->currentIndex())
|
||||
.toStdString();
|
||||
Settings::values.enable_audio_stretching = ui->toggle_audio_stretching->isChecked();
|
||||
Settings::values.audio_device_id =
|
||||
Settings::values->enable_audio_stretching = ui->toggle_audio_stretching->isChecked();
|
||||
Settings::values->audio_device_id =
|
||||
ui->audio_device_combo_box->itemText(ui->audio_device_combo_box->currentIndex())
|
||||
.toStdString();
|
||||
Settings::values.volume =
|
||||
Settings::values->volume =
|
||||
static_cast<float>(ui->volume_slider->sliderPosition()) / ui->volume_slider->maximum();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <QWidget>
|
||||
#include "yuzu/configuration/config.h"
|
||||
|
||||
namespace Ui {
|
||||
class ConfigureAudio;
|
||||
@@ -18,6 +19,10 @@ public:
|
||||
explicit ConfigureAudio(QWidget* parent = nullptr);
|
||||
~ConfigureAudio();
|
||||
|
||||
void setPerGame(bool per_game);
|
||||
void loadValuesChange(const PerGameValuesChange& change);
|
||||
void mergeValuesChange(PerGameValuesChange& change);
|
||||
|
||||
void applyConfiguration();
|
||||
void retranslateUi();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>188</width>
|
||||
<width>402</width>
|
||||
<height>246</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -29,18 +29,31 @@
|
||||
<item>
|
||||
<widget class="QComboBox" name="output_sink_combo_box"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="output_sink_checkbox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="toggle_audio_stretching">
|
||||
<property name="toolTip">
|
||||
<string>This post-processing effect adjusts audio speed to match emulation speed and helps prevent audio stutter. This however increases audio latency.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable audio stretching</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="toggle_audio_stretching">
|
||||
<property name="toolTip">
|
||||
<string>This post-processing effect adjusts audio speed to match emulation speed and helps prevent audio stutter. This however increases audio latency.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable audio stretching</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
@@ -53,6 +66,19 @@
|
||||
<item>
|
||||
<widget class="QComboBox" name="audio_device_combo_box"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="audio_device_checkbox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@@ -115,6 +141,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="volume_checkbox">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -133,6 +166,16 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Check the box next to output engine, audio device, or volume to override the global default setting with this one for this game only.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
||||
Reference in New Issue
Block a user