diff --git a/src/modules/interface/qt/widgets/IntRangeEditor.cpp b/src/modules/interface/qt/widgets/IntRangeEditor.cpp index 5327b6e..08dabc0 100644 --- a/src/modules/interface/qt/widgets/IntRangeEditor.cpp +++ b/src/modules/interface/qt/widgets/IntRangeEditor.cpp @@ -2,6 +2,7 @@ IntRangeEditor::IntRangeEditor(QWidget *parent) : QWidget(parent) { m_mainLayout = new QHBoxLayout; + m_mainLayout->setMargin(0); m_slider = new QSlider(Qt::Horizontal); m_slider->setRange(0, 0); @@ -21,9 +22,29 @@ IntRangeEditor::IntRangeEditor(QWidget *parent) : QWidget(parent) { setLayout(m_mainLayout); } -/*IntRangeEditor::IntRangeEditor(QWidget *parent, const tc_assignable_range_int_t *range) : QWidget(parent){ +IntRangeEditor::IntRangeEditor(QWidget* parent, const AssignableData &data) : QWidget(parent) { + m_mainLayout = new QHBoxLayout; + m_mainLayout->setMargin(0); -}*/ + m_slider = new QSlider(Qt::Horizontal); + m_mainLayout->addWidget(m_slider); + + m_spinBox = new QSpinBox; + m_mainLayout->addWidget(m_spinBox); + + connect(m_slider, &QSlider::valueChanged, m_spinBox, &QSpinBox::setValue); + connect(m_slider, &QSlider::rangeChanged, m_spinBox, &QSpinBox::setRange); + + connect(m_spinBox, QOverload::of(&QSpinBox::valueChanged), m_slider, &QSlider::setValue); + + m_slider->setRange(data.m_rangeInfo.int_range.min, data.m_rangeInfo.int_range.max); + + setLayout(m_mainLayout); +} + +int IntRangeEditor::value() { + return m_slider->value(); +} void IntRangeEditor::setRange(const tc_assignable_range_int_t &range) { m_range = range; diff --git a/src/modules/interface/qt/widgets/IntRangeEditor.h b/src/modules/interface/qt/widgets/IntRangeEditor.h index a858a3c..fce63b0 100644 --- a/src/modules/interface/qt/widgets/IntRangeEditor.h +++ b/src/modules/interface/qt/widgets/IntRangeEditor.h @@ -3,6 +3,7 @@ // Widget for editing TC_ASSIGNABLE_RANGE_INT nodes #include +#include #include #include @@ -13,8 +14,8 @@ class IntRangeEditor : public QWidget { Q_OBJECT public: IntRangeEditor(QWidget *parent = nullptr); - //IntRangeEditor(QWidget *parent = nullptr, const tc_assignable_range_int_t *range = nullptr); - + IntRangeEditor(QWidget *parent = nullptr, const AssignableData &data = nullptr); + int value(); void setRange(const tc_assignable_range_int_t &range); private: QHBoxLayout *m_mainLayout;