diff options
| author | 2018-10-02 20:17:14 -0400 | |
|---|---|---|
| committer | 2018-10-02 20:24:30 -0400 | |
| commit | 1c7c798e9e3c4d826624b9e1f8932f3eba64a587 (patch) | |
| tree | 0a0b8fbc6328f51c13306ad0076400fb3e940a67 /src | |
| parent | configure_audio: Use QString::fromStdString() for converting audio device names (diff) | |
| download | yuzu-1c7c798e9e3c4d826624b9e1f8932f3eba64a587.tar.gz yuzu-1c7c798e9e3c4d826624b9e1f8932f3eba64a587.tar.xz yuzu-1c7c798e9e3c4d826624b9e1f8932f3eba64a587.zip | |
configure_audio: Move combo box index setting to their own functions
Keeps the individual behaviors in their own functions, and cleanly
separate. We can also do a little better by converting the relevant IDs
within the core to a QString only once, instead of converting every
string into a std::string.
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/configuration/configure_audio.cpp | 34 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_audio.h | 2 |
2 files changed, 25 insertions, 11 deletions
diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index ce6b5d9e4..eb1da0f9e 100644 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp | |||
| @@ -36,32 +36,44 @@ ConfigureAudio::ConfigureAudio(QWidget* parent) | |||
| 36 | ConfigureAudio::~ConfigureAudio() = default; | 36 | ConfigureAudio::~ConfigureAudio() = default; |
| 37 | 37 | ||
| 38 | void ConfigureAudio::setConfiguration() { | 38 | void ConfigureAudio::setConfiguration() { |
| 39 | setOutputSinkFromSinkID(); | ||
| 40 | |||
| 41 | // The device list cannot be pre-populated (nor listed) until the output sink is known. | ||
| 42 | updateAudioDevices(ui->output_sink_combo_box->currentIndex()); | ||
| 43 | |||
| 44 | setAudioDeviceFromDeviceID(); | ||
| 45 | |||
| 46 | ui->toggle_audio_stretching->setChecked(Settings::values.enable_audio_stretching); | ||
| 47 | ui->volume_slider->setValue(Settings::values.volume * ui->volume_slider->maximum()); | ||
| 48 | setVolumeIndicatorText(ui->volume_slider->sliderPosition()); | ||
| 49 | } | ||
| 50 | |||
| 51 | void ConfigureAudio::setOutputSinkFromSinkID() { | ||
| 39 | int new_sink_index = 0; | 52 | int new_sink_index = 0; |
| 53 | |||
| 54 | const QString sink_id = QString::fromStdString(Settings::values.sink_id); | ||
| 40 | for (int index = 0; index < ui->output_sink_combo_box->count(); index++) { | 55 | for (int index = 0; index < ui->output_sink_combo_box->count(); index++) { |
| 41 | if (ui->output_sink_combo_box->itemText(index).toStdString() == Settings::values.sink_id) { | 56 | if (ui->output_sink_combo_box->itemText(index) == sink_id) { |
| 42 | new_sink_index = index; | 57 | new_sink_index = index; |
| 43 | break; | 58 | break; |
| 44 | } | 59 | } |
| 45 | } | 60 | } |
| 46 | ui->output_sink_combo_box->setCurrentIndex(new_sink_index); | ||
| 47 | 61 | ||
| 48 | ui->toggle_audio_stretching->setChecked(Settings::values.enable_audio_stretching); | 62 | ui->output_sink_combo_box->setCurrentIndex(new_sink_index); |
| 49 | 63 | } | |
| 50 | // The device list cannot be pre-populated (nor listed) until the output sink is known. | ||
| 51 | updateAudioDevices(new_sink_index); | ||
| 52 | 64 | ||
| 65 | void ConfigureAudio::setAudioDeviceFromDeviceID() { | ||
| 53 | int new_device_index = -1; | 66 | int new_device_index = -1; |
| 67 | |||
| 68 | const QString device_id = QString::fromStdString(Settings::values.audio_device_id); | ||
| 54 | for (int index = 0; index < ui->audio_device_combo_box->count(); index++) { | 69 | for (int index = 0; index < ui->audio_device_combo_box->count(); index++) { |
| 55 | if (ui->audio_device_combo_box->itemText(index).toStdString() == | 70 | if (ui->audio_device_combo_box->itemText(index) == device_id) { |
| 56 | Settings::values.audio_device_id) { | ||
| 57 | new_device_index = index; | 71 | new_device_index = index; |
| 58 | break; | 72 | break; |
| 59 | } | 73 | } |
| 60 | } | 74 | } |
| 61 | ui->audio_device_combo_box->setCurrentIndex(new_device_index); | ||
| 62 | 75 | ||
| 63 | ui->volume_slider->setValue(Settings::values.volume * ui->volume_slider->maximum()); | 76 | ui->audio_device_combo_box->setCurrentIndex(new_device_index); |
| 64 | setVolumeIndicatorText(ui->volume_slider->sliderPosition()); | ||
| 65 | } | 77 | } |
| 66 | 78 | ||
| 67 | void ConfigureAudio::setVolumeIndicatorText(int percentage) { | 79 | void ConfigureAudio::setVolumeIndicatorText(int percentage) { |
diff --git a/src/yuzu/configuration/configure_audio.h b/src/yuzu/configuration/configure_audio.h index 069e79d56..207f9dfb3 100644 --- a/src/yuzu/configuration/configure_audio.h +++ b/src/yuzu/configuration/configure_audio.h | |||
| @@ -26,6 +26,8 @@ public slots: | |||
| 26 | 26 | ||
| 27 | private: | 27 | private: |
| 28 | void setConfiguration(); | 28 | void setConfiguration(); |
| 29 | void setOutputSinkFromSinkID(); | ||
| 30 | void setAudioDeviceFromDeviceID(); | ||
| 29 | void setVolumeIndicatorText(int percentage); | 31 | void setVolumeIndicatorText(int percentage); |
| 30 | 32 | ||
| 31 | std::unique_ptr<Ui::ConfigureAudio> ui; | 33 | std::unique_ptr<Ui::ConfigureAudio> ui; |