Volume slider works
This commit is contained in:
parent
6d74ef422d
commit
96e1a5cbdb
3 changed files with 64 additions and 3 deletions
|
|
@ -120,6 +120,12 @@ QWidget *PipeWireGraphModel::nodeWidget(QtNodes::NodeId nodeId) const
|
|||
return it->second;
|
||||
}
|
||||
|
||||
uint32_t pipewireId = 0;
|
||||
auto nodeIt = m_nodes.find(nodeId);
|
||||
if (nodeIt != m_nodes.end()) {
|
||||
pipewireId = nodeIt->second.id;
|
||||
}
|
||||
|
||||
auto *widget = new QWidget();
|
||||
auto *layout = new QHBoxLayout(widget);
|
||||
layout->setContentsMargins(6, 2, 6, 2);
|
||||
|
|
@ -129,14 +135,25 @@ QWidget *PipeWireGraphModel::nodeWidget(QtNodes::NodeId nodeId) const
|
|||
muteButton->setText("M");
|
||||
muteButton->setCheckable(true);
|
||||
muteButton->setFixedSize(20, 20);
|
||||
muteButton->setToolTip(QString("Mute (UI only)"));
|
||||
muteButton->setToolTip(QString("Mute"));
|
||||
|
||||
auto *slider = new QSlider(Qt::Horizontal, widget);
|
||||
slider->setRange(0, 100);
|
||||
slider->setValue(100);
|
||||
slider->setFixedHeight(18);
|
||||
slider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
slider->setToolTip(QString("Volume (UI only)"));
|
||||
slider->setToolTip(QString("Volume"));
|
||||
|
||||
const auto applyVolume = [this, pipewireId, slider, muteButton]() {
|
||||
if (!m_controller || pipewireId == 0) {
|
||||
return;
|
||||
}
|
||||
const float volume = static_cast<float>(slider->value()) / 100.0f;
|
||||
m_controller->setNodeVolume(pipewireId, volume, muteButton->isChecked());
|
||||
};
|
||||
|
||||
QObject::connect(slider, &QSlider::valueChanged, widget, [applyVolume](int) { applyVolume(); });
|
||||
QObject::connect(muteButton, &QToolButton::toggled, widget, [applyVolume](bool) { applyVolume(); });
|
||||
|
||||
layout->addWidget(muteButton);
|
||||
layout->addWidget(slider);
|
||||
|
|
@ -266,7 +283,14 @@ bool PipeWireGraphModel::connectionPossible(QtNodes::ConnectionId const connecti
|
|||
return false;
|
||||
}
|
||||
|
||||
if (outInfo.mediaClass != inInfo.mediaClass) {
|
||||
const auto isAudioClass = [](Potato::MediaClass mediaClass) {
|
||||
return mediaClass == Potato::MediaClass::AudioSink
|
||||
|| mediaClass == Potato::MediaClass::AudioSource
|
||||
|| mediaClass == Potato::MediaClass::AudioDuplex
|
||||
|| mediaClass == Potato::MediaClass::Stream;
|
||||
};
|
||||
|
||||
if (!isAudioClass(outInfo.mediaClass) || !isAudioClass(inInfo.mediaClass)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue