vsink volume works
This commit is contained in:
parent
978c8c10e3
commit
10fe7103da
4 changed files with 247 additions and 20 deletions
|
|
@ -94,6 +94,8 @@ int NodeVolumeWidget::volume() const { return m_slider->value(); }
|
|||
|
||||
bool NodeVolumeWidget::isMuted() const { return m_muteBtn->isChecked(); }
|
||||
|
||||
bool NodeVolumeWidget::isSliderDown() const { return m_slider->isSliderDown(); }
|
||||
|
||||
void NodeVolumeWidget::setVolume(int value) {
|
||||
QSignalBlocker blocker(m_slider);
|
||||
m_slider->setValue(value);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ public:
|
|||
|
||||
int volume() const;
|
||||
bool isMuted() const;
|
||||
bool isSliderDown() const;
|
||||
|
||||
void setVolume(int value);
|
||||
void setMuted(bool muted);
|
||||
|
|
|
|||
|
|
@ -627,6 +627,38 @@ void WarpGraphModel::refreshFromClient() {
|
|||
}
|
||||
}
|
||||
|
||||
for (const auto &[pwId, qtId] : m_pwToQt) {
|
||||
auto volResult = m_client->GetNodeVolume(warppipe::NodeId{pwId});
|
||||
if (!volResult.ok()) continue;
|
||||
|
||||
float vol = volResult.value.volume;
|
||||
bool mute = volResult.value.mute;
|
||||
int sliderVal = static_cast<int>(std::round(vol * 100.0f));
|
||||
sliderVal = std::clamp(sliderVal, 0, 150);
|
||||
|
||||
auto stateIt = m_volumeStates.find(qtId);
|
||||
if (stateIt == m_volumeStates.end()) continue;
|
||||
|
||||
NodeVolumeState &cached = stateIt->second;
|
||||
bool changed = (std::abs(cached.volume - vol) > 1e-4f) || (cached.mute != mute);
|
||||
if (!changed) continue;
|
||||
|
||||
NodeVolumeState previous = cached;
|
||||
cached.volume = vol;
|
||||
cached.mute = mute;
|
||||
|
||||
auto wIt = m_volumeWidgets.find(qtId);
|
||||
if (wIt != m_volumeWidgets.end()) {
|
||||
auto *vw = static_cast<NodeVolumeWidget *>(wIt->second);
|
||||
if (!vw->isSliderDown()) {
|
||||
vw->setVolume(sliderVal);
|
||||
vw->setMuted(mute);
|
||||
}
|
||||
}
|
||||
|
||||
Q_EMIT nodeVolumeChanged(qtId, previous, cached);
|
||||
}
|
||||
|
||||
m_refreshing = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue