void PropertyWidgetBuilder::visitValue(ValueProperty<QColor> & property) { QHBoxLayout * layout = new QHBoxLayout(m_active_widget); QLabel * label = new QLabel("R: 0.1 G: 0.9 B: 0.22", m_active_widget); QPushButton * button = new QPushButton("Pick Color", m_active_widget); layout->addWidget(label); layout->addWidget(button); m_active_layout->addRow(property.description(), layout); QObject::connect(button, &QPushButton::clicked, [&property, label] (bool) { property.setValue(QColorDialog::getColor(property.value())); QString newlabel = QString("R: %1 G: %2 B: %3") .arg(property.value().red()) .arg(property.value().green()) .arg(property.value().blue()); label->setText(newlabel); qDebug("Set Property %s = %s", qPrintable(property.name()), qPrintable(newlabel)); } ); }
void PropertyWidgetBuilder::visitValue(ValueProperty<bool> & property) { QCheckBox * checkBox = new QCheckBox(m_active_widget); checkBox->setText(property.description()); if (property.value()) checkBox->setCheckState(Qt::Checked); else checkBox->setCheckState(Qt::Unchecked); m_active_layout->addWidget(checkBox); QObject::connect(checkBox, &QCheckBox::stateChanged, [&property] (int state) { property.setValue(state); qDebug("Set Property %s = %i", qPrintable(property.name()), property.value()); } ); }
void PropertyWidgetBuilder::visitValue(ValueProperty<QString> & property) { QLineEdit * lineEdit = new QLineEdit(property.value(), m_active_widget); m_active_layout->addRow(property.description(), lineEdit); QObject::connect(lineEdit, &QLineEdit::textChanged, [&property] (QString text) { property.setValue(text); qDebug("Set Property %s = \"%s\"", qPrintable(property.name()), qPrintable(text)); } ); }