From 8e9de6a771506e41dfc209286cc1c175e4281473 Mon Sep 17 00:00:00 2001 From: Hane Date: Thu, 17 Aug 2023 19:50:01 +0200 Subject: [PATCH] rounding factor and sndvol trick note: ready to move on --- src/qt/qtclasses.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/qt/qtclasses.cpp b/src/qt/qtclasses.cpp index a6bf603..ace2e2b 100644 --- a/src/qt/qtclasses.cpp +++ b/src/qt/qtclasses.cpp @@ -50,9 +50,8 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare mainMuteLayout->addWidget(mainLabel, 0, 0); mainMuteLayout->addWidget(muteButton, 0, 1); layout->addWidget(mainSlider, 0, 1); - - - + + //TODO:0 = mute and muted, change volume = unmuted are client side tricks = 2 callbacks, one for volume, one for mute state. Implement as an user selectable option? connect(mainSlider, &QSlider::valueChanged, this,&EndpointWidget::updateMainVolume); connect(muteButton, &QCheckBox::stateChanged, this, (&EndpointWidget::updateMute)); @@ -82,25 +81,27 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare this->channelLabels.at(i)->setText(QString::number(newValue)); }); } - + + //Polling time timer = new QTimer(this); connect(timer, &QTimer::timeout, [this, idx](){ - if (memcmp(osh->callbackInfo[idx]->caller, osh->getGuid(), sizeof(NGuid)) == 0) return; - //mainSlider->blockSignals(true); - //muteButton->blockSignals(true); - mainSlider->setValue((int)(osh->callbackInfo[idx]->mainVolume * 100)); + //if (memcmp(osh->callbackInfo[idx]->caller, osh->getGuid(), sizeof(NGuid)) == 0) return; + const float roundingFactor = 0.005; + mainSlider->blockSignals(true); + muteButton->blockSignals(true); + mainSlider->setValue((int)((osh->callbackInfo[idx]->mainVolume + roundingFactor) * 100)); muteButton->setCheckState((osh->callbackInfo[idx]->muted == false ? Qt::Unchecked : Qt::Checked)); muteButton->setText(osh->callbackInfo[idx]->muted ? STRING_UNMUTE : STRING_MUTE); for(uint32_t i = 0; i < osh->callbackInfo[idx]->channels; i++){ this->channelSliders.at(i)->blockSignals(true); - this->channelSliders.at(i)->setValue((int)(osh->callbackInfo[idx]->channelVolumes[i] * 100)); - this->channelLabels.at(i)->setText(QString::number((int)(osh->callbackInfo[idx]->channelVolumes[i] * 100))); + this->channelSliders.at(i)->setValue((int)((osh->callbackInfo[idx]->channelVolumes[i] + roundingFactor) * 100)); + this->channelLabels.at(i)->setText(QString::number((int)((osh->callbackInfo[idx]->channelVolumes[i] + roundingFactor) * 100))); this->channelSliders.at(i)->blockSignals(false); } //memcpy(osh->callbackInfo[idx]->caller, osh->getGuid(), sizeof(NGuid)); *osh->callbackInfo[idx]->caller = *osh->getGuid(); - //mainSlider->blockSignals(false); - //muteButton->blockSignals(false); + mainSlider->blockSignals(false); + muteButton->blockSignals(false); }); timer->start(10); @@ -130,6 +131,7 @@ void EndpointWidget::updateMute(int checked){ } void EndpointWidget::updateMainVolume(int newValue){ + //QObject* obj = sender(); this->eph->setVolume(osh->getGuid(), AudioChannel::CHANNEL_MAIN, newValue); } @@ -203,6 +205,7 @@ void MainWindow::reloadEndpointWidgets() { memcpy(osh->callbackInfo[i]->caller, osh->getGuid(),sizeof(NGuid) ); EndpointWidget *epw = new EndpointWidget(i, osh->getEndpointHandlers().at(i), widget); + //TODO: ALWAYS PUSH BACK??? PSZ CHANGE DIS WHEN IMPLEMENTING DYN ENDPOINT DET ews.push_back(epw); layout->addWidget(epw, i, 0);