mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-19 02:10:28 +08:00
wip: try to fix CI before continue -- stage 1
This commit is contained in:
parent
3c023ba022
commit
d42a3ca56a
@ -109,8 +109,8 @@ Qv2rayAddSource(ui, _, w_MainWindow_extra, cpp)
|
||||
Qv2rayAddSource(ui, _, w_PreferencesWindow, cpp, hpp, ui)
|
||||
Qv2rayAddSource(ui, _, w_ScreenShot_Core, cpp, hpp, ui)
|
||||
Qv2rayAddSource(ui, _, w_SubscriptionManager, cpp, hpp, ui)
|
||||
Qv2rayAddSource(ui, widgets, ConnectionWidget, cpp, hpp, ui)
|
||||
Qv2rayAddSource(ui, widgets, StreamSettingsWidget, cpp, hpp, ui)
|
||||
Qv2rayAddSource(ui, widgets, ConnectionItemWidget, cpp, hpp, ui)
|
||||
Qv2rayAddSource(ui, widgets, ConnectionInfoWidget, cpp, hpp, ui)
|
||||
|
||||
SOURCES += $$PWD/src/main.cpp
|
||||
|
@ -1 +1 @@
|
||||
3887
|
||||
3889
|
||||
|
@ -82,7 +82,7 @@ namespace Qv2ray::core::handlers
|
||||
}
|
||||
|
||||
|
||||
const QString QvConnectionHandler:: GetConnectionBasicInfo(const ConnectionId &id) const
|
||||
const QString QvConnectionHandler::GetConnectionBasicInfo(const ConnectionId &id) const
|
||||
{
|
||||
QString result;
|
||||
|
||||
@ -91,28 +91,19 @@ namespace Qv2ray::core::handlers
|
||||
}
|
||||
|
||||
CONFIGROOT root = CHGetConnectionRoot_p(connections[id].groupId, id);
|
||||
bool isTLSEnabled = false;
|
||||
|
||||
if (root.contains("inbounds") && !root["inbounds"].toArray().isEmpty()) {
|
||||
QString inProtocol = tr("Inbounds: ");
|
||||
|
||||
for (auto inbound : root["inbounds"].toArray()) {
|
||||
inProtocol.append(inbound.toObject()["protocol"].toString());
|
||||
inProtocol.append("/");
|
||||
}
|
||||
|
||||
inProtocol.chop(1);
|
||||
result.append(inProtocol);
|
||||
}
|
||||
|
||||
QStringList protocols;
|
||||
QStringList streamProtocols;
|
||||
auto outbound = root["outbounds"].toArray().first().toObject();
|
||||
result.append(outbound["protocol"].toString());
|
||||
|
||||
for (auto outbound : root["outbounds"].toArray()) {
|
||||
protocols.append(outbound.toObject()["protocol"].toString());
|
||||
if (outbound.contains("streamSettings")) {
|
||||
result.append(" + " + outbound["streamSettings"].toObject()["network"].toString());
|
||||
|
||||
if (outbound["streamSettings"].toObject().contains("tls")) {
|
||||
result.append(outbound["streamSettings"].toObject()["tls"].toBool() ? " + tls" : "");
|
||||
}
|
||||
}
|
||||
|
||||
result.chop(1);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -134,7 +125,7 @@ namespace Qv2ray::core::handlers
|
||||
|
||||
const CONFIGROOT QvConnectionHandler::CHGetConnectionRoot_p(const GroupId &group, const ConnectionId &id) const
|
||||
{
|
||||
auto path = QV2RAY_CONNECTIONS_DIR + group.toString() + "/" + id.toString() + QV2RAY_CONFIG_FILE_EXTENSION;
|
||||
auto path = group.toString() + "/" + id.toString() + QV2RAY_CONFIG_FILE_EXTENSION;
|
||||
path.prepend(groups[group].isSubscription ? QV2RAY_SUBSCRIPTION_DIR : QV2RAY_CONNECTIONS_DIR);
|
||||
return CONFIGROOT(JsonFromString(StringFromFile(path)));
|
||||
}
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
#define TRAY_TOOLTIP_PREFIX "Qv2ray " QV2RAY_VERSION_STRING
|
||||
//
|
||||
#define GetItemWidget(item) (static_cast<ConnectionWidget*>(connectionListWidget->itemWidget(item, 0)))
|
||||
#define GetItemWidget(item) (qobject_cast<ConnectionItemWidget*>(connectionListWidget->itemWidget(item, 0)))
|
||||
//
|
||||
//#define ItemConnectionIdentifier(__item__) (__item__->data(0, Qt::UserRole).value<ConnectionIdentifier>())
|
||||
//
|
||||
@ -324,20 +324,25 @@ void MainWindow::OnConfigListChanged(bool need_restart)
|
||||
auto groups = ConnectionHandler->AllGroups();
|
||||
|
||||
for (auto group : groups) {
|
||||
auto groupItem = new QTreeWidgetItem();
|
||||
auto groupItem = new QTreeWidgetItem(QStringList() << "" << ConnectionHandler->GetGroup(group).displayName);
|
||||
connectionListWidget->addTopLevelItem(groupItem);
|
||||
connectionListWidget->setItemWidget(groupItem, 0, new ConnectionWidget(group, connectionListWidget));
|
||||
connectionListWidget->setItemWidget(groupItem, 0, new ConnectionItemWidget(group, connectionListWidget));
|
||||
auto connections = ConnectionHandler->Connections(group);
|
||||
|
||||
for (auto connection : connections) {
|
||||
auto connectionItem = new QTreeWidgetItem();
|
||||
auto connectionItem = new QTreeWidgetItem(QStringList() << "" << ConnectionHandler->GetConnection(connection).displayName);
|
||||
groupItem->addChild(connectionItem);
|
||||
auto widget = new ConnectionWidget(connection, connectionListWidget);
|
||||
connect(widget, &ConnectionWidget::RequestWidgetFocus, this, &MainWindow::onConnectionWidgetFocusRequested);
|
||||
auto widget = new ConnectionItemWidget(connection, connectionListWidget);
|
||||
connect(widget, &ConnectionItemWidget::RequestWidgetFocus, this, &MainWindow::onConnectionWidgetFocusRequested);
|
||||
connectionListWidget->setItemWidget(connectionItem, 0, widget);
|
||||
}
|
||||
}
|
||||
|
||||
// Do not sort
|
||||
//connectionListWidget->sortItems(1, Qt::SortOrder::AscendingOrder);
|
||||
//
|
||||
// ================================================================
|
||||
//
|
||||
//auto wasRunning = vinstance->KernelStarted && need_restart;
|
||||
//
|
||||
//if (wasRunning) on_stopButton_clicked();
|
||||
@ -1011,7 +1016,7 @@ void MainWindow::OnConnected(const ConnectionId &id)
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::onConnectionWidgetFocusRequested(const ConnectionWidget *_widget)
|
||||
void MainWindow::onConnectionWidgetFocusRequested(const ConnectionItemWidget *_widget)
|
||||
{
|
||||
if (_widget == nullptr) {
|
||||
return;
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "ui/messaging/QvMessageBus.hpp"
|
||||
|
||||
// ==========================================================================================
|
||||
#include "ui/widgets/ConnectionWidget.hpp"
|
||||
#include "ui/widgets/ConnectionItemWidget.hpp"
|
||||
#include "ui/widgets/ConnectionInfoWidget.hpp"
|
||||
|
||||
class MainWindow : public QMainWindow, Ui::MainWindow
|
||||
@ -72,7 +72,7 @@ class MainWindow : public QMainWindow, Ui::MainWindow
|
||||
|
||||
private slots:
|
||||
//
|
||||
void onConnectionWidgetFocusRequested(const ConnectionWidget *widget);
|
||||
void onConnectionWidgetFocusRequested(const ConnectionItemWidget *widget);
|
||||
//
|
||||
void on_action_StartThis_triggered();
|
||||
void on_action_RCM_EditJson_triggered();
|
||||
|
@ -127,6 +127,9 @@
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
<property name="indentation">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -386,8 +389,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>459</width>
|
||||
<height>848</height>
|
||||
<width>480</width>
|
||||
<height>851</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
@ -553,7 +556,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>29</height>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
@ -1,32 +1,34 @@
|
||||
#include "ConnectionWidget.hpp"
|
||||
#include "ConnectionItemWidget.hpp"
|
||||
#include "common/QvHelpers.hpp"
|
||||
|
||||
ConnectionWidget::ConnectionWidget(QWidget *parent) : QWidget(parent), connectionId("null"), groupId("null")
|
||||
ConnectionItemWidget::ConnectionItemWidget(QWidget *parent) : QWidget(parent), connectionId("null"), groupId("null")
|
||||
{
|
||||
setupUi(this);
|
||||
connect(ConnectionHandler, &QvConnectionHandler::OnConnected, this, &ConnectionWidget::OnConnected);
|
||||
connect(ConnectionHandler, &QvConnectionHandler::OnConnected, this, &ConnectionItemWidget::OnConnected);
|
||||
}
|
||||
|
||||
ConnectionWidget::ConnectionWidget(const ConnectionId &identifier, QWidget *parent): ConnectionWidget(parent)
|
||||
ConnectionItemWidget::ConnectionItemWidget(const ConnectionId &identifier, QWidget *parent): ConnectionItemWidget(parent)
|
||||
{
|
||||
auto connection = ConnectionHandler->GetConnection(identifier);
|
||||
connectionId = identifier;
|
||||
groupId = connection.groupId;
|
||||
itemType = NODE_ITEM;
|
||||
connNameLabel->setText(connection.displayName);
|
||||
connNameLabel->setText("" + connection.displayName);
|
||||
latencyLabel->setText(QSTRN(connection.latency) + " " + tr("ms"));
|
||||
connTypeLabel->setText("DODO");
|
||||
connTypeLabel->setText(tr("Type: ") + ConnectionHandler->GetConnectionBasicInfo(identifier));
|
||||
dataLabel->setText(FormatBytes(connection.upLinkData + connection.downLinkData));
|
||||
//
|
||||
indentSpacer->changeSize(10, indentSpacer->sizeHint().height());
|
||||
}
|
||||
|
||||
// ======================================= Initialisation for root nodes.
|
||||
ConnectionWidget::ConnectionWidget(const GroupId &id, QWidget *parent) : ConnectionWidget(parent)
|
||||
ConnectionItemWidget::ConnectionItemWidget(const GroupId &id, QWidget *parent) : ConnectionItemWidget(parent)
|
||||
{
|
||||
groupId = id;
|
||||
itemType = GROUP_HEADER_ITEM;
|
||||
auto displayName = ConnectionHandler->GetGroup(id).displayName;
|
||||
auto connectionCount = ConnectionHandler->Connections(id).count();
|
||||
connNameLabel->setText(displayName);
|
||||
connNameLabel->setText(/*"• " +*/ displayName);
|
||||
latencyLabel->setText(QSTRN(connectionCount) + " " + (connectionCount < 2 ? tr("connection") : tr("connections")));
|
||||
//
|
||||
layout()->removeWidget(connTypeLabel);
|
||||
@ -36,7 +38,7 @@ ConnectionWidget::ConnectionWidget(const GroupId &id, QWidget *parent) : Connect
|
||||
}
|
||||
|
||||
|
||||
void ConnectionWidget::BeginConnection()
|
||||
void ConnectionItemWidget::BeginConnection()
|
||||
{
|
||||
if (itemType == NODE_ITEM) {
|
||||
ConnectionHandler->StartConnection(connectionId);
|
||||
@ -45,7 +47,7 @@ void ConnectionWidget::BeginConnection()
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionWidget::OnConnected(const ConnectionId &id)
|
||||
void ConnectionItemWidget::OnConnected(const ConnectionId &id)
|
||||
{
|
||||
if (id == connectionId) {
|
||||
LOG(MODULE_UI, "OnConnected signal received for: " + id.toString())
|
||||
@ -53,7 +55,7 @@ void ConnectionWidget::OnConnected(const ConnectionId &id)
|
||||
}
|
||||
}
|
||||
|
||||
ConnectionWidget::~ConnectionWidget()
|
||||
ConnectionItemWidget::~ConnectionItemWidget()
|
||||
{
|
||||
//
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include "ui_ConnectionWidget.h"
|
||||
#include "ui_ConnectionItemWidget.h"
|
||||
#include "core/handler/ConnectionHandler.hpp"
|
||||
|
||||
enum ITEM_TYPE {
|
||||
@ -9,15 +9,15 @@ enum ITEM_TYPE {
|
||||
NODE_ITEM
|
||||
};
|
||||
|
||||
class ConnectionWidget : public QWidget, private Ui::ConnectionWidget
|
||||
class ConnectionItemWidget : public QWidget, private Ui::ConnectionWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConnectionWidget(const ConnectionId &connecionId, QWidget *parent = nullptr);
|
||||
explicit ConnectionWidget(const GroupId &groupId, QWidget *parent = nullptr);
|
||||
explicit ConnectionItemWidget(const ConnectionId &connecionId, QWidget *parent = nullptr);
|
||||
explicit ConnectionItemWidget(const GroupId &groupId, QWidget *parent = nullptr);
|
||||
//
|
||||
void BeginConnection();
|
||||
~ConnectionWidget();
|
||||
~ConnectionItemWidget();
|
||||
//
|
||||
inline bool NameMatched(const QString &arg)
|
||||
{
|
||||
@ -39,14 +39,14 @@ class ConnectionWidget : public QWidget, private Ui::ConnectionWidget
|
||||
return itemType == NODE_ITEM;
|
||||
}
|
||||
signals:
|
||||
void RequestWidgetFocus(const ConnectionWidget *me);
|
||||
void RequestWidgetFocus(const ConnectionItemWidget *me);
|
||||
private slots:
|
||||
void OnConnected(const ConnectionId &id);
|
||||
private:
|
||||
explicit ConnectionWidget(QWidget *parent = nullptr);
|
||||
explicit ConnectionItemWidget(QWidget *parent = nullptr);
|
||||
ITEM_TYPE itemType;
|
||||
ConnectionId connectionId;
|
||||
GroupId groupId;
|
||||
|
||||
Q_DISABLE_COPY_MOVE(ConnectionWidget)
|
||||
Q_DISABLE_COPY_MOVE(ConnectionItemWidget)
|
||||
};
|
93
src/ui/widgets/ConnectionItemWidget.ui
Normal file
93
src/ui/widgets/ConnectionItemWidget.ui
Normal file
@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConnectionWidget</class>
|
||||
<widget class="QWidget" name="ConnectionWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>277</width>
|
||||
<height>66</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<spacer name="indentSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0">
|
||||
<item>
|
||||
<widget class="QLabel" name="connNameLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Connection Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="latencyLabel">
|
||||
<property name="text">
|
||||
<string>500ms</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,0">
|
||||
<item>
|
||||
<widget class="QLabel" name="connTypeLabel">
|
||||
<property name="text">
|
||||
<string>Type: vmess + tls + ws</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="dataLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0KB</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,66 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConnectionWidget</class>
|
||||
<widget class="QWidget" name="ConnectionWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>283</width>
|
||||
<height>84</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="connNameLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Connection Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="latencyLabel">
|
||||
<property name="text">
|
||||
<string>500ms</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="connTypeLabel">
|
||||
<property name="text">
|
||||
<string>Type: vmess + tls + ws</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="dataLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0KB</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue
Block a user