nodeview: disable toolbar when null graph set
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user