mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
The "core" macro conditions and actions have been extracted out to the "base" plugin. The library now mostly contains functionality which is required across all plugins and (e.g. definitions for macro segments). The goal is to reduce the complexity and cross-dependencies and group the source files in a better way. This should relsove the "library limit of 65535 objects exceeded" build issue occuring in some Windows build environments.
83 lines
2.1 KiB
C++
83 lines
2.1 KiB
C++
#include "slider-spinbox.hpp"
|
|
#include <QHBoxLayout>
|
|
|
|
namespace advss {
|
|
|
|
SliderSpinBox::SliderSpinBox(double min, double max, const QString &label,
|
|
const QString &description,
|
|
bool descriptionAsTooltip, QWidget *parent)
|
|
: QWidget(parent),
|
|
_spinBox(new VariableDoubleSpinBox()),
|
|
_slider(new QSlider())
|
|
{
|
|
_slider->setOrientation(Qt::Horizontal);
|
|
_slider->setRange(min * _scale, max * _scale);
|
|
_spinBox->setMinimum(min);
|
|
_spinBox->setMaximum(max);
|
|
_spinBox->setDecimals(5);
|
|
|
|
connect(_slider, SIGNAL(valueChanged(int)), this,
|
|
SLOT(SliderValueChanged(int)));
|
|
QWidget::connect(
|
|
_spinBox,
|
|
SIGNAL(NumberVariableChanged(const NumberVariable<double> &)),
|
|
this,
|
|
SLOT(SpinBoxValueChanged(const NumberVariable<double> &)));
|
|
|
|
auto mainLayout = new QVBoxLayout();
|
|
auto sliderLayout = new QHBoxLayout();
|
|
if (!label.isEmpty()) {
|
|
sliderLayout->addWidget(new QLabel(label));
|
|
}
|
|
sliderLayout->addWidget(_spinBox);
|
|
sliderLayout->addWidget(_slider);
|
|
mainLayout->addLayout(sliderLayout);
|
|
if (!description.isEmpty()) {
|
|
if (descriptionAsTooltip) {
|
|
setToolTip(description);
|
|
} else {
|
|
mainLayout->addWidget(new QLabel(description));
|
|
}
|
|
}
|
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
|
setLayout(mainLayout);
|
|
}
|
|
|
|
void SliderSpinBox::SetDoubleValue(double value)
|
|
{
|
|
NumberVariable<double> temp = value;
|
|
SetDoubleValue(temp);
|
|
}
|
|
|
|
void SliderSpinBox::SetDoubleValue(const NumberVariable<double> &value)
|
|
{
|
|
const QSignalBlocker b1(_slider);
|
|
const QSignalBlocker b2(_spinBox);
|
|
_slider->setValue(value * _scale);
|
|
_spinBox->SetValue(value);
|
|
SetVisibility(value);
|
|
}
|
|
|
|
void SliderSpinBox::SpinBoxValueChanged(const NumberVariable<double> &value)
|
|
{
|
|
if (value.IsFixedType()) {
|
|
int sliderPos = value * _scale;
|
|
_slider->setValue(sliderPos);
|
|
}
|
|
SetVisibility(value);
|
|
emit DoubleValueChanged(value);
|
|
}
|
|
|
|
void SliderSpinBox::SliderValueChanged(int value)
|
|
{
|
|
NumberVariable<double> doubleValue = value / _scale;
|
|
_spinBox->SetValue(doubleValue);
|
|
}
|
|
|
|
void SliderSpinBox::SetVisibility(const NumberVariable<double> &value)
|
|
{
|
|
_slider->setVisible(value.IsFixedType());
|
|
}
|
|
|
|
} // namespace advss
|