void AVForm::showEvent(QShowEvent*) { getAudioOutDevices(); getAudioInDevices(); createVideoSurface(); getVideoDevices(); Audio::getInstance().subscribeInput(); }
AVForm::AVForm() : GenericForm(QPixmap(":/img/settings/av.png")) , subscribedToAudioIn{false} , camVideoSurface{nullptr} , camera(CameraSource::getInstance()) { bodyUI = new Ui::AVSettings; bodyUI->setupUi(this); const Audio& audio = Audio::getInstance(); bodyUI->btnPlayTestSound->setToolTip( tr("Play a test sound while changing the output volume.")); auto qcbxIndexChangedStr = (void(QComboBox::*)(const QString&)) &QComboBox::currentIndexChanged; auto qcbxIndexChangedInt = (void(QComboBox::*)(int)) &QComboBox::currentIndexChanged; connect(bodyUI->inDevCombobox, qcbxIndexChangedStr, this, &AVForm::onInDevChanged); connect(bodyUI->outDevCombobox, qcbxIndexChangedStr, this, &AVForm::onOutDevChanged); connect(bodyUI->videoDevCombobox, qcbxIndexChangedInt, this, &AVForm::onVideoDevChanged); connect(bodyUI->videoModescomboBox, qcbxIndexChangedInt, this, &AVForm::onVideoModesIndexChanged); connect(bodyUI->rescanButton, &QPushButton::clicked, this, [=]() { getAudioInDevices(); getAudioOutDevices(); getVideoDevices(); }); bodyUI->playbackSlider->setTracking(false); bodyUI->playbackSlider->installEventFilter(this); connect(bodyUI->playbackSlider, &QSlider::valueChanged, this, &AVForm::onPlaybackValueChanged); bodyUI->microphoneSlider->setToolTip( tr("Use slider to set the gain of your input device ranging" " from %1dB to %2dB.") .arg(audio.minInputGain()) .arg(audio.maxInputGain())); bodyUI->microphoneSlider->setMinimum(qRound(audio.minInputGain()) * 10); bodyUI->microphoneSlider->setMaximum(qRound(audio.maxInputGain()) * 10); bodyUI->microphoneSlider->setTickPosition(QSlider::TicksBothSides); bodyUI->microphoneSlider->setTickInterval( (qAbs(bodyUI->microphoneSlider->minimum()) + bodyUI->microphoneSlider->maximum()) / 4); bodyUI->microphoneSlider->setTracking(false); bodyUI->microphoneSlider->installEventFilter(this); connect(bodyUI->microphoneSlider, &QSlider::valueChanged, this, &AVForm::onMicrophoneValueChanged); for (QComboBox* cb : findChildren<QComboBox*>()) { cb->installEventFilter(this); cb->setFocusPolicy(Qt::StrongFocus); } Translator::registerHandler(std::bind(&AVForm::retranslateUi, this), this); }
AVForm::AVForm() : GenericForm(QPixmap(":/img/settings/av.png")) , subscribedToAudioIn{false} , camVideoSurface{nullptr} , camera(CameraSource::getInstance()) { bodyUI = new Ui::AVSettings; bodyUI->setupUi(this); #ifdef QTOX_FILTER_AUDIO bodyUI->filterAudio->setChecked(Settings::getInstance().getFilterAudio()); #else bodyUI->filterAudio->setDisabled(true); #endif auto qcbxIndexChangedStr = (void(QComboBox::*)(const QString&)) &QComboBox::currentIndexChanged; auto qcbxIndexChangedInt = (void(QComboBox::*)(int)) &QComboBox::currentIndexChanged; connect(bodyUI->inDevCombobox, qcbxIndexChangedStr, this, &AVForm::onInDevChanged); connect(bodyUI->outDevCombobox, qcbxIndexChangedStr, this, &AVForm::onOutDevChanged); connect(bodyUI->videoDevCombobox, qcbxIndexChangedInt, this, &AVForm::onVideoDevChanged); connect(bodyUI->videoModescomboBox, qcbxIndexChangedInt, this, &AVForm::onVideoModesIndexChanged); connect(bodyUI->filterAudio, &QCheckBox::toggled, this, &AVForm::onFilterAudioToggled); connect(bodyUI->rescanButton, &QPushButton::clicked, this, [=]() { getAudioInDevices(); getAudioOutDevices(); getVideoDevices(); }); connect(bodyUI->playbackSlider, &QSlider::valueChanged, this, &AVForm::onPlaybackValueChanged); connect(bodyUI->microphoneSlider, &QSlider::valueChanged, this, &AVForm::onMicrophoneValueChanged); bodyUI->playbackSlider->setValue(Settings::getInstance().getOutVolume()); bodyUI->microphoneSlider->setValue(Settings::getInstance().getInVolume()); bodyUI->playbackSlider->installEventFilter(this); bodyUI->microphoneSlider->installEventFilter(this); for (QComboBox* cb : findChildren<QComboBox*>()) { cb->installEventFilter(this); cb->setFocusPolicy(Qt::StrongFocus); } for (QCheckBox *cb : findChildren<QCheckBox*>()) // this one is to allow scrolling on checkboxes { cb->installEventFilter(this); } Translator::registerHandler(std::bind(&AVForm::retranslateUi, this), this); }
void AVForm::showEvent(QShowEvent* event) { getAudioOutDevices(); getAudioInDevices(); createVideoSurface(); getVideoDevices(); if (!subscribedToAudioIn) { // TODO: this should not be done in show/hide events Audio::getInstance().subscribeInput(); subscribedToAudioIn = true; } GenericForm::showEvent(event); }
void AVForm::present() { getAudioOutDevices(); getAudioInDevices(); createVideoSurface(); CamVideoSurface->setSource(Camera::getInstance()); Camera::getInstance()->probeProp(Camera::SATURATION); Camera::getInstance()->probeProp(Camera::CONTRAST); Camera::getInstance()->probeProp(Camera::BRIGHTNESS); Camera::getInstance()->probeProp(Camera::HUE); Camera::getInstance()->probeResolutions(); bodyUI->videoModescomboBox->blockSignals(true); bodyUI->videoModescomboBox->addItem(tr("Initializing Camera...")); bodyUI->videoModescomboBox->blockSignals(false); }
void AVForm::rescanDevices() { getAudioInDevices(); getAudioOutDevices(); getVideoDevices(); }
AVForm::AVForm() : GenericForm(tr("Audio/Video"), QPixmap(":/img/settings/av.png")), CamVideoSurface{nullptr} { bodyUI = new Ui::AVSettings; bodyUI->setupUi(this); #ifdef QTOX_FILTER_AUDIO bodyUI->filterAudio->setChecked(Settings::getInstance().getFilterAudio()); #else bodyUI->filterAudio->setDisabled(true); #endif connect(Camera::getInstance(), &Camera::propProbingFinished, this, &AVForm::onPropProbingFinished); connect(Camera::getInstance(), &Camera::resolutionProbingFinished, this, &AVForm::onResProbingFinished); auto qcomboboxIndexChanged = (void(QComboBox::*)(const QString&)) &QComboBox::currentIndexChanged; connect(bodyUI->inDevCombobox, qcomboboxIndexChanged, this, &AVForm::onInDevChanged); connect(bodyUI->outDevCombobox, qcomboboxIndexChanged, this, &AVForm::onOutDevChanged); connect(bodyUI->filterAudio, &QCheckBox::toggled, this, &AVForm::onFilterAudioToggled); connect(bodyUI->rescanButton, &QPushButton::clicked, this, [=](){getAudioInDevices(); getAudioOutDevices();}); bodyUI->playbackSlider->setValue(100); bodyUI->microphoneSlider->setValue(100); for (QComboBox* cb : findChildren<QComboBox*>()) { cb->installEventFilter(this); cb->setFocusPolicy(Qt::StrongFocus); } }