mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 02:40:20 +08:00
refactor: continuously refactor node editor base class structures
This commit is contained in:
parent
5013cf7947
commit
c02e8475b3
2
3rdparty/QNodeEditor
vendored
2
3rdparty/QNodeEditor
vendored
@ -1 +1 @@
|
||||
Subproject commit 3d380c24459e7363ad54494d0f0f4b1af1a19ee2
|
||||
Subproject commit d571c5734229a67625da85e7e4e76ea2e034771d
|
@ -23,6 +23,7 @@ set(QV2RAY_UI_FORMS
|
||||
set(QV2RAY_UI_NODEEDITOR_SOURCES
|
||||
# NodeEditor Models
|
||||
${CMAKE_SOURCE_DIR}/src/ui/node/NodeBase.hpp
|
||||
${CMAKE_SOURCE_DIR}/src/ui/node/NodeBase.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/ui/node/models/InboundNodeModel.hpp
|
||||
${CMAKE_SOURCE_DIR}/src/ui/node/models/InboundNodeModel.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/ui/node/models/OutboundNodeModel.hpp
|
||||
|
@ -1 +1 @@
|
||||
5798
|
||||
5799
|
||||
|
@ -13,11 +13,10 @@ namespace Qv2ray::base::objects::complex
|
||||
|
||||
struct OutboundObject
|
||||
{
|
||||
QString tag;
|
||||
QString externalTag;
|
||||
OutboundObjectMode mode;
|
||||
ConnectionId connectionId;
|
||||
QJsonObject json;
|
||||
JSONSTRUCT_REGISTER(OutboundObject, F(tag, mode, connectionId, json))
|
||||
JSONSTRUCT_REGISTER(OutboundObject, F(externalTag, mode, connectionId))
|
||||
};
|
||||
|
||||
enum MetaOutboundObjectType
|
||||
@ -27,13 +26,6 @@ namespace Qv2ray::base::objects::complex
|
||||
METAOUTBOUND_CHAINED
|
||||
};
|
||||
|
||||
struct OutboundObjectMeta
|
||||
{
|
||||
MetaOutboundObjectType metaType;
|
||||
OutboundObject object;
|
||||
JSONSTRUCT_REGISTER(OutboundObjectMeta, F(metaType, object))
|
||||
};
|
||||
|
||||
class __ChainID;
|
||||
class __BalancerID;
|
||||
typedef IDType<__ChainID> ChainID;
|
||||
|
@ -1,8 +1,6 @@
|
||||
#include "w_RoutesEditor.hpp"
|
||||
|
||||
#include "components/plugins/QvPluginHost.hpp"
|
||||
#include "core/CoreUtils.hpp"
|
||||
#include "core/connection/ConnectionIO.hpp"
|
||||
#include "core/connection/Generation.hpp"
|
||||
#include "core/handler/ConfigHandler.hpp"
|
||||
#include "ui/common/UIBase.hpp"
|
||||
@ -70,7 +68,7 @@ void RouteEditor::SetupNodeWidget()
|
||||
connect(nodeScene, &FlowScene::connectionCreated, this, &RouteEditor::onConnectionCreated);
|
||||
connect(nodeScene, &FlowScene::connectionDeleted, this, &RouteEditor::onConnectionDeleted);
|
||||
auto view = new FlowView(nodeScene);
|
||||
view->scaleDown();
|
||||
// view->scaleDown();
|
||||
l->addWidget(view);
|
||||
l->setContentsMargins(0, 0, 0, 0);
|
||||
l->setSpacing(0);
|
||||
@ -91,21 +89,24 @@ RouteEditor::RouteEditor(QJsonObject connection, QWidget *parent) : QvDialog(par
|
||||
// domainStrategyCombo->setCurrentText(domainStrategy);
|
||||
//
|
||||
//// Show connections in the node graph
|
||||
// for (const auto &in : root["inbounds"].toArray())
|
||||
//{
|
||||
// AddInbound(INBOUND(in.toObject()));
|
||||
//}
|
||||
//
|
||||
// for (const auto &out : root["outbounds"].toArray())
|
||||
//{
|
||||
// AddOutbound(OUTBOUND(out.toObject()));
|
||||
//}
|
||||
//
|
||||
// for (const auto &item : root["routing"].toObject()["rules"].toArray())
|
||||
//{
|
||||
// AddRule(RuleObject::fromJson(item.toObject()));
|
||||
//}
|
||||
//
|
||||
for (const auto &in : root["inbounds"].toArray())
|
||||
{
|
||||
AddInbound(INBOUND(in.toObject()));
|
||||
}
|
||||
|
||||
for (const auto &out : root["outbounds"].toArray())
|
||||
{
|
||||
OutboundObjectMeta meta;
|
||||
meta.loadJson(out.toObject()[META_OUTBOUND_KEY_NAME].toObject());
|
||||
meta.realOutbound = OUTBOUND(out.toObject());
|
||||
AddOutbound(meta);
|
||||
}
|
||||
|
||||
for (const auto &item : root["routing"].toObject()["rules"].toArray())
|
||||
{
|
||||
AddRule(RuleObject::fromJson(item.toObject()));
|
||||
}
|
||||
|
||||
//// Set default outboung combo text AFTER adding all outbounds.
|
||||
// defaultOutbound = getTag(OUTBOUND(root["outbounds"].toArray().first().toObject()));
|
||||
// defaultOutboundCombo->setCurrentText(defaultOutbound);
|
||||
@ -510,7 +511,8 @@ void RouteEditor::on_insertBlackBtn_clicked()
|
||||
auto blackHole = GenerateBlackHoleOUT(false);
|
||||
auto tag = "blackhole_" + QSTRN(QTime::currentTime().msecsSinceStartOfDay());
|
||||
auto _blackHoleOutbound = GenerateOutboundEntry("blackhole", blackHole, QJsonObject(), QJsonObject(), "0.0.0.0", tag);
|
||||
AddOutbound(_blackHoleOutbound);
|
||||
abort();
|
||||
// AddOutbound(_blackHoleOutbound);
|
||||
}
|
||||
void RouteEditor::on_addInboundBtn_clicked()
|
||||
{
|
||||
@ -545,7 +547,8 @@ void RouteEditor::on_addOutboundBtn_clicked()
|
||||
|
||||
for (int i = 0; i < confList.count(); i++)
|
||||
{
|
||||
AddOutbound(OUTBOUND(confList[i].toObject()));
|
||||
abort();
|
||||
// AddOutbound(OUTBOUND(confList[i].toObject()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -561,9 +564,9 @@ void RouteEditor::on_delBtn_clicked()
|
||||
}
|
||||
|
||||
auto firstNode = nodeScene->selectedNodes()[0];
|
||||
auto isInbound = inboundNodes.values().contains(firstNode->id());
|
||||
auto isOutbound = outboundNodes.values().contains(firstNode->id());
|
||||
auto isRule = ruleNodes.values().contains(firstNode->id());
|
||||
auto isInbound = false; // inboundNodes.values().contains(firstNode->id());
|
||||
auto isOutbound = false; // outboundNodes.values().contains(firstNode->id());
|
||||
auto isRule = false; // ruleNodes.values().contains(firstNode->id());
|
||||
|
||||
// Get the tag first, and call inbounds/outbounds/rules container variable
|
||||
// remove() Remove the node last since some events may trigger. Then remove
|
||||
@ -643,8 +646,8 @@ void RouteEditor::on_editBtn_clicked()
|
||||
}
|
||||
|
||||
const auto firstNode = nodeScene->selectedNodes().at(0);
|
||||
const auto &isInbound = inboundNodes.values().contains(firstNode->id());
|
||||
const auto &isOutbound = outboundNodes.values().contains(firstNode->id());
|
||||
const auto isInbound = false; // inboundNodes.values().contains(firstNode->id());
|
||||
const auto isOutbound = false; // outboundNodes.values().contains(firstNode->id());
|
||||
|
||||
if (isInbound)
|
||||
{
|
||||
@ -784,7 +787,8 @@ void RouteEditor::on_importExistingBtn_clicked()
|
||||
const auto root = ConnectionManager->GetConnectionRoot(connId);
|
||||
auto outbound = root["outbounds"].toArray()[0].toObject();
|
||||
outbound["tag"] = GetDisplayName(connId);
|
||||
AddOutbound(OUTBOUND{ outbound });
|
||||
abort();
|
||||
// AddOutbound(OUTBOUND{ outbound });
|
||||
}
|
||||
|
||||
void RouteEditor::on_importGroupBtn_currentIndexChanged(int)
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "common/QvHelpers.hpp"
|
||||
#include "ui/common/QvDialog.hpp"
|
||||
#include "ui/messaging/QvMessageBus.hpp"
|
||||
#include "ui/node/NodeBase.hpp"
|
||||
#include "ui_w_RoutesEditor.h"
|
||||
|
||||
#include <nodes/internal/ConnectionStyle.hpp>
|
||||
@ -71,14 +72,11 @@ class RouteEditor
|
||||
bool isLoading = false;
|
||||
void RenameItemTag(ROUTE_EDIT_MODE mode, const QString originalTag, QString *newTag);
|
||||
//
|
||||
// QString currentRuleTag;
|
||||
QString currentInboundOutboundTag;
|
||||
// QMap<QString, QStringList> balancers;
|
||||
QString domainStrategy;
|
||||
QString defaultOutbound;
|
||||
//
|
||||
QList<INBOUND> inbounds;
|
||||
QList<OUTBOUND> outbounds;
|
||||
QList<OutboundObjectMeta> outbounds;
|
||||
QList<RuleObject> rules;
|
||||
//
|
||||
CONFIGROOT root;
|
||||
@ -86,15 +84,13 @@ class RouteEditor
|
||||
//
|
||||
// ---------------------------- Node Graph Impl --------------------------
|
||||
void SetupNodeWidget();
|
||||
QHash<QString, QUuid> inboundNodes;
|
||||
QHash<QString, QUuid> outboundNodes;
|
||||
QHash<QString, QUuid> ruleNodes;
|
||||
//
|
||||
FlowScene *nodeScene;
|
||||
// ---------------------------- Extra Source File Headers ----------------
|
||||
void AddInbound(INBOUND in);
|
||||
void AddOutbound(OUTBOUND out);
|
||||
void AddRule(RuleObject rule);
|
||||
void AddInbound(const INBOUND &in);
|
||||
void AddOutbound(OutboundObjectMeta &meta);
|
||||
void AddRule(const RuleObject &rule);
|
||||
QString AddNewRule();
|
||||
//
|
||||
void ResolveDefaultOutboundTag(QString original, QString newTag);
|
||||
};
|
||||
|
@ -9,7 +9,7 @@
|
||||
// Supplementary source file for Routes editor, basically providing
|
||||
// routes-related operations.
|
||||
|
||||
void RouteEditor::AddInbound(INBOUND in)
|
||||
void RouteEditor::AddInbound(const INBOUND &in)
|
||||
{
|
||||
// QString tag = getTag(in);
|
||||
//
|
||||
@ -27,93 +27,60 @@ void RouteEditor::AddInbound(INBOUND in)
|
||||
// inboundNodes.insert(tag, node.id());
|
||||
}
|
||||
|
||||
void RouteEditor::AddOutbound(OUTBOUND out)
|
||||
void RouteEditor::AddOutbound(OutboundObjectMeta &metaOutboud)
|
||||
{
|
||||
// QString tag = getTag(out);
|
||||
//
|
||||
// if (outboundNodes.contains(tag))
|
||||
// tag.append("_" + GenerateRandomString(5));
|
||||
//
|
||||
// out["tag"] = tag;
|
||||
// outbounds << out;
|
||||
// auto _nodeData = std::make_unique<QvOutboundNodeModel>(std::make_shared<OutboundNodeData>(std::make_shared<OUTBOUND>(outbounds.last())));
|
||||
// auto pos = nodeGraphWidget->pos();
|
||||
// pos.setX(pos.x() + 850 + GRAPH_GLOBAL_OFFSET_X);
|
||||
// pos.setY(pos.y() + outboundNodes.count() * 120 + GRAPH_GLOBAL_OFFSET_Y);
|
||||
// auto &node = nodeScene->createNode(std::move(_nodeData));
|
||||
// nodeScene->setNodePosition(node, pos);
|
||||
// outboundNodes.insert(tag, node.id());
|
||||
// defaultOutboundCombo->addItem(tag);
|
||||
QString tag;
|
||||
switch (metaOutboud.metaType)
|
||||
{
|
||||
case complex::METAOUTBOUND_ORIGINAL:
|
||||
{
|
||||
tag = getTag(metaOutboud.realOutbound);
|
||||
break;
|
||||
}
|
||||
case complex::METAOUTBOUND_CHAINED:
|
||||
case complex::METAOUTBOUND_BALANCER:
|
||||
{
|
||||
tag = metaOutboud.object.externalTag;
|
||||
break;
|
||||
}
|
||||
}
|
||||
outbounds << metaOutboud;
|
||||
auto _nodeData = std::make_unique<OutboundNodeModel>(std::make_shared<OutboundObjectMeta>(outbounds.last()));
|
||||
auto pos = nodeGraphWidget->pos();
|
||||
pos.setX(pos.x() + 850 + GRAPH_GLOBAL_OFFSET_X);
|
||||
pos.setY(pos.y() + outbounds.count() * 120 + GRAPH_GLOBAL_OFFSET_Y);
|
||||
auto &node = nodeScene->createNode(std::move(_nodeData));
|
||||
nodeScene->setNodePosition(node, pos);
|
||||
defaultOutboundCombo->addItem(tag);
|
||||
}
|
||||
|
||||
QString RouteEditor::AddNewRule()
|
||||
{
|
||||
//// Add Route
|
||||
// RuleObject rule;
|
||||
////
|
||||
// rule.QV2RAY_RULE_ENABLED = true;
|
||||
// rule.QV2RAY_RULE_USE_BALANCER = false;
|
||||
//// Default balancer tag, it's a random string.
|
||||
// auto bTag = GenerateRandomString();
|
||||
// rule.QV2RAY_RULE_TAG = rules.isEmpty() ? tr("Default rule") : (tr("rule") + "-" + GenerateRandomString(6));
|
||||
// rule.balancerTag = bTag;
|
||||
//// balancers[bTag] = QStringList();
|
||||
// AddRule(rule);
|
||||
// return rule.QV2RAY_RULE_TAG;
|
||||
return "";
|
||||
// Add Route
|
||||
RuleObject rule;
|
||||
//
|
||||
rule.QV2RAY_RULE_ENABLED = true;
|
||||
rule.QV2RAY_RULE_USE_BALANCER = false;
|
||||
// Default balancer tag, it's a random string.
|
||||
auto bTag = GenerateRandomString();
|
||||
rule.QV2RAY_RULE_TAG = rules.isEmpty() ? tr("Default rule") : (tr("rule") + "-" + GenerateRandomString(6));
|
||||
rule.balancerTag = bTag;
|
||||
// balancers[bTag] = QStringList();
|
||||
AddRule(rule);
|
||||
return rule.QV2RAY_RULE_TAG;
|
||||
}
|
||||
|
||||
void RouteEditor::AddRule(RuleObject rule)
|
||||
void RouteEditor::AddRule(const RuleObject &rule)
|
||||
{
|
||||
//// Prevent duplicate
|
||||
// if (ruleNodes.contains(rule.QV2RAY_RULE_TAG))
|
||||
//{
|
||||
// rule.QV2RAY_RULE_TAG += "-" + GenerateRandomString(5);
|
||||
//}
|
||||
//
|
||||
// rules << rule;
|
||||
// auto pos = nodeGraphWidget->pos();
|
||||
// pos.setX(pos.x() + 350 + GRAPH_GLOBAL_OFFSET_X);
|
||||
// pos.setY(pos.y() + ruleNodes.count() * 120 + GRAPH_GLOBAL_OFFSET_Y);
|
||||
// auto _nodeData = std::make_unique<QvRuleNodeModel>(std::make_shared<RuleNodeData>(std::make_shared<RuleObject>(rules.last())));
|
||||
// auto &node = nodeScene->createNode(std::move(_nodeData));
|
||||
// nodeScene->setNodePosition(node, pos);
|
||||
//
|
||||
// for (auto inTag : rule.inboundTag)
|
||||
//{
|
||||
// if (!inboundNodes.contains(inTag))
|
||||
// {
|
||||
// LOG(MODULE_UI, "No inbound tag found for rule: " + rule.QV2RAY_RULE_TAG + ", inbound tag: " + inTag)
|
||||
// QvMessageBoxWarn(this, tr("No Inbound"), tr("No inbound item found: ") + inTag);
|
||||
// rule.inboundTag.removeAll(inTag);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// auto inboundNode = inboundNodes.value(inTag);
|
||||
// auto conn = nodeScene->createConnection(node, 0, *nodeScene->node(inboundNode), 0);
|
||||
// connect(conn.get(), &QtNodes::Connection::connectionCompleted, this, &RouteEditor::onConnectionCreated);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//// If not using balancers (use outbound tag)
|
||||
// if (!rule.QV2RAY_RULE_USE_BALANCER)
|
||||
//{
|
||||
// if (outboundNodes.contains(rule.outboundTag))
|
||||
// {
|
||||
// DEBUG(MODULE_GRAPH, "Found outbound tag: " + rule.outboundTag + ", for rule: " + rule.QV2RAY_RULE_TAG)
|
||||
// auto conn = nodeScene->createConnection(*nodeScene->node(outboundNodes.value(rule.outboundTag)), 0, node, 0);
|
||||
// connect(conn.get(), &QtNodes::Connection::connectionCompleted, this, &RouteEditor::onConnectionCreated);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// LOG(MODULE_GRAPH, "Outbound tag not found: " + rule.outboundTag + ", for: " + rule.QV2RAY_RULE_TAG)
|
||||
// // QvMessageBoxWarn(this, tr("No outbound tag"), tr("Please connect
|
||||
// // the rule with an outbound."));
|
||||
// }
|
||||
//}
|
||||
//
|
||||
// this->ruleNodes.insert(rule.QV2RAY_RULE_TAG, node.id());
|
||||
// ruleListWidget->addItem(rule.QV2RAY_RULE_TAG);
|
||||
rules << rule;
|
||||
auto pos = nodeGraphWidget->pos();
|
||||
pos.setX(pos.x() + 350 + GRAPH_GLOBAL_OFFSET_X);
|
||||
pos.setY(pos.y() + rules.count() * 120 + GRAPH_GLOBAL_OFFSET_Y);
|
||||
auto _nodeData = std::make_unique<RuleNodeModel>(std::make_shared<RuleObject>(rules.last()));
|
||||
auto &node = nodeScene->createNode(std::move(_nodeData));
|
||||
nodeScene->setNodePosition(node, pos);
|
||||
|
||||
ruleListWidget->addItem(rule.QV2RAY_RULE_TAG);
|
||||
}
|
||||
|
||||
// Do not use reference here, we need deep copy of EVERY QString.
|
||||
@ -272,7 +239,7 @@ void RouteEditor::ResolveDefaultOutboundTag(const QString original, const QStrin
|
||||
isLoading = true;
|
||||
defaultOutboundCombo->clear();
|
||||
//
|
||||
for (const auto &out : outbounds) defaultOutboundCombo->addItem(getTag(out));
|
||||
for (const auto &out : outbounds) defaultOutboundCombo->addItem(getTag(out.realOutbound));
|
||||
//
|
||||
isLoading = false;
|
||||
//
|
||||
@ -293,8 +260,8 @@ void RouteEditor::ResolveDefaultOutboundTag(const QString original, const QStrin
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultOutbound = getTag(outbounds.first());
|
||||
defaultOutboundCombo->addItem(getTag(outbounds.first()));
|
||||
defaultOutbound = getTag(outbounds.first().realOutbound);
|
||||
defaultOutboundCombo->addItem(getTag(outbounds.first().realOutbound));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
111
src/ui/node/NodeBase.cpp
Normal file
111
src/ui/node/NodeBase.cpp
Normal file
@ -0,0 +1,111 @@
|
||||
#include "NodeBase.hpp"
|
||||
std::shared_ptr<NodeDataType> InboundNodeModel::dataType(PortType, PortIndex) const
|
||||
{
|
||||
return NODE_TYPE_INBOUND;
|
||||
}
|
||||
|
||||
std::shared_ptr<NodeDataType> OutboundNodeModel::dataType(PortType, PortIndex) const
|
||||
{
|
||||
return NODE_TYPE_OUTBOUND;
|
||||
}
|
||||
|
||||
std::shared_ptr<NodeDataType> RuleNodeModel::dataType(PortType portType, PortIndex) const
|
||||
{
|
||||
switch (portType)
|
||||
{
|
||||
case PortType::In: return NODE_TYPE_INBOUND;
|
||||
case PortType::Out: return NODE_TYPE_OUTBOUND;
|
||||
default: return {};
|
||||
}
|
||||
}
|
||||
//
|
||||
// *******************************************************************************************
|
||||
//
|
||||
|
||||
unsigned int InboundNodeModel::nPorts(PortType portType) const
|
||||
{
|
||||
return portType == PortType::Out ? 1 : 0;
|
||||
}
|
||||
|
||||
unsigned int OutboundNodeModel::nPorts(PortType portType) const
|
||||
{
|
||||
return portType == PortType::Out ? 0 : 1;
|
||||
}
|
||||
unsigned int RuleNodeModel::nPorts(PortType portType) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// *******************************************************************************************
|
||||
//
|
||||
|
||||
std::shared_ptr<NodeData> InboundNodeModel::outData(PortIndex)
|
||||
{
|
||||
return std::make_shared<InboundNodeData>(dataptr);
|
||||
}
|
||||
|
||||
std::shared_ptr<NodeData> OutboundNodeModel::outData(PortIndex)
|
||||
{
|
||||
return std::make_shared<OutboundNodeData>(dataptr);
|
||||
}
|
||||
|
||||
std::shared_ptr<NodeData> RuleNodeModel::outData(PortIndex)
|
||||
{
|
||||
return std::make_shared<RuleNodeData>(dataptr);
|
||||
}
|
||||
|
||||
//
|
||||
// *******************************************************************************************
|
||||
//
|
||||
|
||||
void InboundNodeModel::setInData(std::shared_ptr<NodeData> nodeData, PortIndex port)
|
||||
{
|
||||
setInData(std::vector{ nodeData }, port);
|
||||
}
|
||||
void OutboundNodeModel::setInData(std::shared_ptr<NodeData> nodeData, PortIndex port)
|
||||
{
|
||||
setInData(std::vector{ nodeData }, port);
|
||||
}
|
||||
void RuleNodeModel::setInData(std::shared_ptr<NodeData> nodeData, PortIndex port)
|
||||
{
|
||||
setInData(std::vector{ nodeData }, port);
|
||||
}
|
||||
|
||||
//
|
||||
// *******************************************************************************************
|
||||
//
|
||||
|
||||
QtNodes::NodeDataModel::ConnectionPolicy InboundNodeModel::portInConnectionPolicy(PortIndex) const
|
||||
{
|
||||
// No port
|
||||
return NodeDataModel::ConnectionPolicy::One;
|
||||
}
|
||||
QtNodes::NodeDataModel::ConnectionPolicy OutboundNodeModel::portInConnectionPolicy(PortIndex) const
|
||||
{
|
||||
return NodeDataModel::ConnectionPolicy::One;
|
||||
}
|
||||
|
||||
QtNodes::NodeDataModel::ConnectionPolicy RuleNodeModel::portInConnectionPolicy(PortIndex) const
|
||||
{
|
||||
return NodeDataModel::ConnectionPolicy::Many;
|
||||
}
|
||||
|
||||
//
|
||||
// *******************************************************************************************
|
||||
//
|
||||
|
||||
QtNodes::NodeDataModel::ConnectionPolicy InboundNodeModel::portOutConnectionPolicy(PortIndex) const
|
||||
{
|
||||
return NodeDataModel::ConnectionPolicy::Many;
|
||||
}
|
||||
|
||||
QtNodes::NodeDataModel::ConnectionPolicy OutboundNodeModel::portOutConnectionPolicy(PortIndex) const
|
||||
{
|
||||
// No port
|
||||
return NodeDataModel::ConnectionPolicy::One;
|
||||
}
|
||||
QtNodes::NodeDataModel::ConnectionPolicy RuleNodeModel::portOutConnectionPolicy(PortIndex) const
|
||||
{
|
||||
return NodeDataModel::ConnectionPolicy::One;
|
||||
}
|
@ -9,6 +9,18 @@
|
||||
#include <nodes/internal/NodeDataModel.hpp>
|
||||
#include <nodes/internal/PortType.hpp>
|
||||
|
||||
constexpr auto META_OUTBOUND_KEY_NAME = "QV2RAY_OUTBOUND_METADATA";
|
||||
constexpr auto GRAPH_NODE_LABEL_FONTSIZE_INCREMENT = 3;
|
||||
|
||||
struct OutboundObjectMeta
|
||||
{
|
||||
complex::MetaOutboundObjectType metaType;
|
||||
complex::ChainID chainId;
|
||||
complex::OutboundObject object;
|
||||
OUTBOUND realOutbound;
|
||||
JSONSTRUCT_REGISTER(OutboundObjectMeta, F(metaType, chainId, object))
|
||||
};
|
||||
|
||||
using QtNodes::NodeData;
|
||||
using QtNodes::NodeDataModel;
|
||||
using QtNodes::NodeDataType;
|
||||
@ -16,11 +28,6 @@ using QtNodes::NodeValidationState;
|
||||
using QtNodes::PortIndex;
|
||||
using QtNodes::PortType;
|
||||
|
||||
using QtNodes::NodeData;
|
||||
using QtNodes::NodeDataType;
|
||||
|
||||
constexpr auto GRAPH_NODE_LABEL_FONTSIZE_INCREMENT = 3;
|
||||
|
||||
namespace Qv2ray::ui::nodemodels
|
||||
{
|
||||
const auto NODE_TYPE_OUTBOUND = std::make_shared<NodeDataType>("outbound", QObject::tr("Outbound"));
|
||||
@ -33,8 +40,9 @@ namespace Qv2ray::ui::nodemodels
|
||||
public:
|
||||
explicit QvNodeWidget(QWidget *parent) : QWidget(parent){};
|
||||
template<typename T>
|
||||
void setValue(std::shared_ptr<T>){};
|
||||
virtual void OnSizeUpdated() = 0;
|
||||
void setValue(std::shared_ptr<T>);
|
||||
signals:
|
||||
void OnSizeUpdated();
|
||||
};
|
||||
|
||||
#define DECL_NODE_DATA_TYPE(name, TYPE, INNER_TYPE) \
|
||||
@ -56,13 +64,12 @@ namespace Qv2ray::ui::nodemodels
|
||||
}
|
||||
|
||||
DECL_NODE_DATA_TYPE(InboundNodeData, NODE_TYPE_INBOUND, INBOUND);
|
||||
DECL_NODE_DATA_TYPE(OutboundNodeData, NODE_TYPE_OUTBOUND, complex::OutboundObjectMeta);
|
||||
DECL_NODE_DATA_TYPE(OutboundNodeData, NODE_TYPE_OUTBOUND, OutboundObjectMeta);
|
||||
DECL_NODE_DATA_TYPE(RuleNodeData, NODE_TYPE_RULE, RuleObject);
|
||||
|
||||
//
|
||||
//***********************************************************************************************************************************
|
||||
//
|
||||
|
||||
#define DECL_NODE_DATA_MODEL(NAME, CONTENT_TYPE) \
|
||||
class NAME : public NodeDataModel \
|
||||
{ \
|
||||
@ -71,31 +78,36 @@ namespace Qv2ray::ui::nodemodels
|
||||
explicit NAME(std::shared_ptr<CONTENT_TYPE> data); \
|
||||
~NAME(){}; \
|
||||
\
|
||||
QString caption() const override \
|
||||
inline QString caption() const override \
|
||||
{ \
|
||||
return {}; \
|
||||
} \
|
||||
bool captionVisible() const override \
|
||||
inline bool captionVisible() const override \
|
||||
{ \
|
||||
return false; \
|
||||
} \
|
||||
QString name() const override \
|
||||
inline QString name() const override \
|
||||
{ \
|
||||
return #NAME; \
|
||||
} \
|
||||
ConnectionPolicy portOutConnectionPolicy(PortIndex) const override; \
|
||||
ConnectionPolicy portInConnectionPolicy(PortIndex) const override; \
|
||||
unsigned int nPorts(PortType portType) const override; \
|
||||
std::shared_ptr<NodeDataType> dataType(PortType portType, PortIndex portIndex) const override; \
|
||||
std::shared_ptr<NodeData> outData(PortIndex) override; \
|
||||
void setInData(std::shared_ptr<NodeData>, int) override; \
|
||||
void setData(std::shared_ptr<CONTENT_TYPE> data); \
|
||||
QWidget *embeddedWidget() override \
|
||||
\
|
||||
public: \
|
||||
virtual void setInData(std::shared_ptr<NodeData> nodeData, PortIndex port) override; \
|
||||
virtual void setInData(std::vector<std::shared_ptr<NodeData>> nodeData, PortIndex port) override; \
|
||||
virtual std::shared_ptr<NodeData> outData(PortIndex port) override; \
|
||||
inline QWidget *embeddedWidget() override \
|
||||
{ \
|
||||
return widget; \
|
||||
} \
|
||||
std::unique_ptr<NodeDataModel> clone() const override \
|
||||
inline std::unique_ptr<NodeDataModel> clone() const override \
|
||||
{ \
|
||||
return {}; \
|
||||
}; \
|
||||
\
|
||||
void inputConnectionCreated(const QtNodes::Connection &) override; \
|
||||
void inputConnectionDeleted(const QtNodes::Connection &) override; \
|
||||
void outputConnectionCreated(const QtNodes::Connection &) override; \
|
||||
@ -106,9 +118,9 @@ namespace Qv2ray::ui::nodemodels
|
||||
QvNodeWidget *widget; \
|
||||
}
|
||||
|
||||
DECL_NODE_DATA_MODEL(InboundNodeDataModel, INBOUND);
|
||||
DECL_NODE_DATA_MODEL(OutboundNodeDataModel, complex::OutboundObjectMeta);
|
||||
DECL_NODE_DATA_MODEL(RuleNodeDataModel, RuleObject);
|
||||
DECL_NODE_DATA_MODEL(InboundNodeModel, INBOUND);
|
||||
DECL_NODE_DATA_MODEL(OutboundNodeModel, OutboundObjectMeta);
|
||||
DECL_NODE_DATA_MODEL(RuleNodeModel, RuleObject);
|
||||
|
||||
} // namespace Qv2ray::ui::nodemodels
|
||||
|
||||
|
@ -1,53 +1,30 @@
|
||||
#include "InboundNodeModel.hpp"
|
||||
|
||||
#include "ui/node/widgets/InboundWidget.hpp"
|
||||
|
||||
InboundNodeDataModel::InboundNodeDataModel(std::shared_ptr<INBOUND> data) : NodeDataModel()
|
||||
InboundNodeModel::InboundNodeModel(std::shared_ptr<INBOUND> data) : NodeDataModel()
|
||||
{
|
||||
widget = new InboundWidget();
|
||||
connect(widget, &QvNodeWidget::OnSizeUpdated, this, &InboundNodeDataModel::embeddedWidgetSizeUpdated);
|
||||
connect(widget, &QvNodeWidget::OnSizeUpdated, this, &InboundNodeModel::embeddedWidgetSizeUpdated);
|
||||
widget->setWindowFlags(Qt::FramelessWindowHint);
|
||||
widget->setAttribute(Qt::WA_TranslucentBackground);
|
||||
}
|
||||
|
||||
std::shared_ptr<NodeDataType> InboundNodeDataModel::dataType(PortType portType, PortIndex portIndex) const
|
||||
{
|
||||
return NODE_TYPE_INBOUND;
|
||||
}
|
||||
|
||||
void InboundNodeDataModel::setInData(std::shared_ptr<NodeData>, int)
|
||||
{
|
||||
// dataptr = data;
|
||||
// widget->adjustSize();
|
||||
}
|
||||
unsigned int InboundNodeDataModel::nPorts(PortType portType) const
|
||||
{
|
||||
return portType == PortType::Out ? 1 : 0;
|
||||
}
|
||||
|
||||
std::shared_ptr<NodeData> InboundNodeDataModel::outData(PortIndex)
|
||||
{
|
||||
return std::make_shared<InboundNodeData>(dataptr);
|
||||
}
|
||||
|
||||
void InboundNodeDataModel::setData(std::shared_ptr<INBOUND> data)
|
||||
{
|
||||
dataptr = data;
|
||||
widget->adjustSize();
|
||||
}
|
||||
|
||||
void InboundNodeDataModel::inputConnectionCreated(const QtNodes::Connection &c)
|
||||
void InboundNodeModel::inputConnectionCreated(const QtNodes::Connection &c)
|
||||
{
|
||||
}
|
||||
|
||||
void InboundNodeDataModel::inputConnectionDeleted(const QtNodes::Connection &c)
|
||||
void InboundNodeModel::inputConnectionDeleted(const QtNodes::Connection &c)
|
||||
{
|
||||
}
|
||||
|
||||
void InboundNodeDataModel::outputConnectionCreated(const QtNodes::Connection &c)
|
||||
void InboundNodeModel::outputConnectionCreated(const QtNodes::Connection &c)
|
||||
{
|
||||
}
|
||||
|
||||
void InboundNodeDataModel::outputConnectionDeleted(const QtNodes::Connection &c)
|
||||
void InboundNodeModel::outputConnectionDeleted(const QtNodes::Connection &c)
|
||||
{
|
||||
}
|
||||
|
||||
void InboundNodeModel::setInData(std::vector<std::shared_ptr<NodeData>> nodeData, PortIndex port)
|
||||
{
|
||||
}
|
||||
|
@ -4,60 +4,49 @@
|
||||
#include "ui/node/widgets/OutboundChainWidget.hpp"
|
||||
#include "ui/node/widgets/OutboundWidget.hpp"
|
||||
|
||||
OutboundNodeDataModel::OutboundNodeDataModel(std::shared_ptr<complex::OutboundObjectMeta> data) : NodeDataModel()
|
||||
OutboundNodeModel::OutboundNodeModel(std::shared_ptr<OutboundObjectMeta> data) : NodeDataModel()
|
||||
{
|
||||
switch (data->metaType)
|
||||
{
|
||||
case complex::METAOUTBOUND_CHAINED:
|
||||
case complex::METAOUTBOUND_ORIGINAL:
|
||||
{
|
||||
widget = new OutboundWidget();
|
||||
((OutboundWidget *) widget)->setValue(data);
|
||||
break;
|
||||
}
|
||||
case complex::METAOUTBOUND_BALANCER:
|
||||
case complex::METAOUTBOUND_ORIGINAL: break;
|
||||
{
|
||||
widget = new OutboundBalancerWidget();
|
||||
((OutboundBalancerWidget *) widget)->setValue(data);
|
||||
break;
|
||||
}
|
||||
case complex::METAOUTBOUND_CHAINED:
|
||||
{
|
||||
widget = new OutboundChainWidget();
|
||||
((OutboundChainWidget *) widget)->setValue(data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// widget = new InboundWidget();
|
||||
// widget->setWindowFlags(Qt::FramelessWindowHint);
|
||||
// widget->setAttribute(Qt::WA_TranslucentBackground);
|
||||
connect(widget, &QvNodeWidget::OnSizeUpdated, this, &OutboundNodeModel::embeddedWidgetSizeUpdated);
|
||||
widget->setWindowFlags(Qt::FramelessWindowHint);
|
||||
widget->setAttribute(Qt::WA_TranslucentBackground);
|
||||
}
|
||||
|
||||
std::shared_ptr<NodeDataType> OutboundNodeDataModel::dataType(PortType portType, PortIndex portIndex) const
|
||||
{
|
||||
return NODE_TYPE_OUTBOUND;
|
||||
}
|
||||
|
||||
void OutboundNodeDataModel::setInData(std::shared_ptr<NodeData>, int)
|
||||
{
|
||||
// dataptr = data;
|
||||
// widget->adjustSize();
|
||||
}
|
||||
unsigned int OutboundNodeDataModel::nPorts(PortType portType) const
|
||||
{
|
||||
return portType == PortType::Out ? 0 : 1;
|
||||
}
|
||||
|
||||
std::shared_ptr<NodeData> OutboundNodeDataModel::outData(PortIndex)
|
||||
{
|
||||
return std::make_shared<OutboundNodeData>(dataptr);
|
||||
}
|
||||
|
||||
void OutboundNodeDataModel::setData(std::shared_ptr<complex::OutboundObjectMeta> data)
|
||||
{
|
||||
dataptr = data;
|
||||
widget->adjustSize();
|
||||
}
|
||||
|
||||
void OutboundNodeDataModel::inputConnectionCreated(const QtNodes::Connection &c)
|
||||
void OutboundNodeModel::inputConnectionCreated(const QtNodes::Connection &c)
|
||||
{
|
||||
}
|
||||
|
||||
void OutboundNodeDataModel::inputConnectionDeleted(const QtNodes::Connection &c)
|
||||
void OutboundNodeModel::inputConnectionDeleted(const QtNodes::Connection &c)
|
||||
{
|
||||
}
|
||||
|
||||
void OutboundNodeDataModel::outputConnectionCreated(const QtNodes::Connection &c)
|
||||
void OutboundNodeModel::outputConnectionCreated(const QtNodes::Connection &c)
|
||||
{
|
||||
}
|
||||
|
||||
void OutboundNodeDataModel::outputConnectionDeleted(const QtNodes::Connection &c)
|
||||
void OutboundNodeModel::outputConnectionDeleted(const QtNodes::Connection &c)
|
||||
{
|
||||
}
|
||||
void OutboundNodeModel::setInData(std::vector<std::shared_ptr<NodeData>> nodeData, PortIndex port)
|
||||
{
|
||||
}
|
||||
|
@ -2,57 +2,31 @@
|
||||
|
||||
#include "ui/node/widgets/RuleWidget.hpp"
|
||||
|
||||
RuleNodeDataModel::RuleNodeDataModel(std::shared_ptr<RuleObject> data) : NodeDataModel()
|
||||
RuleNodeModel::RuleNodeModel(std::shared_ptr<RuleObject> data) : NodeDataModel()
|
||||
{
|
||||
widget = new QvNodeRuleWidget();
|
||||
connect(widget, &QvNodeWidget::OnSizeUpdated, this, &RuleNodeDataModel::embeddedWidgetSizeUpdated);
|
||||
connect(widget, &QvNodeWidget::OnSizeUpdated, this, &NodeDataModel::embeddedWidgetSizeUpdated);
|
||||
((QvNodeRuleWidget *) widget)->setValue(data);
|
||||
widget->setWindowFlags(Qt::FramelessWindowHint);
|
||||
widget->setAttribute(Qt::WA_TranslucentBackground);
|
||||
}
|
||||
unsigned int RuleNodeDataModel::nPorts(PortType) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::shared_ptr<NodeData> RuleNodeDataModel::outData(PortIndex)
|
||||
{
|
||||
return std::make_shared<RuleNodeData>(dataptr);
|
||||
}
|
||||
|
||||
std::shared_ptr<NodeDataType> RuleNodeDataModel::dataType(PortType portType, PortIndex portIndex) const
|
||||
{
|
||||
switch (portType)
|
||||
{
|
||||
case PortType::In: return NODE_TYPE_INBOUND;
|
||||
case PortType::Out: return NODE_TYPE_OUTBOUND;
|
||||
default: return {};
|
||||
}
|
||||
}
|
||||
|
||||
void RuleNodeDataModel::setInData(std::shared_ptr<NodeData>, int)
|
||||
{
|
||||
// dataptr = data;
|
||||
// widget->adjustSize();
|
||||
}
|
||||
|
||||
void RuleNodeDataModel::setData(std::shared_ptr<RuleObject> data)
|
||||
{
|
||||
dataptr = data;
|
||||
widget->adjustSize();
|
||||
}
|
||||
|
||||
void RuleNodeDataModel::inputConnectionCreated(const QtNodes::Connection &c)
|
||||
void RuleNodeModel::inputConnectionCreated(const QtNodes::Connection &c)
|
||||
{
|
||||
}
|
||||
|
||||
void RuleNodeDataModel::inputConnectionDeleted(const QtNodes::Connection &c)
|
||||
void RuleNodeModel::inputConnectionDeleted(const QtNodes::Connection &c)
|
||||
{
|
||||
}
|
||||
|
||||
void RuleNodeDataModel::outputConnectionCreated(const QtNodes::Connection &c)
|
||||
void RuleNodeModel::outputConnectionCreated(const QtNodes::Connection &c)
|
||||
{
|
||||
}
|
||||
|
||||
void RuleNodeDataModel::outputConnectionDeleted(const QtNodes::Connection &c)
|
||||
void RuleNodeModel::outputConnectionDeleted(const QtNodes::Connection &c)
|
||||
{
|
||||
}
|
||||
|
||||
void RuleNodeModel::setInData(std::vector<std::shared_ptr<NodeData>> nodeData, PortIndex port)
|
||||
{
|
||||
}
|
||||
|
@ -13,9 +13,6 @@ class InboundWidget
|
||||
explicit InboundWidget(QWidget *parent = nullptr);
|
||||
void setValue(std::shared_ptr<INBOUND> data);
|
||||
|
||||
signals:
|
||||
void OnSizeUpdated() override;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
};
|
||||
|
@ -2,13 +2,18 @@
|
||||
|
||||
#include "base/Qv2rayBase.hpp"
|
||||
|
||||
OutboundBalancerWidget::OutboundBalancerWidget(QWidget *parent) : QWidget(parent)
|
||||
OutboundBalancerWidget::OutboundBalancerWidget(QWidget *parent) : QvNodeWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
balancerAddBtn->setIcon(QICON_R("add.png"));
|
||||
balancerDelBtn->setIcon(QICON_R("delete.png"));
|
||||
}
|
||||
|
||||
void OutboundBalancerWidget::setValue(std::shared_ptr<OutboundObjectMeta> data)
|
||||
{
|
||||
outboundData = data;
|
||||
}
|
||||
|
||||
void OutboundBalancerWidget::changeEvent(QEvent *e)
|
||||
{
|
||||
QWidget::changeEvent(e);
|
||||
@ -28,13 +33,13 @@ void OutboundBalancerWidget::on_balancerAddBtn_clicked()
|
||||
targetList.append(balancerSelectionCombo->currentText());
|
||||
balancerList->addItem(balancerTx);
|
||||
balancerSelectionCombo->setEditText("");
|
||||
// statusLabel->setText(tr("OK"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// statusLabel->setText(tr("Balancer is empty, not processing."));
|
||||
}
|
||||
}
|
||||
|
||||
void OutboundBalancerWidget::on_balancerDelBtn_clicked()
|
||||
{
|
||||
if (balancerList->currentRow() < 0)
|
||||
|
@ -1,20 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui/node/NodeBase.hpp"
|
||||
#include "ui_OutboundBalancerWidget.h"
|
||||
|
||||
class OutboundBalancerWidget
|
||||
: public QWidget
|
||||
: public QvNodeWidget
|
||||
, private Ui::OutboundBalancerWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OutboundBalancerWidget(QWidget *parent = nullptr);
|
||||
void setValue(std::shared_ptr<OutboundObjectMeta> data);
|
||||
private slots:
|
||||
void on_balancerAddBtn_clicked();
|
||||
|
||||
void on_balancerDelBtn_clicked();
|
||||
|
||||
signals:
|
||||
void OnSizeUpdated();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
std::shared_ptr<OutboundObjectMeta> outboundData;
|
||||
QStringList targetList;
|
||||
};
|
||||
|
@ -2,11 +2,15 @@
|
||||
|
||||
#include "base/Qv2rayBase.hpp"
|
||||
|
||||
OutboundChainWidget::OutboundChainWidget(QWidget *parent) : QWidget(parent)
|
||||
OutboundChainWidget::OutboundChainWidget(QWidget *parent) : QvNodeWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
void OutboundChainWidget::setValue(std::shared_ptr<OutboundObjectMeta> data)
|
||||
{
|
||||
}
|
||||
|
||||
void OutboundChainWidget::changeEvent(QEvent *e)
|
||||
{
|
||||
QWidget::changeEvent(e);
|
||||
|
@ -1,16 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui/node/models/RuleNodeModel.hpp"
|
||||
#include "ui/node/NodeBase.hpp"
|
||||
#include "ui_OutboundChainWidget.h"
|
||||
|
||||
class OutboundChainWidget
|
||||
: public QWidget
|
||||
: public QvNodeWidget
|
||||
, private Ui::OutboundChainWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OutboundChainWidget(QWidget *parent = nullptr);
|
||||
void setValue(std::shared_ptr<OutboundObjectMeta> data);
|
||||
|
||||
signals:
|
||||
void OnSizeUpdated();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
@ -1,18 +1,56 @@
|
||||
#include "OutboundWidget.hpp"
|
||||
|
||||
#include "base/Qv2rayBase.hpp"
|
||||
#include "core/CoreUtils.hpp"
|
||||
#include "ui/editors/w_JsonEditor.hpp"
|
||||
#include "ui/editors/w_OutboundEditor.hpp"
|
||||
|
||||
OutboundWidget::OutboundWidget(QWidget *parent) : QWidget(parent)
|
||||
OutboundWidget::OutboundWidget(QWidget *parent) : QvNodeWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
void OutboundWidget::setValue(std::shared_ptr<OutboundObjectMeta> data)
|
||||
{
|
||||
outboundObject = data;
|
||||
tagTxt->setText(getTag(outboundObject->realOutbound));
|
||||
}
|
||||
|
||||
void OutboundWidget::changeEvent(QEvent *e)
|
||||
{
|
||||
QWidget::changeEvent(e);
|
||||
switch (e->type())
|
||||
{
|
||||
case QEvent::LanguageChange: retranslateUi(this); break;
|
||||
case QEvent::LanguageChange:
|
||||
{
|
||||
retranslateUi(this);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void OutboundWidget::on_editBtn_clicked()
|
||||
{
|
||||
OutboundEditor editor{ outboundObject->realOutbound, parentWidget() };
|
||||
outboundObject->realOutbound = editor.OpenEditor();
|
||||
// Set tag
|
||||
const auto newTag = getTag(outboundObject->realOutbound);
|
||||
tagTxt->setText(newTag);
|
||||
outboundObject->realOutbound["tag"] = newTag;
|
||||
}
|
||||
|
||||
void OutboundWidget::on_editJsonBtn_clicked()
|
||||
{
|
||||
JsonEditor editor{ outboundObject->realOutbound, parentWidget() };
|
||||
outboundObject->realOutbound = OUTBOUND{ editor.OpenEditor() };
|
||||
const auto newTag = getTag(outboundObject->realOutbound);
|
||||
// Set tag
|
||||
tagTxt->setText(newTag);
|
||||
outboundObject->realOutbound["tag"] = newTag;
|
||||
}
|
||||
|
||||
void OutboundWidget::on_tagTxt_textEdited(const QString &arg1)
|
||||
{
|
||||
outboundObject->realOutbound["tag"] = arg1;
|
||||
}
|
||||
|
@ -1,17 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui/common/UIBase.hpp"
|
||||
#include "ui/node/NodeBase.hpp"
|
||||
#include "ui_OutboundWidget.h"
|
||||
|
||||
class OutboundWidget
|
||||
: public QWidget
|
||||
: public QvNodeWidget
|
||||
, private Ui::OutboundWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OutboundWidget(QWidget *parent = nullptr);
|
||||
void setValue(std::shared_ptr<OutboundObjectMeta> data);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
QStringList targetList;
|
||||
void changeEvent(QEvent *e) override;
|
||||
|
||||
private slots:
|
||||
void on_editBtn_clicked();
|
||||
void on_editJsonBtn_clicked();
|
||||
void on_tagTxt_textEdited(const QString &arg1);
|
||||
|
||||
private:
|
||||
std::shared_ptr<OutboundObjectMeta> outboundObject;
|
||||
};
|
||||
|
@ -27,10 +27,10 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
<widget class="QLineEdit" name="tagTxt"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<widget class="QPushButton" name="editBtn">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@ -41,7 +41,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<widget class="QPushButton" name="editJsonBtn">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -13,6 +13,8 @@
|
||||
QvNodeRuleWidget::QvNodeRuleWidget(QWidget *parent) : QvNodeWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
settingsFrame->setVisible(false);
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void QvNodeRuleWidget::changeEvent(QEvent *e)
|
||||
@ -20,15 +22,17 @@ void QvNodeRuleWidget::changeEvent(QEvent *e)
|
||||
QWidget::changeEvent(e);
|
||||
switch (e->type())
|
||||
{
|
||||
case QEvent::LanguageChange: retranslateUi(this); break;
|
||||
case QEvent::LanguageChange:
|
||||
{
|
||||
retranslateUi(this);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void QvNodeRuleWidget::setValue(std::shared_ptr<RuleObject> _ruleptr)
|
||||
{
|
||||
LOADINGCHECK
|
||||
|
||||
this->ruleptr = _ruleptr;
|
||||
|
||||
// Switch to the detailed page.
|
||||
@ -58,7 +62,6 @@ void QvNodeRuleWidget::setValue(std::shared_ptr<RuleObject> _ruleptr)
|
||||
isLoading = false;
|
||||
// Networks
|
||||
auto network = rule.network.toLower();
|
||||
bool isBoth = (network.contains("tcp") && network.contains("udp")) || network.isEmpty();
|
||||
netUDPRB->setChecked(network.contains("udp"));
|
||||
netTCPRB->setChecked(network.contains("tcp"));
|
||||
//
|
||||
@ -72,10 +75,10 @@ void QvNodeRuleWidget::setValue(std::shared_ptr<RuleObject> _ruleptr)
|
||||
routePortTxt->setText(rule.port);
|
||||
//
|
||||
// Users
|
||||
QString users = rule.user.join(NEWLINE);
|
||||
const auto users = rule.user.join(NEWLINE);
|
||||
//
|
||||
// Incoming Sources
|
||||
QString sources = rule.source.join(NEWLINE);
|
||||
const auto sources = rule.source.join(NEWLINE);
|
||||
sourceIPList->setPlainText(sources);
|
||||
//
|
||||
// Domains
|
||||
|
@ -13,9 +13,11 @@ class QvNodeRuleWidget
|
||||
public:
|
||||
explicit QvNodeRuleWidget(QWidget *parent = nullptr);
|
||||
void setValue(std::shared_ptr<RuleObject>);
|
||||
|
||||
signals:
|
||||
void OnSizeUpdated() override;
|
||||
inline void SetDetailsVisibilityState(bool state)
|
||||
{
|
||||
settingsFrame->setVisible(state);
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
private slots:
|
||||
void on_toolButton_clicked();
|
||||
@ -34,7 +36,7 @@ class QvNodeRuleWidget
|
||||
void on_ruleEnableCB_stateChanged(int arg1);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
void changeEvent(QEvent *e) override;
|
||||
std::shared_ptr<RuleObject> ruleptr;
|
||||
bool isLoading;
|
||||
|
||||
|
@ -6,13 +6,13 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>330</width>
|
||||
<height>400</height>
|
||||
<width>268</width>
|
||||
<height>350</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>330</width>
|
||||
<width>350</width>
|
||||
<height>400</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -47,9 +47,9 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<widget class="QPushButton" name="toolButton">
|
||||
<property name="text">
|
||||
<string>Show / Hide</string>
|
||||
<string>Details</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -75,7 +75,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<layout class="QGridLayout" name="gridLayout" rowstretch="0,1,0,0">
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
|
Loading…
Reference in New Issue
Block a user