diff --git a/src/main.cpp b/src/main.cpp index fe9a7ffa..f5475388 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -104,8 +104,10 @@ int main(int argc, char *argv[]) // QApplication _qApp(argc, argv); + // Qv2ray Initialize - initQv(); + if (!initQv()) return -1; + #ifdef _WIN32 // Set special font in Windows QFont font; diff --git a/src/w_PrefrencesWindow.cpp b/src/w_PrefrencesWindow.cpp index bd1a3601..7ba5db7f 100644 --- a/src/w_PrefrencesWindow.cpp +++ b/src/w_PrefrencesWindow.cpp @@ -33,7 +33,7 @@ PrefrencesWindow::PrefrencesWindow(QWidget *parent) : QDialog(parent), // bool have_http = CurrentConfig.inBoundSettings.http_port != 0; ui->httpCB->setChecked(have_http); - ui->httpPortLE->setText(QSTRING(to_string(CurrentConfig.inBoundSettings.http_port))); + ui->httpPortLE->setValue(CurrentConfig.inBoundSettings.http_port); ui->httpAuthCB->setChecked(CurrentConfig.inBoundSettings.http_useAuth); // ui->httpAuthCB->setEnabled(have_http); @@ -42,12 +42,11 @@ PrefrencesWindow::PrefrencesWindow(QWidget *parent) : QDialog(parent), ui->httpAuthPasswordTxt->setEnabled(have_http && CurrentConfig.inBoundSettings.http_useAuth); ui->httpAuthUsernameTxt->setText(QSTRING(CurrentConfig.inBoundSettings.httpAccount.user)); ui->httpAuthPasswordTxt->setText(QSTRING(CurrentConfig.inBoundSettings.httpAccount.pass)); - ui->httpPortLE->setValidator(new QIntValidator()); // // bool have_socks = CurrentConfig.inBoundSettings.socks_port != 0; ui->socksCB->setChecked(have_socks); - ui->socksPortLE->setText(QSTRING(to_string(CurrentConfig.inBoundSettings.socks_port))); + ui->socksPortLE->setValue(CurrentConfig.inBoundSettings.socks_port); ui->socksAuthCB->setChecked(CurrentConfig.inBoundSettings.socks_useAuth); // ui->socksAuthCB->setEnabled(have_socks); @@ -56,7 +55,6 @@ PrefrencesWindow::PrefrencesWindow(QWidget *parent) : QDialog(parent), ui->socksAuthPasswordTxt->setEnabled(have_socks && CurrentConfig.inBoundSettings.socks_useAuth); ui->socksAuthUsernameTxt->setText(QSTRING(CurrentConfig.inBoundSettings.socksAccount.user)); ui->socksAuthPasswordTxt->setText(QSTRING(CurrentConfig.inBoundSettings.socksAccount.pass)); - ui->socksPortLE->setValidator(new QIntValidator()); // // ui->vCoreAssetsPathTxt->setText(QSTRING(CurrentConfig.v2AssetsPath)); @@ -118,7 +116,7 @@ void PrefrencesWindow::on_httpCB_stateChanged(int checked) CurrentConfig.inBoundSettings.http_port = checked == Qt::Checked ? CurrentConfig.inBoundSettings.http_port : 0; if (checked != Qt::Checked) { - ui->httpPortLE->setText("0"); + ui->httpPortLE->setValue(0); } } @@ -132,7 +130,7 @@ void PrefrencesWindow::on_socksCB_stateChanged(int checked) CurrentConfig.inBoundSettings.socks_port = checked == Qt::Checked ? CurrentConfig.inBoundSettings.socks_port : 0; if (checked != Qt::Checked) { - ui->socksPortLE->setText("0"); + ui->socksPortLE->setValue(0); } } @@ -197,18 +195,6 @@ void PrefrencesWindow::on_listenIPTxt_textEdited(const QString &arg1) CurrentConfig.inBoundSettings.listenip = arg1.toStdString(); } -void PrefrencesWindow::on_socksPortLE_textEdited(const QString &arg1) -{ - NEEDRESTART - CurrentConfig.inBoundSettings.socks_port = stoi(arg1.toStdString()); -} - -void PrefrencesWindow::on_httpPortLE_textEdited(const QString &arg1) -{ - NEEDRESTART - CurrentConfig.inBoundSettings.http_port = stoi(arg1.toStdString()); -} - void PrefrencesWindow::on_httpAuthUsernameTxt_textEdited(const QString &arg1) { NEEDRESTART @@ -348,3 +334,15 @@ void PrefrencesWindow::on_tProxyCheckBox_stateChanged(int arg1) QvMessageBox(this, tr("Prefrences"), tr("tProxy is not supported on macOS and Windows")); #endif } + +void PrefrencesWindow::on_socksPortLE_valueChanged(int arg1) +{ + NEEDRESTART + CurrentConfig.inBoundSettings.socks_port = arg1; +} + +void PrefrencesWindow::on_httpPortLE_valueChanged(int arg1) +{ + NEEDRESTART + CurrentConfig.inBoundSettings.http_port = arg1; +} diff --git a/src/w_PrefrencesWindow.h b/src/w_PrefrencesWindow.h index 93c53f63..bd6a2a62 100644 --- a/src/w_PrefrencesWindow.h +++ b/src/w_PrefrencesWindow.h @@ -43,9 +43,9 @@ class PrefrencesWindow : public QDialog void on_listenIPTxt_textEdited(const QString &arg1); - void on_socksPortLE_textEdited(const QString &arg1); + void on_socksPortLE_valueChanged(int arg1); - void on_httpPortLE_textEdited(const QString &arg1); + void on_httpPortLE_valueChanged(int arg1); void on_httpAuthUsernameTxt_textEdited(const QString &arg1); diff --git a/src/w_PrefrencesWindow.ui b/src/w_PrefrencesWindow.ui index 20843932..abf9508d 100644 --- a/src/w_PrefrencesWindow.ui +++ b/src/w_PrefrencesWindow.ui @@ -29,7 +29,7 @@ QTabWidget::Rounded - 0 + 2 @@ -247,9 +247,12 @@ - - - + + + 1 + + + 65535 @@ -314,15 +317,12 @@ - - - + + + 1 - - false - - - false + + 65535