23 #include <QFormLayout>
26 #include <QPushButton>
32 auto* spinBox =
new QSpinBox(parentWidget);
33 spinBox->setFocusPolicy(Qt::StrongFocus);
34 spinBox->setKeyboardTracking(
false);
36 spinBox->setMaximum(std::numeric_limits<int>::max());
37 spinBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
39 if (d.
limits.hasLowerLimit())
40 spinBox->setMinimum(
static_cast<int>(d.
limits.lowerLimit()));
41 if (d.
limits.hasUpperLimit())
42 spinBox->setMaximum(
static_cast<int>(d.
limits.upperLimit()));
44 spinBox->setValue(d.
get());
46 QObject::connect(spinBox, QOverload<int>::of(&QSpinBox::valueChanged),
47 [=](
int newValue) { ec->
setInt(newValue, d); });
57 if (parent->layout() !=
nullptr) {
58 m_formLayout =
dynamic_cast<QFormLayout*
>(parent->layout());
63 m_formLayout =
dynamic_cast<QFormLayout*
>(collapser->contentArea()->layout());
68 m_formLayout->setFormAlignment(Qt::AlignLeft | Qt::AlignBottom);
69 m_formLayout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
80 m_formLayout->setContentsMargins(left, top, right, bottom);
91 if (!label.endsWith(
":"))
99 w->setObjectName(
"PropertyBaseWidget");
100 w->setAttribute(Qt::WA_StyledBackground,
true);
101 w->setStyleSheet(
"#PropertyBaseWidget {background-color: transparent}");
103 auto* gridLayout =
new QGridLayout(w);
104 gridLayout->setContentsMargins(0, 0, 0, 0);
105 gridLayout->setSpacing(6);
109 return addRow(labelText, w);
115 w->setObjectName(
"PropertyBaseWidget");
116 w->setAttribute(Qt::WA_StyledBackground,
true);
117 w->setStyleSheet(
"#PropertyBaseWidget {background-color: transparent}");
119 auto* gridLayout =
new QGridLayout(w);
120 gridLayout->setContentsMargins(0, 0, 0, 0);
121 gridLayout->setSpacing(6);
131 m_formLayout->itemAt(row, QFormLayout::LabelRole)->widget()->setVisible(visible);
132 m_formLayout->itemAt(row, QFormLayout::FieldRole)->widget()->setVisible(visible);
143 auto* l =
new QHBoxLayout(w);
144 l->setContentsMargins(0, 0, 0, 0);
145 l->setAlignment(Qt::AlignLeft);
146 l->setSizeConstraint(QLayout::SetMinimumSize);
147 l->addWidget(button);
176 function<
void(
double)> onValueChange)
178 auto labelText = d.
label;
179 if (!labelText.endsWith(
":"))
183 label->setAlignment(Qt::AlignLeft | Qt::AlignBottom);
184 label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
189 label->setBuddy(editor);
QList< DoubleDescriptor > DoubleDescriptors
Defines class DoubleSpinBox.
Defines class GroupBoxCollapser.
Defines class LayerEditorUtils.
Defines class SampleEditorController.
Defines class UIntDescriptor.
Defines class VectorDescriptor.
Describes properties of a double value which are necessary to allow GUI representation,...
QString label
A label text (short, no trailing colon)
SpinBox for DoubleDescriptors, supporting units.
void baseValueChanged(double newBaseValue)
Emitted whenever the value changes.
static GroupBoxCollapser * findInstalledCollapser(QGroupBox *groupBox)
Class to modify a sample from the layer oriented sample editor.
void setInt(int newValue, UIntDescriptor d)
void setDouble(double newValue, DoubleDescriptor d)
Describes properties of a uint value which are necessary to allow GUI representation,...
QString label
A label text (short, no trailing colon)
QString tooltip
Tooltip text.
RealLimits limits
Limits of the value.
function< uint()> get
function to get the current value
Describes properties of a 3D vector, consisting of three double values.
QString label
A label text (short, no trailing colon)
QSpinBox * createSpinBox(QWidget *parent, const UIntDescriptor &d, std::function< void(uint)> slot=nullptr)
Create a spin box with the information found in a UIntDescriptor.
void addMultiPropertyToGrid(QGridLayout *m_gridLayout, int firstCol, const DoubleDescriptors &valueDescriptors, SampleEditorController *ec, bool vertically, bool addSpacer)
Create DoubleSpinBoxes for the DoubeDescriptors and connect them to SampleEditorController::setDouble...
void updateLabelUnit(QLabel *label)
QLabel * createBoldLabel(const QString &text)