mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-04-02 18:31:50 -04:00
Improve UI
This commit is contained in:
parent
2a7230a277
commit
c08ce6298c
@ -11,6 +11,7 @@ GPClient::GPClient(QWidget *parent)
|
||||
QObject::connect(this, &GPClient::connectFailed, [this]() {
|
||||
ui->connectButton->setDisabled(false);
|
||||
ui->connectButton->setText("Connect");
|
||||
ui->statusLabel->setText("Not Connected");
|
||||
});
|
||||
|
||||
// QNetworkAccessManager setup
|
||||
@ -26,6 +27,12 @@ GPClient::GPClient(QWidget *parent)
|
||||
QObject::connect(vpn, &com::yuezk::qt::GPService::connected, this, &GPClient::onVPNConnected);
|
||||
QObject::connect(vpn, &com::yuezk::qt::GPService::disconnected, this, &GPClient::onVPNDisconnected);
|
||||
QObject::connect(vpn, &com::yuezk::qt::GPService::logAvailable, this, &GPClient::onVPNLogAvailable);
|
||||
|
||||
int status = vpn->status();
|
||||
if (status != 0) {
|
||||
ui->statusLabel->setText("Connected");
|
||||
ui->connectButton->setText("Disconnect");
|
||||
}
|
||||
}
|
||||
|
||||
GPClient::~GPClient()
|
||||
@ -39,16 +46,20 @@ GPClient::~GPClient()
|
||||
|
||||
void GPClient::on_connectButton_clicked()
|
||||
{
|
||||
if (ui->connectButton->text() == "Connect") {
|
||||
QString btnText = ui->connectButton->text();
|
||||
|
||||
if (btnText == "Connect") {
|
||||
QString portal = ui->portalInput->text();
|
||||
|
||||
ui->statusLabel->setText("Authenticating...");
|
||||
ui->connectButton->setDisabled(true);
|
||||
ui->connectButton->setText("Connecting...");
|
||||
samlLogin(portal);
|
||||
} else {
|
||||
} else if (btnText == "Cancel") {
|
||||
ui->statusLabel->setText("Canceling...");
|
||||
ui->connectButton->setDisabled(true);
|
||||
vpn->disconnect();
|
||||
} else {
|
||||
ui->statusLabel->setText("Disconnecting...");
|
||||
ui->connectButton->setDisabled(true);
|
||||
ui->connectButton->setText("Disconnecting...");
|
||||
|
||||
vpn->disconnect();
|
||||
}
|
||||
}
|
||||
@ -123,21 +134,23 @@ void GPClient::onLoginSuccess(QJsonObject loginResult)
|
||||
qDebug() << "Server:" << host << ", User:" << user << "Cookie:" << cookieValue;
|
||||
qDebug() << "openconnect --protocol=gp -u" << user << "--passwd-on-stdin" << host;
|
||||
|
||||
ui->statusLabel->setText("Connecting...");
|
||||
ui->connectButton->setText("Cancel");
|
||||
vpn->connect(host, user, cookieValue);
|
||||
}
|
||||
|
||||
void GPClient::onVPNConnected()
|
||||
{
|
||||
qDebug() << "VPN connected";
|
||||
ui->connectButton->setDisabled(false);
|
||||
ui->statusLabel->setText("Connected");
|
||||
ui->connectButton->setText("Disconnect");
|
||||
ui->connectButton->setDisabled(false);
|
||||
}
|
||||
|
||||
void GPClient::onVPNDisconnected()
|
||||
{
|
||||
qDebug() << "VPN disconnected";
|
||||
ui->connectButton->setDisabled(false);
|
||||
ui->statusLabel->setText("Not Connected");
|
||||
ui->connectButton->setText("Connect");
|
||||
ui->connectButton->setDisabled(false);
|
||||
}
|
||||
|
||||
void GPClient::onVPNLogAvailable(QString log)
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>258</width>
|
||||
<height>316</height>
|
||||
<height>301</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -39,9 +39,20 @@
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel" name="statusLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>18</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
<underline>false</underline>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
<string>Not Connected</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
Reference in New Issue
Block a user