diff --git a/Build.Counter b/Build.Counter index 06ea99ce..af2d99d8 100644 --- a/Build.Counter +++ b/Build.Counter @@ -1 +1 @@ -2525 +2550 diff --git a/src/Qv2rayBase.hpp b/src/Qv2rayBase.hpp index 19eddf2c..708e0cb4 100644 --- a/src/Qv2rayBase.hpp +++ b/src/Qv2rayBase.hpp @@ -12,15 +12,17 @@ const int QV2RAY_CONFIG_VERSION = 6; // Linux users and DEs should handle the darkMode UI themselves. -#ifndef Q_OS_LINUX -#define QV2RAY_USE_BUILTIN_DARKTHEME +#ifndef QV2RAY_USE_BUILTIN_DARKTHEME +# ifndef Q_OS_LINUX +# define QV2RAY_USE_BUILTIN_DARKTHEME +# endif #endif // Base folder suffix. #ifdef QT_DEBUG -#define QV2RAY_CONFIG_DIR_SUFFIX "_debug/" +# define QV2RAY_CONFIG_DIR_SUFFIX "_debug/" #else -#define QV2RAY_CONFIG_DIR_SUFFIX "/" +# define QV2RAY_CONFIG_DIR_SUFFIX "/" #endif // Get Configured Config Dir Path @@ -37,15 +39,22 @@ const int QV2RAY_CONFIG_VERSION = 6; #define QV2RAY_GENERATED_DIR (QV2RAY_CONFIG_DIR + "generated/") #define QV2RAY_GENERATED_FILE_PATH (QV2RAY_GENERATED_DIR + "config.gen.json") -#ifndef QV2RAY_DEFAULT_VCORE_PATH -#define QV2RAY_DEFAULT_VASSETS_PATH (QV2RAY_CONFIG_DIR + "vcore/") -#ifdef Q_OS_WIN -#define QV2RAY_DEFAULT_VCORE_PATH (QV2RAY_CONFIG_DIR + "vcore/v2ray.exe") +#if ! defined (QV2RAY_DEFAULT_VCORE_PATH) && ! defined (QV2RAY_DEFAULT_VASSETS_PATH) +# define QV2RAY_DEFAULT_VASSETS_PATH (QV2RAY_CONFIG_DIR + "vcore/") +# ifdef Q_OS_WIN +# define QV2RAY_DEFAULT_VCORE_PATH (QV2RAY_CONFIG_DIR + "vcore/v2ray.exe") +# else +# define QV2RAY_DEFAULT_VCORE_PATH (QV2RAY_CONFIG_DIR + "vcore/v2ray") +# endif +#elif defined (QV2RAY_DEFAULT_VCORE_PATH) && defined (QV2RAY_DEFAULT_VASSETS_PATH) +// ---- Using user-specified VCore and VAssets path #else -#define QV2RAY_DEFAULT_VCORE_PATH (QV2RAY_CONFIG_DIR + "vcore/v2ray") -#endif +# error Both QV2RAY_DEFAULT_VCORE_PATH and QV2RAY_DEFAULT_VASSETS_PATH need to present when specifying the paths. #endif +#undef _HAS_MANUAL_VCORE +#undef _HAS_MANUAL_VASSETS + #define QV2RAY_VCORE_LOG_DIRNAME "logs/" #define QV2RAY_VCORE_ACCESS_LOG_FILENAME "access.log" #define QV2RAY_VCORE_ERROR_LOG_FILENAME "error.log" @@ -60,13 +69,13 @@ const int QV2RAY_CONFIG_VERSION = 6; #define BLACK(obj) \ obj->setPalette(this->palette()); -#define QV2RAY_UI_RESOURCES_ROOT QString::fromStdString(QV2RAY_IS_DARKTHEME ? ":/icons/ui_dark/" : ":/icons/ui_light/") +#define QV2RAY_UI_RESOURCES_ROOT (QV2RAY_IS_DARKTHEME ? QStringLiteral(":/icons/ui_dark/") : QStringLiteral(":/icons/ui_light/")) #define QICON_R(file) QIcon(QV2RAY_UI_RESOURCES_ROOT + file) #define NEWLINE "\r\n" #ifndef MAX -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +# define MAX(a, b) (((a) > (b)) ? (a) : (b)) #endif using namespace std; diff --git a/src/QvConfigUpgrade.cpp b/src/QvConfigUpgrade.cpp index eab7ea6b..c4450bb2 100644 --- a/src/QvConfigUpgrade.cpp +++ b/src/QvConfigUpgrade.cpp @@ -25,7 +25,7 @@ namespace Qv2ray case 2: { // We copied those files. auto vCoreFilePath = root["v2CorePath"].toString(); - auto vCoreDestPath = QV2RAY_DEFAULT_VCORE_PATH; + auto vCoreDestPath = QString(QV2RAY_DEFAULT_VCORE_PATH); // We also need v2ctl auto v2CtlFilePath = QFileInfo(vCoreFilePath).dir().path() + "/v2ctl"; auto v2CtlDestPath = QFileInfo(vCoreDestPath).dir().path() + "/v2ctl"; diff --git a/src/main.cpp b/src/main.cpp index dd698848..a92dfed3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -146,8 +146,8 @@ bool initialiseQv2ray() } Qv2rayConfig conf; - conf.v2AssetsPath = QV2RAY_DEFAULT_VASSETS_PATH; - conf.v2CorePath = QV2RAY_DEFAULT_VCORE_PATH; + conf.v2AssetsPath = QString(QV2RAY_DEFAULT_VASSETS_PATH); + conf.v2CorePath = QString(QV2RAY_DEFAULT_VCORE_PATH); conf.logLevel = 3; // // Save initial config. diff --git a/src/ui/w_MainWindow.cpp b/src/ui/w_MainWindow.cpp index 2e366c4f..2b4733e0 100644 --- a/src/ui/w_MainWindow.cpp +++ b/src/ui/w_MainWindow.cpp @@ -332,7 +332,6 @@ void MainWindow::OnConfigListChanged(bool need_restart) connections.clear(); connectionListWidget->clear(); auto _regularConnections = GetRegularConnections(currentConfig.configs); - // auto _subsConnections = GetSubscriptionConnections(currentConfig.subscriptions.keys()); for (auto i = 0; i < _regularConnections.count(); i++) { @@ -562,7 +561,7 @@ void MainWindow::ShowAndSetConnection(QString guiConnectionName, bool SetConnect } // Get Connection info - auto host_port = MWGetConnectionPortNumber(currentSelectedName); + auto host_port = MWGetConnectionInfo(currentSelectedName); _hostLabel->setText(get<0>(host_port)); _portLabel->setText(QString::number(get<1>(host_port))); _OutBoundTypeLabel->setText(get<2>(host_port)); diff --git a/src/ui/w_MainWindow.hpp b/src/ui/w_MainWindow.hpp index a0b2c017..e5715466 100644 --- a/src/ui/w_MainWindow.hpp +++ b/src/ui/w_MainWindow.hpp @@ -45,15 +45,11 @@ class MainWindow : public QMainWindow, Ui::MainWindow void UpdateVCoreLog(const QString &log); void OnConfigListChanged(bool need_restart); private slots: - void setMasterLogHBar(); void on_action_RCM_ShareQR_triggered(); void on_startButton_clicked(); void on_stopButton_clicked(); void on_reconnectButton_clicked(); - void VersionUpdate(QByteArray &data); void on_activatedTray(QSystemTrayIcon::ActivationReason reason); - void ToggleVisibility(); - void quit(); void on_actionExit_triggered(); void on_preferencesBtn_clicked(); void on_connectionListWidget_doubleClicked(const QModelIndex &index); @@ -69,10 +65,14 @@ class MainWindow : public QMainWindow, Ui::MainWindow void on_shareBtn_clicked(); void on_duplicateBtn_clicked(); void on_subsButton_clicked(); + // + void ToggleVisibility(); + void setMasterLogHBar(); + void VersionUpdate(QByteArray &data); + void quit(); public: static MainWindow *mwInstance; - CONFIGROOT CurrentFullConfig; QString CurrentConnectionName = ""; ConnectionInstance *vinstance; @@ -93,6 +93,7 @@ class MainWindow : public QMainWindow, Ui::MainWindow void SetEditWidgetEnable(bool enabled); void ShowAndSetConnection(QString currentText, bool SetConnection, bool Apply); Qv2rayConfig currentConfig; + CONFIGROOT currentFullConfig; // // Charts QChartView *speedChartView; @@ -148,7 +149,7 @@ class MainWindow : public QMainWindow, Ui::MainWindow bool MWtryStartConnection(); void MWStopConnection(); void MWTryPingConnection(const QString &alias); - tuple MWGetConnectionPortNumber(const QString &alias); + tuple MWGetConnectionInfo(const QString &alias); void MWSetSystemProxy(); void MWClearSystemProxy(bool); }; diff --git a/src/ui/w_MainWindow_extra.cpp b/src/ui/w_MainWindow_extra.cpp index 3162f1f2..603a96b2 100644 --- a/src/ui/w_MainWindow_extra.cpp +++ b/src/ui/w_MainWindow_extra.cpp @@ -106,8 +106,8 @@ void MainWindow::MWSetSystemProxy() bool MainWindow::MWtryStartConnection() { auto connectionRoot = connections[CurrentConnectionName].config; - CurrentFullConfig = GenerateRuntimeConfig(connectionRoot); - bool startFlag = this->vinstance->StartConnection(CurrentFullConfig, currentConfig.connectionConfig.statsPort); + currentFullConfig = GenerateRuntimeConfig(connectionRoot); + bool startFlag = this->vinstance->StartConnection(currentFullConfig, currentConfig.connectionConfig.statsPort); if (startFlag) { bool usePAC = currentConfig.inboundConfig.pacConfig.enablePAC; @@ -177,7 +177,7 @@ void MainWindow::MWStopConnection() void MainWindow::MWTryPingConnection(const QString &alias) { try { - auto info = MWGetConnectionPortNumber(alias); + auto info = MWGetConnectionInfo(alias); QString host = get<0>(info); int port = get<1>(info); tcpingModel->StartPing(alias, host, port); @@ -186,12 +186,11 @@ void MainWindow::MWTryPingConnection(const QString &alias) } } -tuple MainWindow::MWGetConnectionPortNumber(const QString &alias) +tuple MainWindow::MWGetConnectionInfo(const QString &alias) { if (!connections.contains(alias)) return make_tuple(tr("N/A"), 0, tr("N/A")); - auto root = connections[alias].config; - return GetConnectionInfo(root); + return GetConnectionInfo(connections[alias].config); } diff --git a/src/ui/w_PreferencesWindow.cpp b/src/ui/w_PreferencesWindow.cpp index 2a333839..2cfd70eb 100644 --- a/src/ui/w_PreferencesWindow.cpp +++ b/src/ui/w_PreferencesWindow.cpp @@ -377,8 +377,8 @@ void PreferencesWindow::on_tProxyCheckBox_stateChanged(int arg1) // 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()) { - LOG(MODULE_FILE, QV2RAY_DEFAULT_VCORE_PATH.toStdString() + ": File already exists.") - LOG(MODULE_FILE, QV2RAY_DEFAULT_VCORE_PATH.toStdString() + ": Deleting file.") + LOG(MODULE_FILE, QString(QV2RAY_DEFAULT_VCORE_PATH).toStdString() + ": File already exists.") + LOG(MODULE_FILE, QString(QV2RAY_DEFAULT_VCORE_PATH).toStdString() + ": Deleting file.") QFile(QV2RAY_DEFAULT_VCORE_PATH).remove(); } diff --git a/src/ui/w_PreferencesWindow.ui b/src/ui/w_PreferencesWindow.ui index 229fd08a..b9c02941 100644 --- a/src/ui/w_PreferencesWindow.ui +++ b/src/ui/w_PreferencesWindow.ui @@ -42,7 +42,7 @@ QTabWidget::Rounded - 0 + 1 @@ -525,7 +525,7 @@ - + SOCKS Settings @@ -559,62 +559,79 @@ - - - Enabled - - + + + + + Enabled + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + IP: + + + + + + + 127.0.0.1 + + + + - - - Local IP (For UDP) - - - - - - - 127.0.0.1 - - - - Authentication - + Enabled - + Username - + user - + Password - + pass @@ -624,7 +641,7 @@ - + HTTP Settings @@ -695,7 +712,7 @@ - + PAC Settings