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