1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor(avform): use auto-connections in ui signals

This commit is contained in:
Nils Fenner 2016-07-15 04:59:35 +02:00
parent de438f1c23
commit ff92a55950
No known key found for this signature in database
GPG Key ID: 9591A163FF9BE04C
2 changed files with 16 additions and 25 deletions

View File

@ -52,12 +52,6 @@ AVForm::AVForm()
btnPlayTestSound->setToolTip( btnPlayTestSound->setToolTip(
tr("Play a test sound while changing the output volume.")); tr("Play a test sound while changing the output volume."));
auto qcbxIndexChangedInt = static_cast<void(QComboBox::*)(int)>(&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, [=]() connect(rescanButton, &QPushButton::clicked, this, [=]()
{ {
getAudioInDevices(); getAudioInDevices();
@ -81,8 +75,6 @@ AVForm::AVForm()
microphoneSlider->maximum()) / 4); microphoneSlider->maximum()) / 4);
microphoneSlider->setTracking(false); microphoneSlider->setTracking(false);
microphoneSlider->installEventFilter(this); microphoneSlider->installEventFilter(this);
connect(microphoneSlider, &QSlider::valueChanged,
this, &AVForm::onMicrophoneValueChanged);
for (QComboBox* cb : findChildren<QComboBox*>()) for (QComboBox* cb : findChildren<QComboBox*>())
{ {
@ -141,7 +133,7 @@ void AVForm::open(const QString &devName, const VideoMode &mode)
camera.open(devName, mode); camera.open(devName, mode);
} }
void AVForm::onVideoModesIndexChanged(int index) void AVForm::on_videoModescomboBox_currentIndexChanged(int index)
{ {
if (index < 0 || index >= videoModes.size()) if (index < 0 || index >= videoModes.size())
{ {
@ -386,7 +378,7 @@ void AVForm::updateVideoModes(int curIndex)
videoModescomboBox->setCurrentIndex(mid); videoModescomboBox->setCurrentIndex(mid);
} }
void AVForm::onVideoDevChanged(int index) void AVForm::on_videoDevCombobox_currentIndexChanged(int index)
{ {
if (index < 0 || index >= videoDeviceList.size()) if (index < 0 || index >= videoDeviceList.size())
{ {
@ -465,7 +457,7 @@ void AVForm::getAudioOutDevices()
outDevCombobox->setCurrentIndex(idx < 0 ? 1 : idx); outDevCombobox->setCurrentIndex(idx < 0 ? 1 : idx);
} }
void AVForm::onAudioInDevChanged(int deviceIndex) void AVForm::on_inDevCombobox_currentIndexChanged(int deviceIndex)
{ {
Settings::getInstance().setAudioInDevEnabled(deviceIndex != 0); Settings::getInstance().setAudioInDevEnabled(deviceIndex != 0);
@ -481,7 +473,7 @@ void AVForm::onAudioInDevChanged(int deviceIndex)
microphoneSlider->setSliderPosition(qRound(audio.inputGain() * 10.0)); microphoneSlider->setSliderPosition(qRound(audio.inputGain() * 10.0));
} }
void AVForm::onAudioOutDevChanged(int deviceIndex) void AVForm::on_outDevCombobox_currentIndexChanged(int deviceIndex)
{ {
Settings::getInstance().setAudioOutDevEnabled(deviceIndex != 0); 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; const qreal dB = value / 10.0;
@ -560,8 +557,3 @@ void AVForm::retranslateUi()
{ {
Ui::AVForm::retranslateUi(this); Ui::AVForm::retranslateUi(this);
} }
void AVForm::on_btnPlayTestSound_clicked(bool checked)
{
mPlayTestSound = checked;
}

View File

@ -56,18 +56,17 @@ private:
void retranslateUi(); void retranslateUi();
private slots: private slots:
// audio // audio
void onAudioInDevChanged(int deviceIndex); void on_inDevCombobox_currentIndexChanged(int deviceIndex);
void onAudioOutDevChanged(int deviceIndex); void on_outDevCombobox_currentIndexChanged(int deviceIndex);
void on_playbackSlider_valueChanged(int value); void on_playbackSlider_valueChanged(int value);
void onMicrophoneValueChanged(int value); void on_btnPlayTestSound_clicked(bool checked);
void on_microphoneSlider_valueChanged(int value);
// camera // camera
void onVideoDevChanged(int index); void on_videoDevCombobox_currentIndexChanged(int index);
void onVideoModesIndexChanged(int index); void on_videoModescomboBox_currentIndexChanged(int index);
void on_btnPlayTestSound_clicked(bool checked);
protected: protected:
void updateVideoModes(int curIndex); void updateVideoModes(int curIndex);