mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 19:00:22 +08:00
[Fix] Some fixes in Issue #21
This commit is contained in:
parent
28ca0adafd
commit
a3f92dbdca
@ -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;
|
||||
|
@ -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);
|
||||
@ -95,10 +95,18 @@ void MainWindow::on_startButton_clicked()
|
||||
auto full_conf = GenerateRuntimeConfig(connections.value(CurrentConnectionName));
|
||||
StartPreparation(full_conf);
|
||||
bool startFlag = this->vinstance->Start();
|
||||
ui->statusLabel->setText(tr("#Started") + ": " + CurrentConnectionName);
|
||||
|
||||
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,7 +266,10 @@ void MainWindow::on_delConfigBtn_clicked()
|
||||
conf.configs = list.toStdList();
|
||||
SetGlobalConfig(conf);
|
||||
SaveGlobalConfig();
|
||||
reload_config();
|
||||
|
||||
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();
|
||||
}
|
||||
|
@ -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,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