diff -r cd9d6bf6f649 -r f69d53c053df src/ui/objecteditor.cpp --- a/src/ui/objecteditor.cpp Wed Mar 09 14:07:58 2022 +0200 +++ b/src/ui/objecteditor.cpp Wed Mar 09 14:22:22 2022 +0200 @@ -1,13 +1,28 @@ #include +#include #include "objecteditor.h" #include "document.h" ObjectEditor::ObjectEditor(Document* document, const ldraw::id_t id) : QWidget{document}, - document{document} + document{document}, + objectTypeNameLabel{new QLabel{this}}, + objectTypeIconLabel{new QLabel{this}} { this->setObjectId(id); 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); + objectTitleLayout->addWidget(new QSplitter{Qt::Horizontal, this}); + this->layout()->addWidget(objectTitleLayoutContainer); +} + +QString titleCase(const QString& string) +{ + return string.left(1).toUpper() + string.mid(1); } void ObjectEditor::setObjectId(const ldraw::id_t id) @@ -16,6 +31,8 @@ const ldraw::Object* object = this->document->getModel().get(id); if (object != nullptr and object->numPoints() > 0) { + this->objectTypeNameLabel->setText("" + titleCase(object->typeName()) + ""); + this->objectTypeIconLabel->setPixmap(QPixmap{object->iconName()}.scaledToWidth(24)); if (not this->polygonEditor.has_value()) { this->polygonEditor.emplace(this->document, id); @@ -28,6 +45,8 @@ } else { + this->objectTypeNameLabel->clear(); + this->objectTypeIconLabel->clear(); this->polygonEditor.reset(); } }