mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-21 19:30:26 +08:00
Merge pull request #22 from lhy0403/dev
[v1 RC1] Several bug fixes especially in UI.
Former-commit-id: f342374412
This commit is contained in:
commit
b17287d921
@ -275,13 +275,14 @@ namespace Qv2ray
|
||||
int alterId;
|
||||
string security;
|
||||
int level;
|
||||
UserObject() : id(), alterId(64), security("auto"), level(0) {}
|
||||
UserObject() : id(""), alterId(64), security("auto"), level(0) {}
|
||||
XTOSTRUCT(O(id, alterId, security, level))
|
||||
};
|
||||
// OUTBound;
|
||||
string address;
|
||||
int port;
|
||||
list<UserObject> users;
|
||||
ServerObject(): address(""), port(0), users() {}
|
||||
XTOSTRUCT(O(address, port, users))
|
||||
};
|
||||
list<ServerObject> vnext;
|
||||
|
22
src/main.cpp
22
src/main.cpp
@ -24,19 +24,17 @@ bool initializeQv()
|
||||
configPath = "./qv2ray.d";
|
||||
exeDefaultPath = "./qv2ray.d/v2ray";
|
||||
v2AssetsPath = "./qv2ray.d";
|
||||
#elif defined (__APPLE__)
|
||||
// In APPLE's world, the application is contained in a .app folder
|
||||
LOG(QDir::currentPath().toStdString())
|
||||
QDir bin(QCoreApplication::applicationDirPath());
|
||||
bin.cdUp();
|
||||
configPath = bin.absolutePath() + "/Resources";
|
||||
exeDefaultPath = configPath + "/v2ray";
|
||||
v2AssetsPath = configPath;
|
||||
#else
|
||||
// However, for linux, this software can be and/or will be provided as a
|
||||
// package and install to whatever /usr/bin or /usr/local/bin or even /opt/
|
||||
// Thus we save config files in the user's home directory.
|
||||
#else // NOT WINDOWS (*nix)
|
||||
// Global config dir.
|
||||
configPath = QDir::homePath() + "/.qv2ray";
|
||||
exeDefaultPath = configPath + "/vcore/v2ray";
|
||||
v2AssetsPath = configPath + "/vcore";
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
// Special case for GNU/Linux
|
||||
// Unused these values
|
||||
Q_UNUSED(v2AssetsPath)
|
||||
Q_UNUSED(exeDefaultPath)
|
||||
v2AssetsPath = "/etc/v2ray";
|
||||
exeDefaultPath = "/bin/v2ray";
|
||||
#endif
|
||||
|
@ -16,6 +16,9 @@ ConnectionEditWindow::ConnectionEditWindow(QWidget *parent)
|
||||
ui->alterLineEdit->setValidator(new QIntValidator());
|
||||
//
|
||||
LoadGUIContents();
|
||||
vmess = VMessOut::ServerObject();
|
||||
vmess.users.push_back(VMessOut::ServerObject::UserObject());
|
||||
stream = StreamSettingsObject();
|
||||
}
|
||||
|
||||
ConnectionEditWindow::ConnectionEditWindow(QJsonObject editRootObject, QString alias, QWidget *parent)
|
||||
@ -91,7 +94,7 @@ void ConnectionEditWindow::LoadGUIContents()
|
||||
void ConnectionEditWindow::on_buttonBox_accepted()
|
||||
{
|
||||
bool new_config = _alias == "";
|
||||
auto alias = new_config ? ui->ipLineEdit->text() : _alias;
|
||||
auto alias = new_config ? (ui->ipLineEdit->text() + "_" + ui->portLineEdit->text()) : _alias;
|
||||
//
|
||||
auto outbound = GenerateConnectionJson();
|
||||
QJsonArray outbounds;
|
||||
|
@ -26,8 +26,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
QAction *actionShowHide = new QAction(this->windowIcon(), tr("#Hide"), this);
|
||||
QAction *actionQuit = new QAction(tr("#Quit"), this);
|
||||
QAction *actionStart = new QAction(tr("#Start"), this);
|
||||
QAction *actionRestart = new QAction(tr("#Stop"), this);
|
||||
QAction *actionStop = new QAction(tr("#Restart"), this);
|
||||
QAction *actionRestart = new QAction(tr("#Restart"), this);
|
||||
QAction *actionStop = new QAction(tr("#Stop"), this);
|
||||
actionStart->setEnabled(true);
|
||||
actionStop->setEnabled(false);
|
||||
actionRestart->setEnabled(false);
|
||||
@ -48,6 +48,10 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
hTray->setContextMenu(trayMenu);
|
||||
hTray->show();
|
||||
LoadConnections();
|
||||
//
|
||||
if(!vinstance->ValidateV2rayCoreExe()){
|
||||
on_prefrencesBtn_clicked();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::LoadConnections()
|
||||
@ -95,10 +99,18 @@ void MainWindow::on_startButton_clicked()
|
||||
auto full_conf = GenerateRuntimeConfig(connections.value(CurrentConnectionName));
|
||||
StartPreparation(full_conf);
|
||||
bool startFlag = this->vinstance->Start();
|
||||
|
||||
if (startFlag) {
|
||||
ui->statusLabel->setText(tr("#Started") + ": " + CurrentConnectionName);
|
||||
}
|
||||
|
||||
trayMenu->actions()[2]->setEnabled(!startFlag);
|
||||
trayMenu->actions()[3]->setEnabled(startFlag);
|
||||
trayMenu->actions()[4]->setEnabled(startFlag);
|
||||
//
|
||||
ui->startButton->setEnabled(!startFlag);
|
||||
ui->stopButton->setEnabled(startFlag);
|
||||
ui->restartButton->setEnabled(startFlag);
|
||||
}
|
||||
|
||||
void MainWindow::on_stopButton_clicked()
|
||||
@ -111,6 +123,10 @@ void MainWindow::on_stopButton_clicked()
|
||||
trayMenu->actions()[2]->setEnabled(true);
|
||||
trayMenu->actions()[3]->setEnabled(false);
|
||||
trayMenu->actions()[4]->setEnabled(false);
|
||||
//
|
||||
ui->startButton->setEnabled(true);
|
||||
ui->stopButton->setEnabled(false);
|
||||
ui->restartButton->setEnabled(false);
|
||||
}
|
||||
|
||||
void MainWindow::on_restartButton_clicked()
|
||||
@ -243,7 +259,9 @@ void MainWindow::on_delConfigBtn_clicked()
|
||||
|
||||
if (currentSelected < 0) return;
|
||||
|
||||
if (ui->connectionListWidget->item(currentSelected)->text() == CurrentConnectionName) {
|
||||
bool isRemovingRunning = ui->connectionListWidget->item(currentSelected)->text() == CurrentConnectionName;
|
||||
|
||||
if (isRemovingRunning) {
|
||||
on_stopButton_clicked();
|
||||
CurrentConnectionName = "";
|
||||
}
|
||||
@ -252,8 +270,11 @@ void MainWindow::on_delConfigBtn_clicked()
|
||||
conf.configs = list.toStdList();
|
||||
SetGlobalConfig(conf);
|
||||
SaveGlobalConfig();
|
||||
|
||||
if (isRemovingRunning) {
|
||||
reload_config();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_prefrencesBtn_clicked()
|
||||
{
|
||||
@ -276,3 +297,8 @@ void MainWindow::on_editConnectionSettingsBtn_clicked()
|
||||
w->show();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_clearlogButton_clicked()
|
||||
{
|
||||
ui->logText->clear();
|
||||
}
|
||||
|
@ -48,6 +48,8 @@ class MainWindow : public QMainWindow
|
||||
|
||||
void on_editConnectionSettingsBtn_clicked();
|
||||
|
||||
void on_clearlogButton_clicked();
|
||||
|
||||
private:
|
||||
void ShowAndSetConnection(int index, bool SetConnection, bool Apply);
|
||||
void LoadConnections();
|
||||
|
@ -50,6 +50,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="stopButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>#Stop</string>
|
||||
</property>
|
||||
@ -57,6 +60,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="restartButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>#Restart</string>
|
||||
</property>
|
||||
|
@ -19,23 +19,31 @@ PrefrencesWindow::PrefrencesWindow(QWidget *parent) : QDialog(parent),
|
||||
ui->logLevelComboBox->setCurrentIndex(CurrentConfig.logLevel);
|
||||
//
|
||||
//
|
||||
ui->httpCB->setChecked(CurrentConfig.inBoundSettings.http_port != 0);
|
||||
ui->listenIPTxt->setText(QString::fromStdString(CurrentConfig.inBoundSettings.listenip));
|
||||
//
|
||||
bool have_http = CurrentConfig.inBoundSettings.http_port != 0;
|
||||
ui->httpCB->setChecked(have_http);
|
||||
ui->httpPortLE->setText(QString::fromStdString(to_string(CurrentConfig.inBoundSettings.http_port)));
|
||||
ui->httpAuthCB->setChecked(CurrentConfig.inBoundSettings.http_useAuth);
|
||||
//
|
||||
ui->httpAuthUsernameTxt->setEnabled(CurrentConfig.inBoundSettings.http_useAuth);
|
||||
ui->httpAuthPasswordTxt->setEnabled(CurrentConfig.inBoundSettings.http_useAuth);
|
||||
ui->httpAuthCB->setEnabled(have_http);
|
||||
ui->httpAuthCB->setChecked(CurrentConfig.inBoundSettings.http_useAuth);
|
||||
ui->httpAuthUsernameTxt->setEnabled(have_http && CurrentConfig.inBoundSettings.http_useAuth);
|
||||
ui->httpAuthPasswordTxt->setEnabled(have_http && CurrentConfig.inBoundSettings.http_useAuth);
|
||||
ui->httpAuthUsernameTxt->setText(QString::fromStdString(CurrentConfig.inBoundSettings.httpAccount.user));
|
||||
ui->httpAuthPasswordTxt->setText(QString::fromStdString(CurrentConfig.inBoundSettings.httpAccount.pass));
|
||||
ui->httpPortLE->setValidator(new QIntValidator());
|
||||
//
|
||||
//
|
||||
ui->socksCB->setChecked(CurrentConfig.inBoundSettings.socks_port != 0);
|
||||
bool have_socks = CurrentConfig.inBoundSettings.socks_port != 0;
|
||||
ui->socksCB->setChecked(have_socks);
|
||||
ui->socksPortLE->setText(QString::fromStdString(to_string(CurrentConfig.inBoundSettings.socks_port)));
|
||||
ui->socksAuthCB->setChecked(CurrentConfig.inBoundSettings.socks_useAuth);
|
||||
//
|
||||
ui->socksAuthUsernameTxt->setEnabled(CurrentConfig.inBoundSettings.socks_useAuth);
|
||||
ui->socksAuthPasswordTxt->setEnabled(CurrentConfig.inBoundSettings.socks_useAuth);
|
||||
ui->socksAuthCB->setEnabled(have_socks);
|
||||
ui->socksAuthCB->setChecked(CurrentConfig.inBoundSettings.socks_useAuth);
|
||||
ui->socksAuthUsernameTxt->setEnabled(have_socks && CurrentConfig.inBoundSettings.socks_useAuth);
|
||||
ui->socksAuthPasswordTxt->setEnabled(have_socks && CurrentConfig.inBoundSettings.socks_useAuth);
|
||||
ui->socksAuthUsernameTxt->setText(QString::fromStdString(CurrentConfig.inBoundSettings.socksAccount.user));
|
||||
ui->socksAuthPasswordTxt->setText(QString::fromStdString(CurrentConfig.inBoundSettings.socksAccount.pass));
|
||||
ui->socksPortLE->setValidator(new QIntValidator());
|
||||
@ -68,7 +76,10 @@ PrefrencesWindow::~PrefrencesWindow()
|
||||
|
||||
void PrefrencesWindow::on_buttonBox_accepted()
|
||||
{
|
||||
if (ui->httpPortLE->text().toInt() == ui->socksPortLE->text().toInt()) {
|
||||
int sp = ui->socksPortLE->text().toInt();
|
||||
int hp = ui->httpPortLE->text().toInt() ;
|
||||
|
||||
if (!(sp == 0 || hp == 0) && sp == hp) {
|
||||
QvMessageBox(this, tr("Prefrences"), tr("PortNumbersCannotBeSame"));
|
||||
return;
|
||||
}
|
||||
@ -81,8 +92,8 @@ void PrefrencesWindow::on_httpCB_stateChanged(int checked)
|
||||
{
|
||||
ui->httpPortLE->setEnabled(checked == Qt::Checked);
|
||||
ui->httpAuthCB->setEnabled(checked == Qt::Checked);
|
||||
ui->httpAuthUsernameTxt->setEnabled(checked == Qt::Checked);
|
||||
ui->httpAuthPasswordTxt->setEnabled(checked == Qt::Checked);
|
||||
ui->httpAuthUsernameTxt->setEnabled(checked == Qt::Checked && ui->httpAuthCB->isChecked());
|
||||
ui->httpAuthPasswordTxt->setEnabled(checked == Qt::Checked && ui->httpAuthCB->isChecked());
|
||||
CurrentConfig.inBoundSettings.http_port = checked == Qt::Checked ? CurrentConfig.inBoundSettings.http_port : 0;
|
||||
|
||||
if (checked != Qt::Checked) {
|
||||
@ -94,8 +105,8 @@ void PrefrencesWindow::on_socksCB_stateChanged(int checked)
|
||||
{
|
||||
ui->socksPortLE->setEnabled(checked == Qt::Checked);
|
||||
ui->socksAuthCB->setEnabled(checked == Qt::Checked);
|
||||
ui->socksAuthUsernameTxt->setEnabled(checked == Qt::Checked);
|
||||
ui->socksAuthPasswordTxt->setEnabled(checked == Qt::Checked);
|
||||
ui->socksAuthUsernameTxt->setEnabled(checked == Qt::Checked && ui->socksAuthCB->isChecked());
|
||||
ui->socksAuthPasswordTxt->setEnabled(checked == Qt::Checked && ui->socksAuthCB->isChecked());
|
||||
CurrentConfig.inBoundSettings.socks_port = checked == Qt::Checked ? CurrentConfig.inBoundSettings.socks_port : 0;
|
||||
|
||||
if (checked != Qt::Checked) {
|
||||
|
@ -19,6 +19,9 @@
|
||||
<property name="windowTitle">
|
||||
<string>Prefrences</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
|
Loading…
Reference in New Issue
Block a user