mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 02:40:20 +08:00
change: some more refactors
This commit is contained in:
parent
8a8afdea61
commit
0d8f0839f2
@ -1 +1 @@
|
|||||||
4411
|
4427
|
||||||
|
@ -44,15 +44,15 @@ namespace Qv2ray::components::plugins
|
|||||||
|
|
||||||
if (req == "START")
|
if (req == "START")
|
||||||
{
|
{
|
||||||
emit instance->Connect();
|
emit instance->StartConnection();
|
||||||
}
|
}
|
||||||
else if (req == "STOP")
|
else if (req == "STOP")
|
||||||
{
|
{
|
||||||
emit instance->DisConnect();
|
emit instance->StopConnection();
|
||||||
}
|
}
|
||||||
else if (req == "RESTART")
|
else if (req == "RESTART")
|
||||||
{
|
{
|
||||||
emit instance->ReConnect();
|
emit instance->RestartConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto BarConfig = GlobalConfig.toolBarConfig;
|
auto BarConfig = GlobalConfig.toolBarConfig;
|
||||||
|
@ -132,4 +132,20 @@ namespace Qv2ray::core
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString GetDisplayName(const ConnectionId &id, int limit)
|
||||||
|
{
|
||||||
|
return TruncateString(ConnectionManager->GetConnectionMetaObject(id).displayName, limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString GetDisplayName(const GroupId &id, int limit)
|
||||||
|
{
|
||||||
|
return TruncateString(ConnectionManager->GetGroupMetaObject(id).displayName, limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
const GroupId GetConnectionGroupId(const ConnectionId &id)
|
||||||
|
{
|
||||||
|
return ConnectionManager->GetConnectionMetaObject(id).groupId;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Qv2ray::core
|
} // namespace Qv2ray::core
|
||||||
|
@ -39,7 +39,13 @@ namespace Qv2ray::core
|
|||||||
bool IsComplexConfig(const ConnectionId &id);
|
bool IsComplexConfig(const ConnectionId &id);
|
||||||
//
|
//
|
||||||
const QString GetConnectionProtocolString(const ConnectionId &id);
|
const QString GetConnectionProtocolString(const ConnectionId &id);
|
||||||
|
//
|
||||||
|
const QString GetDisplayName(const ConnectionId &id, int limit = -1);
|
||||||
|
const QString GetDisplayName(const GroupId &id, int limit = -1);
|
||||||
|
//
|
||||||
|
|
||||||
|
const GroupId GetConnectionGroupId(const ConnectionId &id);
|
||||||
|
//
|
||||||
} // namespace Qv2ray::core
|
} // namespace Qv2ray::core
|
||||||
|
|
||||||
using namespace Qv2ray::core;
|
using namespace Qv2ray::core;
|
||||||
|
@ -9,6 +9,7 @@ namespace Qv2ray::core::connection
|
|||||||
{
|
{
|
||||||
namespace Serialization
|
namespace Serialization
|
||||||
{
|
{
|
||||||
|
const QString ConvertConfigToString(const QString &alias, const CONFIGROOT &server, bool isSip002);
|
||||||
CONFIGROOT ConvertConfigFromString(const QString &link, QString *alias, QString *errMessage)
|
CONFIGROOT ConvertConfigFromString(const QString &link, QString *alias, QString *errMessage)
|
||||||
{
|
{
|
||||||
CONFIGROOT config;
|
CONFIGROOT config;
|
||||||
@ -31,8 +32,13 @@ namespace Qv2ray::core::connection
|
|||||||
|
|
||||||
const QString ConvertConfigToString(const ConnectionId &id, bool isSip002)
|
const QString ConvertConfigToString(const ConnectionId &id, bool isSip002)
|
||||||
{
|
{
|
||||||
|
auto alias = GetDisplayName(id);
|
||||||
|
if (IsComplexConfig(id))
|
||||||
|
{
|
||||||
|
DEBUG(MODULE_CONNECTION, "Ignored an complex config: " + alias)
|
||||||
|
return QV2RAY_SERIALIZATION_COMPLEX_CONFIG_PLACEHOLDER;
|
||||||
|
}
|
||||||
auto server = ConnectionManager->GetConnectionRoot(id);
|
auto server = ConnectionManager->GetConnectionRoot(id);
|
||||||
auto alias = ConnectionManager->GetDisplayName(id);
|
|
||||||
return ConvertConfigToString(alias, server, isSip002);
|
return ConvertConfigToString(alias, server, isSip002);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,16 +71,16 @@ namespace Qv2ray::core::connection
|
|||||||
|
|
||||||
// From
|
// From
|
||||||
// https://github.com/2dust/v2rayN/wiki/%E5%88%86%E4%BA%AB%E9%93%BE%E6%8E%A5%E6%A0%BC%E5%BC%8F%E8%AF%B4%E6%98%8E(ver-2)
|
// https://github.com/2dust/v2rayN/wiki/%E5%88%86%E4%BA%AB%E9%93%BE%E6%8E%A5%E6%A0%BC%E5%BC%8F%E8%AF%B4%E6%98%8E(ver-2)
|
||||||
QString ConvertConfigToVMessString(const StreamSettingsObject &transfer, const VMessServerObject &serverConfig, const QString &alias)
|
const QString ConvertConfigToVMessString(const StreamSettingsObject &transfer, const VMessServerObject &server, const QString &alias)
|
||||||
{
|
{
|
||||||
QJsonObject vmessUriRoot;
|
QJsonObject vmessUriRoot;
|
||||||
// Constant
|
// Constant
|
||||||
vmessUriRoot["v"] = 2;
|
vmessUriRoot["v"] = 2;
|
||||||
vmessUriRoot["ps"] = alias;
|
vmessUriRoot["ps"] = alias;
|
||||||
vmessUriRoot["add"] = serverConfig.address;
|
vmessUriRoot["add"] = server.address;
|
||||||
vmessUriRoot["port"] = serverConfig.port;
|
vmessUriRoot["port"] = server.port;
|
||||||
vmessUriRoot["id"] = serverConfig.users.front().id;
|
vmessUriRoot["id"] = server.users.front().id;
|
||||||
vmessUriRoot["aid"] = serverConfig.users.front().alterId;
|
vmessUriRoot["aid"] = server.users.front().alterId;
|
||||||
vmessUriRoot["net"] = transfer.network;
|
vmessUriRoot["net"] = transfer.network;
|
||||||
vmessUriRoot["tls"] = transfer.security;
|
vmessUriRoot["tls"] = transfer.security;
|
||||||
|
|
||||||
@ -216,14 +222,14 @@ namespace Qv2ray::core::connection
|
|||||||
CONFIGROOT root;
|
CONFIGROOT root;
|
||||||
OUTBOUNDS outbounds;
|
OUTBOUNDS outbounds;
|
||||||
outbounds.append(
|
outbounds.append(
|
||||||
GenerateOutboundEntry("shadowsocks", GenerateShadowSocksOUT(QList<ShadowSocksServerObject>() << server), QJsonObject()));
|
GenerateOutboundEntry("shadowsocks", GenerateShadowSocksOUT(QList<ShadowSocksServerObject>{ server }), QJsonObject()));
|
||||||
JADD(outbounds)
|
JADD(outbounds)
|
||||||
*alias = alias->isEmpty() ? d_name : *alias + "_" + d_name;
|
*alias = alias->isEmpty() ? d_name : *alias + "_" + d_name;
|
||||||
LOG(MODULE_CONNECTION, "Deduced alias: " + *alias)
|
LOG(MODULE_CONNECTION, "Deduced alias: " + *alias)
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ConvertConfigToSSString(const ShadowSocksServerObject &server, const QString &alias, bool isSip002)
|
const QString ConvertConfigToSSString(const ShadowSocksServerObject &server, const QString &alias, bool isSip002)
|
||||||
{
|
{
|
||||||
auto myAlias = QUrl::toPercentEncoding(alias);
|
auto myAlias = QUrl::toPercentEncoding(alias);
|
||||||
|
|
||||||
@ -333,13 +339,17 @@ namespace Qv2ray::core::connection
|
|||||||
// used as default.
|
// used as default.
|
||||||
// [[val.size() <= 1]] is used when only the default value
|
// [[val.size() <= 1]] is used when only the default value
|
||||||
// exists.
|
// exists.
|
||||||
|
///
|
||||||
// - It can be empty, if so, if the key is not in
|
// - It can be empty, if so, if the key is not in
|
||||||
// the JSON, or the value is empty, it'll report an error.
|
// the JSON, or the value is empty, it'll report an error.
|
||||||
|
//
|
||||||
// - Else if it contains one thing. if the key is not in
|
// - Else if it contains one thing. if the key is not in
|
||||||
// the JSON, or the value is empty, it'll use that one.
|
// the JSON, or the value is empty, it'll use that one.
|
||||||
|
//
|
||||||
// - Else if it contains many things, when the key IS in
|
// - Else if it contains many things, when the key IS in
|
||||||
// the JSON but not in those THINGS, it'll use the first
|
// the JSON but not in those THINGS, it'll use the first
|
||||||
// one in the THINGS
|
// one in the THINGS
|
||||||
|
//
|
||||||
// - Else, it'll use the value found from the JSON object.
|
// - Else, it'll use the value found from the JSON object.
|
||||||
//
|
//
|
||||||
#define empty_arg
|
#define empty_arg
|
||||||
@ -464,11 +474,10 @@ namespace Qv2ray::core::connection
|
|||||||
auto outbound = GenerateOutboundEntry("vmess", vConf, GetRootObject(streaming), QJsonObject(), "0.0.0.0", OUTBOUND_TAG_PROXY);
|
auto outbound = GenerateOutboundEntry("vmess", vConf, GetRootObject(streaming), QJsonObject(), "0.0.0.0", OUTBOUND_TAG_PROXY);
|
||||||
//
|
//
|
||||||
root["outbounds"] = QJsonArray() << outbound;
|
root["outbounds"] = QJsonArray() << outbound;
|
||||||
// If previous alias is empty, just the PS is needed, else, append a
|
// If previous alias is empty, just the PS is needed, else, append a "_"
|
||||||
// "_"
|
|
||||||
*alias = alias->trimmed().isEmpty() ? ps : *alias + "_" + ps;
|
*alias = alias->trimmed().isEmpty() ? ps : *alias + "_" + ps;
|
||||||
#undef default
|
|
||||||
return root;
|
return root;
|
||||||
|
#undef default
|
||||||
}
|
}
|
||||||
} // namespace Serialization
|
} // namespace Serialization
|
||||||
} // namespace Qv2ray::core::connection
|
} // namespace Qv2ray::core::connection
|
||||||
|
@ -5,21 +5,21 @@ namespace Qv2ray::core::connection
|
|||||||
{
|
{
|
||||||
namespace Serialization
|
namespace Serialization
|
||||||
{
|
{
|
||||||
|
const auto QV2RAY_SERIALIZATION_COMPLEX_CONFIG_PLACEHOLDER = QObject::tr("(Complex Connection Config)");
|
||||||
// int VerifyVMessProtocolString(QString vmess);
|
// int VerifyVMessProtocolString(QString vmess);
|
||||||
QString DecodeSubscriptionString(QByteArray arr);
|
QString DecodeSubscriptionString(QByteArray arr);
|
||||||
|
|
||||||
// General
|
// General
|
||||||
CONFIGROOT ConvertConfigFromString(const QString &link, QString *alias, QString *errMessage);
|
CONFIGROOT ConvertConfigFromString(const QString &link, QString *alias, QString *errMessage);
|
||||||
const QString ConvertConfigToString(const ConnectionId &id, bool isSip002 = false);
|
const QString ConvertConfigToString(const ConnectionId &id, bool isSip002 = false);
|
||||||
const QString ConvertConfigToString(const QString &alias, const CONFIGROOT &server, bool isSip002);
|
|
||||||
|
|
||||||
// VMess URI Protocol
|
// VMess URI Protocol
|
||||||
CONFIGROOT ConvertConfigFromVMessString(const QString &vmess, QString *alias, QString *errMessage);
|
CONFIGROOT ConvertConfigFromVMessString(const QString &vmess, QString *alias, QString *errMessage);
|
||||||
QString ConvertConfigToVMessString(const StreamSettingsObject &transfer, const VMessServerObject &serverConfig, const QString &alias);
|
const QString ConvertConfigToVMessString(const StreamSettingsObject &transfer, const VMessServerObject &server, const QString &alias);
|
||||||
|
|
||||||
// SS URI Protocol
|
// SS URI Protocol
|
||||||
CONFIGROOT ConvertConfigFromSSString(const QString &ss, QString *alias, QString *errMessage);
|
CONFIGROOT ConvertConfigFromSSString(const QString &ss, QString *alias, QString *errMessage);
|
||||||
QString ConvertConfigToSSString(const ShadowSocksServerObject &server, const QString &alias, bool isSip002);
|
const QString ConvertConfigToSSString(const ShadowSocksServerObject &server, const QString &alias, bool isSip002);
|
||||||
} // namespace Serialization
|
} // namespace Serialization
|
||||||
} // namespace Qv2ray::core::connection
|
} // namespace Qv2ray::core::connection
|
||||||
|
|
||||||
|
@ -165,18 +165,6 @@ namespace Qv2ray::core::handlers
|
|||||||
return subsList;
|
return subsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString QvConfigHandler::GetDisplayName(const ConnectionId &id, int limit) const
|
|
||||||
{
|
|
||||||
CheckConnectionExistance(id);
|
|
||||||
return TruncateString(connections[id].displayName, limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString QvConfigHandler::GetDisplayName(const GroupId &id, int limit) const
|
|
||||||
{
|
|
||||||
CheckGroupExistance(id);
|
|
||||||
return TruncateString(groups[id].displayName, limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obsolated, Please use:
|
// Obsolated, Please use:
|
||||||
// ConnectionId QvConnectionHandler::GetConnectionIdByDisplayName(const QString &displayName, const GroupId &group) const
|
// ConnectionId QvConnectionHandler::GetConnectionIdByDisplayName(const QString &displayName, const GroupId &group) const
|
||||||
//
|
//
|
||||||
@ -218,17 +206,6 @@ namespace Qv2ray::core::handlers
|
|||||||
return NullGroupId;
|
return NullGroupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
const GroupId QvConfigHandler::GetConnectionGroupId(const ConnectionId &id) const
|
|
||||||
{
|
|
||||||
CheckConnectionExistanceEx(id, NullGroupId);
|
|
||||||
if (!connections.contains(id))
|
|
||||||
{
|
|
||||||
LOG(MODULE_CORE_HANDLER, "Cannot find id: " + id.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return connections[id].groupId;
|
|
||||||
}
|
|
||||||
|
|
||||||
const optional<QString> QvConfigHandler::RenameConnection(const ConnectionId &id, const QString &newName)
|
const optional<QString> QvConfigHandler::RenameConnection(const ConnectionId &id, const QString &newName)
|
||||||
{
|
{
|
||||||
CheckConnectionExistance(id);
|
CheckConnectionExistance(id);
|
||||||
|
@ -68,11 +68,8 @@ namespace Qv2ray::core::handlers
|
|||||||
//
|
//
|
||||||
const QList<GroupId> Subscriptions() const;
|
const QList<GroupId> Subscriptions() const;
|
||||||
//
|
//
|
||||||
// Generic Get Options
|
// Get Options
|
||||||
const QString GetDisplayName(const GroupId &id, int limit = -1) const;
|
|
||||||
const QString GetDisplayName(const ConnectionId &id, int limit = -1) const;
|
|
||||||
const GroupId GetGroupIdByDisplayName(const QString &displayName) const;
|
const GroupId GetGroupIdByDisplayName(const QString &displayName) const;
|
||||||
// const ConnectionId GetConnectionIdByDisplayName(const QString &displayName) const;
|
|
||||||
const ConnectionId GetConnectionIdByDisplayName(const QString &displayName, const GroupId &group) const;
|
const ConnectionId GetConnectionIdByDisplayName(const QString &displayName, const GroupId &group) const;
|
||||||
//
|
//
|
||||||
// Connectivity Operationss
|
// Connectivity Operationss
|
||||||
@ -89,7 +86,6 @@ namespace Qv2ray::core::handlers
|
|||||||
const ConnectionId CreateConnection(const QString &displayName, const GroupId &groupId, const CONFIGROOT &root);
|
const ConnectionId CreateConnection(const QString &displayName, const GroupId &groupId, const CONFIGROOT &root);
|
||||||
//
|
//
|
||||||
// Get Conncetion Property
|
// Get Conncetion Property
|
||||||
const GroupId GetConnectionGroupId(const ConnectionId &id) const;
|
|
||||||
const CONFIGROOT GetConnectionRoot(const ConnectionId &id) const;
|
const CONFIGROOT GetConnectionRoot(const ConnectionId &id) const;
|
||||||
const CONFIGROOT GetConnectionRoot(const GroupId &group, const ConnectionId &id) const;
|
const CONFIGROOT GetConnectionRoot(const GroupId &group, const ConnectionId &id) const;
|
||||||
//
|
//
|
||||||
|
@ -514,8 +514,8 @@ int main(int argc, char *argv[])
|
|||||||
QGuiApplication::setFallbackSessionManagementEnabled(false);
|
QGuiApplication::setFallbackSessionManagementEnabled(false);
|
||||||
QObject::connect(&_qApp, &QGuiApplication::commitDataRequest, []() { LOG(MODULE_INIT, "Quit triggered by session manager.") });
|
QObject::connect(&_qApp, &QGuiApplication::commitDataRequest, []() { LOG(MODULE_INIT, "Quit triggered by session manager.") });
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
signal(SIGUSR1, [](int) { emit MainWindow::mwInstance->Connect(); });
|
signal(SIGUSR1, [](int) { emit MainWindow::mwInstance->StartConnection(); });
|
||||||
signal(SIGUSR2, [](int) { emit MainWindow::mwInstance->DisConnect(); });
|
signal(SIGUSR2, [](int) { emit MainWindow::mwInstance->StopConnection(); });
|
||||||
#endif
|
#endif
|
||||||
auto rcode = _qApp.exec();
|
auto rcode = _qApp.exec();
|
||||||
delete ConnectionManager;
|
delete ConnectionManager;
|
||||||
|
@ -54,7 +54,7 @@ void MainWindow::MWAddConnectionItem_p(const ConnectionId &connection, const Gro
|
|||||||
auto groupItem = groupNodes[groupId];
|
auto groupItem = groupNodes[groupId];
|
||||||
auto connectionItem = make_shared<QTreeWidgetItem>(QStringList{
|
auto connectionItem = make_shared<QTreeWidgetItem>(QStringList{
|
||||||
"", //
|
"", //
|
||||||
ConnectionManager->GetDisplayName(connection), //
|
GetDisplayName(connection), //
|
||||||
NumericString(GetConnectionLatency(connection)), //
|
NumericString(GetConnectionLatency(connection)), //
|
||||||
"IMPORTTIME_NOT_SUPPORTED", //
|
"IMPORTTIME_NOT_SUPPORTED", //
|
||||||
"LAST_CONNECTED_NOT_SUPPORTED", //
|
"LAST_CONNECTED_NOT_SUPPORTED", //
|
||||||
@ -69,7 +69,7 @@ void MainWindow::MWAddConnectionItem_p(const ConnectionId &connection, const Gro
|
|||||||
|
|
||||||
void MainWindow::MWAddGroupItem_p(const GroupId &groupId)
|
void MainWindow::MWAddGroupItem_p(const GroupId &groupId)
|
||||||
{
|
{
|
||||||
auto groupItem = make_shared<QTreeWidgetItem>(QStringList{ "", ConnectionManager->GetDisplayName(groupId) });
|
auto groupItem = make_shared<QTreeWidgetItem>(QStringList{ "", GetDisplayName(groupId) });
|
||||||
groupNodes[groupId] = groupItem;
|
groupNodes[groupId] = groupItem;
|
||||||
connectionListWidget->addTopLevelItem(groupItem.get());
|
connectionListWidget->addTopLevelItem(groupItem.get());
|
||||||
connectionListWidget->setItemWidget(groupItem.get(), 0, new ConnectionItemWidget(groupId, connectionListWidget));
|
connectionListWidget->setItemWidget(groupItem.get(), 0, new ConnectionItemWidget(groupId, connectionListWidget));
|
||||||
@ -77,7 +77,6 @@ void MainWindow::MWAddGroupItem_p(const GroupId &groupId)
|
|||||||
|
|
||||||
void MainWindow::SortConnectionList(MW_ITEM_COL byCol, bool asending)
|
void MainWindow::SortConnectionList(MW_ITEM_COL byCol, bool asending)
|
||||||
{
|
{
|
||||||
|
|
||||||
connectionListWidget->sortByColumn(MW_ITEM_COL_DISPLAYNAME, Qt::AscendingOrder);
|
connectionListWidget->sortByColumn(MW_ITEM_COL_DISPLAYNAME, Qt::AscendingOrder);
|
||||||
for (auto i = 0; i < connectionListWidget->topLevelItemCount(); i++)
|
for (auto i = 0; i < connectionListWidget->topLevelItemCount(); i++)
|
||||||
{
|
{
|
||||||
@ -85,7 +84,7 @@ void MainWindow::SortConnectionList(MW_ITEM_COL byCol, bool asending)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) //, vinstance(), hTray(this), tcpingHelper(3, this)
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
MainWindow::mwInstance = this;
|
MainWindow::mwInstance = this;
|
||||||
@ -138,25 +137,16 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) //, vinstance(), h
|
|||||||
//
|
//
|
||||||
// Setup System tray icons and menus
|
// Setup System tray icons and menus
|
||||||
hTray.setToolTip(TRAY_TOOLTIP_PREFIX);
|
hTray.setToolTip(TRAY_TOOLTIP_PREFIX);
|
||||||
|
//
|
||||||
// Basic actions
|
// Basic actions
|
||||||
action_Tray_ShowHide = new QAction(this->windowIcon(), tr("Hide"), this);
|
|
||||||
action_Tray_ShowPreferencesWindow = new QAction(tr("Preferences"), this);
|
|
||||||
action_Tray_Quit = new QAction(tr("Quit"), this);
|
|
||||||
action_Tray_Start = new QAction(tr("Connect"), this);
|
|
||||||
action_Tray_Reconnect = new QAction(tr("Reconnect"), this);
|
|
||||||
action_Tray_Stop = new QAction(tr("Disconnect"), this);
|
|
||||||
//
|
|
||||||
action_Tray_SetSystemProxy = new QAction(tr("Enable System Proxy"), this);
|
|
||||||
action_Tray_ClearSystemProxy = new QAction(tr("Disable System Proxy"), this);
|
|
||||||
//
|
|
||||||
action_Tray_Start->setEnabled(true);
|
action_Tray_Start->setEnabled(true);
|
||||||
action_Tray_Stop->setEnabled(false);
|
action_Tray_Stop->setEnabled(false);
|
||||||
action_Tray_Reconnect->setEnabled(false);
|
action_Tray_Restart->setEnabled(false);
|
||||||
//
|
//
|
||||||
tray_SystemProxyMenu->addAction(action_Tray_SetSystemProxy);
|
|
||||||
tray_SystemProxyMenu->addAction(action_Tray_ClearSystemProxy);
|
|
||||||
tray_SystemProxyMenu->setTitle(tr("System Proxy"));
|
tray_SystemProxyMenu->setTitle(tr("System Proxy"));
|
||||||
tray_SystemProxyMenu->setEnabled(false);
|
tray_SystemProxyMenu->setEnabled(false);
|
||||||
|
tray_SystemProxyMenu->addAction(action_Tray_SetSystemProxy);
|
||||||
|
tray_SystemProxyMenu->addAction(action_Tray_ClearSystemProxy);
|
||||||
//
|
//
|
||||||
tray_RootMenu->addAction(action_Tray_ShowHide);
|
tray_RootMenu->addAction(action_Tray_ShowHide);
|
||||||
tray_RootMenu->addSeparator();
|
tray_RootMenu->addSeparator();
|
||||||
@ -165,7 +155,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) //, vinstance(), h
|
|||||||
tray_RootMenu->addSeparator();
|
tray_RootMenu->addSeparator();
|
||||||
tray_RootMenu->addAction(action_Tray_Start);
|
tray_RootMenu->addAction(action_Tray_Start);
|
||||||
tray_RootMenu->addAction(action_Tray_Stop);
|
tray_RootMenu->addAction(action_Tray_Stop);
|
||||||
tray_RootMenu->addAction(action_Tray_Reconnect);
|
tray_RootMenu->addAction(action_Tray_Restart);
|
||||||
tray_RootMenu->addSeparator();
|
tray_RootMenu->addSeparator();
|
||||||
tray_RootMenu->addAction(action_Tray_Quit);
|
tray_RootMenu->addAction(action_Tray_Quit);
|
||||||
//
|
//
|
||||||
@ -174,7 +164,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) //, vinstance(), h
|
|||||||
//
|
//
|
||||||
connect(action_Tray_Start, &QAction::triggered, [&] { ConnectionManager->StartConnection(lastConnectedId); });
|
connect(action_Tray_Start, &QAction::triggered, [&] { ConnectionManager->StartConnection(lastConnectedId); });
|
||||||
connect(action_Tray_Stop, &QAction::triggered, ConnectionManager, &QvConfigHandler::StopConnection);
|
connect(action_Tray_Stop, &QAction::triggered, ConnectionManager, &QvConfigHandler::StopConnection);
|
||||||
connect(action_Tray_Reconnect, &QAction::triggered, ConnectionManager, &QvConfigHandler::RestartConnection);
|
connect(action_Tray_Restart, &QAction::triggered, ConnectionManager, &QvConfigHandler::RestartConnection);
|
||||||
//
|
//
|
||||||
connect(action_Tray_Quit, &QAction::triggered, this, &MainWindow::on_actionExit_triggered);
|
connect(action_Tray_Quit, &QAction::triggered, this, &MainWindow::on_actionExit_triggered);
|
||||||
connect(action_Tray_SetSystemProxy, &QAction::triggered, this, &MainWindow::MWSetSystemProxy);
|
connect(action_Tray_SetSystemProxy, &QAction::triggered, this, &MainWindow::MWSetSystemProxy);
|
||||||
@ -196,9 +186,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) //, vinstance(), h
|
|||||||
connect(action_RCM_DuplicateThese, &QAction::triggered, this, &MainWindow::on_action_RCM_DuplicateThese_triggered);
|
connect(action_RCM_DuplicateThese, &QAction::triggered, this, &MainWindow::on_action_RCM_DuplicateThese_triggered);
|
||||||
//
|
//
|
||||||
// Globally invokable signals.
|
// Globally invokable signals.
|
||||||
connect(this, &MainWindow::Connect, [&] { ConnectionManager->StartConnection(lastConnectedId); });
|
connect(this, &MainWindow::StartConnection, ConnectionManager, &QvConfigHandler::RestartConnection);
|
||||||
connect(this, &MainWindow::DisConnect, ConnectionManager, &QvConfigHandler::StopConnection);
|
connect(this, &MainWindow::StopConnection, ConnectionManager, &QvConfigHandler::StopConnection);
|
||||||
connect(this, &MainWindow::ReConnect, ConnectionManager, &QvConfigHandler::RestartConnection);
|
connect(this, &MainWindow::RestartConnection, ConnectionManager, &QvConfigHandler::RestartConnection);
|
||||||
//
|
//
|
||||||
hTray.setContextMenu(tray_RootMenu);
|
hTray.setContextMenu(tray_RootMenu);
|
||||||
hTray.show();
|
hTray.show();
|
||||||
@ -210,13 +200,13 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) //, vinstance(), h
|
|||||||
connectionListMenu->addAction(action_RCM_DeleteThese);
|
connectionListMenu->addAction(action_RCM_DeleteThese);
|
||||||
connectionListMenu->addAction(action_RCM_ConvToComplex);
|
connectionListMenu->addAction(action_RCM_ConvToComplex);
|
||||||
//
|
//
|
||||||
sortMenu = new QMenu(this);
|
QMenu *sortMenu = new QMenu(tr("Sort connection list."), this);
|
||||||
sortAction_SortByName_Asc = new QAction(tr("By connection name, A-Z"));
|
QAction *sortAction_SortByName_Asc = new QAction(tr("By connection name, A-Z"));
|
||||||
sortAction_SortByName_Dsc = new QAction(tr("By connection name, Z-A"));
|
QAction *sortAction_SortByName_Dsc = new QAction(tr("By connection name, Z-A"));
|
||||||
sortAction_SortByData_Asc = new QAction(tr("By data, Ascending"));
|
QAction *sortAction_SortByLatency_Asc = new QAction(tr("By data, Ascending"));
|
||||||
sortAction_SortByData_Dsc = new QAction(tr("By data, Descending"));
|
QAction *sortAction_SortByLatency_Dsc = new QAction(tr("By data, Descending"));
|
||||||
sortAction_SortByLatency_Asc = new QAction(tr("By latency, Ascending"));
|
QAction *sortAction_SortByData_Asc = new QAction(tr("By latency, Ascending"));
|
||||||
sortAction_SortByLatency_Dsc = new QAction(tr("By latency, Descending"));
|
QAction *sortAction_SortByData_Dsc = new QAction(tr("By latency, Descending"));
|
||||||
//
|
//
|
||||||
connect(sortAction_SortByName_Asc, &QAction::triggered, [&] { SortConnectionList(MW_ITEM_COL_DISPLAYNAME, true); });
|
connect(sortAction_SortByName_Asc, &QAction::triggered, [&] { SortConnectionList(MW_ITEM_COL_DISPLAYNAME, true); });
|
||||||
connect(sortAction_SortByName_Dsc, &QAction::triggered, [&] { SortConnectionList(MW_ITEM_COL_DISPLAYNAME, false); });
|
connect(sortAction_SortByName_Dsc, &QAction::triggered, [&] { SortConnectionList(MW_ITEM_COL_DISPLAYNAME, false); });
|
||||||
@ -411,12 +401,12 @@ void MainWindow::ToggleVisibility()
|
|||||||
QThread::msleep(20);
|
QThread::msleep(20);
|
||||||
SetWindowPos(HWND(this->winId()), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
SetWindowPos(HWND(this->winId()), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||||
#endif
|
#endif
|
||||||
tray_RootMenu->actions()[0]->setText(tr("Hide"));
|
action_Tray_ShowHide->setText(tr("Hide"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->hide();
|
this->hide();
|
||||||
tray_RootMenu->actions()[0]->setText(tr("Show"));
|
action_Tray_ShowHide->setText(tr("Show"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,11 +539,11 @@ void MainWindow::OnDisconnected(const ConnectionId &id)
|
|||||||
Q_UNUSED(id)
|
Q_UNUSED(id)
|
||||||
action_Tray_Start->setEnabled(true);
|
action_Tray_Start->setEnabled(true);
|
||||||
action_Tray_Stop->setEnabled(false);
|
action_Tray_Stop->setEnabled(false);
|
||||||
action_Tray_Reconnect->setEnabled(false);
|
action_Tray_Restart->setEnabled(false);
|
||||||
tray_SystemProxyMenu->setEnabled(false);
|
tray_SystemProxyMenu->setEnabled(false);
|
||||||
lastConnectedId = id;
|
lastConnectedId = id;
|
||||||
locateBtn->setEnabled(false);
|
locateBtn->setEnabled(false);
|
||||||
this->hTray.showMessage("Qv2ray", tr("Disconnected from: ") + ConnectionManager->GetDisplayName(id), this->windowIcon());
|
this->hTray.showMessage("Qv2ray", tr("Disconnected from: ") + GetDisplayName(id), this->windowIcon());
|
||||||
hTray.setToolTip(TRAY_TOOLTIP_PREFIX NEWLINE);
|
hTray.setToolTip(TRAY_TOOLTIP_PREFIX NEWLINE);
|
||||||
connetionStatusLabel->setText(tr("Not Connected"));
|
connetionStatusLabel->setText(tr("Not Connected"));
|
||||||
if (GlobalConfig.inboundConfig.setSystemProxy)
|
if (GlobalConfig.inboundConfig.setSystemProxy)
|
||||||
@ -573,12 +563,12 @@ void MainWindow::OnConnected(const ConnectionId &id)
|
|||||||
Q_UNUSED(id)
|
Q_UNUSED(id)
|
||||||
action_Tray_Start->setEnabled(false);
|
action_Tray_Start->setEnabled(false);
|
||||||
action_Tray_Stop->setEnabled(true);
|
action_Tray_Stop->setEnabled(true);
|
||||||
action_Tray_Reconnect->setEnabled(true);
|
action_Tray_Restart->setEnabled(true);
|
||||||
tray_SystemProxyMenu->setEnabled(true);
|
tray_SystemProxyMenu->setEnabled(true);
|
||||||
lastConnectedId = id;
|
lastConnectedId = id;
|
||||||
locateBtn->setEnabled(true);
|
locateBtn->setEnabled(true);
|
||||||
on_clearlogButton_clicked();
|
on_clearlogButton_clicked();
|
||||||
auto name = ConnectionManager->GetDisplayName(id);
|
auto name = GetDisplayName(id);
|
||||||
this->hTray.showMessage("Qv2ray", tr("Connected: ") + name, this->windowIcon());
|
this->hTray.showMessage("Qv2ray", tr("Connected: ") + name, this->windowIcon());
|
||||||
hTray.setToolTip(TRAY_TOOLTIP_PREFIX NEWLINE + tr("Connected: ") + name);
|
hTray.setToolTip(TRAY_TOOLTIP_PREFIX NEWLINE + tr("Connected: ") + name);
|
||||||
connetionStatusLabel->setText(tr("Connected: ") + name);
|
connetionStatusLabel->setText(tr("Connected: ") + name);
|
||||||
@ -727,8 +717,8 @@ void MainWindow::OnStatsAvailable(const ConnectionId &id, const quint64 upS, con
|
|||||||
netspeedLabel->setText(totalSpeedUp + NEWLINE + totalSpeedDown);
|
netspeedLabel->setText(totalSpeedUp + NEWLINE + totalSpeedDown);
|
||||||
dataamountLabel->setText(totalDataUp + NEWLINE + totalDataDown);
|
dataamountLabel->setText(totalDataUp + NEWLINE + totalDataDown);
|
||||||
//
|
//
|
||||||
hTray.setToolTip(TRAY_TOOLTIP_PREFIX NEWLINE + tr("Connected: ") + //
|
hTray.setToolTip(TRAY_TOOLTIP_PREFIX NEWLINE + tr("Connected: ") + GetDisplayName(id) + //
|
||||||
ConnectionManager->GetDisplayName(id) + NEWLINE "Up: " + totalSpeedUp + " Down: " + totalSpeedDown);
|
NEWLINE "Up: " + totalSpeedUp + " Down: " + totalSpeedDown);
|
||||||
//
|
//
|
||||||
// Set data accordingly
|
// Set data accordingly
|
||||||
connectionNodes[id]->setText(MW_ITEM_COL_DATAUSAGE, NumericString(GetConnectionTotalData(id)));
|
connectionNodes[id]->setText(MW_ITEM_COL_DATAUSAGE, NumericString(GetConnectionTotalData(id)));
|
||||||
@ -808,7 +798,7 @@ void MainWindow::OnJsonEditRequested(const ConnectionId &id)
|
|||||||
void MainWindow::OnConnectionCreated(const ConnectionId &id, const QString &displayName)
|
void MainWindow::OnConnectionCreated(const ConnectionId &id, const QString &displayName)
|
||||||
{
|
{
|
||||||
Q_UNUSED(displayName)
|
Q_UNUSED(displayName)
|
||||||
MWAddConnectionItem_p(id, ConnectionManager->GetConnectionGroupId(id));
|
MWAddConnectionItem_p(id, GetConnectionGroupId(id));
|
||||||
}
|
}
|
||||||
void MainWindow::OnConnectionDeleted(const ConnectionId &id, const GroupId &groupId)
|
void MainWindow::OnConnectionDeleted(const ConnectionId &id, const GroupId &groupId)
|
||||||
{
|
{
|
||||||
@ -869,21 +859,16 @@ void MainWindow::on_action_RCM_DuplicateThese_triggered()
|
|||||||
|
|
||||||
LOG(MODULE_UI, "Selected " + QSTRN(connlist.count()) + " items")
|
LOG(MODULE_UI, "Selected " + QSTRN(connlist.count()) + " items")
|
||||||
|
|
||||||
if (connlist.isEmpty())
|
if (connlist.count() > 1 && QvMessageBoxAsk(this, tr("Duplicating Connection(s)"), //
|
||||||
{
|
tr("Are you sure to duplicate these connection(s)?")) != QMessageBox::Yes)
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (connlist.count() > 1 &&
|
|
||||||
QvMessageBoxAsk(this, tr("Duplicating Connection(s)"), tr("Are you sure to duplicate these connection(s)?")) != QMessageBox::Yes)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto conn : connlist)
|
for (auto conn : connlist)
|
||||||
{
|
{
|
||||||
ConnectionManager->CreateConnection(ConnectionManager->GetDisplayName(conn) + tr(" (Copy)"), //
|
ConnectionManager->CreateConnection(GetDisplayName(conn) + tr(" (Copy)"), //
|
||||||
ConnectionManager->GetConnectionGroupId(conn), //
|
GetConnectionGroupId(conn), //
|
||||||
ConnectionManager->GetConnectionRoot(conn));
|
ConnectionManager->GetConnectionRoot(conn));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,9 @@ class MainWindow
|
|||||||
explicit MainWindow(QWidget *parent = nullptr);
|
explicit MainWindow(QWidget *parent = nullptr);
|
||||||
~MainWindow() override;
|
~MainWindow() override;
|
||||||
signals:
|
signals:
|
||||||
void Connect() const;
|
void StartConnection() const;
|
||||||
void DisConnect() const;
|
void StopConnection() const;
|
||||||
void ReConnect() const;
|
void RestartConnection() const;
|
||||||
public slots:
|
public slots:
|
||||||
QvMessageBusSlotDecl;
|
QvMessageBusSlotDecl;
|
||||||
private slots:
|
private slots:
|
||||||
@ -113,29 +113,19 @@ class MainWindow
|
|||||||
ConnectionInfoWidget *infoWidget;
|
ConnectionInfoWidget *infoWidget;
|
||||||
//
|
//
|
||||||
// Actions in the system tray menu
|
// Actions in the system tray menu
|
||||||
//
|
|
||||||
QMenu *tray_RootMenu = new QMenu(this);
|
QMenu *tray_RootMenu = new QMenu(this);
|
||||||
QAction *action_Tray_ShowHide;
|
QAction *action_Tray_ShowHide = new QAction(this->windowIcon(), tr("Hide"), this);
|
||||||
QAction *action_Tray_ShowPreferencesWindow;
|
QAction *action_Tray_ShowPreferencesWindow = new QAction(tr("Preferences"), this);
|
||||||
QAction *action_Tray_Quit;
|
QAction *action_Tray_Quit = new QAction(tr("Quit"), this);
|
||||||
// --> Connectivities
|
// --> Connectivities
|
||||||
QAction *action_Tray_Start;
|
QAction *action_Tray_Start = new QAction(tr("Connect"), this);
|
||||||
QAction *action_Tray_Reconnect;
|
QAction *action_Tray_Restart = new QAction(tr("Reconnect"), this);
|
||||||
QAction *action_Tray_Stop;
|
QAction *action_Tray_Stop = new QAction(tr("Disconnect"), this);
|
||||||
// --> System proxy settings
|
// --> System proxy settings
|
||||||
QMenu *tray_SystemProxyMenu = new QMenu(this);
|
QMenu *tray_SystemProxyMenu = new QMenu(this);
|
||||||
QAction *action_Tray_SetSystemProxy;
|
QAction *action_Tray_SetSystemProxy = new QAction(tr("Enable System Proxy"), this);
|
||||||
QAction *action_Tray_ClearSystemProxy;
|
QAction *action_Tray_ClearSystemProxy = new QAction(tr("Disable System Proxy"), this);
|
||||||
//
|
//
|
||||||
QMenu *sortMenu;
|
|
||||||
QAction *sortAction_SortByName_Asc;
|
|
||||||
QAction *sortAction_SortByName_Dsc;
|
|
||||||
QAction *sortAction_SortByLatency_Asc;
|
|
||||||
QAction *sortAction_SortByLatency_Dsc;
|
|
||||||
QAction *sortAction_SortByData_Asc;
|
|
||||||
QAction *sortAction_SortByData_Dsc;
|
|
||||||
//
|
|
||||||
// Extra Headers For w_MainWindow_extra.cpp Handling V2ray Connectivities.
|
|
||||||
ConnectionId lastConnectedId;
|
ConnectionId lastConnectedId;
|
||||||
void MWSetSystemProxy();
|
void MWSetSystemProxy();
|
||||||
void CheckSubscriptionsUpdate();
|
void CheckSubscriptionsUpdate();
|
||||||
|
@ -164,21 +164,21 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent), Current
|
|||||||
//
|
//
|
||||||
// Empty for global config.
|
// Empty for global config.
|
||||||
auto autoStartConnId = ConnectionId(CurrentConfig.autoStartId);
|
auto autoStartConnId = ConnectionId(CurrentConfig.autoStartId);
|
||||||
auto autoStartGroupId = ConnectionManager->GetConnectionGroupId(autoStartConnId);
|
auto autoStartGroupId = GetConnectionGroupId(autoStartConnId);
|
||||||
|
|
||||||
for (auto group : ConnectionManager->AllGroups())
|
for (auto group : ConnectionManager->AllGroups())
|
||||||
{
|
{
|
||||||
autoStartSubsCombo->addItem(ConnectionManager->GetDisplayName(group));
|
autoStartSubsCombo->addItem(GetDisplayName(group));
|
||||||
}
|
}
|
||||||
|
|
||||||
autoStartSubsCombo->setCurrentText(ConnectionManager->GetDisplayName(autoStartGroupId));
|
autoStartSubsCombo->setCurrentText(GetDisplayName(autoStartGroupId));
|
||||||
|
|
||||||
for (auto conn : ConnectionManager->Connections(autoStartGroupId))
|
for (auto conn : ConnectionManager->Connections(autoStartGroupId))
|
||||||
{
|
{
|
||||||
autoStartConnCombo->addItem(ConnectionManager->GetDisplayName(conn));
|
autoStartConnCombo->addItem(GetDisplayName(conn));
|
||||||
}
|
}
|
||||||
|
|
||||||
autoStartConnCombo->setCurrentText(ConnectionManager->GetDisplayName(autoStartConnId));
|
autoStartConnCombo->setCurrentText(GetDisplayName(autoStartConnId));
|
||||||
|
|
||||||
// FP Settings
|
// FP Settings
|
||||||
if (CurrentConfig.connectionConfig.forwardProxyConfig.type.trimmed().isEmpty())
|
if (CurrentConfig.connectionConfig.forwardProxyConfig.type.trimmed().isEmpty())
|
||||||
@ -1029,7 +1029,7 @@ void PreferencesWindow::on_autoStartSubsCombo_currentIndexChanged(const QString
|
|||||||
|
|
||||||
for (auto id : list)
|
for (auto id : list)
|
||||||
{
|
{
|
||||||
autoStartConnCombo->addItem(ConnectionManager->GetDisplayName(id));
|
autoStartConnCombo->addItem(GetDisplayName(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ SubscribeEditor::SubscribeEditor(QWidget *parent) : QDialog(parent)
|
|||||||
|
|
||||||
for (auto subs : ConnectionManager->Subscriptions())
|
for (auto subs : ConnectionManager->Subscriptions())
|
||||||
{
|
{
|
||||||
subscriptionList->addTopLevelItem(new QTreeWidgetItem(QStringList{ ConnectionManager->GetDisplayName(subs), subs.toString() }));
|
subscriptionList->addTopLevelItem(new QTreeWidgetItem(QStringList{ GetDisplayName(subs), subs.toString() }));
|
||||||
}
|
}
|
||||||
if (subscriptionList->topLevelItemCount() > 0)
|
if (subscriptionList->topLevelItemCount() > 0)
|
||||||
{
|
{
|
||||||
@ -31,7 +31,7 @@ QvMessageBusSlotImpl(SubscribeEditor)
|
|||||||
|
|
||||||
tuple<QString, CONFIGROOT> SubscribeEditor::GetSelectedConfig()
|
tuple<QString, CONFIGROOT> SubscribeEditor::GetSelectedConfig()
|
||||||
{
|
{
|
||||||
return { ConnectionManager->GetDisplayName(currentConnectionId), ConnectionManager->GetConnectionRoot(currentConnectionId) };
|
return { GetDisplayName(currentConnectionId), ConnectionManager->GetConnectionRoot(currentConnectionId) };
|
||||||
}
|
}
|
||||||
|
|
||||||
SubscribeEditor::~SubscribeEditor()
|
SubscribeEditor::~SubscribeEditor()
|
||||||
@ -101,7 +101,7 @@ void SubscribeEditor::on_subscriptionList_itemClicked(QTreeWidgetItem *item, int
|
|||||||
groupBox_2->setEnabled(true);
|
groupBox_2->setEnabled(true);
|
||||||
currentSubId = GroupId(item->text(1));
|
currentSubId = GroupId(item->text(1));
|
||||||
//
|
//
|
||||||
subNameTxt->setText(ConnectionManager->GetDisplayName(currentSubId));
|
subNameTxt->setText(GetDisplayName(currentSubId));
|
||||||
auto const [addr, lastUpdated, updateInterval] = ConnectionManager->GetSubscriptionData(currentSubId);
|
auto const [addr, lastUpdated, updateInterval] = ConnectionManager->GetSubscriptionData(currentSubId);
|
||||||
subAddrTxt->setText(addr);
|
subAddrTxt->setText(addr);
|
||||||
lastUpdatedLabel->setText(timeToString(lastUpdated));
|
lastUpdatedLabel->setText(timeToString(lastUpdated));
|
||||||
@ -111,7 +111,7 @@ void SubscribeEditor::on_subscriptionList_itemClicked(QTreeWidgetItem *item, int
|
|||||||
|
|
||||||
for (auto conn : ConnectionManager->Connections(currentSubId))
|
for (auto conn : ConnectionManager->Connections(currentSubId))
|
||||||
{
|
{
|
||||||
connectionsList->addItem(ConnectionManager->GetDisplayName(conn)); //
|
connectionsList->addItem(GetDisplayName(conn)); //
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ void ConnectionInfoWidget::ShowDetails(const tuple<GroupId, ConnectionId> &_iden
|
|||||||
shareLinkTxt->setText(shareLink);
|
shareLinkTxt->setText(shareLink);
|
||||||
protocolLabel->setText(GetConnectionProtocolString(connectionId));
|
protocolLabel->setText(GetConnectionProtocolString(connectionId));
|
||||||
//
|
//
|
||||||
groupLabel->setText(ConnectionManager->GetDisplayName(groupId, 175));
|
groupLabel->setText(GetDisplayName(groupId, 175));
|
||||||
auto [protocol, host, port] = GetConnectionInfo(connectionId);
|
auto [protocol, host, port] = GetConnectionInfo(connectionId);
|
||||||
Q_UNUSED(protocol)
|
Q_UNUSED(protocol)
|
||||||
addressLabel->setText(host);
|
addressLabel->setText(host);
|
||||||
@ -65,12 +65,19 @@ void ConnectionInfoWidget::ShowDetails(const tuple<GroupId, ConnectionId> &_iden
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
connectBtn->setIcon(QICON_R("connect.png"));
|
connectBtn->setIcon(QICON_R("connect.png"));
|
||||||
groupNameLabel->setText(ConnectionManager->GetDisplayName(groupId));
|
groupNameLabel->setText(GetDisplayName(groupId));
|
||||||
QStringList shareLinks;
|
QStringList shareLinks;
|
||||||
for (auto connection : ConnectionManager->Connections(groupId))
|
for (auto connection : ConnectionManager->Connections(groupId))
|
||||||
{
|
{
|
||||||
shareLinks << ConvertConfigToString(connection, false);
|
shareLinks << ConvertConfigToString(connection, false);
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
auto complexCount = shareLinks.removeAll(QV2RAY_SERIALIZATION_COMPLEX_CONFIG_PLACEHOLDER);
|
||||||
|
if (complexCount > 0)
|
||||||
|
{
|
||||||
|
shareLinks << tr("(Ignored %1 complex config(s))").arg(complexCount);
|
||||||
|
}
|
||||||
|
//
|
||||||
groupShareTxt->setPlainText(shareLinks.join(NEWLINE));
|
groupShareTxt->setPlainText(shareLinks.join(NEWLINE));
|
||||||
groupSubsLinkLabel->setText(ConnectionManager->IsSubscription(groupId) ? get<0>(ConnectionManager->GetSubscriptionData(groupId)) :
|
groupSubsLinkLabel->setText(ConnectionManager->IsSubscription(groupId) ? get<0>(ConnectionManager->GetSubscriptionData(groupId)) :
|
||||||
tr("Not a subscription"));
|
tr("Not a subscription"));
|
||||||
|
@ -17,8 +17,8 @@ ConnectionItemWidget::ConnectionItemWidget(QWidget *parent) : QWidget(parent), c
|
|||||||
ConnectionItemWidget::ConnectionItemWidget(const ConnectionId &id, QWidget *parent) : ConnectionItemWidget(parent)
|
ConnectionItemWidget::ConnectionItemWidget(const ConnectionId &id, QWidget *parent) : ConnectionItemWidget(parent)
|
||||||
{
|
{
|
||||||
connectionId = id;
|
connectionId = id;
|
||||||
groupId = ConnectionManager->GetConnectionGroupId(id);
|
groupId = GetConnectionGroupId(id);
|
||||||
originalItemName = ConnectionManager->GetDisplayName(id);
|
originalItemName = GetDisplayName(id);
|
||||||
itemType = NODE_ITEM;
|
itemType = NODE_ITEM;
|
||||||
auto latency = GetConnectionLatency(id);
|
auto latency = GetConnectionLatency(id);
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ ConnectionItemWidget::ConnectionItemWidget(const GroupId &id, QWidget *parent) :
|
|||||||
//
|
//
|
||||||
groupId = id;
|
groupId = id;
|
||||||
itemType = GROUP_HEADER_ITEM;
|
itemType = GROUP_HEADER_ITEM;
|
||||||
originalItemName = ConnectionManager->GetDisplayName(id);
|
originalItemName = GetDisplayName(id);
|
||||||
RecalculateConnectionsCount();
|
RecalculateConnectionsCount();
|
||||||
//
|
//
|
||||||
auto font = connNameLabel->font();
|
auto font = connNameLabel->font();
|
||||||
|
@ -27,7 +27,7 @@ class ConnectionItemWidget
|
|||||||
inline bool NameMatched(const QString &arg)
|
inline bool NameMatched(const QString &arg)
|
||||||
{
|
{
|
||||||
auto searchString = arg.toLower();
|
auto searchString = arg.toLower();
|
||||||
auto headerMatched = ConnectionManager->GetDisplayName(groupId).toLower().contains(arg);
|
auto headerMatched = GetDisplayName(groupId).toLower().contains(arg);
|
||||||
|
|
||||||
if (itemType != NODE_ITEM)
|
if (itemType != NODE_ITEM)
|
||||||
{
|
{
|
||||||
@ -35,7 +35,7 @@ class ConnectionItemWidget
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return headerMatched || ConnectionManager->GetDisplayName(connectionId).toLower().contains(searchString);
|
return headerMatched || GetDisplayName(connectionId).toLower().contains(searchString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline const tuple<GroupId, ConnectionId> Identifier() const
|
inline const tuple<GroupId, ConnectionId> Identifier() const
|
||||||
|
Loading…
Reference in New Issue
Block a user