update: fixed build (by removing all codes?)

This commit is contained in:
QwQ 2020-07-16 22:31:32 +08:00
parent b907167138
commit b9e2b38965
No known key found for this signature in database
GPG Key ID: E7FAEFAFCD031D4B
20 changed files with 344 additions and 328 deletions

View File

@ -48,12 +48,12 @@ set(QV2RAY_UI_SOURCES
${CMAKE_SOURCE_DIR}/src/ui/widgets/node/RuleWidget.cpp ${CMAKE_SOURCE_DIR}/src/ui/widgets/node/RuleWidget.cpp
${CMAKE_SOURCE_DIR}/src/ui/widgets/node/RuleWidget.hpp ${CMAKE_SOURCE_DIR}/src/ui/widgets/node/RuleWidget.hpp
${CMAKE_SOURCE_DIR}/src/ui/widgets/node/RuleWidget.ui ${CMAKE_SOURCE_DIR}/src/ui/widgets/node/RuleWidget.ui
${CMAKE_SOURCE_DIR}/src/ui/widgets/node/InboundOutboundWidget.cpp ${CMAKE_SOURCE_DIR}/src/ui/widgets/node/InboundWidget.cpp
${CMAKE_SOURCE_DIR}/src/ui/widgets/node/InboundOutboundWidget.hpp ${CMAKE_SOURCE_DIR}/src/ui/widgets/node/InboundWidget.hpp
${CMAKE_SOURCE_DIR}/src/ui/widgets/node/InboundOutboundWidget.ui ${CMAKE_SOURCE_DIR}/src/ui/widgets/node/InboundWidget.ui
${CMAKE_SOURCE_DIR}/src/ui/widgets/node/OutboundBalancerWidget.cpp ${CMAKE_SOURCE_DIR}/src/ui/widgets/node/OutboundWidget.cpp
${CMAKE_SOURCE_DIR}/src/ui/widgets/node/OutboundBalancerWidget.hpp ${CMAKE_SOURCE_DIR}/src/ui/widgets/node/OutboundWidget.hpp
${CMAKE_SOURCE_DIR}/src/ui/widgets/node/OutboundBalancerWidget.ui ${CMAKE_SOURCE_DIR}/src/ui/widgets/node/OutboundWidget.ui
# Style Manager # Style Manager
${CMAKE_SOURCE_DIR}/src/ui/styles/StyleManager.cpp ${CMAKE_SOURCE_DIR}/src/ui/styles/StyleManager.cpp
${CMAKE_SOURCE_DIR}/src/ui/styles/StyleManager.hpp ${CMAKE_SOURCE_DIR}/src/ui/styles/StyleManager.hpp

View File

@ -1 +1 @@
5793 5794

View File

@ -405,8 +405,7 @@ namespace Qv2ray::base::objects
bool ota; bool ota;
int level; int level;
int port; int port;
ShadowSocksServerObject() ShadowSocksServerObject() : email(""), address("0.0.0.0"), method("aes-256-cfb"), password(""), ota(false), level(0), port(0){};
: email(""), address("0.0.0.0"), method("aes-256-cfb"), password(""), ota(false), level(0), port(0){};
JSONSTRUCT_REGISTER(ShadowSocksServerObject, F(email, address, port, method, password, ota, level)) JSONSTRUCT_REGISTER(ShadowSocksServerObject, F(email, address, port, method, password, ota, level))
}; };
} // namespace protocol } // namespace protocol

View File

@ -17,6 +17,21 @@ namespace Qv2ray::base::objects::complex
OutboundObjectMode mode; OutboundObjectMode mode;
ConnectionId connectionId; ConnectionId connectionId;
QJsonObject json; QJsonObject json;
JSONSTRUCT_REGISTER(OutboundObject, F(tag, mode, connectionId, json))
};
enum MetaOutboundObjectType
{
METAOUTBOUND_ORIGINAL,
METAOUTBOUND_BALANCER,
METAOUTBOUND_CHAINED
};
struct OutboundObjectMeta
{
MetaOutboundObjectType metaType;
OutboundObject object;
JSONSTRUCT_REGISTER(OutboundObjectMeta, F(metaType, object))
}; };
class __ChainID; class __ChainID;
@ -25,5 +40,4 @@ namespace Qv2ray::base::objects::complex
typedef IDType<__BalancerID> BalancerID; typedef IDType<__BalancerID> BalancerID;
typedef QList<OutboundObject> ChainObject; typedef QList<OutboundObject> ChainObject;
typedef BalancerObject BalancerObject; typedef BalancerObject BalancerObject;
} // namespace Qv2ray::base::objects::complex } // namespace Qv2ray::base::objects::complex

View File

@ -199,12 +199,12 @@ namespace Qv2ray::base
} }
QJsonValue toJson() const QJsonValue toJson() const
{ {
return JsonStructHelper::___json_struct_store_data(entries); return JsonStructHelper::Serialize(entries);
} }
void loadJson(const QJsonValue &d) void loadJson(const QJsonValue &d)
{ {
entries.clear(); entries.clear();
JsonStructHelper::___json_struct_load_data(entries, d); JsonStructHelper::Deserialize(entries, d);
} }
void Clear() void Clear()
{ {

View File

@ -47,11 +47,12 @@ namespace Qv2ray::base::safetype
template<typename enumKey, typename TValue, typename = typename std::enable_if<std::is_enum<enumKey>::value>::type> template<typename enumKey, typename TValue, typename = typename std::enable_if<std::is_enum<enumKey>::value>::type>
struct QvEnumMap : QMap<enumKey, TValue> struct QvEnumMap : QMap<enumKey, TValue>
{ {
// WARN: Changing this will bread all existing JSON.
static constexpr auto ENUM_JSON_KEY_PREFIX = "$"; static constexpr auto ENUM_JSON_KEY_PREFIX = "$";
void loadJson(const QJsonValue &json_object) void loadJson(const QJsonValue &json_object)
{ {
QMap<QString, TValue> data; QMap<QString, TValue> data;
JsonStructHelper::___json_struct_load_data(data, json_object); JsonStructHelper::Deserialize(data, json_object);
this->clear(); this->clear();
for (QString k_str : data.keys()) for (QString k_str : data.keys())
{ {
@ -72,7 +73,7 @@ namespace Qv2ray::base::safetype
{ {
data[ENUM_JSON_KEY_PREFIX + QString::number(k)] = this->value(k); data[ENUM_JSON_KEY_PREFIX + QString::number(k)] = this->value(k);
} }
return JsonStructHelper::___json_struct_store_data(data).toObject(); return JsonStructHelper::Serialize(data).toObject();
} }
}; };

View File

@ -87,45 +87,45 @@ RouteEditor::RouteEditor(QJsonObject connection, QWidget *parent) : QvDialog(par
// //
updateColorScheme(); updateColorScheme();
// //
domainStrategy = root["routing"].toObject()["domainStrategy"].toString(); // domainStrategy = root["routing"].toObject()["domainStrategy"].toString();
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())); // AddOutbound(OUTBOUND(out.toObject()));
} //}
//
for (const auto &item : root["routing"].toObject()["rules"].toArray()) // for (const auto &item : root["routing"].toObject()["rules"].toArray())
{ //{
AddRule(RuleObject::fromJson(item.toObject())); // 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);
//
// // Find and add balancers. //// // Find and add balancers.
// for (auto _balancer : root["routing"].toObject()["balancers"].toArray()) //// for (auto _balancer : root["routing"].toObject()["balancers"].toArray())
// { //// {
// auto _balancerObject = _balancer.toObject(); //// auto _balancerObject = _balancer.toObject();
// if (!_balancerObject["tag"].toString().isEmpty()) //// if (!_balancerObject["tag"].toString().isEmpty())
// { //// {
// balancers.insert(_balancerObject["tag"].toString(), _balancerObject["selector"].toVariant().toStringList()); //// balancers.insert(_balancerObject["tag"].toString(), _balancerObject["selector"].toVariant().toStringList());
// } //// }
// } //// }
//
for (const auto &group : ConnectionManager->AllGroups()) for (const auto &group : ConnectionManager->AllGroups())
{ {
importGroupBtn->addItem(GetDisplayName(group), group.toString()); importGroupBtn->addItem(GetDisplayName(group), group.toString());
} }
//
isLoading = false; // isLoading = false;
} }
QvMessageBusSlotImpl(RouteEditor) QvMessageBusSlotImpl(RouteEditor)
@ -141,52 +141,52 @@ QvMessageBusSlotImpl(RouteEditor)
void RouteEditor::onNodeClicked(Node &n) void RouteEditor::onNodeClicked(Node &n)
{ {
LOADINGCHECK // LOADINGCHECK
//
if (isExiting) // if (isExiting)
return; // return;
//
auto isOut = outboundNodes.values().contains(n.id()); // auto isOut = outboundNodes.values().contains(n.id());
auto isIn = inboundNodes.values().contains(n.id()); // auto isIn = inboundNodes.values().contains(n.id());
auto isRule = ruleNodes.values().contains(n.id()); // auto isRule = ruleNodes.values().contains(n.id());
//
/* if (isRule) // /* if (isRule)
{ // {
// It's a rule object // // It's a rule object
currentRuleTag = GetFirstNodeData(n.id(), RuleNode)->GetRuleTag(); // currentRuleTag = GetFirstNodeData(n.id(), RuleNode)->GetRuleTag();
DEBUG(MODULE_GRAPH, "Selecting rule: " + currentRuleTag) // DEBUG(MODULE_GRAPH, "Selecting rule: " + currentRuleTag)
// ShowCurrentRuleDetail(); // // ShowCurrentRuleDetail();
toolBox->setCurrentIndex(1); // toolBox->setCurrentIndex(1);
} // }
else*/ // else*/
if (isOut || isIn) // if (isOut || isIn)
{ // {
// It's an inbound or an outbound. // // It's an inbound or an outbound.
QString tag; // QString tag;
QString host; // QString host;
int port; // int port;
QString protocol; // QString protocol;
//
if (isOut) // if (isOut)
{ // {
const auto root = GetFirstNodeData(n.id(), OutboundNode)->GetOutbound(); // const auto root = GetFirstNodeData(n.id(), OutboundNode)->GetOutbound();
GetOutboundInfo(*root, &host, &port, &protocol); // GetOutboundInfo(*root, &host, &port, &protocol);
} // }
else // else
{ // {
const auto root = GetFirstNodeData(n.id(), InboundNode)->GetInbound(); // const auto root = GetFirstNodeData(n.id(), InboundNode)->GetInbound();
GetInboundInfo(*root, &host, &port, &protocol); // GetInboundInfo(*root, &host, &port, &protocol);
} // }
//
tagLabel->setText(tag); // tagLabel->setText(tag);
protocolLabel->setText(protocol); // protocolLabel->setText(protocol);
portLabel->setText(QSTRN(port)); // portLabel->setText(QSTRN(port));
hostLabel->setText(host); // hostLabel->setText(host);
} // }
else // else
{ // {
LOG(MODULE_GRAPH, "Selected an unknown node, RARE.") // LOG(MODULE_GRAPH, "Selected an unknown node, RARE.")
} // }
} }
void RouteEditor::onConnectionCreated(QtNodes::Connection const &c) void RouteEditor::onConnectionCreated(QtNodes::Connection const &c)
@ -308,96 +308,96 @@ CONFIGROOT RouteEditor::OpenEditor()
on_addRouteBtn_clicked(); on_addRouteBtn_clicked();
} }
// If clicking OK // // If clicking OK
if (result == QDialog::Accepted) // if (result == QDialog::Accepted)
{ // {
QJsonArray rulesArray; // QJsonArray rulesArray;
QJsonArray _balancers; // QJsonArray _balancers;
//
//// Append rules by order
// for (auto i = 0; i < ruleListWidget->count(); i++)
//{
// auto _rule = rules[i];
// auto ruleJsonObject = _rule.toJson();
//
// // Process balancer for a rule
// if (_rule.QV2RAY_RULE_USE_BALANCER)
// {
// // Do not use outbound tag.
// ruleJsonObject.remove("outboundTag");
//
// // // Find balancer list
// // if (!balancers.contains(_rule.balancerTag))
// // {
// // LOG(MODULE_UI, "Cannot find a balancer for tag: " + _rule.balancerTag)
// // }
// // else
// // {
// // auto _balancerList = balancers[_rule.balancerTag];
// // QJsonObject balancerEntry;
// // balancerEntry["tag"] = _rule.balancerTag;
// // balancerEntry["selector"] = QJsonArray::fromStringList(_balancerList);
// // _balancers.append(balancerEntry);
// // }
// }
//
// // Remove some empty fields.
// if (_rule.port.isEmpty())
// {
// ruleJsonObject.remove("port");
// }
//
// if (_rule.network.isEmpty())
// {
// ruleJsonObject.remove("network");
// }
//
// rulesArray.append(ruleJsonObject);
//}
// Append rules by order // QJsonObject routing;
for (auto i = 0; i < ruleListWidget->count(); i++) // routing["domainStrategy"] = domainStrategy;
{ // routing["rules"] = rulesArray;
auto _rule = rules[i]; // routing["balancers"] = _balancers;
auto ruleJsonObject = _rule.toJson(); // //
// QJsonArray _inbounds;
// Process balancer for a rule // QJsonArray _outbounds;
if (_rule.QV2RAY_RULE_USE_BALANCER) //
{ // // Convert our internal data format to QJsonArray
// Do not use outbound tag. // for (auto x : inbounds)
ruleJsonObject.remove("outboundTag"); // {
// if (x.isEmpty())
// // Find balancer list // continue;
// if (!balancers.contains(_rule.balancerTag)) //
// { // _inbounds.append(x.raw());
// LOG(MODULE_UI, "Cannot find a balancer for tag: " + _rule.balancerTag) // }
// } //
// else // for (auto x : outbounds)
// { // {
// auto _balancerList = balancers[_rule.balancerTag]; // if (x.isEmpty())
// QJsonObject balancerEntry; // continue;
// balancerEntry["tag"] = _rule.balancerTag; //
// balancerEntry["selector"] = QJsonArray::fromStringList(_balancerList); // if (getTag(x) == defaultOutbound)
// _balancers.append(balancerEntry); // {
// } // LOG(MODULE_CONNECTION, "Pushing default outbound to the front.")
} // // Put the default outbound to the first.
// _outbounds.push_front(x.raw());
// Remove some empty fields. // }
if (_rule.port.isEmpty()) // else
{ // {
ruleJsonObject.remove("port"); // _outbounds.push_back(x.raw());
} // }
// }
if (_rule.network.isEmpty()) //
{ // root["inbounds"] = _inbounds;
ruleJsonObject.remove("network"); // root["outbounds"] = _outbounds;
} // root["routing"] = routing;
// return root;
rulesArray.append(ruleJsonObject); //}
} // else
//{
QJsonObject routing; return original;
routing["domainStrategy"] = domainStrategy; //}
routing["rules"] = rulesArray;
routing["balancers"] = _balancers;
//
QJsonArray _inbounds;
QJsonArray _outbounds;
// Convert our internal data format to QJsonArray
for (auto x : inbounds)
{
if (x.isEmpty())
continue;
_inbounds.append(x.raw());
}
for (auto x : outbounds)
{
if (x.isEmpty())
continue;
if (getTag(x) == defaultOutbound)
{
LOG(MODULE_CONNECTION, "Pushing default outbound to the front.")
// Put the default outbound to the first.
_outbounds.push_front(x.raw());
}
else
{
_outbounds.push_back(x.raw());
}
}
root["inbounds"] = _inbounds;
root["outbounds"] = _outbounds;
root["routing"] = routing;
return root;
}
else
{
return original;
}
} }
RouteEditor::~RouteEditor() RouteEditor::~RouteEditor()
@ -414,12 +414,12 @@ void RouteEditor::on_buttonBox_accepted()
void RouteEditor::on_insertDirectBtn_clicked() void RouteEditor::on_insertDirectBtn_clicked()
{ {
auto freedom = GenerateFreedomOUT("AsIs", "", 0); // auto freedom = GenerateFreedomOUT("AsIs", "", 0);
auto tag = "Freedom_" + QSTRN(QTime::currentTime().msecsSinceStartOfDay()); // auto tag = "Freedom_" + QSTRN(QTime::currentTime().msecsSinceStartOfDay());
auto out = GenerateOutboundEntry("freedom", freedom, QJsonObject(), QJsonObject(), "0.0.0.0", tag); // auto out = GenerateOutboundEntry("freedom", freedom, QJsonObject(), QJsonObject(), "0.0.0.0", tag);
// ADD NODE //// ADD NODE
AddOutbound(out); // AddOutbound(out);
statusLabel->setText(tr("Added DIRECT outbound")); // statusLabel->setText(tr("Added DIRECT outbound"));
} }
void RouteEditor::on_addDefaultBtn_clicked() void RouteEditor::on_addDefaultBtn_clicked()

View File

@ -11,108 +11,109 @@
void RouteEditor::AddInbound(INBOUND in) void RouteEditor::AddInbound(INBOUND in)
{ {
QString tag = getTag(in); // QString tag = getTag(in);
//
if (inboundNodes.contains(tag)) // if (inboundNodes.contains(tag))
tag.append("_" + GenerateRandomString(5)); // tag.append("_" + GenerateRandomString(5));
//
in["tag"] = tag; // in["tag"] = tag;
inbounds << in; // inbounds << in;
auto _nodeData = std::make_unique<QvInboundNodeModel>(std::make_shared<InboundNodeData>(std::make_shared<INBOUND>(inbounds.last()))); // auto _nodeData = std::make_unique<QvInboundNodeModel>(std::make_shared<InboundNodeData>(std::make_shared<INBOUND>(inbounds.last())));
auto &node = nodeScene->createNode(std::move(_nodeData)); // auto &node = nodeScene->createNode(std::move(_nodeData));
QPointF pos; // QPointF pos;
pos.setX(0 + GRAPH_GLOBAL_OFFSET_X); // pos.setX(0 + GRAPH_GLOBAL_OFFSET_X);
pos.setY(inboundNodes.count() * 130 + GRAPH_GLOBAL_OFFSET_Y); // pos.setY(inboundNodes.count() * 130 + GRAPH_GLOBAL_OFFSET_Y);
nodeScene->setNodePosition(node, pos); // nodeScene->setNodePosition(node, pos);
inboundNodes.insert(tag, node.id()); // inboundNodes.insert(tag, node.id());
} }
void RouteEditor::AddOutbound(OUTBOUND out) void RouteEditor::AddOutbound(OUTBOUND out)
{ {
QString tag = getTag(out); // QString tag = getTag(out);
//
if (outboundNodes.contains(tag)) // if (outboundNodes.contains(tag))
tag.append("_" + GenerateRandomString(5)); // tag.append("_" + GenerateRandomString(5));
//
out["tag"] = tag; // out["tag"] = tag;
outbounds << out; // outbounds << out;
auto _nodeData = std::make_unique<QvOutboundNodeModel>(std::make_shared<OutboundNodeData>(std::make_shared<OUTBOUND>(outbounds.last()))); // auto _nodeData = std::make_unique<QvOutboundNodeModel>(std::make_shared<OutboundNodeData>(std::make_shared<OUTBOUND>(outbounds.last())));
auto pos = nodeGraphWidget->pos(); // auto pos = nodeGraphWidget->pos();
pos.setX(pos.x() + 850 + GRAPH_GLOBAL_OFFSET_X); // pos.setX(pos.x() + 850 + GRAPH_GLOBAL_OFFSET_X);
pos.setY(pos.y() + outboundNodes.count() * 120 + GRAPH_GLOBAL_OFFSET_Y); // pos.setY(pos.y() + outboundNodes.count() * 120 + GRAPH_GLOBAL_OFFSET_Y);
auto &node = nodeScene->createNode(std::move(_nodeData)); // auto &node = nodeScene->createNode(std::move(_nodeData));
nodeScene->setNodePosition(node, pos); // nodeScene->setNodePosition(node, pos);
outboundNodes.insert(tag, node.id()); // outboundNodes.insert(tag, node.id());
defaultOutboundCombo->addItem(tag); // 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(RuleObject rule)
{ {
// Prevent duplicate //// Prevent duplicate
if (ruleNodes.contains(rule.QV2RAY_RULE_TAG)) // if (ruleNodes.contains(rule.QV2RAY_RULE_TAG))
{ //{
rule.QV2RAY_RULE_TAG += "-" + GenerateRandomString(5); // rule.QV2RAY_RULE_TAG += "-" + GenerateRandomString(5);
} //}
//
rules << rule; // rules << rule;
auto pos = nodeGraphWidget->pos(); // auto pos = nodeGraphWidget->pos();
pos.setX(pos.x() + 350 + GRAPH_GLOBAL_OFFSET_X); // pos.setX(pos.x() + 350 + GRAPH_GLOBAL_OFFSET_X);
pos.setY(pos.y() + ruleNodes.count() * 120 + GRAPH_GLOBAL_OFFSET_Y); // 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 _nodeData = std::make_unique<QvRuleNodeModel>(std::make_shared<RuleNodeData>(std::make_shared<RuleObject>(rules.last())));
auto &node = nodeScene->createNode(std::move(_nodeData)); // auto &node = nodeScene->createNode(std::move(_nodeData));
nodeScene->setNodePosition(node, pos); // nodeScene->setNodePosition(node, pos);
//
for (auto inTag : rule.inboundTag) // for (auto inTag : rule.inboundTag)
{ //{
if (!inboundNodes.contains(inTag)) // if (!inboundNodes.contains(inTag))
{ // {
LOG(MODULE_UI, "No inbound tag found for rule: " + rule.QV2RAY_RULE_TAG + ", inbound tag: " + 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); // QvMessageBoxWarn(this, tr("No Inbound"), tr("No inbound item found: ") + inTag);
rule.inboundTag.removeAll(inTag); // rule.inboundTag.removeAll(inTag);
} // }
else // else
{ // {
auto inboundNode = inboundNodes.value(inTag); // auto inboundNode = inboundNodes.value(inTag);
auto conn = nodeScene->createConnection(node, 0, *nodeScene->node(inboundNode), 0); // auto conn = nodeScene->createConnection(node, 0, *nodeScene->node(inboundNode), 0);
connect(conn.get(), &QtNodes::Connection::connectionCompleted, this, &RouteEditor::onConnectionCreated); // connect(conn.get(), &QtNodes::Connection::connectionCompleted, this, &RouteEditor::onConnectionCreated);
} // }
} //}
//
// If not using balancers (use outbound tag) //// If not using balancers (use outbound tag)
if (!rule.QV2RAY_RULE_USE_BALANCER) // if (!rule.QV2RAY_RULE_USE_BALANCER)
{ //{
if (outboundNodes.contains(rule.outboundTag)) // if (outboundNodes.contains(rule.outboundTag))
{ // {
DEBUG(MODULE_GRAPH, "Found outbound tag: " + rule.outboundTag + ", for rule: " + rule.QV2RAY_RULE_TAG) // 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); // auto conn = nodeScene->createConnection(*nodeScene->node(outboundNodes.value(rule.outboundTag)), 0, node, 0);
connect(conn.get(), &QtNodes::Connection::connectionCompleted, this, &RouteEditor::onConnectionCreated); // connect(conn.get(), &QtNodes::Connection::connectionCompleted, this, &RouteEditor::onConnectionCreated);
} // }
else // else
{ // {
LOG(MODULE_GRAPH, "Outbound tag not found: " + rule.outboundTag + ", for: " + rule.QV2RAY_RULE_TAG) // LOG(MODULE_GRAPH, "Outbound tag not found: " + rule.outboundTag + ", for: " + rule.QV2RAY_RULE_TAG)
// QvMessageBoxWarn(this, tr("No outbound tag"), tr("Please connect // // QvMessageBoxWarn(this, tr("No outbound tag"), tr("Please connect
// the rule with an outbound.")); // // the rule with an outbound."));
} // }
} //}
//
this->ruleNodes.insert(rule.QV2RAY_RULE_TAG, node.id()); // this->ruleNodes.insert(rule.QV2RAY_RULE_TAG, node.id());
ruleListWidget->addItem(rule.QV2RAY_RULE_TAG); // 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.

View File

@ -3,10 +3,10 @@
QvInboundNodeModel::QvInboundNodeModel(std::shared_ptr<InboundNodeData> data) : NodeDataModel() QvInboundNodeModel::QvInboundNodeModel(std::shared_ptr<InboundNodeData> data) : NodeDataModel()
{ {
_in = data; _in = data;
widget = new InboundOutboundWidget(); widget = new InboundWidget();
widget->setWindowFlags(Qt::FramelessWindowHint); widget->setWindowFlags(Qt::FramelessWindowHint);
widget->setAttribute(Qt::WA_TranslucentBackground); widget->setAttribute(Qt::WA_TranslucentBackground);
connect(widget, &InboundOutboundWidget::OnSizeUpdated, this, &QvInboundNodeModel::embeddedWidgetSizeUpdated); connect(widget, &InboundWidget::OnSizeUpdated, this, &QvInboundNodeModel::embeddedWidgetSizeUpdated);
} }
std::unique_ptr<NodeDataModel> QvInboundNodeModel::clone() const std::unique_ptr<NodeDataModel> QvInboundNodeModel::clone() const

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "NodeModelsBase.hpp" #include "NodeModelsBase.hpp"
#include "ui/widgets/node/InboundOutboundWidget.hpp" #include "ui/widgets/node/InboundWidget.hpp"
#include <QtCore/qglobal.h> #include <QtCore/qglobal.h>
@ -40,5 +40,5 @@ class QvInboundNodeModel : public NodeDataModel
QString modelValidationError = tr("Missing or incorrect inputs"); QString modelValidationError = tr("Missing or incorrect inputs");
// //
std::shared_ptr<InboundNodeData> _in; std::shared_ptr<InboundNodeData> _in;
InboundOutboundWidget *widget; InboundWidget *widget;
}; };

View File

@ -24,6 +24,7 @@ namespace Qv2ray::ui::nodemodels
{ {
const std::shared_ptr<NodeDataType> NODE_TYPE_OUTBOUND = std::make_shared<NodeDataType>("outbound", QObject::tr("Outbound")); const std::shared_ptr<NodeDataType> NODE_TYPE_OUTBOUND = std::make_shared<NodeDataType>("outbound", QObject::tr("Outbound"));
const std::shared_ptr<NodeDataType> NODE_TYPE_INBOUND = std::make_shared<NodeDataType>("inbound", QObject::tr("Inbound")); const std::shared_ptr<NodeDataType> NODE_TYPE_INBOUND = std::make_shared<NodeDataType>("inbound", QObject::tr("Inbound"));
const std::shared_ptr<NodeDataType> NODE_TYPE_RULE = std::make_shared<NodeDataType>("rule", QObject::tr("Rule"));
class InboundNodeData : public NodeData class InboundNodeData : public NodeData
{ {
@ -32,7 +33,7 @@ namespace Qv2ray::ui::nodemodels
std::shared_ptr<NodeDataType> type() const override std::shared_ptr<NodeDataType> type() const override
{ {
return NODE_TYPE_INBOUND; return NODE_TYPE_RULE;
} }
std::shared_ptr<INBOUND> GetInbound() std::shared_ptr<INBOUND> GetInbound()
@ -47,20 +48,20 @@ namespace Qv2ray::ui::nodemodels
class OutboundNodeData : public NodeData class OutboundNodeData : public NodeData
{ {
public: public:
explicit OutboundNodeData(std::shared_ptr<OUTBOUND> data) : outboundData(data){}; explicit OutboundNodeData(std::shared_ptr<complex::OutboundObjectMeta> data) : outboundData(data){};
std::shared_ptr<NodeDataType> type() const override std::shared_ptr<NodeDataType> type() const override
{ {
return NODE_TYPE_INBOUND; return NODE_TYPE_OUTBOUND;
} }
std::shared_ptr<OUTBOUND> GetOutbound() std::shared_ptr<complex::OutboundObjectMeta> GetOutbound()
{ {
return outboundData; return outboundData;
} }
private: private:
std::shared_ptr<OUTBOUND> outboundData; std::shared_ptr<complex::OutboundObjectMeta> outboundData;
}; };
class RuleNodeData : public NodeData class RuleNodeData : public NodeData

View File

@ -3,7 +3,7 @@
QvOutboundNodeModel::QvOutboundNodeModel(std::shared_ptr<OutboundNodeData> data) : NodeDataModel() QvOutboundNodeModel::QvOutboundNodeModel(std::shared_ptr<OutboundNodeData> data) : NodeDataModel()
{ {
_out = data; _out = data;
widget = new InboundOutboundWidget(); widget = new InboundWidget();
widget->setWindowFlags(Qt::FramelessWindowHint); widget->setWindowFlags(Qt::FramelessWindowHint);
widget->setAttribute(Qt::WA_TranslucentBackground); widget->setAttribute(Qt::WA_TranslucentBackground);
} }

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "ui/models/NodeModelsBase.hpp" #include "ui/models/NodeModelsBase.hpp"
#include "ui/widgets/node/InboundOutboundWidget.hpp" #include "ui/widgets/node/InboundWidget.hpp"
#include <QtCore/qglobal.h> #include <QtCore/qglobal.h>
@ -45,7 +45,7 @@ class QvOutboundNodeModel : public NodeDataModel
return _out; return _out;
} }
void setData(std::shared_ptr<OUTBOUND> data) void setData(std::shared_ptr<complex::OutboundObjectMeta> data)
{ {
_out = std::make_shared<OutboundNodeData>(data); _out = std::make_shared<OutboundNodeData>(data);
widget->adjustSize(); widget->adjustSize();
@ -70,5 +70,5 @@ class QvOutboundNodeModel : public NodeDataModel
QString modelValidationError = tr("Missing or incorrect inputs"); QString modelValidationError = tr("Missing or incorrect inputs");
// //
std::shared_ptr<OutboundNodeData> _out; std::shared_ptr<OutboundNodeData> _out;
InboundOutboundWidget *widget; InboundWidget *widget;
}; };

View File

@ -1,19 +0,0 @@
#pragma once
#include "ui_InboundOutboundWidget.h"
class InboundOutboundWidget
: public QWidget
, private Ui::InboundOutboundWidget
{
Q_OBJECT
public:
explicit InboundOutboundWidget(QWidget *parent = nullptr);
signals:
void OnSizeUpdated();
protected:
void changeEvent(QEvent *e);
};

View File

@ -1,11 +1,11 @@
#include "InboundOutboundWidget.hpp" #include "InboundWidget.hpp"
InboundOutboundWidget::InboundOutboundWidget(QWidget *parent) : QWidget(parent) InboundWidget::InboundWidget(QWidget *parent) : QWidget(parent)
{ {
setupUi(this); setupUi(this);
} }
void InboundOutboundWidget::changeEvent(QEvent *e) void InboundWidget::changeEvent(QEvent *e)
{ {
QWidget::changeEvent(e); QWidget::changeEvent(e);
switch (e->type()) switch (e->type())

View File

@ -0,0 +1,19 @@
#pragma once
#include "ui_InboundWidget.h"
class InboundWidget
: public QWidget
, private Ui::InboundWidget
{
Q_OBJECT
public:
explicit InboundWidget(QWidget *parent = nullptr);
signals:
void OnSizeUpdated();
protected:
void changeEvent(QEvent *e);
};

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>InboundOutboundWidget</class> <class>InboundWidget</class>
<widget class="QWidget" name="InboundOutboundWidget"> <widget class="QWidget" name="InboundWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>

View File

@ -1,15 +1,15 @@
#include "OutboundBalancerWidget.hpp" #include "OutboundWidget.hpp"
#include "base/Qv2rayBase.hpp" #include "base/Qv2rayBase.hpp"
OutboundBalancerWidget::OutboundBalancerWidget(QWidget *parent) : QWidget(parent) OutboundWidget::OutboundWidget(QWidget *parent) : QWidget(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::changeEvent(QEvent *e) void OutboundWidget::changeEvent(QEvent *e)
{ {
QWidget::changeEvent(e); QWidget::changeEvent(e);
switch (e->type()) switch (e->type())
@ -19,7 +19,7 @@ void OutboundBalancerWidget::changeEvent(QEvent *e)
} }
} }
void OutboundBalancerWidget::on_balancerAddBtn_clicked() void OutboundWidget::on_balancerAddBtn_clicked()
{ {
auto balancerTx = balancerSelectionCombo->currentText(); auto balancerTx = balancerSelectionCombo->currentText();
@ -35,7 +35,7 @@ void OutboundBalancerWidget::on_balancerAddBtn_clicked()
// statusLabel->setText(tr("Balancer is empty, not processing.")); // statusLabel->setText(tr("Balancer is empty, not processing."));
} }
} }
void OutboundBalancerWidget::on_balancerDelBtn_clicked() void OutboundWidget::on_balancerDelBtn_clicked()
{ {
if (balancerList->currentRow() < 0) if (balancerList->currentRow() < 0)
{ {

View File

@ -1,15 +1,15 @@
#pragma once #pragma once
#include "ui_OutboundBalancerWidget.h" #include "ui_OutboundWidget.h"
class OutboundBalancerWidget class OutboundWidget
: public QWidget : public QWidget
, private Ui::OutboundBalancerWidget , private Ui::OutboundWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit OutboundBalancerWidget(QWidget *parent = nullptr); explicit OutboundWidget(QWidget *parent = nullptr);
void on_balancerAddBtn_clicked(); void on_balancerAddBtn_clicked();
void on_balancerDelBtn_clicked(); void on_balancerDelBtn_clicked();

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>OutboundBalancerWidget</class> <class>OutboundWidget</class>
<widget class="QWidget" name="OutboundBalancerWidget"> <widget class="QWidget" name="OutboundWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>