code cleanup; channels callback coalesced again

This commit is contained in:
Hane 2023-08-15 17:03:23 +02:00
commit 729f01a189
6 changed files with 58 additions and 55 deletions

View file

@ -73,12 +73,14 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
void EndpointWidget::updateMute(bool muted){
log_debugcpp("cliqui callboqui cloqui");
//TODO: Here to diagnose slider visuals locking when playing DJ with external volume bar. Functionality is restored when mute checkbox is clicked.
this->muteButton->blockSignals(true);
//TIP: Blocksignals here to diagnose slider visuals locking when playing DJ with external volume bar. Functionality is restored when mute checkbox is clicked.
//this->blockSignals(true);
//this->muteButton->blockSignals(true);
//this->eph->setMute(osh->getGuid(), muted);
this->muteButton->setChecked(muted);
this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
this->muteButton->blockSignals(false);
//this->muteButton->blockSignals(false);
//this->blockSignals(false);
}
void EndpointWidget::updateMute(int checked){
@ -96,18 +98,20 @@ void EndpointWidget::updateMainVolume(int newValue){
}
void EndpointWidget::updateMainVolume(float newValue){
//this->blockSignals(true);
int newVal = newValue * 100;
log_debugcpp("mainvolcallback int: " << newVal);
//this->mainSlider->blockSignals(true);
//TODO: Above
if(this->mainSlider->value() != newVal) {
this->mainSlider->setValue(newVal);
}
//this->mainSlider->blockSignals(false);
//this->blockSignals(false);
}
void EndpointWidget::updateChannelVolume(uint32_t channel, float newValue){
this->blockSignals(true);
//this->blockSignals(true);
if (channel == (uint32_t)AudioChannel::CHANNEL_MAIN)
updateMainVolume(newValue);
@ -116,25 +120,27 @@ void EndpointWidget::updateChannelVolume(uint32_t channel, float newValue){
for (size_t i = 0; i < sizeof(uint32_t) * 8 && i < channelSliders.size(); ++i) {
if (((channel >> i) & 1) && this->channelSliders.at(i)->value() != newVal) {
this->channelSliders.at(i)->blockSignals(true);
//this->channelSliders.at(i)->blockSignals(true);
this->channelSliders.at(i)->setValue(newVal);
this->channelLabels.at(i)->setText(QString::number((int)(newValue * 100)));
this->channelSliders.at(i)->blockSignals(false);
//this->channelSliders.at(i)->blockSignals(false);
}
}
this->blockSignals(false);
//this->blockSignals(false);
}
void EndpointWidget::toggleFrontEvents(bool active){
this->muteButton->blockSignals(active);
this->mainSlider->blockSignals(active);
for(uint32_t i = 0; i < this->channelSliders.size(); i++){
this->channelSliders.at(i)->blockSignals(active);
}
}
/*
* void EndpointWidget::toggleFrontEvents(bool active){
* this->muteButton->blockSignals(active);
* this->mainSlider->blockSignals(active);
* for(uint32_t i = 0; i < this->channelSliders.size(); i++){
* this->channelSliders.at(i)->blockSignals(active);
* }
* }
*/
void EndpointWidget::setIndex(uint64_t idx){
@ -168,7 +174,7 @@ void MainWindow::reloadEndpointWidgets() {
ews.push_back(epw);
layout->addWidget(epw, i, 0);
}
osh->setEndpointWidgets(ews);
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), i, 0);
osh->setFrontVolumeCallback([this](uint64_t device, uint32_t channel, float value) {
@ -181,9 +187,6 @@ void MainWindow::reloadEndpointWidgets() {
});
}
//#include "qtclosemwh.h"
/*
* void MainWindow::setPlotButton() {
* button = new QPushButton("push"),