diff --git a/3rdparty/x2struct b/3rdparty/x2struct index 927be09b..8e3a395a 160000 --- a/3rdparty/x2struct +++ b/3rdparty/x2struct @@ -1 +1 @@ -Subproject commit 927be09b77bef91ec50ca9bcf76d7b639805c4b1 +Subproject commit 8e3a395ad794e9f5095cb172e1625975e2b82d38 diff --git a/Build.Counter b/Build.Counter index ac54f8be..3ea5cbc9 100644 --- a/Build.Counter +++ b/Build.Counter @@ -1 +1 @@ -2445 +2517 diff --git a/Qv2ray.pro b/Qv2ray.pro index 1c1f3f42..fbfa245b 100644 --- a/Qv2ray.pro +++ b/Qv2ray.pro @@ -24,9 +24,11 @@ DEFINES += QT_DEPRECATED_WARNINGS QV2RAY_VERSION_STRING=\"\\\"v$${VERSION}\\\"\" # Don't merge those configs with below. CONFIG += enable_decoder_qr_code enable_encoder_qr_code qt c++11 openssl-linked + include(3rdparty/qzxing/src/QZXing-components.pri) include(3rdparty/SingleApplication/singleapplication.pri) include(3rdparty/QNodeEditor/QNodeEditor.pri) +include(3rdparty/x2struct/x2struct.pri) # Main config CONFIG += lrelease embed_translations diff --git a/src/Qv2rayBase.hpp b/src/Qv2rayBase.hpp index 9b0ab490..33a2e8e3 100644 --- a/src/Qv2rayBase.hpp +++ b/src/Qv2rayBase.hpp @@ -60,10 +60,9 @@ const int QV2RAY_CONFIG_VERSION = 6; #define BLACK(obj) \ obj->setPalette(this->palette()); -#define QV2RAY_UI_RESOURCES_ROOT QSTRING(QV2RAY_IS_DARKTHEME ? ":/icons/ui_dark/" : ":/icons/ui_light/") +#define QV2RAY_UI_RESOURCES_ROOT QString::fromStdString(QV2RAY_IS_DARKTHEME ? ":/icons/ui_dark/" : ":/icons/ui_light/") #define QICON_R(file) QIcon(QV2RAY_UI_RESOURCES_ROOT + file) -#define QSTRING(std_string) QString::fromStdString(std_string) #define NEWLINE "\r\n" #ifndef MAX @@ -80,7 +79,7 @@ namespace Qv2ray QJsonObject UpgradeConfig(int fromVersion, int toVersion, QJsonObject root); struct QvBarLine { - string Family; + QString Family; bool Bold; bool Italic; int ColorA; @@ -89,7 +88,7 @@ namespace Qv2ray int ColorB; int ContentType; double Size; - string Message; + QString Message; QvBarLine() : Family("Consolas") , Bold(true) @@ -103,13 +102,13 @@ namespace Qv2ray struct QvBarPage { int OffsetYpx; - vector Lines; + QList Lines; QvBarPage() : OffsetYpx(5) { } XTOSTRUCT(O(OffsetYpx, Lines)) }; struct Qv2rayToolBarConfig { - vector Pages; + QList Pages; XTOSTRUCT(O(Pages)) }; @@ -118,7 +117,7 @@ namespace Qv2ray struct Qv2raySubscriptionConfig { time_t lastUpdated; int updateInterval; - string address; + QString address; Qv2raySubscriptionConfig() : lastUpdated(system_clock::to_time_t(system_clock::now())), updateInterval(5), address("") { } XTOSTRUCT(O(lastUpdated, updateInterval, address)) }; @@ -126,14 +125,14 @@ namespace Qv2ray struct Qv2rayPACConfig { bool enablePAC; int port; - string localIP; + QString localIP; bool useSocksProxy; Qv2rayPACConfig() : enablePAC(false), port(8989), useSocksProxy(false) { } XTOSTRUCT(O(enablePAC, port, localIP, useSocksProxy)) }; struct Qv2rayInboundsConfig { - string listenip; + QString listenip; bool setSystemProxy; Qv2rayPACConfig pacConfig; @@ -142,7 +141,7 @@ namespace Qv2ray int socks_port; bool socks_useAuth; bool socksUDP; - string socksLocalIP; + QString socksLocalIP; AccountObject socksAccount; // HTTP bool useHTTP; @@ -158,8 +157,8 @@ namespace Qv2ray }; struct Qv2rayUIConfig { - string theme; - string language; + QString theme; + QString language; bool useDarkTheme; bool useDarkTrayIcon; Qv2rayUIConfig() : theme("Fusion"), language("en-US"), useDarkTheme(false), useDarkTrayIcon(true) { } @@ -170,7 +169,7 @@ namespace Qv2ray bool bypassCN; bool enableProxy; bool withLocalDNS; - list dnsList; + QList dnsList; int statsPort; Qv2rayConnectionConfig() : bypassCN(true), enableProxy(true), withLocalDNS(true), dnsList(), statsPort(15490) { } XTOSTRUCT(O(bypassCN, enableProxy, withLocalDNS, dnsList, statsPort)) @@ -181,13 +180,13 @@ namespace Qv2ray bool tProxySupport; int logLevel; // - string v2CorePath; - string v2AssetsPath; + QString v2CorePath; + QString v2AssetsPath; Qv2rayConfigIdentifier autoStartConfig; - string ignoredVersion; + QString ignoredVersion; // - list configs; - map subscriptions; + QList configs; + QMap subscriptions; // Qv2rayUIConfig uiConfig; Qv2rayInboundsConfig inboundConfig; diff --git a/src/QvConfigUpgrade.cpp b/src/QvConfigUpgrade.cpp index 2337328b..eab7ea6b 100644 --- a/src/QvConfigUpgrade.cpp +++ b/src/QvConfigUpgrade.cpp @@ -97,7 +97,7 @@ namespace Qv2ray // //UPDATELOG("Renamed usePAC to enablePAC.") // Qv2rayConfigIdentifier i; - i.connectionName = root["autoStartConfig"].toString().toStdString(); + i.connectionName = root["autoStartConfig"].toString(); root["autoStartConfig"] = GetRootObject(i); UPDATELOG("Added subscription feature to autoStartConfig.") break; @@ -113,7 +113,7 @@ namespace Qv2ray for (auto item = subs.begin(); item != subs.end(); item++) { auto key = item.key(); Qv2raySubscriptionConfig _conf; - _conf.address = item.value().toString().toStdString(); + _conf.address = item.value().toString(); _conf.lastUpdated = system_clock::to_time_t(system_clock::now()); _conf.updateInterval = 5; auto value = GetRootObject(_conf); diff --git a/src/QvCoreConfigObjects.hpp b/src/QvCoreConfigObjects.hpp index b3f00083..a2d61d32 100644 --- a/src/QvCoreConfigObjects.hpp +++ b/src/QvCoreConfigObjects.hpp @@ -21,8 +21,8 @@ namespace Qv2ray // To prevent anonying QJsonObject misuse struct Qv2rayConfigIdentifier { - string subscriptionName; - string connectionName; + QString subscriptionName; + QString connectionName; XTOSTRUCT(O(subscriptionName, connectionName)) }; SAFE_TYPEDEF(QJsonObject, INBOUNDSETTING) @@ -48,15 +48,15 @@ namespace Qv2ray // // Used in config generation struct AccountObject { - string user; - string pass; + QString user; + QString pass; XTOSTRUCT(O(user, pass)) }; // // struct ApiObject { - string tag; - list services; + QString tag; + QList services; ApiObject() : tag("api"), services() {} XTOSTRUCT(O(tag, services)) }; @@ -84,7 +84,7 @@ namespace Qv2ray // // struct PolicyObject { - map level; + QMap level; list system; PolicyObject(): level(), system() {} XTOSTRUCT(O(level, system)) @@ -95,28 +95,28 @@ namespace Qv2ray // Added due to the request of @aliyuchang33 bool QV2RAY_RULE_ENABLED; bool QV2RAY_RULE_USE_BALANCER; - string QV2RAY_RULE_TAG; + QString QV2RAY_RULE_TAG; // - string type; - list domain; - list ip; - string port; - string network; - list source; - list user; - list inboundTag; - list protocol; - string attrs; - string outboundTag; - string balancerTag; + QString type; + QList domain; + QList ip; + QString port; + QString network; + QList source; + QList user; + QList inboundTag; + QList protocol; + QString attrs; + QString outboundTag; + QString balancerTag; RuleObject() : QV2RAY_RULE_ENABLED(true), QV2RAY_RULE_USE_BALANCER(false), QV2RAY_RULE_TAG("new rule"), type("field"), domain(), ip(), port("1-65535"), network(""), source(), user(), inboundTag(), protocol(), attrs(), outboundTag(""), balancerTag("") {} XTOSTRUCT(O(QV2RAY_RULE_ENABLED, QV2RAY_RULE_USE_BALANCER, QV2RAY_RULE_TAG, type, domain, ip, port, network, source, user, inboundTag, protocol, attrs, outboundTag, balancerTag)) }; // // struct BalancerObject { - string tag ; - list selector; + QString tag ; + QList selector; BalancerObject() : tag(), selector() {} XTOSTRUCT(O(tag, selector)) }; @@ -125,27 +125,27 @@ namespace Qv2ray namespace TSObjects { struct HTTPRequestObject { - string version; - string method; - list path; - map> headers; + QString version; + QString method; + QList path; + QMap> headers; HTTPRequestObject(): version("1.1"), method("GET"), path(), headers() {} XTOSTRUCT(O(version, method, path, headers)) }; // // struct HTTPResponseObject { - string version; - string status; - string reason; - map> headers; + QString version; + QString status; + QString reason; + QMap> headers; HTTPResponseObject(): version("1.1"), status("200"), reason("OK"), headers() {} XTOSTRUCT(O(version, status, reason, headers)) }; // // struct TCPHeader_M_Object { - string type; + QString type; HTTPRequestObject request; HTTPResponseObject response; TCPHeader_M_Object(): type("none"), request(), response() {} @@ -154,7 +154,7 @@ namespace Qv2ray // // struct HeaderObject { - string type; + QString type; HeaderObject(): type("none") {} XTOSTRUCT(O(type)) }; @@ -182,31 +182,31 @@ namespace Qv2ray // // struct WebSocketObject { - string path; - map headers; + QString path; + QMap headers; WebSocketObject(): path("/"), headers() {} XTOSTRUCT(O(path, headers)) }; // // struct HttpObject { - list host; - string path; + QList host; + QString path; HttpObject() : host(), path("/") {} XTOSTRUCT(O(host, path)) }; // // struct DomainSocketObject { - string path; + QString path; DomainSocketObject(): path("/") {} XTOSTRUCT(O(path)) }; // // struct QuicObject { - string security; - string key; + QString security; + QString key; HeaderObject header; QuicObject(): security(""), key(""), header() {} XTOSTRUCT(O(security, key, header)) @@ -216,27 +216,27 @@ namespace Qv2ray struct SockoptObject { int mark; bool tcpFastOpen; - string tproxy; + QString tproxy; SockoptObject(): mark(0), tcpFastOpen(false), tproxy("off") {} XTOSTRUCT(O(mark, tcpFastOpen, tproxy)) }; // // struct CertificateObject { - string usage; - string certificateFile; - string keyFile; - list certificate; - list key; + QString usage; + QString certificateFile; + QString keyFile; + QList certificate; + QList key; CertificateObject(): usage(), certificateFile(), keyFile(), certificate(), key() {} XTOSTRUCT(O(usage, certificateFile, keyFile, certificate, key)) }; // // struct TLSObject { - string serverName; + QString serverName; bool allowInsecure; - list alpn; + QList alpn; list certificates; bool disableSystemRoot; TLSObject(): serverName(), allowInsecure(), certificates(), disableSystemRoot() {} @@ -247,15 +247,15 @@ namespace Qv2ray // struct SniffingObject { bool enabled = false; - list destOverride; + QList destOverride; SniffingObject(): enabled(), destOverride() {} XTOSTRUCT(O(enabled, destOverride)) }; // // struct StreamSettingsObject { - string network; - string security; + QString network; + QString security; TSObjects::SockoptObject sockopt; TSObjects::TLSObject tlsSettings; TSObjects::TCPObject tcpSettings; @@ -281,8 +281,8 @@ namespace Qv2ray { // DNS, OutBound struct DNSOut { - string network; - string address; + QString network; + QString address; int port; DNSOut(): network(""), address("0.0.0.0"), port(0) {} XTOSTRUCT(O(network, address, port)) @@ -291,9 +291,9 @@ namespace Qv2ray // MTProto, InBound || OutBound struct MTProtoIn { struct UserObject { - string email; + QString email; int level; - string secret; + QString secret; UserObject() : email("user@domain.com"), level(0), secret("") {} XTOSTRUCT(O(email, level, secret)) }; @@ -304,14 +304,14 @@ namespace Qv2ray // Socks, OutBound struct SocksServerObject { struct UserObject { - string user; - string pass; + QString user; + QString pass; int level; UserObject(): user("username"), pass("password"), level(0) {} XTOSTRUCT(O(user, pass, level)) }; - string address; + QString address; int port; list users; SocksServerObject(): address("0.0.0.0"), port(0), users() {} @@ -321,15 +321,15 @@ namespace Qv2ray // VMess Server struct VMessServerObject { struct UserObject { - string id; + QString id; int alterId; - string security; + QString security; int level; UserObject() : id(""), alterId(64), security("auto"), level(0) {} XTOSTRUCT(O(id, alterId, security, level)) }; - string address; + QString address; int port; list users; VMessServerObject(): address(""), port(0), users() {} @@ -338,10 +338,10 @@ namespace Qv2ray // // ShadowSocks Server struct ShadowSocksServerObject { - string email; - string address; - string method; - string password; + QString email; + QString address; + QString method; + QString password; bool ota; int level; int port; diff --git a/src/QvCoreConfigOperations.cpp b/src/QvCoreConfigOperations.cpp index 18300e76..f5abfaa8 100644 --- a/src/QvCoreConfigOperations.cpp +++ b/src/QvCoreConfigOperations.cpp @@ -15,20 +15,20 @@ namespace Qv2ray return conf; } - QMap GetRegularConnections(list connectionNames) + QMap GetRegularConnections(QStringList connectionNames) { QMap list; for (auto conn : connectionNames) { - list.insert(QSTRING(conn), _ReadConnection(QV2RAY_CONFIG_DIR + QSTRING(conn) + QV2RAY_CONFIG_FILE_EXTENSION)); + list.insert(conn, _ReadConnection(QV2RAY_CONFIG_DIR + conn + QV2RAY_CONFIG_FILE_EXTENSION)); } return list; } - QMap GetSubscriptionConnection(string subscription) + QMap GetSubscriptionConnection(QString subscription) { - auto _files = GetFileList(QV2RAY_SUBSCRIPTION_DIR + QSTRING(subscription)); + auto _files = GetFileList(QV2RAY_SUBSCRIPTION_DIR + subscription); QMap _config; for (auto _file : _files) { @@ -37,27 +37,27 @@ namespace Qv2ray auto confName = _file; // Remove the extension confName.chop(sizeof(QV2RAY_CONFIG_FILE_EXTENSION) - 1); - _config[confName] = _ReadConnection(QV2RAY_SUBSCRIPTION_DIR + QSTRING(subscription) + "/" + _file); + _config[confName] = _ReadConnection(QV2RAY_SUBSCRIPTION_DIR + subscription + "/" + _file); } else { LOG(MODULE_SUBSCRIPTION, "Found a file in subscription folder but without proper suffix: " + _file.toStdString()) } } if (_config.isEmpty()) { - LOG(MODULE_SUBSCRIPTION, "WARN: Maybe loading an empty subscrption: " + subscription) + LOG(MODULE_SUBSCRIPTION, "WARN: Maybe loading an empty subscrption: " + subscription.toStdString()) } return _config; } - QMap> GetSubscriptionConnections(list subscriptions) + QMap> GetSubscriptionConnections(QStringList subscriptions) { // SUB-NAME CONN-NAME CONN-ROOT QMap> list; for (auto singleSub : subscriptions) { - LOG(MODULE_SUBSCRIPTION, "Processing subscription: " + singleSub) - list[QSTRING(singleSub)] = GetSubscriptionConnection(singleSub); + LOG(MODULE_SUBSCRIPTION, "Processing subscription: " + singleSub.toStdString()) + list[singleSub] = GetSubscriptionConnection(singleSub); } return list; diff --git a/src/QvCoreConfigOperations.hpp b/src/QvCoreConfigOperations.hpp index 729801e5..7d63abc4 100644 --- a/src/QvCoreConfigOperations.hpp +++ b/src/QvCoreConfigOperations.hpp @@ -16,9 +16,9 @@ namespace Qv2ray // -------------------------- BEGIN GENERAL FUNCTIONS ---------------------------------------------- namespace ConfigOperations { - QMap GetRegularConnections(list connections); - QMap GetSubscriptionConnection(string subscription); - QMap> GetSubscriptionConnections(list subscriptions); + QMap GetRegularConnections(QStringList connections); + QMap GetSubscriptionConnection(QString subscription); + QMap> GetSubscriptionConnections(QStringList subscriptions); bool CheckIsComplexConfig(CONFIGROOT root); int FindIndexByTag(INOUTLIST list, const QString &tag); diff --git a/src/QvCoreConfigOperations_Convertion.cpp b/src/QvCoreConfigOperations_Convertion.cpp index 98835554..2319c4c0 100644 --- a/src/QvCoreConfigOperations_Convertion.cpp +++ b/src/QvCoreConfigOperations_Convertion.cpp @@ -13,32 +13,32 @@ namespace Qv2ray // Constant vmessUriRoot["v"] = 2; vmessUriRoot["ps"] = alias; - vmessUriRoot["add"] = QSTRING(serverConfig.address); + vmessUriRoot["add"] = serverConfig.address; vmessUriRoot["port"] = serverConfig.port; - vmessUriRoot["id"] = QSTRING(serverConfig.users.front().id); + vmessUriRoot["id"] = serverConfig.users.front().id; vmessUriRoot["aid"] = serverConfig.users.front().alterId; - vmessUriRoot["net"] = QSTRING(transfer.network); - vmessUriRoot["tls"] = QSTRING(transfer.security); + vmessUriRoot["net"] = transfer.network; + vmessUriRoot["tls"] = transfer.security; if (transfer.network == "tcp") { - vmessUriRoot["type"] = QSTRING(transfer.tcpSettings.header.type); + vmessUriRoot["type"] = transfer.tcpSettings.header.type; } else if (transfer.network == "kcp") { - vmessUriRoot["type"] = QSTRING(transfer.kcpSettings.header.type); + vmessUriRoot["type"] = transfer.kcpSettings.header.type; } else if (transfer.network == "quic") { - vmessUriRoot["type"] = QSTRING(transfer.quicSettings.header.type); - vmessUriRoot["host"] = QSTRING(transfer.quicSettings.security); - vmessUriRoot["path"] = QSTRING(transfer.quicSettings.key); + vmessUriRoot["type"] = transfer.quicSettings.header.type; + vmessUriRoot["host"] = transfer.quicSettings.security; + vmessUriRoot["path"] = transfer.quicSettings.key; } else if (transfer.network == "ws") { - auto x = QMap(transfer.wsSettings.headers); + auto x = transfer.wsSettings.headers; auto host = x.contains("host"); auto CapHost = x.contains("Host"); auto realHost = host ? x["host"] : (CapHost ? x["Host"] : ""); // - vmessUriRoot["host"] = QSTRING(realHost); - vmessUriRoot["path"] = QSTRING(transfer.wsSettings.path); + vmessUriRoot["host"] = realHost; + vmessUriRoot["path"] = transfer.wsSettings.path; } else if (transfer.network == "h2" || transfer.network == "http") { vmessUriRoot["host"] = Stringify(transfer.httpSettings.host, ","); - vmessUriRoot["path"] = QSTRING(transfer.httpSettings.path); + vmessUriRoot["path"] = transfer.httpSettings.path; } // @@ -165,7 +165,7 @@ namespace Qv2ray //return flag ? 0 : 1; } catch (exception *e) { LOG(MODULE_IMPORT, "Failed to decode vmess string: " + string(e->what())) - *errMessage = QSTRING(e->what()); + *errMessage = e->what(); return CONFIGROOT(); } @@ -174,18 +174,18 @@ namespace Qv2ray QStringRef vmessJsonB64(&vmess, 8, vmess.length() - 8); auto vmessConf = JsonFromString(Base64Decode(vmessJsonB64.toString())); // - string ps, add, id, net, type, host, path, tls; + QString ps, add, id, net, type, host, path, tls; int port, aid; // - ps = vmessConf.contains("ps") ? vmessConf["ps"].toVariant().toString().toStdString() - : (vmessConf["add"].toVariant().toString().toStdString() + ":" + vmessConf["port"].toVariant().toString().toStdString()); - add = vmessConf["add"].toVariant().toString().toStdString(); - id = vmessConf["id"].toVariant().toString().toStdString(); - net = vmessConf.contains("net") ? vmessConf["net"].toVariant().toString().toStdString() : "tcp"; - type = vmessConf.contains("type") ? vmessConf["type"].toVariant().toString().toStdString() : "none"; - host = vmessConf["host"].toVariant().toString().toStdString(); - path = vmessConf["path"].toVariant().toString().toStdString(); - tls = vmessConf.contains("tls") ? vmessConf["tls"].toVariant().toString().toStdString() : ""; + ps = vmessConf.contains("ps") ? vmessConf["ps"].toVariant().toString() + : (vmessConf["add"].toVariant().toString() + ":" + vmessConf["port"].toVariant().toString()); + add = vmessConf["add"].toVariant().toString(); + id = vmessConf["id"].toVariant().toString(); + net = vmessConf.contains("net") ? vmessConf["net"].toVariant().toString() : "tcp"; + type = vmessConf.contains("type") ? vmessConf["type"].toVariant().toString() : "none"; + host = vmessConf["host"].toVariant().toString(); + path = vmessConf["path"].toVariant().toString(); + tls = vmessConf.contains("tls") ? vmessConf["tls"].toVariant().toString() : ""; // port = vmessConf["port"].toVariant().toInt(); aid = vmessConf["aid"].toVariant().toInt(); @@ -217,13 +217,13 @@ namespace Qv2ray streaming.tcpSettings.header.type = type; } else if (net == "http" || net == "h2") { // Fill hosts for HTTP - for (auto _host : QString::fromStdString(host).split(',')) { - streaming.httpSettings.host.push_back(_host.toStdString()); + for (auto _host : host.split(',')) { + streaming.httpSettings.host.push_back(_host); } streaming.httpSettings.path = path; } else if (net == "ws") { - streaming.wsSettings.headers.insert(make_pair("Host", host)); + streaming.wsSettings.headers["Host"] = host; streaming.wsSettings.path = path; } else if (net == "kcp") { streaming.kcpSettings.header.type = type; @@ -245,7 +245,7 @@ namespace Qv2ray // root["outbounds"] = QJsonArray() << outbound; // If previous alias is empty, just the PS is needed, else, append a "_" - *alias = alias->isEmpty() ? QSTRING(ps) : *alias + "_" + QSTRING(ps); + *alias = alias->isEmpty() ? ps : *alias + "_" + ps; return root; } diff --git a/src/QvCoreConfigOperations_Generation.cpp b/src/QvCoreConfigOperations_Generation.cpp index 640c41fb..1571a8c5 100644 --- a/src/QvCoreConfigOperations_Generation.cpp +++ b/src/QvCoreConfigOperations_Generation.cpp @@ -181,12 +181,7 @@ namespace Qv2ray logObject.insert("loglevel", vLogLevels[gConf.logLevel]); root.insert("log", logObject); // - QStringList dnsList; - - foreach (auto str, gConf.connectionConfig.dnsList) { - dnsList.append(QString::fromStdString(str)); - } - + auto dnsList = gConf.connectionConfig.dnsList; auto dnsObject = GenerateDNS(gConf.connectionConfig.withLocalDNS, dnsList); root.insert("dns", dnsObject); // @@ -196,7 +191,7 @@ namespace Qv2ray // HTTP InBound if (gConf.inboundConfig.useHTTP) { INBOUND httpInBoundObject; - httpInBoundObject.insert("listen", QString::fromStdString(gConf.inboundConfig.listenip)); + httpInBoundObject.insert("listen", gConf.inboundConfig.listenip); httpInBoundObject.insert("port", gConf.inboundConfig.http_port); httpInBoundObject.insert("protocol", "http"); httpInBoundObject.insert("tag", "http_IN"); @@ -212,14 +207,14 @@ namespace Qv2ray // SOCKS InBound if (gConf.inboundConfig.useSocks) { INBOUND socksInBoundObject; - socksInBoundObject.insert("listen", QString::fromStdString(gConf.inboundConfig.listenip)); + socksInBoundObject.insert("listen", gConf.inboundConfig.listenip); socksInBoundObject.insert("port", gConf.inboundConfig.socks_port); socksInBoundObject.insert("protocol", "socks"); socksInBoundObject.insert("tag", "socks_IN"); auto socksInSettings = GenerateSocksIN(gConf.inboundConfig.socks_useAuth ? "password" : "noauth", QList() << gConf.inboundConfig.socksAccount, gConf.inboundConfig.socksUDP, - QSTRING(gConf.inboundConfig.socksLocalIP)); + gConf.inboundConfig.socksLocalIP); socksInBoundObject.insert("settings", socksInSettings); inboundsList.append(socksInBoundObject); } diff --git a/src/QvUtils.cpp b/src/QvUtils.cpp index 1c76a854..a6842fe6 100644 --- a/src/QvUtils.cpp +++ b/src/QvUtils.cpp @@ -86,19 +86,19 @@ namespace Qv2ray if (*protocol == "vmess") { auto Server = StructFromJsonString(JsonToString(out["settings"].toObject()["vnext"].toArray().first().toObject())); - *host = QSTRING(Server.address); + *host = Server.address; *port = Server.port; return true; } else if (*protocol == "shadowsocks") { auto x = JsonToString(out["settings"].toObject()["servers"].toArray().first().toObject()); auto Server = StructFromJsonString(x); - *host = QSTRING(Server.address); + *host = Server.address; *port = Server.port; return true; } else if (*protocol == "socks") { auto x = JsonToString(out["settings"].toObject()["servers"].toArray().first().toObject()); auto Server = StructFromJsonString(x); - *host = QSTRING(Server.address); + *host = Server.address; *port = Server.port; return true; } else { diff --git a/src/components/QvCoreInteractions.cpp b/src/components/QvCoreInteractions.cpp index 48249d33..e96434f1 100644 --- a/src/components/QvCoreInteractions.cpp +++ b/src/components/QvCoreInteractions.cpp @@ -22,12 +22,12 @@ namespace Qv2ray { auto conf = GetGlobalConfig(); - if (QFile::exists(QSTRING(conf.v2CorePath))) { + if (QFile::exists(conf.v2CorePath)) { QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - env.insert("V2RAY_LOCATION_ASSET", QSTRING(conf.v2AssetsPath)); + env.insert("V2RAY_LOCATION_ASSET", conf.v2AssetsPath); QProcess process; process.setProcessEnvironment(env); - process.start(QSTRING(conf.v2CorePath), QStringList() << "-test" << "-config" << path, QIODevice::ReadWrite | QIODevice::Text); + process.start(conf.v2CorePath, QStringList() << "-test" << "-config" << path, QIODevice::ReadWrite | QIODevice::Text); if (!process.waitForFinished(1000) && process.exitCode() != 0) { LOG(MODULE_VCORE, "v2ray core failed with exitcode: " + to_string(process.exitCode())) @@ -46,7 +46,7 @@ namespace Qv2ray } else { QvMessageBox(nullptr, tr("Cannot start v2ray"), tr("v2ray core file cannot be found at:") + NEWLINE + - QSTRING(conf.v2CorePath) + NEWLINE + NEWLINE + + conf.v2CorePath + NEWLINE + NEWLINE + tr("Please go to Preference Window to change the location.") + NEWLINE + tr("Or place your v2ray core file in the location above.")); return false; @@ -91,9 +91,9 @@ namespace Qv2ray if (ValidateConfig(filePath)) { QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - env.insert("V2RAY_LOCATION_ASSET", QSTRING(GetGlobalConfig().v2AssetsPath)); + env.insert("V2RAY_LOCATION_ASSET", GetGlobalConfig().v2AssetsPath); vProcess->setProcessEnvironment(env); - vProcess->start(QSTRING(GetGlobalConfig().v2CorePath), QStringList() << "-config" << filePath, QIODevice::ReadWrite | QIODevice::Text); + vProcess->start(GetGlobalConfig().v2CorePath, QStringList() << "-config" << filePath, QIODevice::ReadWrite | QIODevice::Text); vProcess->waitForStarted(); ConnectionStatus = STARTED; { diff --git a/src/components/QvGFWPACConverter.cpp b/src/components/QvGFWPACConverter.cpp index 914c37a0..4734be18 100644 --- a/src/components/QvGFWPACConverter.cpp +++ b/src/components/QvGFWPACConverter.cpp @@ -130,7 +130,7 @@ namespace Qv2ray NEWLINE " }" NEWLINE " }"; // - return QSTRING(outputContent); + return QString::fromStdString(outputContent); } } } diff --git a/src/components/QvPACHandler.cpp b/src/components/QvPACHandler.cpp index 4afb0a49..a0584da0 100644 --- a/src/components/QvPACHandler.cpp +++ b/src/components/QvPACHandler.cpp @@ -27,7 +27,7 @@ namespace Qv2ray connect(pacServer, &QHttpServer::newRequest, this, &PACServer::onNewRequest); // auto conf = GetGlobalConfig(); - auto address = QSTRING(conf.inboundConfig.listenip); + auto address = conf.inboundConfig.listenip; auto port = conf.inboundConfig.pacConfig.port; // QString gfwContent = StringFromFile(new QFile(QV2RAY_RULES_GFWLIST_PATH)); diff --git a/src/components/QvTCPing.cpp b/src/components/QvTCPing.cpp index 93ce480a..6e5ae2b1 100644 --- a/src/components/QvTCPing.cpp +++ b/src/components/QvTCPing.cpp @@ -52,7 +52,7 @@ namespace Qv2ray #if defined (__WIN32) && defined (UNICODE) data.errorMessage = QString::fromStdWString(gai_strerror(errcode)); #else - data.errorMessage = QSTRING(gai_strerror(errcode)); + data.errorMessage = gai_strerror(errcode); #endif return data; } diff --git a/src/main.cpp b/src/main.cpp index 7c460143..6bc5170e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -146,8 +146,8 @@ bool initialiseQv2ray() } Qv2rayConfig conf; - conf.v2AssetsPath = QV2RAY_DEFAULT_VASSETS_PATH.toStdString(); - conf.v2CorePath = QV2RAY_DEFAULT_VCORE_PATH.toStdString(); + conf.v2AssetsPath = QV2RAY_DEFAULT_VASSETS_PATH; + conf.v2CorePath = QV2RAY_DEFAULT_VCORE_PATH; conf.logLevel = 3; // // Save initial config. @@ -275,20 +275,20 @@ int main(int argc, char *argv[]) qApp->removeTranslator(_sysTranslator); LOG(MODULE_INIT, "Removing system translations") - if (confObject.uiConfig.language.empty()) { + if (confObject.uiConfig.language.isEmpty()) { // Prevent empty. LOG(MODULE_UI, "Setting default UI language to en-US") confObject.uiConfig.language = "en-US"; } - if (qApp->installTranslator(getTranslator(QSTRING(confObject.uiConfig.language)))) { - LOG(MODULE_INIT, "Successfully installed a translator for " + confObject.uiConfig.language) + if (qApp->installTranslator(getTranslator(confObject.uiConfig.language))) { + LOG(MODULE_INIT, "Successfully installed a translator for " + confObject.uiConfig.language.toStdString()) } else { // Do not translate these..... // If a translator fails to load, pop up a message. QvMessageBox( nullptr, "Translation Failed", - "Cannot load translation for " + QSTRING(confObject.uiConfig.language) + ", English is now used.\r\n\r\n" + "Cannot load translation for " + confObject.uiConfig.language + ", English is now used.\r\n\r\n" "Please go to Preferences Window to change or Report a Bug at: \r\n" "https://github.com/lhy0403/Qv2ray/issues/new"); } @@ -297,12 +297,12 @@ int main(int argc, char *argv[]) SetGlobalConfig(confObject); // // Check OpenSSL version for auto-update and subscriptions - auto osslReqVersion = QSslSocket::sslLibraryBuildVersionString().toStdString(); - auto osslCurVersion = QSslSocket::sslLibraryVersionString().toStdString(); - LOG(MODULE_NETWORK, "Current OpenSSL version: " + osslCurVersion) + auto osslReqVersion = QSslSocket::sslLibraryBuildVersionString(); + auto osslCurVersion = QSslSocket::sslLibraryVersionString(); + LOG(MODULE_NETWORK, "Current OpenSSL version: " + osslCurVersion.toStdString()) if (!QSslSocket::supportsSsl()) { - LOG(MODULE_NETWORK, "Required OpenSSL version: " + osslReqVersion) + LOG(MODULE_NETWORK, "Required OpenSSL version: " + osslReqVersion.toStdString()) LOG(MODULE_NETWORK, "OpenSSL library MISSING, Quitting.") QvMessageBox(nullptr, QObject::tr("DependencyMissing"), QObject::tr("Cannot find openssl libs") + "\r\n" + @@ -311,8 +311,8 @@ int main(int argc, char *argv[]) QObject::tr("Please refer to Github Issue #65 to check for solutions.") + "\r\n" + QObject::tr("Github Issue Link: ") + "https://github.com/lhy0403/Qv2ray/issues/65" + "\r\n\r\n" + QObject::tr("Technical Details") + "\r\n" + - "OSsl.Rq.V=" + QSTRING(osslReqVersion) + "\r\n" + - "OSsl.Cr.V=" + QSTRING(osslCurVersion)); + "OSsl.Rq.V=" + osslReqVersion + "\r\n" + + "OSsl.Cr.V=" + osslCurVersion); return -2; } @@ -361,9 +361,9 @@ int main(int argc, char *argv[]) QStringList themes = QStyleFactory::keys(); //_qApp.setDesktopFileName("qv2ray.desktop"); - if (themes.contains(QSTRING(confObject.uiConfig.theme))) { - _qApp.setStyle(QSTRING(confObject.uiConfig.theme)); - LOG(MODULE_INIT " " MODULE_UI, "Setting Qv2ray UI themes: " + confObject.uiConfig.theme) + if (themes.contains(confObject.uiConfig.theme)) { + _qApp.setStyle(confObject.uiConfig.theme); + LOG(MODULE_INIT " " MODULE_UI, "Setting Qv2ray UI themes: " + confObject.uiConfig.theme.toStdString()) } #endif diff --git a/src/ui/NetSpeedBar/QvNetSpeedBar.cpp b/src/ui/NetSpeedBar/QvNetSpeedBar.cpp index 839e7bad..28de705e 100644 --- a/src/ui/NetSpeedBar/QvNetSpeedBar.cpp +++ b/src/ui/NetSpeedBar/QvNetSpeedBar.cpp @@ -70,13 +70,13 @@ namespace Qv2ray case 101: { // Current Time - CL.Message = QTime().currentTime().toString("hh:mm:ss").toStdString(); + CL.Message = QTime().currentTime().toString("hh:mm:ss"); break; } case 102: { // Current Date - CL.Message = QDate().currentDate().toString("yyyy-MM-dd").toStdString(); + CL.Message = QDate().currentDate().toString("yyyy-MM-dd"); break; } @@ -88,7 +88,7 @@ namespace Qv2ray case 104: { // Current Connection Name - CL.Message = instance->CurrentConnectionName.toStdString(); + CL.Message = instance->CurrentConnectionName; break; } @@ -96,17 +96,17 @@ namespace Qv2ray // Current Connection Status switch (instance->vinstance->ConnectionStatus) { case STARTED: { - CL.Message = QObject::tr("Connected").toStdString(); + CL.Message = QObject::tr("Connected"); break; } case STOPPED: { - CL.Message = QObject::tr("Disconnected").toStdString(); + CL.Message = QObject::tr("Disconnected"); break; } case STARTING: { - CL.Message = QObject::tr("Connecting").toStdString(); + CL.Message = QObject::tr("Connecting"); break; } } @@ -116,49 +116,49 @@ namespace Qv2ray case 201: { // Total upload speed; - CL.Message = FormatBytes(vinstance->getAllSpeedUp()).toStdString() + "/s"; + CL.Message = FormatBytes(vinstance->getAllSpeedUp()) + "/s"; break; } case 202: { // Total download speed; - CL.Message = (FormatBytes(vinstance->getAllSpeedDown()) + "/s").toStdString(); + CL.Message = FormatBytes(vinstance->getAllSpeedDown()) + "/s"; break; } case 203: { // Upload speed for tag - CL.Message = FormatBytes(vinstance->getTagSpeedUp(QSTRING(CL.Message))).toStdString() + "/s"; + CL.Message = FormatBytes(vinstance->getTagSpeedUp(CL.Message)) + "/s"; break; } case 204: { // Download speed for tag - CL.Message = FormatBytes(vinstance->getTagSpeedDown(QSTRING(CL.Message))).toStdString() + "/s"; + CL.Message = FormatBytes(vinstance->getTagSpeedDown(CL.Message)) + "/s"; break; } case 301: { // Total Upload - CL.Message = FormatBytes(vinstance->getAllDataUp()).toStdString(); + CL.Message = FormatBytes(vinstance->getAllDataUp()); break; } case 302: { // Total download - CL.Message = FormatBytes(vinstance->getAllDataDown()).toStdString(); + CL.Message = FormatBytes(vinstance->getAllDataDown()); break; } case 303: { // Upload for tag - CL.Message = FormatBytes(vinstance->getTagDataUp(QSTRING(CL.Message))).toStdString(); + CL.Message = FormatBytes(vinstance->getTagDataUp(CL.Message)); break; } case 304: { // Download for tag - CL.Message = FormatBytes(vinstance->getTagDataDown(QSTRING(CL.Message))).toStdString(); + CL.Message = FormatBytes(vinstance->getTagDataDown(CL.Message)); break; } diff --git a/src/ui/w_MainWindow.cpp b/src/ui/w_MainWindow.cpp index 8bcd8be5..2e366c4f 100644 --- a/src/ui/w_MainWindow.cpp +++ b/src/ui/w_MainWindow.cpp @@ -285,8 +285,8 @@ void MainWindow::VersionUpdate(QByteArray &data) QJsonObject root = JsonFromString(QString(data)); // QVersionNumber newversion = QVersionNumber::fromString(root["tag_name"].toString("v").remove(0, 1)); - QVersionNumber current = QVersionNumber::fromString(QSTRING(QV2RAY_VERSION_STRING).remove(0, 1)); - QVersionNumber ignored = QVersionNumber::fromString(QSTRING(currentConfig.ignoredVersion)); + QVersionNumber current = QVersionNumber::fromString(QString(QV2RAY_VERSION_STRING).remove(0, 1)); + QVersionNumber ignored = QVersionNumber::fromString(currentConfig.ignoredVersion); LOG(MODULE_UPDATE, "Received update info, Latest: " + newversion.toString().toStdString() + " Current: " + current.toString().toStdString() + " Ignored: " + ignored.toString().toStdString()) // If the version is newer than us. @@ -307,7 +307,7 @@ void MainWindow::VersionUpdate(QByteArray &data) QDesktopServices::openUrl(QUrl::fromUserInput(link)); } else if (result == QMessageBox::Ignore) { // Set and save ingored version. - currentConfig.ignoredVersion = newversion.toString().toStdString(); + currentConfig.ignoredVersion = newversion.toString(); SetGlobalConfig(currentConfig); } } @@ -333,8 +333,7 @@ void MainWindow::OnConfigListChanged(bool need_restart) connectionListWidget->clear(); auto _regularConnections = GetRegularConnections(currentConfig.configs); // - auto _vector = mapExt::Keys(currentConfig.subscriptions); - auto _subsConnections = GetSubscriptionConnections(list(_vector.begin(), _vector.end())); + auto _subsConnections = GetSubscriptionConnections(currentConfig.subscriptions.keys()); for (auto i = 0; i < _regularConnections.count(); i++) { ConnectionObject _o; @@ -650,7 +649,7 @@ void MainWindow::on_connectionListWidget_itemChanged(QTreeWidgetItem *item, int) canContinueRename = false; } - if (contains(currentConfig.configs, newName.toStdString())) { + if (currentConfig.configs.contains(newName)) { QvMessageBox(this, tr("Rename a Connection"), tr("The name has been used already, Please choose another.")); canContinueRename = false; } @@ -669,13 +668,13 @@ void MainWindow::on_connectionListWidget_itemChanged(QTreeWidgetItem *item, int) // Change auto start config. // |--------------=== In case it's not in a subscription --| - if (currentConfig.autoStartConfig.subscriptionName.empty() && renameOriginalName.toStdString() == currentConfig.autoStartConfig.connectionName) { - currentConfig.autoStartConfig.connectionName = newName.toStdString(); + if (currentConfig.autoStartConfig.subscriptionName.isEmpty() && renameOriginalName == currentConfig.autoStartConfig.connectionName) { + currentConfig.autoStartConfig.connectionName = newName; } // Replace the items in the current loaded config list and settings. - currentConfig.configs.remove(renameOriginalName.toStdString()); - currentConfig.configs.push_back(newName.toStdString()); + currentConfig.configs.removeOne(renameOriginalName); + currentConfig.configs.push_back(newName); connections[newName] = connections.take(renameOriginalName); RenameConnection(renameOriginalName, newName); LOG(MODULE_UI, "Saving a global config") @@ -721,8 +720,8 @@ void MainWindow::on_removeConfigButton_clicked() auto connData = connections[name]; // Remove auto start config. - if (currentConfig.autoStartConfig.subscriptionName == connData.subscriptionName.toStdString() && - currentConfig.autoStartConfig.connectionName == connData.connectionName.toStdString()) + if (currentConfig.autoStartConfig.subscriptionName == connData.subscriptionName && + currentConfig.autoStartConfig.connectionName == connData.connectionName) // If all those settings match. { currentConfig.autoStartConfig.subscriptionName.clear(); @@ -736,7 +735,7 @@ void MainWindow::on_removeConfigButton_clicked() connData.subscriptionName.clear(); } - currentConfig.configs.remove(name.toStdString()); + currentConfig.configs.removeOne(name); if (!RemoveConnection(name)) { QvMessageBox(this, tr("Removing this Connection"), tr("Failed to delete connection file, please delete manually.")); @@ -777,7 +776,7 @@ void MainWindow::on_importConfigButton_clicked() continue; SaveConnectionConfig(conf, &name, false); - currentConfig.configs.push_back(name.toStdString()); + currentConfig.configs.push_back(name); } SetGlobalConfig(currentConfig); @@ -1020,7 +1019,7 @@ void MainWindow::on_duplicateBtn_clicked() // Alias may change. SaveConnectionConfig(conf, &alias, false); - currentConfig.configs.push_back(alias.toStdString()); + currentConfig.configs.push_back(alias); SetGlobalConfig(currentConfig); this->OnConfigListChanged(false); } diff --git a/src/ui/w_MainWindow_extra.cpp b/src/ui/w_MainWindow_extra.cpp index 7a5734aa..3162f1f2 100644 --- a/src/ui/w_MainWindow_extra.cpp +++ b/src/ui/w_MainWindow_extra.cpp @@ -6,11 +6,11 @@ void MainWindow::MWFindAndStartAutoConfig() { - if (!currentConfig.autoStartConfig.connectionName.empty()) { + if (!currentConfig.autoStartConfig.connectionName.isEmpty()) { // User has auto start configured, we try to find that connection item. - auto name = currentConfig.autoStartConfig.subscriptionName.empty() - ? QSTRING(currentConfig.autoStartConfig.connectionName) - : QSTRING(currentConfig.autoStartConfig.connectionName) + " (" + tr("Subscription:") + " " + QSTRING(currentConfig.autoStartConfig.subscriptionName) + ")"; + auto name = currentConfig.autoStartConfig.subscriptionName.isEmpty() + ? currentConfig.autoStartConfig.connectionName + : currentConfig.autoStartConfig.connectionName + " (" + tr("Subscription:") + " " + currentConfig.autoStartConfig.subscriptionName + ")"; // LOG(MODULE_UI, "Found auto start config: " + name.toStdString()) CurrentConnectionName = name; @@ -68,7 +68,7 @@ void MainWindow::MWSetSystemProxy() if ((httpEnabled && !pacUseSocks) || (socksEnabled && pacUseSocks)) { // If we use PAC and socks/http are properly configured for PAC LOG(MODULE_PROXY, "System proxy uses PAC") - proxyAddress = "http://" + QSTRING(currentConfig.inboundConfig.listenip) + ":" + QString::number(currentConfig.inboundConfig.pacConfig.port) + "/pac"; + proxyAddress = "http://" + currentConfig.inboundConfig.listenip + ":" + QString::number(currentConfig.inboundConfig.pacConfig.port) + "/pac"; } else { // Not properly configured LOG(MODULE_PROXY, "Failed to process pac due to following reasons:") @@ -118,7 +118,7 @@ bool MainWindow::MWtryStartConnection() if (usePAC) { bool canStartPAC = true; QString pacProxyString; // Something like this --> SOCKS5 127.0.0.1:1080; SOCKS 127.0.0.1:1080; DIRECT; http://proxy:8080 - auto pacIP = QSTRING(currentConfig.inboundConfig.pacConfig.localIP); + auto pacIP = currentConfig.inboundConfig.pacConfig.localIP; if (pacIP.isEmpty()) { LOG(MODULE_PROXY, "PAC Local IP is empty, default to 127.0.0.1") diff --git a/src/ui/w_OutboundEditor.cpp b/src/ui/w_OutboundEditor.cpp index 5212d195..0b96775b 100644 --- a/src/ui/w_OutboundEditor.cpp +++ b/src/ui/w_OutboundEditor.cpp @@ -87,71 +87,73 @@ void OutboundEditor::ReLoad_GUI_JSON_ModelContent() { if (OutboundType == "vmess") { outBoundTypeCombo->setCurrentIndex(0); - ipLineEdit->setText(QSTRING(vmess.address)); + ipLineEdit->setText(vmess.address); portLineEdit->setText(QString::number(vmess.port)); - idLineEdit->setText(QSTRING(vmess.users.front().id)); + idLineEdit->setText(vmess.users.front().id); alterLineEdit->setValue(vmess.users.front().alterId); - securityCombo->setCurrentText(QSTRING(vmess.users.front().security)); - tranportCombo->setCurrentText(QSTRING(stream.network)); + securityCombo->setCurrentText(vmess.users.front().security); + tranportCombo->setCurrentText(stream.network); tlsCB->setChecked(stream.security == "tls"); // TCP - tcpHeaderTypeCB->setCurrentText(QSTRING(stream.tcpSettings.header.type)); + tcpHeaderTypeCB->setCurrentText(stream.tcpSettings.header.type); tcpRequestTxt->setPlainText(StructToJsonString(stream.tcpSettings.header.request)); tcpRespTxt->setPlainText(StructToJsonString(stream.tcpSettings.header.response)); // HTTP QString allHosts; foreach (auto host, stream.httpSettings.host) { - allHosts = allHosts + QSTRING(host) + "\r\n"; + allHosts = allHosts + host + "\r\n"; } httpHostTxt->setPlainText(allHosts); - httpPathTxt->setText(QSTRING(stream.httpSettings.path)); + httpPathTxt->setText(stream.httpSettings.path); // WS - wsPathTxt->setText(QSTRING(stream.wsSettings.path)); - QString wsHeaders = std::accumulate(stream.wsSettings.headers.begin(), stream.wsSettings.headers.end(), QString(), [](QString in1, const pair &in2) { - in1 += QSTRING(in2.first + "|" + in2.second) + "\r\n"; - return in1; - }); + wsPathTxt->setText(stream.wsSettings.path); + QString wsHeaders; + + for (auto item = stream.wsSettings.headers.begin(); item != stream.wsSettings.headers.end(); item++) { + wsHeaders += item.key() + "|" + item.value() + NEWLINE; + } + wsHeadersTxt->setPlainText(wsHeaders); // mKCP kcpMTU->setValue(stream.kcpSettings.mtu); kcpTTI->setValue(stream.kcpSettings.tti); - kcpHeaderType->setCurrentText(QSTRING(stream.kcpSettings.header.type)); + kcpHeaderType->setCurrentText(stream.kcpSettings.header.type); kcpCongestionCB->setChecked(stream.kcpSettings.congestion); kcpReadBufferSB->setValue(stream.kcpSettings.readBufferSize); kcpUploadCapacSB->setValue(stream.kcpSettings.uplinkCapacity); kcpDownCapacitySB->setValue(stream.kcpSettings.downlinkCapacity); kcpWriteBufferSB->setValue(stream.kcpSettings.writeBufferSize); // DS - dsPathTxt->setText(QSTRING(stream.dsSettings.path)); + dsPathTxt->setText(stream.dsSettings.path); // QUIC - quicKeyTxt->setText(QSTRING(stream.quicSettings.key)); - quicSecurityCB->setCurrentText(QSTRING(stream.quicSettings.security)); - quicHeaderTypeCB->setCurrentText(QSTRING(stream.quicSettings.header.type)); + quicKeyTxt->setText(stream.quicSettings.key); + quicSecurityCB->setCurrentText(stream.quicSettings.security); + quicHeaderTypeCB->setCurrentText(stream.quicSettings.header.type); // SOCKOPT - tProxyCB->setCurrentText(QSTRING(stream.sockopt.tproxy)); + tProxyCB->setCurrentText(stream.sockopt.tproxy); tcpFastOpenCB->setChecked(stream.sockopt.tcpFastOpen); soMarkSpinBox->setValue(stream.sockopt.mark); } else if (OutboundType == "shadowsocks") { outBoundTypeCombo->setCurrentIndex(1); // ShadowSocks Configs - ipLineEdit->setText(QSTRING(shadowsocks.address)); + ipLineEdit->setText(shadowsocks.address); portLineEdit->setText(QString::number(shadowsocks.port)); - ss_emailTxt->setText(QSTRING(shadowsocks.email)); + ss_emailTxt->setText(shadowsocks.email); ss_levelSpin->setValue(shadowsocks.level); ss_otaCheckBox->setChecked(shadowsocks.ota); - ss_passwordTxt->setText(QSTRING(shadowsocks.password)); - ss_encryptionMethod->setCurrentText(QSTRING(shadowsocks.method)); + ss_passwordTxt->setText(shadowsocks.password); + ss_encryptionMethod->setCurrentText(shadowsocks.method); } else if (OutboundType == "socks") { outBoundTypeCombo->setCurrentIndex(2); - ipLineEdit->setText(QSTRING(socks.address)); + ipLineEdit->setText(socks.address); portLineEdit->setText(QString::number(socks.port)); if (socks.users.empty()) socks.users.push_back(SocksServerObject::UserObject()); - socks_PasswordTxt->setText(QSTRING(socks.users.front().pass)); - socks_UserNameTxt->setText(QSTRING(socks.users.front().user)); + socks_PasswordTxt->setText(socks.users.front().pass); + socks_UserNameTxt->setText(socks.users.front().user); } muxEnabledCB->setChecked(Mux["enabled"].toBool()); @@ -166,17 +168,17 @@ void OutboundEditor::on_buttonBox_accepted() void OutboundEditor::on_ipLineEdit_textEdited(const QString &arg1) { - vmess.address = arg1.toStdString(); - shadowsocks.address = arg1.toStdString(); - socks.address = arg1.toStdString(); + vmess.address = arg1; + shadowsocks.address = arg1; + socks.address = arg1; } void OutboundEditor::on_portLineEdit_textEdited(const QString &arg1) { if (arg1 != "") { - vmess.port = stoi(arg1.toStdString()); - shadowsocks.port = stoi(arg1.toStdString()); - socks.port = stoi(arg1.toStdString()); + vmess.port = arg1.toInt(); + shadowsocks.port = arg1.toInt(); + socks.port = arg1.toInt(); } } @@ -184,24 +186,24 @@ void OutboundEditor::on_idLineEdit_textEdited(const QString &arg1) { if (vmess.users.empty()) vmess.users.push_back(VMessServerObject::UserObject()); - vmess.users.front().id = arg1.toStdString(); + vmess.users.front().id = arg1; } void OutboundEditor::on_securityCombo_currentIndexChanged(const QString &arg1) { if (vmess.users.empty()) vmess.users.push_back(VMessServerObject::UserObject()); - vmess.users.front().security = arg1.toStdString(); + vmess.users.front().security = arg1; } void OutboundEditor::on_tranportCombo_currentIndexChanged(const QString &arg1) { - stream.network = arg1.toStdString(); + stream.network = arg1; } void OutboundEditor::on_httpPathTxt_textEdited(const QString &arg1) { - stream.httpSettings.path = arg1.toStdString(); + stream.httpSettings.path = arg1; } void OutboundEditor::on_httpHostTxt_textChanged() @@ -212,7 +214,7 @@ void OutboundEditor::on_httpHostTxt_textChanged() foreach (auto host, hosts) { if (host.trimmed() != "") - stream.httpSettings.host.push_back(host.trimmed().toStdString()); + stream.httpSettings.host.push_back(host.trimmed()); } BLACK(httpHostTxt) @@ -230,11 +232,11 @@ void OutboundEditor::on_wsHeadersTxt_textChanged() foreach (auto header, headers) { if (header.isEmpty()) continue; - auto content = header.split("|"); + auto index = header.indexOf("|"); - if (content.length() < 2) throw "fast fail to set RED color"; + if (index < 0) throw "fast fail to set RED color"; - stream.wsSettings.headers.insert(make_pair(content[0].toStdString(), content[1].toStdString())); + stream.wsSettings.headers[header.left(index)] = header.right(index + 1); } BLACK(wsHeadersTxt) @@ -303,27 +305,27 @@ void OutboundEditor::on_tcpFastOpenCB_stateChanged(int arg1) } void OutboundEditor::on_tProxyCB_currentIndexChanged(const QString &arg1) { - stream.sockopt.tproxy = arg1.toStdString(); + stream.sockopt.tproxy = arg1; } void OutboundEditor::on_quicSecurityCB_currentTextChanged(const QString &arg1) { - stream.quicSettings.security = arg1.toStdString(); + stream.quicSettings.security = arg1; } void OutboundEditor::on_quicKeyTxt_textEdited(const QString &arg1) { - stream.quicSettings.key = arg1.toStdString(); + stream.quicSettings.key = arg1; } void OutboundEditor::on_quicHeaderTypeCB_currentIndexChanged(const QString &arg1) { - stream.quicSettings.header.type = arg1.toStdString(); + stream.quicSettings.header.type = arg1; } void OutboundEditor::on_tcpHeaderTypeCB_currentIndexChanged(const QString &arg1) { - stream.tcpSettings.header.type = arg1.toStdString(); + stream.tcpSettings.header.type = arg1; } void OutboundEditor::on_wsPathTxt_textEdited(const QString &arg1) { - stream.wsSettings.path = arg1.toStdString(); + stream.wsSettings.path = arg1; } void OutboundEditor::on_kcpMTU_valueChanged(int arg1) { @@ -355,7 +357,7 @@ void OutboundEditor::on_kcpWriteBufferSB_valueChanged(int arg1) } void OutboundEditor::on_kcpHeaderType_currentTextChanged(const QString &arg1) { - stream.kcpSettings.header.type = arg1.toStdString(); + stream.kcpSettings.header.type = arg1; } void OutboundEditor::on_tranportCombo_currentIndexChanged(int index) { @@ -363,7 +365,7 @@ void OutboundEditor::on_tranportCombo_currentIndexChanged(int index) } void OutboundEditor::on_dsPathTxt_textEdited(const QString &arg1) { - stream.dsSettings.path = arg1.toStdString(); + stream.dsSettings.path = arg1; } void OutboundEditor::on_outBoundTypeCombo_currentIndexChanged(int index) { @@ -373,17 +375,17 @@ void OutboundEditor::on_outBoundTypeCombo_currentIndexChanged(int index) void OutboundEditor::on_ss_emailTxt_textEdited(const QString &arg1) { - shadowsocks.email = arg1.toStdString(); + shadowsocks.email = arg1; } void OutboundEditor::on_ss_passwordTxt_textEdited(const QString &arg1) { - shadowsocks.password = arg1.toStdString(); + shadowsocks.password = arg1; } void OutboundEditor::on_ss_encryptionMethod_currentIndexChanged(const QString &arg1) { - shadowsocks.method = arg1.toStdString(); + shadowsocks.method = arg1; } void OutboundEditor::on_ss_levelSpin_valueChanged(int arg1) @@ -398,12 +400,12 @@ void OutboundEditor::on_ss_otaCheckBox_stateChanged(int arg1) void OutboundEditor::on_socks_UserNameTxt_textEdited(const QString &arg1) { - socks.users.front().user = arg1.toStdString(); + socks.users.front().user = arg1; } void OutboundEditor::on_socks_PasswordTxt_textEdited(const QString &arg1) { - socks.users.front().pass = arg1.toStdString(); + socks.users.front().pass = arg1; } void OutboundEditor::on_tcpRequestEditBtn_clicked() diff --git a/src/ui/w_PreferencesWindow.cpp b/src/ui/w_PreferencesWindow.cpp index 5ea606aa..2a333839 100644 --- a/src/ui/w_PreferencesWindow.cpp +++ b/src/ui/w_PreferencesWindow.cpp @@ -39,7 +39,7 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent), qvBuildTime->setText(__DATE__ " " __TIME__); CurrentConfig = GetGlobalConfig(); // - themeCombo->setCurrentText(QSTRING(CurrentConfig.uiConfig.theme)); + themeCombo->setCurrentText(CurrentConfig.uiConfig.theme); darkThemeCB->setChecked(CurrentConfig.uiConfig.useDarkTheme); darkTrayCB->setChecked(CurrentConfig.uiConfig.useDarkTrayIcon); #ifdef QV2RAY_USE_BUILTIN_DARKTHEME @@ -47,12 +47,12 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent), themeCombo->setEnabled(!CurrentConfig.uiConfig.useDarkTheme); darkThemeLabel->setText(tr("Use Darkmode Theme")); #endif - languageComboBox->setCurrentText(QSTRING(CurrentConfig.uiConfig.language)); + languageComboBox->setCurrentText(CurrentConfig.uiConfig.language); logLevelComboBox->setCurrentIndex(CurrentConfig.logLevel); tProxyCheckBox->setChecked(CurrentConfig.tProxySupport); // // - listenIPTxt->setText(QSTRING(CurrentConfig.inboundConfig.listenip)); + listenIPTxt->setText(CurrentConfig.inboundConfig.listenip); bool pacEnabled = CurrentConfig.inboundConfig.pacConfig.enablePAC; enablePACCB->setChecked(pacEnabled); setSysProxyCB->setChecked(CurrentConfig.inboundConfig.setSystemProxy); @@ -60,7 +60,7 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent), // PAC pacGroupBox->setEnabled(pacEnabled); pacPortSB->setValue(CurrentConfig.inboundConfig.pacConfig.port); - pacProxyTxt->setText(QSTRING(CurrentConfig.inboundConfig.pacConfig.localIP)); + pacProxyTxt->setText(CurrentConfig.inboundConfig.pacConfig.localIP); pacProxyCB->setCurrentIndex(CurrentConfig.inboundConfig.pacConfig.useSocksProxy ? 1 : 0); // bool have_http = CurrentConfig.inboundConfig.useHTTP; @@ -71,8 +71,8 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent), httpAuthCB->setChecked(CurrentConfig.inboundConfig.http_useAuth); httpAuthUsernameTxt->setEnabled(CurrentConfig.inboundConfig.http_useAuth); httpAuthPasswordTxt->setEnabled(CurrentConfig.inboundConfig.http_useAuth); - httpAuthUsernameTxt->setText(QSTRING(CurrentConfig.inboundConfig.httpAccount.user)); - httpAuthPasswordTxt->setText(QSTRING(CurrentConfig.inboundConfig.httpAccount.pass)); + httpAuthUsernameTxt->setText(CurrentConfig.inboundConfig.httpAccount.user); + httpAuthPasswordTxt->setText(CurrentConfig.inboundConfig.httpAccount.pass); httpGroupBox->setEnabled(have_http); // // @@ -83,17 +83,17 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent), socksAuthCB->setChecked(CurrentConfig.inboundConfig.socks_useAuth); socksAuthUsernameTxt->setEnabled(CurrentConfig.inboundConfig.socks_useAuth); socksAuthPasswordTxt->setEnabled(CurrentConfig.inboundConfig.socks_useAuth); - socksAuthUsernameTxt->setText(QSTRING(CurrentConfig.inboundConfig.socksAccount.user)); - socksAuthPasswordTxt->setText(QSTRING(CurrentConfig.inboundConfig.socksAccount.pass)); + socksAuthUsernameTxt->setText(CurrentConfig.inboundConfig.socksAccount.user); + socksAuthPasswordTxt->setText(CurrentConfig.inboundConfig.socksAccount.pass); // Socks UDP Options socksUDPCB->setChecked(CurrentConfig.inboundConfig.socksUDP); socksUDPIP->setEnabled(CurrentConfig.inboundConfig.socksUDP); - socksUDPIP->setText(QSTRING(CurrentConfig.inboundConfig.socksLocalIP)); + socksUDPIP->setText(CurrentConfig.inboundConfig.socksLocalIP); socksGroupBox->setEnabled(have_socks); // // - vCorePathTxt->setText(QSTRING(CurrentConfig.v2CorePath)); - vCoreAssetsPathTxt->setText(QSTRING(CurrentConfig.v2AssetsPath)); + vCorePathTxt->setText(CurrentConfig.v2CorePath); + vCoreAssetsPathTxt->setText(CurrentConfig.v2AssetsPath); statsPortBox->setValue(CurrentConfig.connectionConfig.statsPort); // // @@ -105,7 +105,7 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent), DNSListTxt->clear(); foreach (auto dnsStr, CurrentConfig.connectionConfig.dnsList) { - auto str = QString::fromStdString(dnsStr).trimmed(); + auto str = dnsStr.trimmed(); if (!str.isEmpty()) { DNSListTxt->appendPlainText(str); @@ -114,9 +114,9 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent), // cancelIgnoreVersionBtn->setEnabled(CurrentConfig.ignoredVersion != ""); - ignoredNextVersion->setText(QSTRING(CurrentConfig.ignoredVersion)); + ignoredNextVersion->setText(CurrentConfig.ignoredVersion); - for (size_t i = 0; i < CurrentConfig.toolBarConfig.Pages.size(); i++) { + for (auto i = 0; i < CurrentConfig.toolBarConfig.Pages.size(); i++) { nsBarPagesList->addItem(tr("Page") + QString::number(i + 1) + ": " + QString::number(CurrentConfig.toolBarConfig.Pages[i].Lines.size()) + " " + tr("Item(s)")); } @@ -134,20 +134,20 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent), CurrentBarPageId = 0; // // Empty for global config. - auto autoSub = QSTRING(CurrentConfig.autoStartConfig.subscriptionName); - auto autoCon = QSTRING(CurrentConfig.autoStartConfig.connectionName); + auto autoSub = CurrentConfig.autoStartConfig.subscriptionName; + auto autoCon = CurrentConfig.autoStartConfig.connectionName; autoStartConnCombo->addItem(""); - for (auto item : CurrentConfig.subscriptions) { - autoStartSubsCombo->addItem(QSTRING(item.first)); + for (auto item : CurrentConfig.subscriptions.keys()) { + autoStartSubsCombo->addItem(item); } autoStartSubsCombo->setCurrentText(autoSub); - if (CurrentConfig.autoStartConfig.subscriptionName.empty()) { - autoStartConnCombo->addItems(ConvertQStringList(toQList(CurrentConfig.configs))); + if (CurrentConfig.autoStartConfig.subscriptionName.isEmpty()) { + autoStartConnCombo->addItems(CurrentConfig.configs); } else { - auto list = GetSubscriptionConnection(autoSub.toStdString()); + auto list = GetSubscriptionConnection(autoSub); autoStartConnCombo->addItems(list.keys()); } @@ -215,7 +215,7 @@ void PreferencesWindow::on_languageComboBox_currentTextChanged(const QString &ar // A strange bug prevents us to change the UI language online // https://github.com/lhy0403/Qv2ray/issues/34 // - CurrentConfig.uiConfig.language = arg1.toStdString(); + CurrentConfig.uiConfig.language = arg1; // // //if (QApplication::installTranslator(getTranslator(arg1))) { @@ -237,38 +237,38 @@ void PreferencesWindow::on_logLevelComboBox_currentIndexChanged(int index) void PreferencesWindow::on_vCoreAssetsPathTxt_textEdited(const QString &arg1) { NEEDRESTART - CurrentConfig.v2AssetsPath = arg1.toStdString(); + CurrentConfig.v2AssetsPath = arg1; } void PreferencesWindow::on_listenIPTxt_textEdited(const QString &arg1) { NEEDRESTART - CurrentConfig.inboundConfig.listenip = arg1.toStdString(); + CurrentConfig.inboundConfig.listenip = arg1; //pacAccessPathTxt->setText("http://" + arg1 + ":" + QString::number(pacPortSB->value()) + "/pac"); } void PreferencesWindow::on_httpAuthUsernameTxt_textEdited(const QString &arg1) { NEEDRESTART - CurrentConfig.inboundConfig.httpAccount.user = arg1.toStdString(); + CurrentConfig.inboundConfig.httpAccount.user = arg1; } void PreferencesWindow::on_httpAuthPasswordTxt_textEdited(const QString &arg1) { NEEDRESTART - CurrentConfig.inboundConfig.httpAccount.pass = arg1.toStdString(); + CurrentConfig.inboundConfig.httpAccount.pass = arg1; } void PreferencesWindow::on_socksAuthUsernameTxt_textEdited(const QString &arg1) { NEEDRESTART - CurrentConfig.inboundConfig.socksAccount.user = arg1.toStdString(); + CurrentConfig.inboundConfig.socksAccount.user = arg1; } void PreferencesWindow::on_socksAuthPasswordTxt_textEdited(const QString &arg1) { NEEDRESTART - CurrentConfig.inboundConfig.socksAccount.pass = arg1.toStdString(); + CurrentConfig.inboundConfig.socksAccount.pass = arg1; } void PreferencesWindow::on_proxyDefaultCb_stateChanged(int arg1) @@ -307,7 +307,7 @@ void PreferencesWindow::on_selectVCoreBtn_clicked() void PreferencesWindow::on_vCorePathTxt_textEdited(const QString &arg1) { NEEDRESTART - CurrentConfig.v2CorePath = arg1.toStdString(); + CurrentConfig.v2CorePath = arg1; } void PreferencesWindow::on_DNSListTxt_textChanged() @@ -320,7 +320,7 @@ void PreferencesWindow::on_DNSListTxt_textChanged() foreach (auto host, hosts) { if (host != "" && host != "\r") { // Not empty, so we save. - CurrentConfig.connectionConfig.dnsList.push_back(host.toStdString()); + CurrentConfig.connectionConfig.dnsList.push_back(host); NEEDRESTART } } @@ -364,8 +364,8 @@ void PreferencesWindow::on_tProxyCheckBox_stateChanged(int arg1) LOG(MODULE_UI, "Canceled enabling tProxy feature.") } else { LOG(MODULE_VCORE, "ENABLING tProxy Support") - LOG(MODULE_FILE, " --> Origin v2ray core file is at: " + CurrentConfig.v2CorePath) - auto v2ctlPath = QFileInfo(QSTRING(CurrentConfig.v2CorePath)).path() + "/v2ctl"; + LOG(MODULE_FILE, " --> Origin v2ray core file is at: " + CurrentConfig.v2CorePath.toStdString()) + auto v2ctlPath = QFileInfo(CurrentConfig.v2CorePath).path() + "/v2ctl"; auto newPath = QFileInfo(QV2RAY_DEFAULT_VCORE_PATH).path(); // LOG(MODULE_FILE, " --> Origin v2ctl file is at: " + v2ctlPath.toStdString()) @@ -373,7 +373,7 @@ void PreferencesWindow::on_tProxyCheckBox_stateChanged(int arg1) // LOG(MODULE_FILE, " --> Copying files....") - if (QFileInfo(QSTRING(CurrentConfig.v2CorePath)).absoluteFilePath() != QFileInfo(QV2RAY_DEFAULT_VCORE_PATH).absoluteFilePath()) { + if (QFileInfo(CurrentConfig.v2CorePath).absoluteFilePath() != QFileInfo(QV2RAY_DEFAULT_VCORE_PATH).absoluteFilePath()) { // Only trying to remove file when they are not in the default dir. // (In other words...) Keep using the current files. if (QFile(QV2RAY_DEFAULT_VCORE_PATH).exists()) { @@ -388,7 +388,7 @@ void PreferencesWindow::on_tProxyCheckBox_stateChanged(int arg1) QFile(newPath + "/v2ctl").remove(); } - string vCoreresult = QFile(QSTRING(CurrentConfig.v2CorePath)).copy(QV2RAY_DEFAULT_VCORE_PATH) ? "OK" : "FAILED"; + string vCoreresult = QFile(CurrentConfig.v2CorePath).copy(QV2RAY_DEFAULT_VCORE_PATH) ? "OK" : "FAILED"; LOG(MODULE_FILE, " --> v2ray Core: " + vCoreresult) // string vCtlresult = QFile(v2ctlPath).copy(newPath + "/v2ctl") ? "OK" : "FAILED"; @@ -402,7 +402,7 @@ void PreferencesWindow::on_tProxyCheckBox_stateChanged(int arg1) LOG(MODULE_VCORE, "FAILED to copy v2ray files. Aborting.") QvMessageBox(this, tr("Enable tProxy Support"), tr("Qv2ray cannot copy one or both v2ray files from: ") + NEWLINE + NEWLINE + - QSTRING(CurrentConfig.v2CorePath) + NEWLINE + v2ctlPath + NEWLINE + NEWLINE + + CurrentConfig.v2CorePath + NEWLINE + v2ctlPath + NEWLINE + NEWLINE + tr("to this path: ") + NEWLINE + newPath); return; } @@ -412,7 +412,7 @@ void PreferencesWindow::on_tProxyCheckBox_stateChanged(int arg1) } LOG(MODULE_UI, "Calling pkexec and setcap...") - int ret = QProcess::execute("pkexec setcap CAP_NET_ADMIN,CAP_NET_RAW,CAP_NET_BIND_SERVICE=eip " + QSTRING(CurrentConfig.v2CorePath)); + int ret = QProcess::execute("pkexec setcap CAP_NET_ADMIN,CAP_NET_RAW,CAP_NET_BIND_SERVICE=eip " + CurrentConfig.v2CorePath); if (ret != 0) { LOG(MODULE_UI, "WARN: setcap exits with code: " + to_string(ret)) @@ -423,7 +423,7 @@ void PreferencesWindow::on_tProxyCheckBox_stateChanged(int arg1) NEEDRESTART } } else { - int ret = QProcess::execute("pkexec setcap -r " + QSTRING(CurrentConfig.v2CorePath)); + int ret = QProcess::execute("pkexec setcap -r " + CurrentConfig.v2CorePath); if (ret != 0) { LOG(MODULE_UI, "WARN: setcap exits with code: " + to_string(ret)) @@ -478,7 +478,7 @@ void PreferencesWindow::on_socksUDPCB_stateChanged(int arg1) void PreferencesWindow::on_socksUDPIP_textEdited(const QString &arg1) { NEEDRESTART - CurrentConfig.inboundConfig.socksLocalIP = arg1.toStdString(); + CurrentConfig.inboundConfig.socksLocalIP = arg1; } // ------------------- NET SPEED PLUGIN OPERATIONS ----------------------------------------------------------------- @@ -511,7 +511,7 @@ void PreferencesWindow::on_nsBarPageAddBTN_clicked() void PreferencesWindow::on_nsBarPageDelBTN_clicked() { if (nsBarPagesList->currentRow() >= 0) { - RemoveItem(CurrentConfig.toolBarConfig.Pages, static_cast(nsBarPagesList->currentRow())); + CurrentConfig.toolBarConfig.Pages.removeAt(nsBarPagesList->currentRow()); nsBarPagesList->takeItem(nsBarPagesList->currentRow()); if (nsBarPagesList->count() <= 0) { @@ -548,7 +548,7 @@ void PreferencesWindow::on_nsBarLineAddBTN_clicked() void PreferencesWindow::on_nsBarLineDelBTN_clicked() { if (nsBarLinesList->currentRow() >= 0) { - RemoveItem(CurrentBarPage.Lines, static_cast(nsBarLinesList->currentRow())); + CurrentBarPage.Lines.removeAt(nsBarLinesList->currentRow()); nsBarLinesList->takeItem(nsBarLinesList->currentRow()); CurrentBarLineId = 0; @@ -597,7 +597,7 @@ void PreferencesWindow::on_nsBarLinesList_currentRowChanged(int currentRow) void PreferencesWindow::on_fontComboBox_currentFontChanged(const QFont &f) { LOADINGCHECK - CurrentBarLine.Family = f.family().toStdString(); + CurrentBarLine.Family = f.family(); SET_LINE_LIST_TEXT } @@ -660,7 +660,7 @@ QString PreferencesWindow::GetBarLineDescription(QvBarLine barLine) result = NetSpeedPluginMessages[barLine.ContentType]; if (barLine.ContentType == 0) { - result += " (" + QSTRING(barLine.Message) + ")"; + result += " (" + barLine.Message + ")"; } result = result.append(barLine.Bold ? ", " + tr("Bold") : ""); @@ -672,8 +672,8 @@ void PreferencesWindow::ShowLineParameters(QvBarLine &barLine) { finishedLoading = false; - if (!barLine.Family.empty()) { - fontComboBox->setCurrentFont(QFont(QSTRING(barLine.Family))); + if (!barLine.Family.isEmpty()) { + fontComboBox->setCurrentFont(QFont(barLine.Family)); } // Colors @@ -683,16 +683,16 @@ void PreferencesWindow::ShowLineParameters(QvBarLine &barLine) nsBarFontRSB->setValue(barLine.ColorR); // QColor color = QColor::fromRgb(barLine.ColorR, barLine.ColorG, barLine.ColorB, barLine.ColorA); - QString s("background: #" - + QString(color.red() < 16 ? "0" : "") + QString::number(color.red(), 16) - + QString(color.green() < 16 ? "0" : "") + QString::number(color.green(), 16) - + QString(color.blue() < 16 ? "0" : "") + QString::number(color.blue(), 16) + ";"); + QString s(QStringLiteral("background: #") + + ((color.red() < 16) ? "0" : "") + QString::number(color.red(), 16) + + ((color.green() < 16) ? "0" : "") + QString::number(color.green(), 16) + + ((color.blue() < 16) ? "0" : "") + QString::number(color.blue(), 16) + ";"); chooseColorBtn->setStyleSheet(s); nsBarFontSizeSB->setValue(barLine.Size); nsBarFontBoldCB->setChecked(barLine.Bold); nsBarFontItalicCB->setChecked(barLine.Italic); nsBarContentCombo->setCurrentText(NetSpeedPluginMessages[barLine.ContentType]); - nsBarTagTxt->setText(QSTRING(barLine.Message)); + nsBarTagTxt->setText(barLine.Message); finishedLoading = true; nsBarVerticalLayout->setEnabled(true); } @@ -713,7 +713,7 @@ void PreferencesWindow::on_chooseColorBtn_clicked() void PreferencesWindow::on_nsBarTagTxt_textEdited(const QString &arg1) { LOADINGCHECK - CurrentBarLine.Message = arg1.toStdString(); + CurrentBarLine.Message = arg1; SET_LINE_LIST_TEXT } @@ -734,7 +734,7 @@ void PreferencesWindow::on_applyNSBarSettingsBtn_clicked() void PreferencesWindow::on_themeCombo_currentTextChanged(const QString &arg1) { LOADINGCHECK - CurrentConfig.uiConfig.theme = arg1.toStdString(); + CurrentConfig.uiConfig.theme = arg1; } void PreferencesWindow::on_darkThemeCB_stateChanged(int arg1) @@ -864,20 +864,20 @@ void PreferencesWindow::on_pacProxyTxt_textEdited(const QString &arg1) { LOADINGCHECK NEEDRESTART - CurrentConfig.inboundConfig.pacConfig.localIP = arg1.toStdString(); + CurrentConfig.inboundConfig.pacConfig.localIP = arg1; } void PreferencesWindow::on_autoStartSubsCombo_currentIndexChanged(const QString &arg1) { LOADINGCHECK - CurrentConfig.autoStartConfig.subscriptionName = arg1.toStdString(); + CurrentConfig.autoStartConfig.subscriptionName = arg1; autoStartConnCombo->clear(); if (arg1.isEmpty()) { autoStartConnCombo->addItem(""); - autoStartConnCombo->addItems(ConvertQStringList(toQList(CurrentConfig.configs))); + autoStartConnCombo->addItems(CurrentConfig.configs); } else { - auto list = GetSubscriptionConnection(arg1.toStdString()); + auto list = GetSubscriptionConnection(arg1); autoStartConnCombo->addItems(list.keys()); } } @@ -885,7 +885,7 @@ void PreferencesWindow::on_autoStartSubsCombo_currentIndexChanged(const QString void PreferencesWindow::on_autoStartConnCombo_currentIndexChanged(const QString &arg1) { LOADINGCHECK - CurrentConfig.autoStartConfig.connectionName = arg1.toStdString(); + CurrentConfig.autoStartConfig.connectionName = arg1; } void PreferencesWindow::on_installBootStart_clicked() diff --git a/src/ui/w_RoutesEditor.cpp b/src/ui/w_RoutesEditor.cpp index 017a9f90..95691714 100644 --- a/src/ui/w_RoutesEditor.cpp +++ b/src/ui/w_RoutesEditor.cpp @@ -189,17 +189,17 @@ void RouteEditor::onConnectionCreated(QtNodes::Connection const &c) // caused by multi-in connection _inbounds.removeDuplicates(); - CurrentRule.inboundTag = ConvertStdStringList(_inbounds); + CurrentRule.inboundTag = _inbounds; } else if (ruleNodes.values().contains(sourceNode) && outboundNodes.values().contains(targetNode)) { // It's a rule-outbound connection onNodeClicked(*sourceNode); onNodeClicked(*targetNode); - CurrentRule.outboundTag = GetFirstNodeData((*targetNode), QvOutboundNodeModel, OutboundNodeData)->GetOutbound().toStdString(); + CurrentRule.outboundTag = GetFirstNodeData((*targetNode), QvOutboundNodeModel, OutboundNodeData)->GetOutbound(); // Connecting to an outbound will disable the balancer feature. CurrentRule.QV2RAY_RULE_USE_BALANCER = false; // Update balancer settings. ShowCurrentRuleDetail(); - LOG(MODULE_GRAPH, "Updated outbound: " + CurrentRule.outboundTag) + LOG(MODULE_GRAPH, "Updated outbound: " + CurrentRule.outboundTag.toStdString()) } else { // It's an impossible connection LOG(MODULE_GRAPH, "Unrecognized connection, RARE.") @@ -223,7 +223,7 @@ void RouteEditor::onConnectionDeleted(QtNodes::Connection const &c) currentRuleTag = GetFirstNodeData(*target, QvRuleNodeDataModel, RuleNodeData)->GetRuleTag(); auto _inboundTag = GetFirstNodeData(*source, QvInboundNodeModel, InboundNodeData)->GetInbound(); LOG(MODULE_UI, "Removing inbound: " + _inboundTag.toStdString() + " from rule: " + currentRuleTag.toStdString()) - CurrentRule.inboundTag.remove(_inboundTag.toStdString()); + CurrentRule.inboundTag.removeAll(_inboundTag); } else if (ruleNodes.values().contains(source) && outboundNodes.values().contains(target)) { // It's a rule-outbound connection onNodeClicked(*source); @@ -231,7 +231,7 @@ void RouteEditor::onConnectionDeleted(QtNodes::Connection const &c) currentRuleTag = GetFirstNodeData(*source, QvRuleNodeDataModel, RuleNodeData)->GetRuleTag(); auto _outboundTag = GetFirstNodeData(*target, QvOutboundNodeModel, OutboundNodeData)->GetOutbound(); - if (!CurrentRule.QV2RAY_RULE_USE_BALANCER && CurrentRule.outboundTag == _outboundTag.toStdString()) { + if (!CurrentRule.QV2RAY_RULE_USE_BALANCER && CurrentRule.outboundTag == _outboundTag) { CurrentRule.outboundTag.clear(); } @@ -267,23 +267,23 @@ CONFIGROOT RouteEditor::OpenEditor() ruleJsonObject.remove("outboundTag"); // Find balancer list - if (!_balancers.contains(QSTRING(_rule.balancerTag))) { - LOG(MODULE_UI, "Cannot find a balancer for tag: " + _rule.balancerTag) + if (!_balancers.contains(_rule.balancerTag)) { + LOG(MODULE_UI, "Cannot find a balancer for tag: " + _rule.balancerTag.toStdString()) } else { - auto _balancerList = balancers[QSTRING(_rule.balancerTag)]; + auto _balancerList = balancers[_rule.balancerTag]; QJsonObject balancerEntry; - balancerEntry["tag"] = QSTRING(_rule.balancerTag); + balancerEntry["tag"] = _rule.balancerTag; balancerEntry["selector"] = QJsonArray::fromStringList(_balancerList); _balancers.append(balancerEntry); } } // Remove some empty fields. - if (_rule.port.empty()) { + if (_rule.port.isEmpty()) { ruleJsonObject.remove("port"); } - if (_rule.network.empty()) { + if (_rule.network.isEmpty()) { ruleJsonObject.remove("network"); } @@ -337,7 +337,7 @@ void RouteEditor::ShowCurrentRuleDetail() ruleEnableCB->setEnabled(true); ruleEnableCB->setChecked(CurrentRule.QV2RAY_RULE_ENABLED); LOAD_FLAG_BEGIN - ruleTagLineEdit->setText(QSTRING(CurrentRule.QV2RAY_RULE_TAG)); + ruleTagLineEdit->setText(CurrentRule.QV2RAY_RULE_TAG); balancerSelectionCombo->clear(); // BUG added the wrong items, should be outbound list. @@ -350,27 +350,27 @@ void RouteEditor::ShowCurrentRuleDetail() enableBalancerCB->setChecked(CurrentRule.QV2RAY_RULE_USE_BALANCER); balancersWidget->setEnabled(CurrentRule.QV2RAY_RULE_USE_BALANCER); - if (!QSTRING(CurrentRule.balancerTag).isEmpty()) { + if (!CurrentRule.balancerTag.isEmpty()) { balancerList->clear(); - balancerList->addItems(balancers[QSTRING(CurrentRule.balancerTag)]); + balancerList->addItems(balancers[CurrentRule.balancerTag]); } isLoading = false; // Networks - auto network = QSTRING(CurrentRule.network).toLower(); + auto network = CurrentRule.network.toLower(); bool isBoth = (network.contains("tcp") && network.contains("udp")) || network.isEmpty(); netUDPRB->setChecked(network.contains("udp")); netTCPRB->setChecked(network.contains("tcp")); netBothRB->setChecked(isBoth); // // Set protocol checkboxes. - auto protocol = toQList(CurrentRule.protocol); + auto protocol = CurrentRule.protocol; routeProtocolHTTPCB->setChecked(protocol.contains("http")); routeProtocolTLSCB->setChecked(protocol.contains("tls")); routeProtocolBTCB->setChecked(protocol.contains("bittorrent")); // // Port - routePortTxt->setText(QSTRING(CurrentRule.port)); + routePortTxt->setText(CurrentRule.port); // // Users QString users = Stringify(CurrentRule.user, NEWLINE); @@ -401,7 +401,7 @@ void RouteEditor::on_insertDirectBtn_clicked() void RouteEditor::on_routeProtocolHTTPCB_stateChanged(int arg1) { LOADINGCHECK - list protocols; + QStringList protocols; if (arg1 == Qt::Checked) protocols.push_back("http"); @@ -415,7 +415,7 @@ void RouteEditor::on_routeProtocolHTTPCB_stateChanged(int arg1) void RouteEditor::on_routeProtocolTLSCB_stateChanged(int arg1) { LOADINGCHECK - list protocols; + QStringList protocols; if (arg1 == Qt::Checked) protocols.push_back("tls"); @@ -429,7 +429,7 @@ void RouteEditor::on_routeProtocolTLSCB_stateChanged(int arg1) void RouteEditor::on_routeProtocolBTCB_stateChanged(int arg1) { LOADINGCHECK - list protocols; + QStringList protocols; if (arg1 == Qt::Checked) protocols.push_back("bittorrent"); @@ -446,7 +446,7 @@ void RouteEditor::on_balancerAddBtn_clicked() auto balancerTx = balancerSelectionCombo->currentText(); if (!balancerTx.isEmpty()) { - this->balancers[QSTRING(CurrentRule.balancerTag)].append(balancerSelectionCombo->currentText()); + this->balancers[CurrentRule.balancerTag].append(balancerSelectionCombo->currentText()); balancerList->addItem(balancerTx); balancerSelectionCombo->setEditText(""); statusLabel->setText(tr("OK")); @@ -462,29 +462,29 @@ void RouteEditor::on_balancerDelBtn_clicked() return; } - balancers[QSTRING(CurrentRule.balancerTag)].removeAt(balancerList->currentRow()); + balancers[CurrentRule.balancerTag].removeAt(balancerList->currentRow()); balancerList->takeItem(balancerList->currentRow()); statusLabel->setText(tr("Removed a balancer entry.")); } void RouteEditor::on_hostList_textChanged() { LOADINGCHECK - CurrentRule.domain = SplitLines_std(hostList->toPlainText()); + CurrentRule.domain = SplitLines(hostList->toPlainText()); } void RouteEditor::on_ipList_textChanged() { LOADINGCHECK - CurrentRule.ip = SplitLines_std(ipList->toPlainText()); + CurrentRule.ip = SplitLines(ipList->toPlainText()); } void RouteEditor::on_routePortTxt_textEdited(const QString &arg1) { LOADINGCHECK - CurrentRule.port = arg1.toStdString(); + CurrentRule.port = arg1; } void RouteEditor::on_routeUserTxt_textEdited(const QString &arg1) { LOADINGCHECK - CurrentRule.user = SplitLines_std(arg1); + CurrentRule.user = SplitLines(arg1); } void RouteEditor::on_addRouteBtn_clicked() { @@ -496,8 +496,8 @@ void RouteEditor::on_addRouteBtn_clicked() rule.QV2RAY_RULE_USE_BALANCER = false; // Default balancer tag, it's a random string. auto bTag = GenerateRandomString(); - rule.QV2RAY_RULE_TAG = GenerateRandomString(5).toStdString(); - rule.balancerTag = bTag.toStdString(); + rule.QV2RAY_RULE_TAG = GenerateRandomString(5); + rule.balancerTag = bTag; balancers[bTag] = QStringList(); AddNewRule(rule); } @@ -519,12 +519,12 @@ void RouteEditor::on_netTCPRB_clicked() void RouteEditor::on_routeUserTxt_textChanged() { LOADINGCHECK - CurrentRule.user = SplitLines_std(routeUserTxt->toPlainText()); + CurrentRule.user = SplitLines(routeUserTxt->toPlainText()); } void RouteEditor::on_sourceIPList_textChanged() { LOADINGCHECK - CurrentRule.source = SplitLines_std(sourceIPList->toPlainText()); + CurrentRule.source = SplitLines(sourceIPList->toPlainText()); } void RouteEditor::on_enableBalancerCB_stateChanged(int arg1) { @@ -533,13 +533,13 @@ void RouteEditor::on_enableBalancerCB_stateChanged(int arg1) CurrentRule.QV2RAY_RULE_USE_BALANCER = useBalancer; balancersWidget->setEnabled(useBalancer); - if (CurrentRule.balancerTag.empty()) { + if (CurrentRule.balancerTag.isEmpty()) { LOG(MODULE_UI, "Creating a new balancer tag.") - CurrentRule.balancerTag = GenerateRandomString(6).toStdString(); - balancers[QSTRING(CurrentRule.balancerTag)] = QStringList(); + CurrentRule.balancerTag = GenerateRandomString(6); + balancers[CurrentRule.balancerTag] = QStringList(); } - DEBUG(MODULE_UI, "Balancer: " + CurrentRule.balancerTag) + DEBUG(MODULE_UI, "Balancer: " + CurrentRule.balancerTag.toStdString()) if (useBalancer) { LOG(MODULE_UI, "A rule has been set to use balancer, disconnect it to any outbound.") @@ -565,10 +565,10 @@ void RouteEditor::on_addDefaultBtn_clicked() auto _in_httpConf = GenerateHTTPIN(QList() << _Inconfig.httpAccount); auto _in_socksConf = GenerateSocksIN((_Inconfig.socks_useAuth ? "password" : "noauth"), QList() << _Inconfig.socksAccount, - _Inconfig.socksUDP, QSTRING(_Inconfig.socksLocalIP)); + _Inconfig.socksUDP, _Inconfig.socksLocalIP); // - auto _in_HTTP = GenerateInboundEntry(QSTRING(_Inconfig.listenip), _Inconfig.http_port, "http", _in_httpConf, "HTTP_gConf"); - auto _in_SOCKS = GenerateInboundEntry(QSTRING(_Inconfig.listenip), _Inconfig.socks_port, "socks", _in_socksConf, "SOCKS_gConf"); + auto _in_HTTP = GenerateInboundEntry(_Inconfig.listenip, _Inconfig.http_port, "http", _in_httpConf, "HTTP_gConf"); + auto _in_SOCKS = GenerateInboundEntry(_Inconfig.listenip, _Inconfig.socks_port, "socks", _in_socksConf, "SOCKS_gConf"); // AddNewInbound(_in_HTTP); AddNewInbound(_in_SOCKS); @@ -769,5 +769,5 @@ void RouteEditor::on_defaultOutboundCombo_currentIndexChanged(const QString &arg void RouteEditor::on_ruleTagLineEdit_textEdited(const QString &arg1) { - RenameItemTag(RENAME_RULE, QSTRING(CurrentRule.QV2RAY_RULE_TAG), arg1); + RenameItemTag(RENAME_RULE, CurrentRule.QV2RAY_RULE_TAG, arg1); } diff --git a/src/ui/w_RoutesEditor_extra.cpp b/src/ui/w_RoutesEditor_extra.cpp index d78f530e..3d26f9a2 100644 --- a/src/ui/w_RoutesEditor_extra.cpp +++ b/src/ui/w_RoutesEditor_extra.cpp @@ -36,30 +36,30 @@ void RouteEditor::AddNewOutbound(OUTBOUND out) void RouteEditor::AddNewRule(RuleObject rule) { // Prevent duplicate - if (ruleNodes.contains(QSTRING(rule.QV2RAY_RULE_TAG))) { - rule.QV2RAY_RULE_TAG += "-" + GenerateRandomString(5).toStdString(); + if (ruleNodes.contains(rule.QV2RAY_RULE_TAG)) { + rule.QV2RAY_RULE_TAG += "-" + GenerateRandomString(5); } - rules[QSTRING(rule.QV2RAY_RULE_TAG)] = rule; + rules[rule.QV2RAY_RULE_TAG] = rule; auto pos = nodeGraphWidget->pos(); pos.setX(pos.x() + 350 + GRAPH_GLOBAL_OFFSET_X); pos.setY(pos.y() + ruleNodes.count() * 120 + GRAPH_GLOBAL_OFFSET_Y); - auto _nodeData = make_unique(make_shared(QSTRING(rule.QV2RAY_RULE_TAG))); + auto _nodeData = make_unique(make_shared(rule.QV2RAY_RULE_TAG)); auto &node = nodeScene->createNode(std::move(_nodeData)); nodeScene->setNodePosition(node, pos); for (auto inTag : rule.inboundTag) { - auto inboundNode = inboundNodes[QSTRING(inTag)]; + auto inboundNode = inboundNodes[inTag]; nodeScene->createConnection(node, 0, *inboundNode, 0); } // If not using balancers (use outbound tag) - if (!rule.QV2RAY_RULE_USE_BALANCER && outboundNodes.contains(QSTRING(rule.outboundTag))) { - nodeScene->createConnection(*outboundNodes[QSTRING(rule.outboundTag)], 0, node, 0); + if (!rule.QV2RAY_RULE_USE_BALANCER && outboundNodes.contains(rule.outboundTag)) { + nodeScene->createConnection(*outboundNodes[rule.outboundTag], 0, node, 0); } - this->ruleNodes[QSTRING(rule.QV2RAY_RULE_TAG)] = &node; - ruleListWidget->addItem(QSTRING(rule.QV2RAY_RULE_TAG)); + this->ruleNodes[rule.QV2RAY_RULE_TAG] = &node; + ruleListWidget->addItem(rule.QV2RAY_RULE_TAG); } void RouteEditor::RenameItemTag(ROUTE_EDIT_MODE mode, const QString &originalTag, const QString &newTag) @@ -75,7 +75,7 @@ void RouteEditor::RenameItemTag(ROUTE_EDIT_MODE mode, const QString &originalTag rules[newTag] = rules.take(originalTag); ruleNodes[newTag] = ruleNodes.take(originalTag); // - rules[newTag].QV2RAY_RULE_TAG = newTag.toStdString(); + rules[newTag].QV2RAY_RULE_TAG = newTag; if (currentRuleTag == originalTag) { currentRuleTag = newTag; @@ -107,8 +107,8 @@ void RouteEditor::RenameItemTag(ROUTE_EDIT_MODE mode, const QString &originalTag for (auto k : rules.keys()) { auto v = rules[k]; - if (v.outboundTag == originalTag.toStdString()) { - v.outboundTag = newTag.toStdString(); + if (v.outboundTag == originalTag) { + v.outboundTag = newTag; // Put this inside the if block since no need an extra operation if the condition is false. rules[k] = v; } @@ -134,9 +134,9 @@ void RouteEditor::RenameItemTag(ROUTE_EDIT_MODE mode, const QString &originalTag for (auto k : rules.keys()) { auto v = rules[k]; - if (contains(v.inboundTag, originalTag.toStdString())) { - v.inboundTag.remove(originalTag.toStdString()); - v.inboundTag.push_back(newTag.toStdString()); + if (v.inboundTag.contains(originalTag)) { + v.inboundTag.removeAll(originalTag); + v.inboundTag.append(newTag); // Put this inside the if block since no need an extra operation if the condition is false. rules[k] = v; } diff --git a/src/ui/w_SubscriptionEditor.cpp b/src/ui/w_SubscriptionEditor.cpp index 6b7b7280..8b5a175c 100644 --- a/src/ui/w_SubscriptionEditor.cpp +++ b/src/ui/w_SubscriptionEditor.cpp @@ -10,8 +10,8 @@ SubscribeEditor::SubscribeEditor(QWidget *parent) : addSubsButton->setIcon(QICON_R("add.png")); removeSubsButton->setIcon(QICON_R("delete.png")); - for (auto _ : conf.subscriptions) { - subscriptions[QSTRING(_.first)] = _.second; + for (auto i = conf.subscriptions.begin(); i != conf.subscriptions.end(); i++) { + subscriptions[i.key()] = i.value(); } LoadSubscriptionList(subscriptions); @@ -83,10 +83,10 @@ void SubscribeEditor::on_updateButton_clicked() // // Update auto-start config if possible auto conf = GetGlobalConfig(); - auto ASsetting = QSTRING(conf.autoStartConfig.subscriptionName); + auto ASsetting = conf.autoStartConfig.subscriptionName; if (ASsetting == currentSubName) { - conf.autoStartConfig.subscriptionName = newName.toStdString(); + conf.autoStartConfig.subscriptionName = newName; } SetGlobalConfig(conf); @@ -97,9 +97,9 @@ void SubscribeEditor::on_updateButton_clicked() subscriptions[currentSubName].updateInterval = newUpdateInterval; - if (subscriptions[currentSubName].address != newAddress.toStdString()) { - LOG(MODULE_SUBSCRIPTION, "Setting new address, from " + subscriptions[currentSubName].address + " to: " + newAddress.toStdString()) - subscriptions[currentSubName].address = newAddress.toStdString(); + if (subscriptions[currentSubName].address != newAddress) { + LOG(MODULE_SUBSCRIPTION, "Setting new address, from " + subscriptions[currentSubName].address.toStdString() + " to: " + newAddress.toStdString()) + subscriptions[currentSubName].address = newAddress; } SaveConfig(); @@ -112,7 +112,7 @@ void SubscribeEditor::on_updateButton_clicked() void SubscribeEditor::StartUpdateSubscription(const QString &subscriptionName) { this->setEnabled(false); - auto data = helper.syncget(QSTRING(subscriptions[subscriptionName].address)); + auto data = helper.syncget(subscriptions[subscriptionName].address); auto content = DecodeSubscriptionString(data).trimmed(); if (!content.isEmpty()) { @@ -160,7 +160,7 @@ void SubscribeEditor::on_removeSubsButton_clicked() // If removed a whole subscription... auto conf = GetGlobalConfig(); - if (conf.autoStartConfig.subscriptionName == name.toStdString()) { + if (conf.autoStartConfig.subscriptionName == name) { conf.autoStartConfig.subscriptionName.clear(); conf.autoStartConfig.connectionName.clear(); SetGlobalConfig(conf); @@ -184,12 +184,12 @@ void SubscribeEditor::on_subscriptionList_currentRowChanged(int currentRow) LOG(MODULE_UI, "Subscription row changed, new name: " + currentSubName.toStdString()) // subNameTxt->setText(currentSubName); - subAddrTxt->setText(QSTRING(subscriptions[currentSubName].address)); + subAddrTxt->setText(subscriptions[currentSubName].address); updateIntervalSB->setValue(subscriptions[currentSubName].updateInterval); - lastUpdatedLabel->setText(QSTRING(timeToString(subscriptions[currentSubName].lastUpdated))); + lastUpdatedLabel->setText(QString::fromStdString(timeToString(subscriptions[currentSubName].lastUpdated))); // connectionsList->clear(); - auto _list = GetSubscriptionConnection(currentSubName.toStdString()); + auto _list = GetSubscriptionConnection(currentSubName); for (auto i = 0; i < _list.count(); i++) { connectionsList->addItem(_list.keys()[i]); @@ -199,15 +199,15 @@ void SubscribeEditor::on_subscriptionList_currentRowChanged(int currentRow) void SubscribeEditor::SaveConfig() { auto conf = GetGlobalConfig(); - QMap newConf; + QMap newConf; for (auto _ : subscriptions.toStdMap()) { - if (!_.second.address.empty()) { - newConf[_.first.toStdString()] = _.second; + if (!_.second.address.isEmpty()) { + newConf[_.first] = _.second; } } - conf.subscriptions = newConf.toStdMap(); + conf.subscriptions = newConf; SetGlobalConfig(conf); } diff --git a/src/utils/QvHelpers.cpp b/src/utils/QvHelpers.cpp index e9a39059..cf892fe8 100644 --- a/src/utils/QvHelpers.cpp +++ b/src/utils/QvHelpers.cpp @@ -47,7 +47,7 @@ namespace Qv2ray QString out; for (auto item : list) { - out.append(QSTRING(item)); + out.append(QString::fromStdString(item)); out.append(saperator); }