Files
uLib/app/gcompose/src/PropertiesPanel.cpp

55 lines
1.6 KiB
C++

#include "PropertiesPanel.h"
#include "PropertyWidgets.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include "Core/Object.h"
PropertiesPanel::PropertiesPanel(QWidget* parent) : QWidget(parent) {
this->setObjectName("PropertiesPanel");
this->setAttribute(Qt::WA_StyledBackground);
m_layout = new QVBoxLayout(this);
m_layout->setContentsMargins(0, 0, 0, 0);
m_layout->setSpacing(0);
// Title bar
m_titleBar = new QWidget(this);
m_titleBar->setObjectName("PaneTitleBar");
m_titleBar->setFixedHeight(22);
auto* titleLayout = new QHBoxLayout(m_titleBar);
titleLayout->setContentsMargins(5, 0, 5, 0);
m_titleLabel = new QLabel("Properties", m_titleBar);
m_titleLabel->setObjectName("TitleLabel");
titleLayout->addWidget(m_titleLabel);
titleLayout->addStretch();
m_layout->addWidget(m_titleBar);
// Editor
m_editor = new uLib::Qt::PropertyEditor(this);
m_layout->addWidget(m_editor, 1);
connect(m_editor, &uLib::Qt::PropertyEditor::propertyUpdated, [this](uLib::PropertyBase*){
emit propertyUpdated();
});
}
void PropertiesPanel::setObject(uLib::Object* obj) {
if (obj) {
m_titleLabel->setText(QString("Properties: %1 (%2)")
.arg(QString::fromStdString(obj->GetInstanceName()))
.arg(obj->GetClassName()));
} else {
m_titleLabel->setText("Properties: (No selection)");
}
m_editor->setObject(obj);
}
void PropertiesPanel::setContext(uLib::ObjectsContext* context) {
m_editor->setContext(context);
}
PropertiesPanel::~PropertiesPanel() {}