예제 #1
0
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));
        }
    );
}
예제 #2
0
void PropertyWidgetBuilder::visitValue(ValueProperty<int> & property)
{
    QSpinBox * spinbox = new QSpinBox(m_active_widget);
    m_active_layout->addRow(property.description(), spinbox);

    QObject::connect(spinbox,
        static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
        [&property] (int i) {
            property.setValue(i);
            qDebug("Set Property %s = %i", qPrintable(property.name()), i);
        }
    );
}
예제 #3
0
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));
        }
    );
}
예제 #4
0
void PropertyWidgetBuilder::visitValue(ValueProperty<float> & property)
{
    QSlider * slider = new QSlider(m_active_widget);
    slider->setOrientation(Qt::Horizontal);

    m_active_layout->addRow(property.description(), slider);

    QObject::connect(slider, &QSlider::valueChanged,
        [&property] (int i) {
            property.setValue(i);
            qDebug("Set Property %s = %i",
                   qPrintable(property.name()),
                   i);
        }
    );
}
예제 #5
0
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());
        }
    );
}