[Fix] Some fixes in Issue #21

This commit is contained in:
Leroy.H.Y 2019-07-10 21:28:17 +08:00
parent 28ca0adafd
commit a3f92dbdca
No known key found for this signature in database
GPG Key ID: 6AC1673B587DC37D
6 changed files with 44 additions and 7 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);
@ -95,10 +95,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 +119,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 +255,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 +266,11 @@ void MainWindow::on_delConfigBtn_clicked()
conf.configs = list.toStdList();
SetGlobalConfig(conf);
SaveGlobalConfig();
if (isRemovingRunning) {
reload_config();
}
}
void MainWindow::on_prefrencesBtn_clicked()
{
@ -276,3 +293,8 @@ void MainWindow::on_editConnectionSettingsBtn_clicked()
w->show();
}
}
void MainWindow::on_clearlogButton_clicked()
{
ui->logText->clear();
}

View File

@ -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();

View File

@ -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>

View File

@ -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">