nodeview: added rudimentary toolbar

Only button there is a toggle for the mini-map.
This commit is contained in:
itsmattkc
2021-07-09 21:57:53 -07:00
parent 94e6fa843c
commit 652a53c18e
6 changed files with 113 additions and 1 deletions
+19 -1
View File
@@ -20,20 +20,38 @@
#include "node.h"
#include <QVBoxLayout>
namespace olive {
NodePanel::NodePanel(QWidget *parent) :
PanelWidget(QStringLiteral("NodePanel"), parent)
{
QWidget *outer_widget = new QWidget(this);
QVBoxLayout *outer_layout = new QVBoxLayout(outer_widget);
outer_layout->setMargin(0);
NodeViewToolBar *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);
// Set defaults
toolbar->SetMiniMapEnabled(true);
node_view_->SetMiniMapEnabled(true);
// Connect node view signals to this panel
connect(node_view_, &NodeView::NodesSelected, this, &NodePanel::NodesSelected);
connect(node_view_, &NodeView::NodesDeselected, this, &NodePanel::NodesDeselected);
// Set it as the main widget of this panel
SetWidgetWithPadding(node_view_);
SetWidgetWithPadding(outer_widget);
// Set strings
Retranslate();
+1
View File
@@ -22,6 +22,7 @@
#define NODEPANEL_H
#include "widget/nodeview/nodeview.h"
#include "widget/nodeview/nodeviewtoolbar.h"
#include "widget/panel/panel.h"
namespace olive {
+2
View File
@@ -27,6 +27,8 @@ set(OLIVE_SOURCES
widget/nodeview/nodeviewminimap.h
widget/nodeview/nodeviewscene.cpp
widget/nodeview/nodeviewscene.h
widget/nodeview/nodeviewtoolbar.cpp
widget/nodeview/nodeviewtoolbar.h
widget/nodeview/nodeviewundo.cpp
widget/nodeview/nodeviewundo.h
PARENT_SCOPE
+6
View File
@@ -78,6 +78,12 @@ public:
void ZoomOut();
public slots:
void SetMiniMapEnabled(bool e)
{
minimap_->setVisible(e);
}
signals:
void NodesSelected(const QVector<Node*>& nodes);
+47
View File
@@ -0,0 +1,47 @@
#include "nodeviewtoolbar.h"
#include <QEvent>
#include <QHBoxLayout>
namespace olive {
#define super QWidget
NodeViewToolBar::NodeViewToolBar(QWidget *parent) :
QWidget(parent)
{
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setMargin(0);
minimap_btn_ = new QPushButton();
minimap_btn_->setCheckable(true);
connect(minimap_btn_, &QPushButton::clicked, this, &NodeViewToolBar::MiniMapEnabledToggled);
layout->addWidget(minimap_btn_);
layout->addStretch();
Retranslate();
UpdateIcons();
}
void NodeViewToolBar::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
Retranslate();
} else if (e->type() == QEvent::StyleChange) {
UpdateIcons();
}
super::changeEvent(e);
}
void NodeViewToolBar::Retranslate()
{
minimap_btn_->setText(tr("Mini-Map"));
minimap_btn_->setToolTip(tr("Toggle Mini-Map"));
}
void NodeViewToolBar::UpdateIcons()
{
}
}
+38
View File
@@ -0,0 +1,38 @@
#ifndef NODEVIEWTOOLBAR_H
#define NODEVIEWTOOLBAR_H
#include <QPushButton>
#include <QWidget>
namespace olive {
class NodeViewToolBar : public QWidget
{
Q_OBJECT
public:
NodeViewToolBar(QWidget *parent = nullptr);
public slots:
void SetMiniMapEnabled(bool e)
{
minimap_btn_->setChecked(e);
}
signals:
void MiniMapEnabledToggled(bool e);
protected:
virtual void changeEvent(QEvent *e) override;
private:
void Retranslate();
void UpdateIcons();
QPushButton *minimap_btn_;
};
}
#endif // NODEVIEWTOOLBAR_H