diff -r 79de20dc6a1e -r 27fb1c3c9fbb src/ui/objecteditor.cpp --- a/src/ui/objecteditor.cpp Sun Mar 13 20:11:06 2022 +0200 +++ b/src/ui/objecteditor.cpp Sun Mar 13 20:26:28 2022 +0200 @@ -10,34 +10,17 @@ #include "widgets/colorbutton.h" #include "widgets/colorindexinput.h" #include "widgets/vec3editor.h" - -template -static void makeColorEditor() -{ - QString propertyName = ldraw::PropertyTraits::name; -} +#include "ui_objecteditor.h" ObjectEditor::ObjectEditor(Document* document, const ldraw::id_t id) : QWidget{document}, - document{document}, - formContainer{new QWidget{this}}, - objectTypeNameLabel{new QLabel{this}}, - objectTypeIconLabel{new QLabel{this}} + ui{*new Ui_ObjectEditor}, + document{document} { - this->setLayout(new QVBoxLayout{this}); - QWidget* objectTitleLayoutContainer = new QWidget{this}; - QLayout* objectTitleLayout = new QHBoxLayout{objectTitleLayoutContainer}; - objectTitleLayoutContainer->setLayout(objectTitleLayout); - objectTitleLayout->addWidget(this->objectTypeIconLabel); - objectTitleLayout->addWidget(this->objectTypeNameLabel); - this->layout()->addWidget(objectTitleLayoutContainer); - this->layout()->addWidget(formContainer); + this->ui.setupUi(this); this->setObjectId(id); - - QWidget* const parent = this->formContainer; - QFormLayout* formLayout = new QFormLayout{parent}; - this->formContainer->setLayout(formLayout); - + QFormLayout* formLayout = new QFormLayout{ui.properties}; + this->ui.properties->setLayout(formLayout); for (const ldraw::Property property : ldraw::ALL_PROPERTIES) { QWidget* editorWidget = this->makeEditorWidgetForProperty(property); @@ -49,8 +32,12 @@ this->propertyWidgets[property] = {propertyLabel, editorWidget}; } } + this->setObjectId(ldraw::NULL_ID); +} - this->setObjectId(ldraw::NULL_ID); +ObjectEditor::~ObjectEditor() +{ + delete &this->ui; } QString titleCase(const QString& string) @@ -79,10 +66,11 @@ { this->objectId = id; const ldraw::Object* object = this->document->getModel().get(id); + this->ui.properties->setVisible(object != nullptr); if (object != nullptr) { - this->objectTypeNameLabel->setText("" + titleCase(object->typeName()) + ""); - this->objectTypeIconLabel->setPixmap(QPixmap{object->iconName()}.scaledToWidth(24)); + this->ui.typeNameLabel->setText("" + titleCase(object->typeName()) + ""); + this->ui.typeIconLabel->setPixmap(QPixmap{object->iconName()}.scaledToWidth(24)); for (const ldraw::Property property : ldraw::ALL_PROPERTIES) { const QVariant value = object->getProperty(property); @@ -100,13 +88,8 @@ } else { - this->objectTypeNameLabel->clear(); - this->objectTypeIconLabel->clear(); - for (auto& pair : this->propertyWidgets) - { - pair.first->setVisible(false); - pair.second->setVisible(false); - } + this->ui.typeNameLabel->setText(tr("No object selected")); + this->ui.typeIconLabel->clear(); } }