mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 02:40:20 +08:00
add: added ChainWidget impl
This commit is contained in:
parent
51da85cfe1
commit
f666b479c9
@ -1 +1 @@
|
||||
5829
|
||||
5830
|
||||
|
@ -63,7 +63,7 @@ void RouteEditor::SetupNodeWidget()
|
||||
"PointDiameter": 10.0,"UseDataDefinedColors": false}})");
|
||||
}
|
||||
{
|
||||
ruleWidget = new RoutingEditorWidget(this);
|
||||
ruleWidget = new RoutingEditorWidget(ruleEditorUIWidget);
|
||||
if (!ruleEditorUIWidget->layout())
|
||||
{
|
||||
// The QWidget will take ownership of layout.
|
||||
@ -75,7 +75,7 @@ void RouteEditor::SetupNodeWidget()
|
||||
l->setSpacing(0);
|
||||
}
|
||||
{
|
||||
chainWidget = new ChainEditorWidget(this);
|
||||
chainWidget = new ChainEditorWidget(chainEditorUIWidget);
|
||||
if (!chainEditorUIWidget->layout())
|
||||
{
|
||||
// The QWidget will take ownership of layout.
|
||||
@ -98,7 +98,7 @@ RouteEditor::RouteEditor(QJsonObject connection, QWidget *parent) : QvDialog(par
|
||||
SetupNodeWidget();
|
||||
updateColorScheme();
|
||||
//
|
||||
nodeDispatcher = std::make_shared<NodeDispatcher>(ruleWidget->scene());
|
||||
nodeDispatcher = std::make_shared<NodeDispatcher>(ruleWidget->getScene());
|
||||
connect(nodeDispatcher.get(), &NodeDispatcher::OnInboundCreated, this, &RouteEditor::OnDispatcherInboundCreated);
|
||||
connect(nodeDispatcher.get(), &NodeDispatcher::OnOutboundCreated, this, &RouteEditor::OnDispatcherOutboundCreated);
|
||||
connect(nodeDispatcher.get(), &NodeDispatcher::OnRuleCreated, this, &RouteEditor::OnDispatcherRuleCreated);
|
||||
@ -151,7 +151,7 @@ void RouteEditor::OnDispatcherInboundOutboundHovered(const QString &tag, const P
|
||||
void RouteEditor::OnDispatcherInboundCreated(std::shared_ptr<INBOUND>, QtNodes::Node &node)
|
||||
{
|
||||
QPoint pos{ 0 + GRAPH_GLOBAL_OFFSET_X, nodeDispatcher->InboundsCount() * 130 + GRAPH_GLOBAL_OFFSET_Y };
|
||||
ruleWidget->scene()->setNodePosition(node, pos);
|
||||
ruleWidget->getScene()->setNodePosition(node, pos);
|
||||
}
|
||||
|
||||
void RouteEditor::OnDispatcherOutboundCreated(std::shared_ptr<OutboundObjectMeta> out, QtNodes::Node &node)
|
||||
@ -159,7 +159,7 @@ void RouteEditor::OnDispatcherOutboundCreated(std::shared_ptr<OutboundObjectMeta
|
||||
auto pos = ruleWidget->pos();
|
||||
pos.setX(pos.x() + 850 + GRAPH_GLOBAL_OFFSET_X);
|
||||
pos.setY(pos.y() + nodeDispatcher->OutboundsCount() * 120 + GRAPH_GLOBAL_OFFSET_Y);
|
||||
ruleWidget->scene()->setNodePosition(node, pos);
|
||||
ruleWidget->getScene()->setNodePosition(node, pos);
|
||||
defaultOutboundCombo->addItem(out->getTag());
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ void RouteEditor::OnDispatcherRuleCreated(std::shared_ptr<RuleObject> rule, QtNo
|
||||
auto pos = ruleWidget->pos();
|
||||
pos.setX(pos.x() + 350 + GRAPH_GLOBAL_OFFSET_X);
|
||||
pos.setY(pos.y() + nodeDispatcher->RulesCount() * 120 + GRAPH_GLOBAL_OFFSET_Y);
|
||||
ruleWidget->scene()->setNodePosition(node, pos);
|
||||
ruleWidget->getScene()->setNodePosition(node, pos);
|
||||
ruleListWidget->addItem(rule->QV2RAY_RULE_TAG);
|
||||
}
|
||||
|
||||
@ -413,19 +413,19 @@ void RouteEditor::on_addOutboundBtn_clicked()
|
||||
|
||||
void RouteEditor::on_delBtn_clicked()
|
||||
{
|
||||
if (ruleWidget->scene()->selectedNodes().empty())
|
||||
if (ruleWidget->getScene()->selectedNodes().empty())
|
||||
{
|
||||
QvMessageBoxWarn(this, tr("Remove Items"), tr("Please select a node from the graph to continue."));
|
||||
return;
|
||||
}
|
||||
|
||||
const auto selecteNodes = ruleWidget->scene()->selectedNodes();
|
||||
const auto selecteNodes = ruleWidget->getScene()->selectedNodes();
|
||||
if (selecteNodes.empty())
|
||||
{
|
||||
QvMessageBoxWarn(this, tr("Deleting a node"), tr("You need to select a node first"));
|
||||
return;
|
||||
}
|
||||
ruleWidget->scene()->removeNode(*selecteNodes.front());
|
||||
ruleWidget->getScene()->removeNode(*selecteNodes.front());
|
||||
}
|
||||
|
||||
void RouteEditor::on_addRouteBtn_clicked()
|
||||
|
@ -1,9 +1,30 @@
|
||||
#include "ChainEditorWidget.hpp"
|
||||
|
||||
ChainEditorWidget::ChainEditorWidget(QWidget *parent) : QtNodes::FlowView(parent)
|
||||
ChainEditorWidget::ChainEditorWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
setScene(new QtNodes::FlowScene(this));
|
||||
QvMessageBusConnect(ChainEditorWidget);
|
||||
scene = new QtNodes::FlowScene(this);
|
||||
view = new QtNodes::FlowView(scene, this);
|
||||
if (!viewWidget->layout())
|
||||
{
|
||||
// The QWidget will take ownership of layout.
|
||||
viewWidget->setLayout(new QVBoxLayout());
|
||||
}
|
||||
auto l = viewWidget->layout();
|
||||
l->addWidget(view);
|
||||
l->setContentsMargins(0, 0, 0, 0);
|
||||
l->setSpacing(0);
|
||||
}
|
||||
|
||||
QvMessageBusSlotImpl(ChainEditorWidget)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
MBRetranslateDefaultImpl;
|
||||
MBUpdateColorSchemeDefaultImpl;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void ChainEditorWidget::changeEvent(QEvent *e)
|
||||
|
@ -1,23 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui/messaging/QvMessageBus.hpp"
|
||||
#include "ui/node/NodeBase.hpp"
|
||||
#include "ui_ChainEditorWidget.h"
|
||||
|
||||
#include <nodes/FlowScene>
|
||||
#include <nodes/FlowView>
|
||||
|
||||
class ChainEditorWidget
|
||||
: public QtNodes::FlowView
|
||||
: public QWidget
|
||||
, private Ui::ChainEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ChainEditorWidget(QWidget *parent = nullptr);
|
||||
auto scene()
|
||||
auto getScene()
|
||||
{
|
||||
return QtNodes::FlowView::scene();
|
||||
return scene;
|
||||
}
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private:
|
||||
void updateColorScheme(){};
|
||||
QvMessageBusSlotDecl;
|
||||
|
||||
private:
|
||||
QtNodes::FlowScene *scene;
|
||||
QtNodes::FlowView *view;
|
||||
};
|
||||
|
@ -1,21 +1,104 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<author/>
|
||||
<comment/>
|
||||
<exportmacro/>
|
||||
<class>ChainEditorWidget</class>
|
||||
<widget class="QWidget" name="ChainEditorWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>984</width>
|
||||
<height>594</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Chains</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="chainList"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../resources.new.qrc">
|
||||
<normaloff>:/assets/icons/ui_light/add.svg</normaloff>:/assets/icons/ui_light/add.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_2">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../resources.new.qrc">
|
||||
<normaloff>:/assets/icons/ui_light/minus.svg</normaloff>:/assets/icons/ui_light/minus.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="viewWidget" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<pixmapfunction/>
|
||||
<resources>
|
||||
<include location="../../../../resources.new.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -3,11 +3,22 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <nodes/FlowScene>
|
||||
|
||||
RoutingEditorWidget::RoutingEditorWidget(QWidget *parent) : QtNodes::FlowView(parent)
|
||||
RoutingEditorWidget::RoutingEditorWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
setScene(new QtNodes::FlowScene(this));
|
||||
scaleDown();
|
||||
scene = new QtNodes::FlowScene(this);
|
||||
view = new QtNodes::FlowView(scene, this);
|
||||
view->scaleDown();
|
||||
|
||||
if (!viewWidget->layout())
|
||||
{
|
||||
// The QWidget will take ownership of layout.
|
||||
viewWidget->setLayout(new QVBoxLayout());
|
||||
}
|
||||
auto l = viewWidget->layout();
|
||||
l->addWidget(view);
|
||||
l->setContentsMargins(0, 0, 0, 0);
|
||||
l->setSpacing(0);
|
||||
}
|
||||
|
||||
void RoutingEditorWidget::changeEvent(QEvent *e)
|
||||
|
@ -1,22 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include "base/Qv2rayBase.hpp"
|
||||
#include "ui/common/UIBase.hpp"
|
||||
#include "ui_RoutingEditorWidget.h"
|
||||
|
||||
#include <nodes/FlowScene>
|
||||
#include <nodes/FlowView>
|
||||
|
||||
class RoutingEditorWidget
|
||||
: public QtNodes::FlowView
|
||||
: public QWidget
|
||||
, private Ui::RoutingEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RoutingEditorWidget(QWidget *parent = nullptr);
|
||||
auto scene()
|
||||
auto getScene()
|
||||
{
|
||||
return QtNodes::FlowView::scene();
|
||||
return scene;
|
||||
}
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private:
|
||||
void updateColorScheme(){};
|
||||
|
||||
private:
|
||||
QtNodes::FlowScene *scene;
|
||||
QtNodes::FlowView *view;
|
||||
};
|
||||
|
@ -1,21 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<author/>
|
||||
<comment/>
|
||||
<exportmacro/>
|
||||
<class>RoutingEditorWidget</class>
|
||||
<widget class="QWidget" name="RoutingEditorWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>926</width>
|
||||
<height>594</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="1">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="viewWidget" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<pixmapfunction/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
Reference in New Issue
Block a user