From ff92a5595002a4156bada85eeffe4bdb3cdd7f8e Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Fri, 15 Jul 2016 04:59:35 +0200 Subject: [PATCH] refactor(avform): use auto-connections in ui signals --- src/widget/form/settings/avform.cpp | 28 ++++++++++------------------ src/widget/form/settings/avform.h | 13 ++++++------- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/widget/form/settings/avform.cpp b/src/widget/form/settings/avform.cpp index 71f1dfc49..374867bdd 100644 --- a/src/widget/form/settings/avform.cpp +++ b/src/widget/form/settings/avform.cpp @@ -52,12 +52,6 @@ AVForm::AVForm() btnPlayTestSound->setToolTip( tr("Play a test sound while changing the output volume.")); - auto qcbxIndexChangedInt = static_cast(&QComboBox::currentIndexChanged); - - connect(inDevCombobox, qcbxIndexChangedInt, this, &AVForm::onAudioInDevChanged); - connect(outDevCombobox, qcbxIndexChangedInt, this, &AVForm::onAudioOutDevChanged); - connect(videoDevCombobox, qcbxIndexChangedInt, this, &AVForm::onVideoDevChanged); - connect(videoModescomboBox, qcbxIndexChangedInt, this, &AVForm::onVideoModesIndexChanged); connect(rescanButton, &QPushButton::clicked, this, [=]() { getAudioInDevices(); @@ -81,8 +75,6 @@ AVForm::AVForm() microphoneSlider->maximum()) / 4); microphoneSlider->setTracking(false); microphoneSlider->installEventFilter(this); - connect(microphoneSlider, &QSlider::valueChanged, - this, &AVForm::onMicrophoneValueChanged); for (QComboBox* cb : findChildren()) { @@ -141,7 +133,7 @@ void AVForm::open(const QString &devName, const VideoMode &mode) camera.open(devName, mode); } -void AVForm::onVideoModesIndexChanged(int index) +void AVForm::on_videoModescomboBox_currentIndexChanged(int index) { if (index < 0 || index >= videoModes.size()) { @@ -386,7 +378,7 @@ void AVForm::updateVideoModes(int curIndex) videoModescomboBox->setCurrentIndex(mid); } -void AVForm::onVideoDevChanged(int index) +void AVForm::on_videoDevCombobox_currentIndexChanged(int index) { if (index < 0 || index >= videoDeviceList.size()) { @@ -465,7 +457,7 @@ void AVForm::getAudioOutDevices() outDevCombobox->setCurrentIndex(idx < 0 ? 1 : idx); } -void AVForm::onAudioInDevChanged(int deviceIndex) +void AVForm::on_inDevCombobox_currentIndexChanged(int deviceIndex) { Settings::getInstance().setAudioInDevEnabled(deviceIndex != 0); @@ -481,7 +473,7 @@ void AVForm::onAudioInDevChanged(int deviceIndex) microphoneSlider->setSliderPosition(qRound(audio.inputGain() * 10.0)); } -void AVForm::onAudioOutDevChanged(int deviceIndex) +void AVForm::on_outDevCombobox_currentIndexChanged(int deviceIndex) { Settings::getInstance().setAudioOutDevEnabled(deviceIndex != 0); @@ -512,7 +504,12 @@ void AVForm::on_playbackSlider_valueChanged(int value) } } -void AVForm::onMicrophoneValueChanged(int value) +void AVForm::on_btnPlayTestSound_clicked(bool checked) +{ + mPlayTestSound = checked; +} + +void AVForm::on_microphoneSlider_valueChanged(int value) { const qreal dB = value / 10.0; @@ -560,8 +557,3 @@ void AVForm::retranslateUi() { Ui::AVForm::retranslateUi(this); } - -void AVForm::on_btnPlayTestSound_clicked(bool checked) -{ - mPlayTestSound = checked; -} diff --git a/src/widget/form/settings/avform.h b/src/widget/form/settings/avform.h index edebef4cc..8c4e9b36d 100644 --- a/src/widget/form/settings/avform.h +++ b/src/widget/form/settings/avform.h @@ -56,18 +56,17 @@ private: void retranslateUi(); private slots: - // audio - void onAudioInDevChanged(int deviceIndex); - void onAudioOutDevChanged(int deviceIndex); + void on_inDevCombobox_currentIndexChanged(int deviceIndex); + void on_outDevCombobox_currentIndexChanged(int deviceIndex); void on_playbackSlider_valueChanged(int value); - void onMicrophoneValueChanged(int value); + void on_btnPlayTestSound_clicked(bool checked); + void on_microphoneSlider_valueChanged(int value); // camera - void onVideoDevChanged(int index); - void onVideoModesIndexChanged(int index); + void on_videoDevCombobox_currentIndexChanged(int index); + void on_videoModescomboBox_currentIndexChanged(int index); - void on_btnPlayTestSound_clicked(bool checked); protected: void updateVideoModes(int curIndex);