pan y pitchs faders horizontales, funciona varias instancias con

multidispositivo y patcheable en jack.
This commit is contained in:
snt 2024-05-10 20:03:14 +02:00
parent 7631e54d51
commit 103a33820e
12 changed files with 188 additions and 105 deletions

View file

@ -1,5 +1,17 @@
#include "slidergroup.h"
#include <QCursor>
#include <QStyle>
DoubleSpinBoxClickable::DoubleSpinBoxClickable(QWidget *parent)
: QDoubleSpinBox{parent} {}
DoubleSpinBoxClickable::~DoubleSpinBoxClickable() {}
SliderClickDisable::SliderClickDisable(QWidget *parent)
: QSlider{parent} {}
SliderClickDisable::~SliderClickDisable() {}
SliderGroup::SliderGroup(QString name,
int min,
int max,
@ -7,42 +19,46 @@ SliderGroup::SliderGroup(QString name,
QWidget *parent)
: QWidget(parent)
{
QVBoxLayout *layout = new QVBoxLayout;
QBoxLayout *layout;
if (decimals) {
layout = new QVBoxLayout;
slider.setOrientation(Qt::Vertical);
}
else {
layout = new QHBoxLayout;
slider.setOrientation(Qt::Horizontal);
slider.setMinimumHeight(10);
}
layout->setAlignment(Qt::AlignHCenter);
layout->setContentsMargins(0, 0, 0, 0);
//this->setMaximumWidth(40);
slider = new QSlider(Qt::Orientation::Vertical);
slider->setFocusPolicy(Qt::StrongFocus);
slider->setTickPosition(QSlider::TicksBothSides);
slider->setTickInterval((max - min) / 11);
slider->setMinimumHeight(0);
slider->setSingleStep(1);
slider->setRange(min, max);
slider->setValue(0);
slider->setMinimumWidth(50);
slider->setToolTip(name);
slider->setStyleSheet("QSlider {"
slider.setFocusPolicy(Qt::StrongFocus);
slider.setTickPosition(QSlider::TicksBothSides);
slider.setTickInterval((max - min) / 11);
slider.setMinimumHeight(0);
slider.setSingleStep(1);
slider.setRange(min, max);
slider.setValue(0);
slider.setMinimumWidth(50);
slider.setToolTip(name);
slider.setStyleSheet("QSlider {"
"border: 1px solid #5a4855;"
"margin: 0px;"
"height: 200px;"
"width: 50px;}"
"margin: 0px;}"
);
slider->setContentsMargins(0, 0, 0, 0);
valueBox = new QDoubleSpinBox();
valueBox->setFocusPolicy(Qt::NoFocus);
valueBox->setButtonSymbols(QAbstractSpinBox::NoButtons);
valueBox->setMinimumWidth(50);
valueBox->setRange(min, max);
valueBox->setValue(0);
valueBox->setDecimals(decimals);
valueBox->setObjectName(name);
valueBox->setToolTip(name);
valueBox->setAlignment(Qt::AlignHCenter);
valueBox->setContentsMargins(0, 0, 0, 0);
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(sliderValueChanged(int)));
//connect(slider, SIGNAL(mousePressEvent(QMouseEvent)), this, SLOT(mousePressEvent(QMouseEvent *)));
layout->addWidget(slider);
layout->addWidget(valueBox);
slider.setContentsMargins(0, 0, 0, 0);
valueBox.setFocusPolicy(Qt::NoFocus);
valueBox.setButtonSymbols(QAbstractSpinBox::NoButtons);
valueBox.setMinimumWidth(50);
valueBox.setRange(min, max);
valueBox.setValue(0);
valueBox.setDecimals(decimals);
valueBox.setObjectName(name);
valueBox.setToolTip(name);
valueBox.setAlignment(Qt::AlignHCenter);
valueBox.setContentsMargins(0, 0, 0, 0);
connect(&slider, SIGNAL(valueChanged(int)), this, SLOT(sliderValueChanged(int)));
connect(&valueBox, SIGNAL(enableSlider()), this, SLOT(enableSlider()));
layout->addWidget(&slider);
layout->addWidget(&valueBox);
this->setStyleSheet("border: 1px solid #5a4855;"
"width: 50px;"
"margin: 0px;"
@ -55,27 +71,19 @@ SliderGroup::SliderGroup(QString name,
void SliderGroup::sliderValueChanged(int value)
{
valueBox->blockSignals(true);
valueBox->setValue(value);
valueBox->blockSignals(false);
valueBox.blockSignals(true);
valueBox.setValue(value);
valueBox.blockSignals(false);
emit valueChanged(value);
};
void SliderGroup::setValue(float value)
{
slider->blockSignals(true);
valueBox->blockSignals(true);
if (int(value) != slider->value())
slider->setValue(value);
valueBox->setValue(value);
slider->blockSignals(false);
valueBox->blockSignals(false);
}
void SliderGroup::mousePressEvent(QMouseEvent* event) {
Q_UNUSED(event);
if (slider->isEnabled())
slider->setDisabled(true);
else
slider->setDisabled(false);
slider.blockSignals(true);
valueBox.blockSignals(true);
if (int(value) != slider.value())
slider.setValue(value);
valueBox.setValue(value);
slider.blockSignals(false);
valueBox.blockSignals(false);
}