mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-04-02 18:31:50 -04:00
Update UI
This commit is contained in:
parent
c3a5f8d39d
commit
02d78d7607
@ -54,3 +54,6 @@ desktop_icon.path = /usr/share/pixmaps/
|
|||||||
desktop_icon.files = com.yuezk.qt.GPClient.svg
|
desktop_icon.files = com.yuezk.qt.GPClient.svg
|
||||||
|
|
||||||
INSTALLS += desktop_entry desktop_icon
|
INSTALLS += desktop_entry desktop_icon
|
||||||
|
|
||||||
|
RESOURCES += \
|
||||||
|
resources.qrc
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
viewBox="0 0 96 96"
|
viewBox="0 0 96 96"
|
||||||
style="enable-background:new 0 0 96 96;"
|
style="enable-background:new 0 0 96 96;"
|
||||||
xml:space="preserve"
|
xml:space="preserve"
|
||||||
sodipodi:docname="logo.svg"
|
sodipodi:docname="com.yuezk.qt.GPClient.svg"
|
||||||
inkscape:version="0.92.4 5da689c313, 2019-01-14"><metadata
|
inkscape:version="0.92.4 5da689c313, 2019-01-14"><metadata
|
||||||
id="metadata14"><rdf:RDF><cc:Work
|
id="metadata14"><rdf:RDF><cc:Work
|
||||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
|
||||||
id="defs12" /><sodipodi:namedview
|
id="defs12" /><sodipodi:namedview
|
||||||
pagecolor="#ffffff"
|
pagecolor="#ffffff"
|
||||||
bordercolor="#666666"
|
bordercolor="#666666"
|
||||||
@ -34,9 +34,9 @@
|
|||||||
inkscape:window-height="1006"
|
inkscape:window-height="1006"
|
||||||
id="namedview10"
|
id="namedview10"
|
||||||
showgrid="false"
|
showgrid="false"
|
||||||
inkscape:zoom="1.7383042"
|
inkscape:zoom="6.9532168"
|
||||||
inkscape:cx="30.139499"
|
inkscape:cx="7.9545315"
|
||||||
inkscape:cy="105.664"
|
inkscape:cy="59.062386"
|
||||||
inkscape:window-x="0"
|
inkscape:window-x="0"
|
||||||
inkscape:window-y="0"
|
inkscape:window-y="0"
|
||||||
inkscape:window-maximized="1"
|
inkscape:window-maximized="1"
|
||||||
@ -96,4 +96,4 @@
|
|||||||
inkscape:connector-curvature="0"
|
inkscape:connector-curvature="0"
|
||||||
id="XMLID_8_"
|
id="XMLID_8_"
|
||||||
class="st5"
|
class="st5"
|
||||||
d="m 50,48.2 c 0,-1 -0.8,-1.8 -1.8,-1.8 -1,0 -1.8,0.8 -1.8,1.8 0,0.7 0.4,1.3 1,1.6 l -1,5.2 H 50 l -1,-5.2 c 0.6,-0.3 1,-0.9 1,-1.6 z" /></g></g></svg>
|
d="m 50.35,48.2 c 0,-1 -0.8,-1.8 -1.8,-1.8 -1,0 -1.8,0.8 -1.8,1.8 0,0.7 0.4,1.3 1,1.6 l -1,5.2 h 3.6 l -1,-5.2 c 0.6,-0.3 1,-0.9 1,-1.6 z" /></g></g></svg>
|
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.7 KiB |
BIN
GPClient/connected.png
Normal file
BIN
GPClient/connected.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
@ -3,23 +3,26 @@
|
|||||||
#include "samlloginwindow.h"
|
#include "samlloginwindow.h"
|
||||||
|
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
#include <QGraphicsPixmapItem>
|
||||||
|
#include <QImage>
|
||||||
|
#include <QStyle>
|
||||||
|
|
||||||
GPClient::GPClient(QWidget *parent)
|
GPClient::GPClient(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
, ui(new Ui::GPClient)
|
, ui(new Ui::GPClient)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
setFixedSize(width(), height());
|
setFixedSize(width(), height());
|
||||||
moveCenter();
|
moveCenter();
|
||||||
|
|
||||||
|
// Restore portal from the previous settings
|
||||||
settings = new QSettings("com.yuezk.qt", "GPClient");
|
settings = new QSettings("com.yuezk.qt", "GPClient");
|
||||||
ui->portalInput->setText(settings->value("portal", "").toString());
|
ui->portalInput->setText(settings->value("portal", "").toString());
|
||||||
|
|
||||||
QObject::connect(this, &GPClient::connectFailed, [this]() {
|
QObject::connect(this, &GPClient::connectFailed, [this]() {
|
||||||
ui->connectButton->setDisabled(false);
|
updateConnectionStatus("not_connected");
|
||||||
ui->connectButton->setText("Connect");
|
|
||||||
ui->statusLabel->setText("Not Connected");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// QNetworkAccessManager setup
|
// QNetworkAccessManager setup
|
||||||
@ -38,8 +41,7 @@ GPClient::GPClient(QWidget *parent)
|
|||||||
|
|
||||||
int status = vpn->status();
|
int status = vpn->status();
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
ui->statusLabel->setText("Connected");
|
updateConnectionStatus("connected");
|
||||||
ui->connectButton->setText("Disconnect");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,15 +63,19 @@ void GPClient::on_connectButton_clicked()
|
|||||||
QString portal = ui->portalInput->text();
|
QString portal = ui->portalInput->text();
|
||||||
settings->setValue("portal", portal);
|
settings->setValue("portal", portal);
|
||||||
ui->statusLabel->setText("Authenticating...");
|
ui->statusLabel->setText("Authenticating...");
|
||||||
ui->connectButton->setDisabled(true);
|
updateConnectionStatus("pending");
|
||||||
samlLogin(portal);
|
samlLogin(portal);
|
||||||
} else if (btnText == "Cancel") {
|
} else if (btnText == "Cancel") {
|
||||||
ui->statusLabel->setText("Canceling...");
|
ui->statusLabel->setText("Canceling...");
|
||||||
ui->connectButton->setDisabled(true);
|
updateConnectionStatus("pending");
|
||||||
|
|
||||||
|
if (reply->isRunning()) {
|
||||||
|
reply->abort();
|
||||||
|
}
|
||||||
vpn->disconnect();
|
vpn->disconnect();
|
||||||
} else {
|
} else {
|
||||||
ui->statusLabel->setText("Disconnecting...");
|
ui->statusLabel->setText("Disconnecting...");
|
||||||
ui->connectButton->setDisabled(true);
|
updateConnectionStatus("pending");
|
||||||
vpn->disconnect();
|
vpn->disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,7 +124,6 @@ void GPClient::preloginResultFinished()
|
|||||||
loginWindow->login(samlRequest);
|
loginWindow->login(samlRequest);
|
||||||
loginWindow->exec();
|
loginWindow->exec();
|
||||||
}
|
}
|
||||||
delete reply;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPClient::onLoginSuccess(QJsonObject loginResult)
|
void GPClient::onLoginSuccess(QJsonObject loginResult)
|
||||||
@ -141,27 +146,38 @@ void GPClient::onLoginSuccess(QJsonObject loginResult)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString host = QString("https://%1/%2:%3").arg(loginResult.value("server").toString(), shortpath, cookieName);
|
QString host = QString("https://%1/%2:%3").arg(loginResult.value("server").toString(), shortpath, cookieName);
|
||||||
qDebug() << "Server:" << host << ", User:" << user << "Cookie:" << cookieValue;
|
vpn->connect(host, user, cookieValue);
|
||||||
qDebug() << "openconnect --protocol=gp -u" << user << "--passwd-on-stdin" << host;
|
|
||||||
|
|
||||||
ui->statusLabel->setText("Connecting...");
|
ui->statusLabel->setText("Connecting...");
|
||||||
|
updateConnectionStatus("pending");
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPClient::updateConnectionStatus(QString status)
|
||||||
|
{
|
||||||
|
if (status == "not_connected") {
|
||||||
|
ui->statusLabel->setText("Not Connected");
|
||||||
|
ui->statusImage->setStyleSheet("image: url(:/images/not_connected.png); padding: 15;");
|
||||||
|
ui->connectButton->setText("Connect");
|
||||||
|
ui->connectButton->setDisabled(false);
|
||||||
|
} else if (status == "pending") {
|
||||||
|
ui->statusImage->setStyleSheet("image: url(:/images/pending.png); padding: 15;");
|
||||||
ui->connectButton->setText("Cancel");
|
ui->connectButton->setText("Cancel");
|
||||||
ui->connectButton->setDisabled(false);
|
ui->connectButton->setDisabled(false);
|
||||||
vpn->connect(host, user, cookieValue);
|
} else if (status == "connected") {
|
||||||
|
ui->statusLabel->setText("Connected");
|
||||||
|
ui->statusImage->setStyleSheet("image: url(:/images/connected.png); padding: 15;");
|
||||||
|
ui->connectButton->setText("Disconnect");
|
||||||
|
ui->connectButton->setDisabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPClient::onVPNConnected()
|
void GPClient::onVPNConnected()
|
||||||
{
|
{
|
||||||
ui->statusLabel->setText("Connected");
|
updateConnectionStatus("connected");
|
||||||
ui->connectButton->setText("Disconnect");
|
|
||||||
ui->connectButton->setDisabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPClient::onVPNDisconnected()
|
void GPClient::onVPNDisconnected()
|
||||||
{
|
{
|
||||||
ui->statusLabel->setText("Not Connected");
|
updateConnectionStatus("not_connected");
|
||||||
ui->connectButton->setText("Connect");
|
|
||||||
ui->connectButton->setDisabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPClient::onVPNLogAvailable(QString log)
|
void GPClient::onVPNLogAvailable(QString log)
|
||||||
|
@ -41,6 +41,7 @@ private:
|
|||||||
QSettings *settings;
|
QSettings *settings;
|
||||||
|
|
||||||
void moveCenter();
|
void moveCenter();
|
||||||
|
void updateConnectionStatus(QString status);
|
||||||
void samlLogin(const QString portal);
|
void samlLogin(const QString portal);
|
||||||
};
|
};
|
||||||
#endif // GPCLIENT_H
|
#endif // GPCLIENT_H
|
||||||
|
@ -7,15 +7,18 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>260</width>
|
<width>260</width>
|
||||||
<height>300</height>
|
<height>338</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>GP VPN Client</string>
|
<string>GP VPN Client</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowIcon">
|
<property name="windowIcon">
|
||||||
<iconset>
|
<iconset resource="resources.qrc">
|
||||||
<normaloff>com.yuezk.qt.GPClient.svg</normaloff>com.yuezk.qt.GPClient.svg</iconset>
|
<normaloff>:/images/logo.svg</normaloff>:/images/logo.svg</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
@ -47,12 +50,28 @@
|
|||||||
<number>15</number>
|
<number>15</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0">
|
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,0">
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>15</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="statusImage">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">#statusImage {
|
||||||
|
image: url(:/images/not_connected.png);
|
||||||
|
padding: 15
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="statusLabel">
|
<widget class="QLabel" name="statusLabel">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<pointsize>18</pointsize>
|
<pointsize>14</pointsize>
|
||||||
<weight>50</weight>
|
<weight>50</weight>
|
||||||
<bold>false</bold>
|
<bold>false</bold>
|
||||||
<underline>false</underline>
|
<underline>false</underline>
|
||||||
@ -101,6 +120,8 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="resources.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
BIN
GPClient/not_connected.png
Normal file
BIN
GPClient/not_connected.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
GPClient/pending.png
Normal file
BIN
GPClient/pending.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
11
GPClient/resources.qrc
Normal file
11
GPClient/resources.qrc
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/images">
|
||||||
|
<file alias="logo.svg">com.yuezk.qt.GPClient.svg</file>
|
||||||
|
<file>connected.png</file>
|
||||||
|
<file>pending.png</file>
|
||||||
|
<file>not_connected.png</file>
|
||||||
|
</qresource>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>styles.css</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
0
GPClient/styles.css
Normal file
0
GPClient/styles.css
Normal file
@ -6,4 +6,4 @@ Wants=network.target
|
|||||||
[Service]
|
[Service]
|
||||||
Type=dbus
|
Type=dbus
|
||||||
BusName=com.yuezk.qt.GPService
|
BusName=com.yuezk.qt.GPService
|
||||||
ExecStart=/usr/local/bin/gpservice --no-dtls -U nm-openconnect
|
ExecStart=/usr/local/bin/gpservice
|
||||||
|
Loading…
Reference in New Issue
Block a user