nodeview: disable toolbar when null graph set

This commit is contained in:
itsmattkc
2021-07-23 23:35:08 -07:00
parent 1c8b1b6006
commit c356c241b9
3 changed files with 12 additions and 5 deletions
+5 -5
View File
@@ -32,19 +32,19 @@ NodePanel::NodePanel(QWidget *parent) :
QVBoxLayout *outer_layout = new QVBoxLayout(outer_widget);
outer_layout->setMargin(0);
NodeViewToolBar *toolbar = new NodeViewToolBar();
outer_layout->addWidget(toolbar);
toolbar_ = new NodeViewToolBar();
outer_layout->addWidget(toolbar_);
// Create NodeView widget
node_view_ = new NodeView(this);
outer_layout->addWidget(node_view_);
// Connect toolbar to NodeView
connect(toolbar, &NodeViewToolBar::MiniMapEnabledToggled, node_view_, &NodeView::SetMiniMapEnabled);
connect(toolbar, &NodeViewToolBar::AddNodeClicked, node_view_, &NodeView::ShowAddMenu);
connect(toolbar_, &NodeViewToolBar::MiniMapEnabledToggled, node_view_, &NodeView::SetMiniMapEnabled);
connect(toolbar_, &NodeViewToolBar::AddNodeClicked, node_view_, &NodeView::ShowAddMenu);
// Set defaults
toolbar->SetMiniMapEnabled(true);
toolbar_->SetMiniMapEnabled(true);
node_view_->SetMiniMapEnabled(true);
// Connect node view signals to this panel
+3
View File
@@ -44,6 +44,7 @@ public:
void SetGraph(NodeGraph *graph, const QVector<Node*> &nodes)
{
node_view_->SetGraph(graph, nodes);
toolbar_->setEnabled(graph);
}
void ClearGraph()
@@ -125,6 +126,8 @@ private:
NodeView* node_view_;
NodeViewToolBar *toolbar_;
};
}
+4
View File
@@ -975,6 +975,10 @@ void NodeView::ShowContextMenu(const QPoint &pos)
void NodeView::CreateNodeSlot(QAction *action)
{
if (!graph_) {
return;
}
Node* new_node = NodeFactory::CreateFromMenuAction(action);
if (new_node) {