Merge pull request #3831 from FearlessTobi/add-volume-slider

citra_qt: Add a volume slider
This commit is contained in:
James Rowe 2018-07-18 09:56:47 -06:00 committed by GitHub
commit 2f8c9c8126
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 110 additions and 20 deletions

View file

@ -122,6 +122,7 @@ void Config::ReadValues() {
qt_config->value("enable_audio_stretching", true).toBool();
Settings::values.audio_device_id =
qt_config->value("output_device", "auto").toString().toStdString();
Settings::values.volume = qt_config->value("volume", 1).toFloat();
qt_config->endGroup();
using namespace Service::CAM;
@ -344,6 +345,7 @@ void Config::SaveValues() {
qt_config->setValue("output_engine", QString::fromStdString(Settings::values.sink_id));
qt_config->setValue("enable_audio_stretching", Settings::values.enable_audio_stretching);
qt_config->setValue("output_device", QString::fromStdString(Settings::values.audio_device_id));
qt_config->setValue("volume", Settings::values.volume);
qt_config->endGroup();
using namespace Service::CAM;

View file

@ -19,6 +19,10 @@ ConfigureAudio::ConfigureAudio(QWidget* parent)
ui->output_sink_combo_box->addItem(sink_detail.id);
}
connect(ui->volume_slider, &QSlider::valueChanged, [this] {
ui->volume_indicator->setText(tr("%1 %").arg(ui->volume_slider->sliderPosition()));
});
this->setConfiguration();
connect(ui->output_sink_combo_box,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
@ -51,6 +55,9 @@ void ConfigureAudio::setConfiguration() {
}
}
ui->audio_device_combo_box->setCurrentIndex(new_device_index);
ui->volume_slider->setValue(Settings::values.volume * ui->volume_slider->maximum());
ui->volume_indicator->setText(tr("%1 %").arg(ui->volume_slider->sliderPosition()));
}
void ConfigureAudio::applyConfiguration() {
@ -61,6 +68,8 @@ void ConfigureAudio::applyConfiguration() {
Settings::values.audio_device_id =
ui->audio_device_combo_box->itemText(ui->audio_device_combo_box->currentIndex())
.toStdString();
Settings::values.volume =
static_cast<float>(ui->volume_slider->sliderPosition()) / ui->volume_slider->maximum();
}
void ConfigureAudio::updateAudioDevices(int sink_index) {

View file

@ -1,11 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ConfigureAudio</class>
<widget class="QWidget" name="ConfigureAudio">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>188</width>
<height>246</height>
</rect>
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QGroupBox">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Audio</string>
</property>
@ -13,39 +20,99 @@
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel">
<widget class="QLabel" name="label">
<property name="text">
<string>Output Engine:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="output_sink_combo_box">
</widget>
<widget class="QComboBox" name="output_sink_combo_box"/>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="toggle_audio_stretching">
<property name="text">
<string>Enable audio stretching</string>
</property>
<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>
<widget class="QLabel">
<widget class="QLabel" name="label">
<property name="text">
<string>Audio Device:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="audio_device_combo_box">
<widget class="QComboBox" name="audio_device_combo_box"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Volume:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSlider" name="volume_slider">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="pageStep">
<number>10</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="volume_indicator">
<property name="minimumSize">
<size>
<width>32</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0 %</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
@ -60,14 +127,14 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<width>167</width>
<height>55</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources />
<connections />
<resources/>
<connections/>
</ui>