diff -r 27fb1c3c9fbb -r 97b591813c8b src/ui/objecteditor.cpp --- a/src/ui/objecteditor.cpp Sun Mar 13 20:26:28 2022 +0200 +++ b/src/ui/objecteditor.cpp Tue Mar 15 18:52:48 2022 +0200 @@ -1,9 +1,6 @@ -#include +#include +#include #include -#include -#include -#include -#include #include "objecteditor.h" #include "document.h" #include "modeleditor.h" @@ -59,6 +56,22 @@ { vec3Editor->setValue(value.value()); } + else + { + QCheckBox* checkBox = qobject_cast(widget); + if (checkBox != nullptr) + { + checkBox->setChecked(value.toBool()); + } + else + { + QLineEdit* lineEdit = qobject_cast(widget); + if (lineEdit != nullptr) + { + lineEdit->setText(value.toString()); + } + } + } } } @@ -66,7 +79,7 @@ { this->objectId = id; const ldraw::Object* object = this->document->getModel().get(id); - this->ui.properties->setVisible(object != nullptr); + this->ui.properties->setEnabled(object != nullptr); if (object != nullptr) { this->ui.typeNameLabel->setText("" + titleCase(object->typeName()) + ""); @@ -77,8 +90,8 @@ const auto it = this->propertyWidgets.find(property); if (it != this->propertyWidgets.end()) { - it->first->setVisible(not value.isNull()); - it->second->setVisible(not value.isNull()); + it->first->setEnabled(not value.isNull()); + it->second->setEnabled(not value.isNull()); if (not value.isNull()) { setValueToWidget(it->second, value); @@ -103,6 +116,16 @@ this->handlePropertyChange(this->sender(), QVariant::fromValue(value)); } +void ObjectEditor::handleBoolChange(bool value) +{ + this->handlePropertyChange(this->sender(), QVariant::fromValue(value)); +} + +void ObjectEditor::handleStringChange(const QString &value) +{ + this->handlePropertyChange(this->sender(), QVariant::fromValue(value)); +} + QWidget* ObjectEditor::makeEditorWidgetForProperty(ldraw::Property property) { QWidget* const parent = qobject_cast(this->parent()); @@ -118,6 +141,18 @@ connect(editor, &Vec3Editor::valueChanged, this, &ObjectEditor::handleVec3Change); return editor; } + else if (ldraw::traits(property).type == qMetaTypeId()) + { + QCheckBox* editor = new QCheckBox{{}, parent}; + connect(editor, &QCheckBox::clicked, this, &ObjectEditor::handleBoolChange); + return editor; + } + else if (ldraw::traits(property).type == qMetaTypeId()) + { + QLineEdit* editor = new QLineEdit{{}, parent}; + connect(editor, &QLineEdit::textChanged, this, &ObjectEditor::handleStringChange); + return editor; + } else { return nullptr;