Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions modules/editor/grapheditor/editor/graph/graphnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ GraphNode::GraphNode() :
m_nodeWidget(nullptr),
m_graph(nullptr) {

connect(this, &GraphNode::objectNameChanged, this, &GraphNode::onNameChanged);
}

GraphNode::~GraphNode() {
Expand Down Expand Up @@ -102,6 +103,12 @@ std::vector<NodePort> &GraphNode::ports() {
return m_ports;
}

void GraphNode::onNameChanged() {
if(m_nodeWidget) {
static_cast<NodeWidget *>(m_nodeWidget)->updateName();
}
}

void GraphNode::saveUserData(QVariantMap &data) {
const QMetaObject *meta = metaObject();
for(int i = 0; i < meta->propertyCount(); i++) {
Expand Down
3 changes: 3 additions & 0 deletions modules/editor/grapheditor/editor/graph/graphnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ class NODEGRAPH_EXPORT GraphNode : public QObject {
signals:
void updated();

protected:
void onNameChanged();

protected:
std::vector<NodePort> m_ports;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ NodeWidget::NodeWidget() :

void NodeWidget::setGraphNode(GraphNode *node) {
m_node = node;
if(m_label) {
std::string title = !m_node->objectName().isEmpty() ? qPrintable(m_node->objectName()) : m_node->typeName();
m_label->setText(title);
}

updateName();

if(m_title) {
m_title->setColor(m_node->color());
Expand Down Expand Up @@ -87,6 +85,13 @@ void NodeWidget::setGraphNode(GraphNode *node) {
rect->setSize(size);
}

void NodeWidget::updateName() {
if(m_label) {
std::string title = !m_node->objectName().isEmpty() ? qPrintable(m_node->objectName()) : m_node->typeName();
m_label->setText(title);
}
}

void NodeWidget::setSelected(bool flag) {
if(flag) {
setBorderColor(Vector4(1.0f));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class NodeWidget : public Frame {

void setGraphNode(GraphNode *node);

void updateName();

void setSelected(bool flag);

Frame *title() const;
Expand Down
4 changes: 0 additions & 4 deletions modules/editor/grapheditor/editor/graph/nodegroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ QString NodeGroup::text() const {
}
void NodeGroup::setText(const QString &text) {
setObjectName(text);

if(m_nodeWidget) {
static_cast<GroupWidget *>(m_nodeWidget)->label()->setText(text.toStdString());
}
}

QColor NodeGroup::groupColor() const {
Expand Down