From 787773635e88ebad7f6d563ebe76fa414fe3b55a Mon Sep 17 00:00:00 2001 From: "Leroy.H.Y" Date: Sun, 23 Jun 2019 19:19:20 +0800 Subject: [PATCH] [Added] Added UI Translations Signed-off-by: Leroy.H.Y Former-commit-id: 688071dd0069274e098472bd4833f7c7e4cb2945 --- Hv2ray.pro | 15 +- Himeki.ico => icons/Hv2ray.ico | Bin resources.qrc | 7 + src/ConnectionEditWindow.cpp | 4 +- src/ConnectionEditWindow.h | 2 +- src/ConnectionEditWindow.ui | 196 ++++---- src/ImportConfig.cpp | 40 +- src/ImportConfig.ui | 29 +- src/MainWindow.cpp | 87 ++-- src/MainWindow.h | 1 + src/MainWindow.ui | 66 ++- src/PrefrencesWindow.cpp | 30 +- src/PrefrencesWindow.h | 9 +- src/PrefrencesWindow.ui | 83 ++-- src/main.cpp | 4 +- src/utils.cpp | 2 +- src/vinteract.cpp | 2 +- translations/en-US.ts | 578 +++++++++++++----------- translations/zh-CN.ts | 798 ++++++++++++++++----------------- 19 files changed, 1035 insertions(+), 918 deletions(-) rename Himeki.ico => icons/Hv2ray.ico (100%) create mode 100644 resources.qrc diff --git a/Hv2ray.pro b/Hv2ray.pro index af80cf45..75a3e79d 100644 --- a/Hv2ray.pro +++ b/Hv2ray.pro @@ -24,8 +24,7 @@ DEFINES += QT_DEPRECATED_WARNINGS CONFIG += c++11 -VPATH += ./src \ - ./translations +VPATH += ./src SOURCES += \ main.cpp \ @@ -52,15 +51,21 @@ FORMS += \ ImportConfig.ui \ PrefrencesWindow.ui -TRANSLATIONS += ./translations/zh-CN.ts +RESOURCES += \ + resources.qrc + + +TRANSLATIONS += \ + ./translations/zh-CN.ts \ + ./translations/en-US.ts + +RC_ICONS += ./icons/Hv2ray.ico # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -RC_ICONS = Himeki.ico - WITH_PYTHON = no unix: exists( "/usr/include/python3.7m/Python.h" ) { diff --git a/Himeki.ico b/icons/Hv2ray.ico similarity index 100% rename from Himeki.ico rename to icons/Hv2ray.ico diff --git a/resources.qrc b/resources.qrc new file mode 100644 index 00000000..bd23da9a --- /dev/null +++ b/resources.qrc @@ -0,0 +1,7 @@ + + + icons/Hv2ray.ico + translations/zh-CN.qm + translations/en-US.qm + + diff --git a/src/ConnectionEditWindow.cpp b/src/ConnectionEditWindow.cpp index 8e8a67d1..c8239c20 100644 --- a/src/ConnectionEditWindow.cpp +++ b/src/ConnectionEditWindow.cpp @@ -19,12 +19,12 @@ ConnectionEditWindow::~ConnectionEditWindow() { delete ui; } -int vConfig::save() +int Hv2Config::save() { return -1; } -void vConfig::getConfigFromDialog(Ui::ConnectionEditWindow *ui) +void Hv2Config::getConfigFromDialog(Ui::ConnectionEditWindow *ui) { this->host = ui->ipLineEdit->text(); this->port = ui->portLineEdit->text(); diff --git a/src/ConnectionEditWindow.h b/src/ConnectionEditWindow.h index 4d434996..d6bce706 100644 --- a/src/ConnectionEditWindow.h +++ b/src/ConnectionEditWindow.h @@ -8,7 +8,7 @@ namespace Ui class ConnectionEditWindow; } -class vConfig +class Hv2Config { public: QString host; diff --git a/src/ConnectionEditWindow.ui b/src/ConnectionEditWindow.ui index ef86e008..0bbb1213 100644 --- a/src/ConnectionEditWindow.ui +++ b/src/ConnectionEditWindow.ui @@ -17,7 +17,7 @@ - Connection Settings + #ConnectionSettings @@ -25,7 +25,7 @@ - Host + #Host @@ -39,7 +39,7 @@ - Port + #Port @@ -53,7 +53,7 @@ - Name + #Name @@ -70,7 +70,7 @@ - UUID + #UUID @@ -87,7 +87,7 @@ - Alter ID + #AlterID @@ -101,7 +101,7 @@ - Security + #Security @@ -132,7 +132,7 @@ - Transport + #Transport @@ -172,13 +172,26 @@ + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + Qt::LeftToRight - Transport Settings (StreamSettingsObject) + #TransportSettings @@ -202,7 +215,7 @@ - 5 + 0 true @@ -225,7 +238,7 @@ - http (HttpHeaderobject) + http @@ -233,7 +246,7 @@ - type + #Type @@ -246,7 +259,7 @@ - Request (HTTPRequestObject) + #Request @@ -256,28 +269,20 @@ QPlainTextEdit::NoWrap - { - "version": "1.1", - "method": "GET", - "path": ["/"], - "headers": { - "Host": ["www.baidu.com", "www.bing.com"], - "User-Agent": [ - "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36", - "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/53.0.2785.109 Mobile/14A456 Safari/601.1.46" - ], - "Accept-Encoding": ["gzip, deflate"], - "Connection": ["keep-alive"], - "Pragma": "no-cache" - } -} - + false + + + + #InsertDefaultContent + + + @@ -285,7 +290,7 @@ - Response (HTTPResponseObject) + #Response @@ -295,17 +300,14 @@ QPlainTextEdit::NoWrap - { - "version": "1.1", - "status": "200", - "reason": "OK", - "headers": { - "Content-Type": ["application/octet-stream", "video/mpeg"], - "Transfer-Encoding": ["chunked"], - "Connection": ["keep-alive"], - "Pragma": "no-cache" - } -} + + + + + + + + #InsertDefaultContent @@ -325,32 +327,26 @@ - - - - v2ray.com - - - + - host + #Host - path + #Path - / + @@ -370,14 +366,14 @@ - path + #Path - / + @@ -386,7 +382,7 @@ - headers (Key Value Pair) + #Headers @@ -418,11 +414,6 @@ -1 - - - Host - - @@ -436,11 +427,6 @@ QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked - - - v2ray.com - - @@ -459,7 +445,7 @@ - MTU + #MTU @@ -485,7 +471,7 @@ - TTI (ms) + #TTI (ms) @@ -511,7 +497,7 @@ - UplinkCapacity (MB/s) + #UplinkCapacity (MB/s) @@ -534,14 +520,14 @@ - Congestion + #Congestion - Enabled + #Enabled @@ -552,7 +538,7 @@ - downlinkCapacity (MB/s) + #DownlinkCapacity (MB/s) @@ -575,7 +561,7 @@ - readBufferSize (MB) + #ReadBufferSize (MB) @@ -598,7 +584,7 @@ - writeBufferSize (MB) + #WriteBufferSize (MB) @@ -623,13 +609,13 @@ - header (Header Object) + #Header - type + #Type @@ -688,14 +674,14 @@ - path + #Path - /path/to/ds/file + @@ -713,7 +699,7 @@ - security + #Security @@ -745,21 +731,21 @@ - key + #Key - xxxxx + - header + #Headers @@ -772,7 +758,7 @@ - header (HeaderObject) + #Header @@ -780,7 +766,7 @@ - type + #Type @@ -838,21 +824,41 @@ - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - + + ipLineEdit + portLineEdit + aliasLineEdit + idLineEdit + alterLineEdit + securityCombo + tranportCombo + tabWidget + comboBox + plainTextEdit + pushButton + plainTextEdit_2 + pushButton_2 + listWidget + plainTextEdit_3 + lineEdit + listWidget_3 + listWidget_2 + spinBox + spinBox_3 + spinBox_5 + checkBox + spinBox_2 + spinBox_4 + spinBox_6 + comboBox_2 + lineEdit_2 + comboBox_3 + lineEdit_3 + comboBox_4 + textBrowser + diff --git a/src/ImportConfig.cpp b/src/ImportConfig.cpp index dbbe51d4..1ee03959 100644 --- a/src/ImportConfig.cpp +++ b/src/ImportConfig.cpp @@ -31,17 +31,18 @@ ImportConfig::~ImportConfig() void ImportConfig::on_pushButton_clicked() { - QString dir = QFileDialog::getOpenFileName(this, tr("Open Config File"), "~/"); + QString dir = QFileDialog::getOpenFileName(this, tr("OpenConfigFile"), "~/"); ui->fileLineTxt->setText(dir); } void ImportConfig::savefromFile(QString path, QString alias) { - vConfig newConf; - newConf.alias = alias; + Hv2Config newConfig; + newConfig.alias = alias; QFile configFile(path); if(!configFile.open(QIODevice::ReadOnly)) { - qDebug() << "Couldn't open config json"; + showWarnMessageBox(this, tr("ImportConfig"), tr("CannotOpenFile")); + qDebug() << "ImportConfig::CannotOpenFile"; return; } QByteArray allData = configFile.readAll(); @@ -56,25 +57,27 @@ void ImportConfig::savefromFile(QString path, QString alias) } QJsonObject vnext = switchJsonArrayObject(outbound.value("settings").toObject(), "vnext"); QJsonObject user = switchJsonArrayObject(vnext, "users"); - newConf.host = vnext.value("address").toString(); - newConf.port = QString::number(vnext.value("port").toInt()); - newConf.alterid = QString::number(user.value("alterId").toInt()); - newConf.uuid = user.value("id").toString(); - newConf.security = user.value("security").toString(); - if (newConf.security.isNull()) { - newConf.security = "auto"; + newConfig.host = vnext.value("address").toString(); + newConfig.port = QString::number(vnext.value("port").toInt()); + newConfig.alterid = QString::number(user.value("alterId").toInt()); + newConfig.uuid = user.value("id").toString(); + newConfig.security = user.value("security").toString(); + if (newConfig.security.isNull()) { + newConfig.security = "auto"; } - newConf.isCustom = 1; - int id = newConf.save(); + newConfig.isCustom = 1; + int id = newConfig.save(); if(id < 0) { - showWarnMessageBox(this, "Database Error", "Failed to open database while saving"); + showWarnMessageBox(this, tr("ImportConfig"), tr("SaveFailed")); + qDebug() << "ImportConfig::SaveFailed"; return; } emit updateConfTable(); QString newFile = "conf/" + QString::number(id) + ".conf"; if(!QFile::copy(path, newFile)) { - showWarnMessageBox(this, "Copy error", "Failed to copy custom config file."); + showWarnMessageBox(this, tr("ImportConfig"), tr("CannotCopyCustomConfig")); + qDebug() << "ImportConfig::CannotCopyCustomConfig"; } } @@ -93,9 +96,7 @@ void ImportConfig::on_buttonBox_accepted() { QString vmess = ui->vmessConnectionStringTxt->toPlainText(); Py_Initialize(); - if ( !Py_IsInitialized() ) { - qDebug() << "Python is not initialized"; - } + assert(Py_IsInitialized()); QString param = "--inbound socks:1080 " + vmess + " -o config.json.tmp"; PyRun_SimpleString("import sys"); PyRun_SimpleString("sys.path.append('./utils')"); @@ -113,7 +114,8 @@ void ImportConfig::on_buttonBox_accepted() } QFile::remove("config.json.tmp"); } else { - showWarnMessageBox(this, "Error occured", "Failed to generate config file."); + showWarnMessageBox(this, tr("ImportConfig"), tr("CannotGenerateConfig")); + qDebug() << "ImportConfig::CannotGenerateConfig"; } } diff --git a/src/ImportConfig.ui b/src/ImportConfig.ui index 4aec2832..dc5f219f 100644 --- a/src/ImportConfig.ui +++ b/src/ImportConfig.ui @@ -25,7 +25,7 @@ - Import From + #ImportFrom @@ -48,13 +48,13 @@ - From File + #FromFile - Path + #Path @@ -70,7 +70,7 @@ - Select File + #SelectFile @@ -79,7 +79,7 @@ - Name + #Name @@ -89,7 +89,7 @@ - Inbound + #Inbound @@ -98,7 +98,7 @@ - Use Current + #UseCurrent true @@ -108,7 +108,7 @@ - Use Imported + #UseImported @@ -120,13 +120,13 @@ - From VMess Connection String + #From VMess Connection String - VMess Connection String + #VMess Connection String @@ -148,6 +148,15 @@ + + importSourceCombo + fileLineTxt + selectFileBtn + nameTxt + useCurrentSettingRidBtn + useImportedRidBtn + vmessConnectionStringTxt + diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index eef323b9..8d87d2d8 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -8,29 +8,61 @@ #include #include +#include "ui_MainWindow.h" #include "PrefrencesWindow.h" #include "MainWindow.h" -#include #include "ConnectionEditWindow.h" #include "ImportConfig.h" #include "vinteract.h" #include "utils.h" +void MainWindow::CreateTrayIcon() +{ + hTray = new QSystemTrayIcon(); + hTray->setToolTip(tr("Hv2ray")); + hTray->setIcon(this->windowIcon()); + connect(hTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(on_activatedTray(QSystemTrayIcon::ActivationReason))); + + QAction *actionShow = new QAction(this); + QAction *actionQuit = new QAction(this); + QAction *actionStart = new QAction(this); + QAction *actionRestart = new QAction(this); + QAction *actionStop = new QAction(this); + actionShow->setText(tr("#Hide")); + actionQuit->setText(tr("#Quit")); + actionStart->setText(tr("#Start")); + actionStop->setText(tr("#Stop")); + actionRestart->setText(tr("#Restart")); + actionStart->setEnabled(true); + actionStop->setEnabled(false); + actionRestart->setEnabled(false); + trayMenu->addAction(actionShow); + trayMenu->addSeparator(); + trayMenu->addAction(actionStart); + trayMenu->addAction(actionStop); + trayMenu->addAction(actionRestart); + trayMenu->addSeparator(); + trayMenu->addAction(actionQuit); + connect(actionShow, SIGNAL(triggered()), this, SLOT(toggleMainWindowVisibility())); + connect(actionStart, SIGNAL(triggered()), this, SLOT(on_startButton_clicked())); + connect(actionStop, SIGNAL(triggered()), this, SLOT(on_stopButton_clicked())); + connect(actionRestart, SIGNAL(triggered()), this, SLOT(on_restartButton_clicked())); + connect(actionQuit, SIGNAL(triggered()), this, SLOT(quit())); + hTray->setContextMenu(trayMenu); + hTray->show(); +} + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { - this->setWindowIcon(QIcon("Himeki.ico")); + this->setWindowIcon(QIcon(":/icons/Hv2ray.ico")); ui->setupUi(this); UpdateConfigTable(); // ui->configTable->setContextMenuPolicy(Qt::CustomContextMenu); // connect(ui->configTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showMenu(QPoint))); this->v2instance = new v2Instance(); - hTray = new QSystemTrayIcon(); - hTray->setToolTip("Hv2ray"); - hTray->setIcon(QIcon("Himeki.ico")); - connect(hTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(on_activatedTray(QSystemTrayIcon::ActivationReason))); - createTrayAction(); + CreateTrayIcon(); if(QFileInfo("config.json").exists()) { v2instance->start(this); } @@ -50,8 +82,10 @@ MainWindow::MainWindow(QWidget *parent) : MainWindow::~MainWindow() { - delete ui; + hTray->hide(); + delete this->hTray; delete this->v2instance; + delete ui; } void MainWindow::on_actionEdit_triggered() @@ -95,7 +129,7 @@ void MainWindow::UpdateConfigTable() } void MainWindow::GenerateConfig(int idIntable) { - vConfig tmpConf; + Hv2Config tmpConf; emit UpdateConfigTable(); if (tmpConf.isCustom == 1) { QString src = "conf/" + QString::number(idIntable) + ".conf"; @@ -153,37 +187,6 @@ void MainWindow::closeEvent(QCloseEvent *event) event->ignore(); } -void MainWindow::createTrayAction() -{ - QAction *actionShow = new QAction(this); - QAction *actionQuit = new QAction(this); - QAction *actionStart = new QAction(this); - QAction *actionRestart = new QAction(this); - QAction *actionStop = new QAction(this); - actionShow->setText("Hide"); - actionQuit->setText("Quit Hv2ray"); - actionStart->setText("Start v2ray"); - actionStop->setText("Stop v2ray"); - actionRestart->setText("Restart v2ray"); - actionStart->setEnabled(true); - actionStop->setEnabled(false); - actionRestart->setEnabled(false); - trayMenu->addAction(actionShow); - trayMenu->addSeparator(); - trayMenu->addAction(actionStart); - trayMenu->addAction(actionStop); - trayMenu->addAction(actionRestart); - trayMenu->addSeparator(); - trayMenu->addAction(actionQuit); - connect(actionShow, SIGNAL(triggered()), this, SLOT(toggleMainWindowVisibility())); - connect(actionStart, SIGNAL(triggered()), this, SLOT(on_startButton_clicked())); - connect(actionStop, SIGNAL(triggered()), this, SLOT(on_stopButton_clicked())); - connect(actionRestart, SIGNAL(triggered()), this, SLOT(on_restartButton_clicked())); - connect(actionQuit, SIGNAL(triggered()), this, SLOT(quit())); - hTray->setContextMenu(trayMenu); - hTray->show(); -} - void MainWindow::on_activatedTray(QSystemTrayIcon::ActivationReason reason) { switch (reason) { @@ -216,10 +219,10 @@ void MainWindow::toggleMainWindowVisibility() { if(this->isHidden()) { this->show(); - trayMenu->actions()[0]->setText("Hide"); + trayMenu->actions()[0]->setText(tr("#Hide")); } else { this->hide(); - trayMenu->actions()[0]->setText("Show"); + trayMenu->actions()[0]->setText(tr("#Show")); } } diff --git a/src/MainWindow.h b/src/MainWindow.h index d3956117..a46dba8f 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -57,6 +57,7 @@ private: void closeEvent(QCloseEvent *); void createTrayAction(); + void CreateTrayIcon(); }; #endif // MAINWINDOW_H diff --git a/src/MainWindow.ui b/src/MainWindow.ui index 5c8f2f9a..7d890a69 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -43,21 +43,21 @@ - Start + #Start - Stop + #Stop - Restart + #Restart false @@ -67,7 +67,7 @@ - Clear Log + #ClearLog @@ -94,7 +94,7 @@ - Host list + #HostList @@ -129,11 +129,6 @@ QListView::ListMode - - - Config 1 (www.hostname.com:port) - - @@ -142,7 +137,7 @@ - Config Detail + #ConfigDetail @@ -151,56 +146,56 @@ - Host + #Host - www.hostname.com + - Port + #Port - 12345 + - UUID + #UUID - TextLabel + - Transport + #Transport - mKCP + @@ -213,14 +208,14 @@ - Connection Settings + #ConnectionSettings - Settings + #ConnectionSettings @@ -246,16 +241,16 @@ 0 0 568 - 29 + 21 - File + #File - New Connection + #NewConnection @@ -265,37 +260,40 @@ - - - About - - - - Manual + #ManuallyInput - Import + #ImportConnection - Exit + #Exit - Preferences + #Preferences + + startButton + stopButton + restartButton + clearlogButton + listWidget + pushButton + logText + diff --git a/src/PrefrencesWindow.cpp b/src/PrefrencesWindow.cpp index 2fec61b8..887c9071 100644 --- a/src/PrefrencesWindow.cpp +++ b/src/PrefrencesWindow.cpp @@ -8,13 +8,12 @@ #include #include #include +#include #include "utils.h" #include "PrefrencesWindow.h" -#include "MainWindow.h" -#include "ui_PrefrencesWindow.h" -PrefrencesWindow::PrefrencesWindow(MainWindow *parent) : +PrefrencesWindow::PrefrencesWindow(QWidget *parent) : QDialog(parent), ui(new Ui::PrefrencesWindow) { @@ -23,16 +22,16 @@ PrefrencesWindow::PrefrencesWindow(MainWindow *parent) : QJsonObject http = findValueFromJsonArray(rootObj.value("inbounds").toArray(), "tag", "http-in"); QJsonObject socks = findValueFromJsonArray(rootObj.value("inbounds").toArray(), "tag", "socks-in"); if(rootObj.value("v2suidEnabled").toBool()) { - ui->checkBox->setCheckState(Qt::Checked); + ui->runAsRootCheckBox->setCheckState(Qt::Checked); } if(!http.isEmpty()) { - ui->httpPortLE->setText(QString::number(http.value("port").toInt())); + ui->httpPortLE->setText(http.value("port").toString()); ui->httpCB->setCheckState(Qt::Checked); } else { ui->httpPortLE->setDisabled(true); } if(!socks.isEmpty()) { - ui->socksPortLE->setText(QString::number(socks.value("port").toInt())); + ui->socksPortLE->setText(socks.value("port").toString()); ui->socksCB->setCheckState(Qt::Checked); } else { ui->socksPortLE->setDisabled(true); @@ -110,12 +109,13 @@ void PrefrencesWindow::on_buttonBox_accepted() QByteArray byteArray = modifiedDoc.toJson(QJsonDocument::Indented); QFile confFile("conf/Hv2ray.config.json"); if(!confFile.open(QIODevice::WriteOnly)) { + showWarnMessageBox(this, tr("#Prefrences"), tr("#CannotOpenConfigFile")); qDebug() << "Cannot open Hv2ray.config.json for modifying"; } confFile.write(byteArray); confFile.close(); } else { - showWarnMessageBox(this, tr("Config error"), tr("Port numbers cannot be the same!")); + showWarnMessageBox(this, tr("Prefrences"), tr("PortNumbersCannotBeSame")); } } } @@ -140,3 +140,19 @@ void PrefrencesWindow::on_socksCB_stateChanged(int checked) ui->socksPortLE->setText("1080"); } } + +void PrefrencesWindow::on_httpAuthCB_stateChanged(int checked) +{ + if(checked) + { + + } +} + +void PrefrencesWindow::on_runAsRootCheckBox_stateChanged(int arg1) +{ + Q_UNUSED(arg1); +#ifdef _WIN32 + showWarnMessageBox(this, tr("Prefrences"), tr("RunAsRootNotOnWindows")); +#endif +} diff --git a/src/PrefrencesWindow.h b/src/PrefrencesWindow.h index 8e4ca4ee..de856f08 100644 --- a/src/PrefrencesWindow.h +++ b/src/PrefrencesWindow.h @@ -3,7 +3,6 @@ #include #include -#include "MainWindow.h" namespace Ui { @@ -15,16 +14,20 @@ class PrefrencesWindow : public QDialog Q_OBJECT public: - explicit PrefrencesWindow(MainWindow *parent = nullptr); + explicit PrefrencesWindow(QWidget *parent = nullptr); ~PrefrencesWindow(); QJsonObject rootObj; - MainWindow *parentMW; + QWidget *parentMW; private slots: void on_buttonBox_accepted(); void on_httpCB_stateChanged(int arg1); void on_socksCB_stateChanged(int arg1); + void on_httpAuthCB_stateChanged(int arg1); + + void on_runAsRootCheckBox_stateChanged(int arg1); + private: Ui::PrefrencesWindow *ui; }; diff --git a/src/PrefrencesWindow.ui b/src/PrefrencesWindow.ui index c797f244..12586791 100644 --- a/src/PrefrencesWindow.ui +++ b/src/PrefrencesWindow.ui @@ -23,7 +23,7 @@ - General + #General @@ -31,12 +31,12 @@ - Language + #Language - + 0 @@ -58,26 +58,26 @@ - Run v2ray with root + #RunAsRoot - + - Enabled + #Enabled - Log Level + #LogLevel - + 0 @@ -122,32 +122,32 @@ - Mux Cool + #MuxCool - Enabled + #Enabled - + - Enabled + #Enabled - Concurrency + #Concurrency - + 1 @@ -168,7 +168,7 @@ - Inbound Settings + #InboundSettings @@ -183,14 +183,14 @@ Qt::LeftToRight - Enabled + #Enabled - Port + #Port @@ -210,36 +210,36 @@ - Username + #Username - Auth + #Auth - Password + #Password - + - Enabled + #Enabled - + - + @@ -253,7 +253,7 @@ - Port + #Port @@ -267,43 +267,43 @@ - Enabled + #Enabled - Auth + #Auth - Username + #Username - Password + #Password - + - Enabled + #Enabled - + - + @@ -323,6 +323,23 @@ + + languageComboBox + runAsRootCheckBox + logLevelCheckBox + muxEnabledCB + muxConcurrencyTxt + httpCB + httpPortLE + httpAuthCB + httpAuthUsernameTxt + httpAuthPasswordTxt + socksCB + socksPortLE + socksAuthCB + socksAuthUsernameTxt + socksAuthPasswordTxt + diff --git a/src/main.cpp b/src/main.cpp index 2e1486f0..2a7f729d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) QApplication _qApp(argc, argv); QTranslator translator; - if (translator.load(QString("zh-CN.qm"), QString("translations"))) + if (translator.load(QString(":/translations/zh-CN.qm"), QString("translations"))) { cout << "Loaded Chinese translations" << endl; } @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) RunGuard guard("Hv2ray"); if(!guard.isSingleInstance()) { - showWarnMessageBox(nullptr, "Hv2Ray", "Another instance of Hv2ray is already running!"); + showWarnMessageBox(nullptr, QObject::tr("Hv2Ray"), QObject::tr("AnotherInstanceRunning")); return -1; } diff --git a/src/utils.cpp b/src/utils.cpp index f2fdd606..30621892 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -53,7 +53,7 @@ bool checkVCoreExes() if (QFileInfo("v2ray").exists() && QFileInfo("geoip.dat").exists() && QFileInfo("geosite.dat").exists() && QFileInfo("v2ctl").exists()) { return true; } else { - showWarnMessageBox(nullptr, "v2ray core not found", "V2ray core files not found. Please download the latest version of v2ray and extract it into the current folder."); + showWarnMessageBox(nullptr, QObject::tr("CoreNotFound"), QObject::tr("CoreFileNotFoundExplaination")); return false; } } diff --git a/src/vinteract.cpp b/src/vinteract.cpp index eae2f417..898486cb 100644 --- a/src/vinteract.cpp +++ b/src/vinteract.cpp @@ -25,7 +25,7 @@ bool validationCheck(QString path) QString output = QString(process.readAllStandardOutput()); if (!output.contains("Configuration OK")) { - showWarnMessageBox(nullptr, "Error in configuration", output.mid(output.indexOf("anti-censorship.") + 17)); + showWarnMessageBox(nullptr, QObject::tr("ConfigurationError"), output.mid(output.indexOf("anti-censorship.") + 17)); return false; } else return true; diff --git a/translations/en-US.ts b/translations/en-US.ts index 1749ee2b..072e20e8 100644 --- a/translations/en-US.ts +++ b/translations/en-US.ts @@ -3,35 +3,41 @@ ConnectionEditWindow + + + #ConnectionSettings + + - - Host + + #Host - Port + #Port - Name + #Name - UUID + #UUID - Alter ID + #AlterID - Security + + #Security @@ -41,28 +47,28 @@ - + aes-128-gcm - + chacha20-poly1305 - - - - + + + + none - Transport + #Transport @@ -96,514 +102,558 @@ - - Transport Settings (StreamSettingsObject) + + #TransportSettings - + TCP - - Connection Settings - - - - - http (HttpHeaderobject) - - - - - - - type + + http - Request (HTTPRequestObject) + + + #Type - - { - "version": "1.1", - "method": "GET", - "path": ["/"], - "headers": { - "Host": ["www.baidu.com", "www.bing.com"], - "User-Agent": [ - "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36", - "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/53.0.2785.109 Mobile/14A456 Safari/601.1.46" - ], - "Accept-Encoding": ["gzip, deflate"], - "Connection": ["keep-alive"], - "Pragma": "no-cache" - } -} - + + #Request - - Response (HTTPResponseObject) + + + #InsertDefaultContent - - { - "version": "1.1", - "status": "200", - "reason": "OK", - "headers": { - "Content-Type": ["application/octet-stream", "video/mpeg"], - "Transfer-Encoding": ["chunked"], - "Connection": ["keep-alive"], - "Pragma": "no-cache" - } -} + + #Response - + HTTP - - - v2ray.com + + + + #Path - - host - - - - - - - path - - - - - - / - - - - + WebSocket - - headers (Key Value Pair) + + + #Headers - + mKCP - - MTU + + #MTU - - TTI (ms) + + #TTI (ms) - - UplinkCapacity (MB/s) + + #UplinkCapacity (MB/s) - - Congestion + + #Congestion - - Enabled + + #Enabled - - downlinkCapacity (MB/s) + + #DownlinkCapacity (MB/s) - - readBufferSize (MB) + + #ReadBufferSize (MB) - - writeBufferSize (MB) + + #WriteBufferSize (MB) - - header (Header Object) + + + #Header - - + + srtp (SRTP, FaceTime) - - + + utp (BitTorrent) - - + + wechat-video (WeChat Video Message) - - + + dtls (DTLS 1.2) - - + + wireguard (WireGuard fake packets) - + DomainSocket - - /path/to/ds/file - - - - + QUIC - - security + + #Key + + + + + ImportConfig + + + Import file - - key + + #ImportFrom - - xxxxx + + Existing File - - header + + VMess Connection String - - header (HeaderObject) + + #FromFile + + + + + #Path + + + + + #SelectFile + + + + + #Name + + + + + #Inbound + + + + + #UseCurrent + + + + + #UseImported + + + + + #From VMess Connection String + + + + + #VMess Connection String + + + + + OpenConfigFile + + + + + + + + ImportConfig + + + + + CannotOpenFile + + + + + SaveFailed + + + + + CannotCopyCustomConfig + + + + + CannotGenerateConfig MainWindow - + + Hv2ray - - Start + + + #Start - - Stop + + + #Stop - - Restart + + + #Restart - - Clear Log + + #ClearLog - - Config Detail + + #HostList - - Host list + + #ConfigDetail - - Config 1 (www.hostname.com:port) + + #Host - - Host + + #Port - - www.hostname.com + + #UUID - - Port + + #Transport - - 12345 + + + #ConnectionSettings - - UUID + + #File - - TextLabel + + #NewConnection - - Transport + + #ManuallyInput - - mKCP + + #ImportConnection - - Connection Settings + + #Exit - - Settings + + #Preferences - - File + + + #Hide - - New + + #Quit - - From - - - - - About - - - - - Edit - - - - - Vmess - - - - - Existing config - - - - - Exit - - - - - Preferences + + #Show PrefrencesWindow - + + + Prefrences - - General - - - - - Language - - - - + zh-CN - + en-US - - Run v2ray with root + + #General - - - - Enabled + + #Language - - Log Level + + #RunAsRoot - + + + + + + + + #Enabled + + + + + #LogLevel + + + + debug - + info - + warning - + error - + none - - Inbound Settings + + #MuxCool - + + #Concurrency + + + + + #InboundSettings + + + + + + #Port + + + + + + #Username + + + + + + #Auth + + + + + + #Password + + + + HTTP - - - Port - - - - + 8080 - + SOCKS - + 9001 - - - importConf - - Import file + + #Prefrences - - File name: + + #CannotOpenConfigFile - - open + + PortNumbersCannotBeSame - - Alias: - - - - - Open Config File + + RunAsRootNotOnWindows - import_vmess + QObject - - Vmess + + Hv2Ray - - Alias: + + AnotherInstanceRunning + + + + + CoreNotFound + + + + + CoreFileNotFoundExplaination + + + + + ConfigurationError diff --git a/translations/zh-CN.ts b/translations/zh-CN.ts index 4381fcee..072e20e8 100644 --- a/translations/zh-CN.ts +++ b/translations/zh-CN.ts @@ -1,509 +1,512 @@ - + ConnectionEditWindow + + + #ConnectionSettings + + - - Host - 主机名 + + #Host + - Port - 端口 + #Port + - Name - 备注 + #Name + - UUID - UUID + #UUID + - Alter ID - Alter ID + #AlterID + - Security - 安全设置 + + #Security + auto - 自动 + - + aes-128-gcm - + - + chacha20-poly1305 - + - - - - + + + + none - 不使用 + - Transport - 传输设置 + #Transport + tcp (TCP) - + http (HTTP) - + ws (WebSocket) - + kcp (mKCP) - + domainsocket (Domain Socket) - + quic (Quick UDP Internet Connection) - + - - Transport Settings (StreamSettingsObject) - 传输设置 + + #TransportSettings + - + TCP - + - none (NoneHeaderObject) - - - - - Connection Settings - - - - - http (HttpHeaderobject) - - - - - - - type - 伪装类型 + + http + - Request (HTTPRequestObject) - 请求包 (HTTPRequestObject) - - - - { - "version": "1.1", - "method": "GET", - "path": ["/"], - "headers": { - "Host": ["www.baidu.com", "www.bing.com"], - "User-Agent": [ - "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36", - "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/53.0.2785.109 Mobile/14A456 Safari/601.1.46" - ], - "Accept-Encoding": ["gzip, deflate"], - "Connection": ["keep-alive"], - "Pragma": "no-cache" - } -} - + + + #Type - - Response (HTTPResponseObject) - 响应包 (HTTPResponseObject) - - - - { - "version": "1.1", - "status": "200", - "reason": "OK", - "headers": { - "Content-Type": ["application/octet-stream", "video/mpeg"], - "Transfer-Encoding": ["chunked"], - "Connection": ["keep-alive"], - "Pragma": "no-cache" - } -} + + #Request - + + + #InsertDefaultContent + + + + + #Response + + + + HTTP - - - - - - v2ray.com - - host - 域名 - - - - - - path - 路径 - - - - - / + + + + #Path - + WebSocket - + - - headers (Key Value Pair) - HTTP 头 + + + #Headers + - + mKCP - - MTU - 最大传输单元 - - - - TTI (ms) - 传输时间间隔 - - - - UplinkCapacity (MB/s) - 上行链路容量 (MB/s) - - - - Congestion - 拥塞控制 - - - - Enabled - 启用 - - - - downlinkCapacity (MB/s) - 下行链路容量 (MB/s) - - - - readBufferSize (MB) - 读取缓冲区 (MB) - - - - writeBufferSize (MB) - 写入缓冲区 (MB) - - - - header (Header Object) - 数据包头部伪装 - - - none (None) - 不使用 - - - - - srtp (SRTP, FaceTime) - - - - - - utp (BitTorrent) - - - - - - wechat-video (WeChat Video Message) - - - - - - dtls (DTLS 1.2) - - - - - - wireguard (WireGuard fake packets) - - - - - DomainSocket - - - - - /path/to/ds/file - - - - - QUIC - - - - - security - 加密方式 - - - - key - 密钥 - - - - xxxxx + + #MTU - - header - 头部伪装 + + #TTI (ms) + - - header (HeaderObject) - 头部伪装 (HeaderObject) + + #UplinkCapacity (MB/s) + + + + + #Congestion + + + + + #Enabled + + + + + #DownlinkCapacity (MB/s) + + + + + #ReadBufferSize (MB) + + + + + #WriteBufferSize (MB) + + + + + + #Header + + + + + + srtp (SRTP, FaceTime) + + + + + + utp (BitTorrent) + + + + + + wechat-video (WeChat Video Message) + + + + + + dtls (DTLS 1.2) + + + + + + wireguard (WireGuard fake packets) + + + + + DomainSocket + + + + + QUIC + + + + + #Key + + + + + ImportConfig + + + Import file + + + + + #ImportFrom + + + + + Existing File + + + + + VMess Connection String + + + + + #FromFile + + + + + #Path + + + + + #SelectFile + + + + + #Name + + + + + #Inbound + + + + + #UseCurrent + + + + + #UseImported + + + + + #From VMess Connection String + + + + + #VMess Connection String + + + + + OpenConfigFile + + + + + + + + ImportConfig + + + + + CannotOpenFile + + + + + SaveFailed + + + + + CannotCopyCustomConfig + + + + + CannotGenerateConfig + MainWindow + Hv2ray - Start - 启动 + + #Start + - Stop - 停止 + + #Stop + - Restart - 重新启动 + + #Restart + - Clear Log - 清除日志 - - - - Config Detail - 详细配置 + #ClearLog + - Host list - 服务器列表 - - - - Config 1 (www.hostname.com:port) + #HostList - - Host - 主机名 - - - - www.hostname.com + + #ConfigDetail - - Port - 端口 - - - - 12345 + + #Host - - UUID - UUID - - - - TextLabel + + #Port - - Transport - 传输设置 - - - - mKCP + + #UUID - - Connection Settings - 连接设置 - - - - Settings - 设置 - - - - File - 文件 - - - - New - 新建 - - - - From - 导入 - - - - About - 关于 - - - - Edit - 编辑 - - - - Vmess + + #Transport - - Existing config - 现有配置 + + + #ConnectionSettings + - - Exit - 退出 + + #File + - - Preferences - 首选项 + + #NewConnection + + + + + #ManuallyInput + + + + + #ImportConnection + + + + + #Exit + + + + + #Preferences + + + + + + #Hide + + + + + #Quit + + + + + #Show + PrefrencesWindow + + Prefrences - 首选项 - - - - General - 基本 - - - - Language - 语言 + zh-CN - 中文 + en-US - 英语 + + + + + #General + + + + + #Language + - Run v2ray with root - 使用 root 启动 v2ray + #RunAsRoot + @@ -513,147 +516,144 @@ - Enabled - 启用 + #Enabled + - Log Level - 日志等级 + #LogLevel + debug - 调试 + info - 信息 + warning - 警告 + error - 错误 + none - 不使用 + - Mux Cool + #MuxCool - Concurrency + #Concurrency - Inbound Settings - 入站设置 - - - - HTTP - HTTP + #InboundSettings + - Port - 端口 - - - - 8080 - + #Port + - Username + #Username - Auth + #Auth - Password + #Password + + + + + HTTP + + + + + 8080 SOCKS - SOCKS + 9001 - + - - Config error + + #Prefrences + + + + + #CannotOpenConfigFile - Port numbers cannot be the same! + PortNumbersCannotBeSame + + + + + RunAsRootNotOnWindows - importConf + QObject - - Import file + + Hv2Ray - - File name: + + AnotherInstanceRunning - - open + + CoreNotFound - - Alias: + + CoreFileNotFoundExplaination - - Open Config File - - - - - import_vmess - - - Vmess - - - - - Alias: + + ConfigurationError