1#ifndef PROJECTCONFIG_P_H
2#define PROJECTCONFIG_P_H
8#include "ui_projectconfig.h"
10#include <QtWidgets/QPushButton>
31 , _ctx(std::move(ctx))
36 , _plugins(_graphScene.registry())
49 _ui->layout->addWidget(_graphView);
51 _ui->scrollArea->setMinimumSize(165, 0);
52 _ui->scrollArea->setMaximumSize(165, 10000);
53 _plugins.initSections(*_ui);
56 QJsonObject msg = initBcast(node);
57 msg[
"msg"] = BcastMsg::ConfigChanged;
59 auto& component = getComponent(node);
60 auto propObj = component.getQConfig();
61 auto prop = propObj->property(
"exposedProperties");
64 for (
const auto& p : prop.toStringList()) {
65 confObj[p] = propObj->property(p.toStdString().c_str()).toString();
68 msg[
"config"] = confObj;
79 bgColor = QColor(94, 94, 94);
81 bgColor = QColor(255, 255, 255);
84 _plugins.clearSections();
85 _plugins.addWidgets(bgColor);
92 return _graphScene.saveToMemory();
95 void load(
const QByteArray& data)
97 return _graphScene.loadFromMemory(data);
102 return _graphScene.clearScene();
109 auto& iface = getComponentModel(node);
110 iface.initModel(node, _nodeCnt, _darkMode);
118 node.nodeGraphicsObject().setOpacity(node.nodeDataModel()->nodeStyle().Opacity);
120 node.nodeGraphicsObject().update();
124 cds_debug(
"Node '{}' created", node.nodeDataModel()->caption().toStdString());
126 QJsonObject msg = initBcast(node);
127 msg[
"msg"] = BcastMsg::NodeCreated;
135 auto& component = getComponent(node);
137 cds_debug(
"Node '{}' deleted", node.nodeDataModel()->caption().toStdString());
141 QJsonObject msg = initBcast(node);
142 msg[
"msg"] = BcastMsg::NodeDeleted;
149 auto& component = getComponent(node);
151 cds_debug(
"Node '{}' double clicked", node.nodeDataModel()->caption().toStdString());
153 if (component.mainWidget() !=
nullptr) {
164 auto& component = getComponent(node);
165 cds_debug(
"Node '{}' context menu", node.nodeDataModel()->caption().toStdString());
167 QMenu contextMenu(tr(
"Node options"),
this);
169 QAction actionOpen(
"Open",
this);
170 connect(&actionOpen, &QAction::triggered, [
this, &node]() { openWidget(node); });
172 QAction actionProperties(
"Properties",
this);
173 connect(&actionProperties, &QAction::triggered, [
this, &node]() { _pcInt.
openProperties(node); });
176 actionProperties.setDisabled(
true);
179 QAction actionDelete(
"Delete",
this);
180 connect(&actionDelete, &QAction::triggered, [
this, &node]() { _graphScene.removeNode(node); });
182 if (component.mainWidget() !=
nullptr) {
183 contextMenu.addAction(&actionOpen);
184 contextMenu.addAction(&actionProperties);
185 contextMenu.setDefaultAction(&actionOpen);
187 contextMenu.addAction(&actionProperties);
188 contextMenu.setDefaultAction(&actionProperties);
191 contextMenu.addAction(&actionDelete);
193 _pcInt.
showContextMenu(contextMenu, mapToGlobal(_graphView->mapFromScene(pos)));
198 _darkMode = darkMode;
200 _graphScene.iterateOverNodes([
this](QtNodes::Node* node) {
201 auto& iface = getComponentModel(*node);
202 iface.setColorMode(_darkMode);
203 node->nodeGraphicsObject().update();
208 msg[
"msg"] = BcastMsg::GuiStyleSwitched;
209 msg[
"dark_mode_style"] = darkMode;
215 void simBcast(
const QJsonObject& msg,
const QVariant& param = QVariant());
218 void openWidget(QtNodes::Node& node)
221 auto& component = getComponent(node);
228 auto& iface = getComponentModel(node);
229 auto& component = iface.getComponent();
235 auto dataModel = node.nodeDataModel();
236 assert(
nullptr != dataModel);
242 void addShadow(QtNodes::Node& node)
244 auto const& nodeStyle = node.nodeDataModel()->nodeStyle();
245 auto effect =
new QGraphicsDropShadowEffect;
247 effect->setOffset(4, 4);
248 effect->setBlurRadius(20);
249 effect->setColor(nodeStyle.ShadowColor);
250 node.nodeGraphicsObject().setGraphicsEffect(effect);
253 QJsonObject initBcast(
const QtNodes::Node& node)
256 msg[
"id"] = node.id().toString();
257 msg[
"name"] = node.nodeDataModel()->name();
258 msg[
"caption"] = node.nodeDataModel()->caption();
269 QtNodes::FlowScene _graphScene;
271 std::unique_ptr<Ui::ProjectConfigPrivate> _ui;
Definition projectconfig.h:16
void handleWidgetDeletion(QWidget *widget)
void handleWidgetShowing(QWidget *widget, bool docked)
void handleDock(QWidget *component)
Definition projectconfig_p.h:24
void addModelIcons()
Definition projectconfig_p.h:74
void nodeDoubleClickedCallback(QtNodes::Node &node)
Definition projectconfig_p.h:147
bool _simStarted
Definition projectconfig_p.h:264
void nodeDeletedCallback(QtNodes::Node &node)
Definition projectconfig_p.h:132
void clearGraphView()
Definition projectconfig_p.h:100
QByteArray save() const
Definition projectconfig_p.h:90
void load(const QByteArray &data)
Definition projectconfig_p.h:95
void updateNodeStyle(bool darkMode)
Definition projectconfig_p.h:196
void nodeCreatedCallback(QtNodes::Node &node)
Definition projectconfig_p.h:105
void nodeContextMenuCallback(QtNodes::Node &node, const QPointF &pos)
Definition projectconfig_p.h:162
void simBcast(const QJsonObject &msg, const QVariant ¶m=QVariant())
~ProjectConfigPrivate()
Definition projectconfig_p.h:88
ProjectConfigPrivate(ProjectConfig *q, QWidget *parent, ProjectConfigCtx &&ctx=ProjectConfigCtx(new PCImpl()))
Definition projectconfig_p.h:29
#define cds_debug(fmt,...)
Definition log.h:13
Definition canrawsender_p.h:13
Context< PCInterface > ProjectConfigCtx
Definition projectconfig.h:8
Interface to be implemented by every component.
Definition componentinterface.h:15
Definition componentmodel.h:15
virtual void simBcastRcv(const QJsonObject &msg, const QVariant ¶m)=0
void handleDock(QWidget *widget)
void simBcastSnd(const QJsonObject &msg, const QVariant ¶m)
Definition flowviewwrapper.h:7
Definition pcinterface.h:16
virtual void setNodeDoubleClickedCallback(QtNodes::FlowScene *scene, const node_t &cb)=0
virtual void setConfigChangedCbk(const node_t cb)=0
virtual void showContextMenu(QMenu &menu, const QPoint &pos)=0
virtual void setNodeContextMenuCallback(QtNodes::FlowScene *scene, const menu_t &cb)=0
virtual void setNodeDeletedCallback(QtNodes::FlowScene *scene, const node_t &cb)=0
virtual void setNodeCreatedCallback(QtNodes::FlowScene *scene, const node_t &cb)=0
virtual void openProperties(QtNodes::Node &node)=0