mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-04-02 18:31:50 -04:00
Open window at center
This commit is contained in:
parent
c08ce6298c
commit
5d57fd5fd1
@ -2,12 +2,17 @@
|
||||
#include "ui_gpclient.h"
|
||||
#include "samlloginwindow.h"
|
||||
|
||||
#include <QDesktopWidget>
|
||||
|
||||
GPClient::GPClient(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::GPClient)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setFixedSize(width(), height());
|
||||
moveCenter();
|
||||
|
||||
QObject::connect(this, &GPClient::connectFailed, [this]() {
|
||||
ui->connectButton->setDisabled(false);
|
||||
ui->connectButton->setText("Connect");
|
||||
@ -136,6 +141,7 @@ void GPClient::onLoginSuccess(QJsonObject loginResult)
|
||||
|
||||
ui->statusLabel->setText("Connecting...");
|
||||
ui->connectButton->setText("Cancel");
|
||||
ui->connectButton->setDisabled(false);
|
||||
vpn->connect(host, user, cookieValue);
|
||||
}
|
||||
|
||||
@ -158,6 +164,28 @@ void GPClient::onVPNLogAvailable(QString log)
|
||||
qDebug() << log;
|
||||
}
|
||||
|
||||
void GPClient::moveCenter()
|
||||
{
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
|
||||
int screenWidth, width;
|
||||
int screenHeight, height;
|
||||
int x, y;
|
||||
QSize windowSize;
|
||||
|
||||
screenWidth = desktop->width();
|
||||
screenHeight = desktop->height();
|
||||
|
||||
windowSize = size();
|
||||
width = windowSize.width();
|
||||
height = windowSize.height();
|
||||
|
||||
x = (screenWidth - width) / 2;
|
||||
y = (screenHeight - height) / 2;
|
||||
y -= 50;
|
||||
move(x, y);
|
||||
}
|
||||
|
||||
void GPClient::samlLogin(const QString portal)
|
||||
{
|
||||
const QString preloginUrl = "https://" + portal + "/ssl-vpn/prelogin.esp";
|
||||
|
@ -39,6 +39,7 @@ private:
|
||||
QNetworkReply *reply;
|
||||
com::yuezk::qt::GPService *vpn;
|
||||
|
||||
void moveCenter();
|
||||
void samlLogin(const QString portal);
|
||||
};
|
||||
#endif // GPCLIENT_H
|
||||
|
@ -6,12 +6,12 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>258</width>
|
||||
<height>301</height>
|
||||
<width>260</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>GPClient</string>
|
||||
<string>GP VPN Client</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<property name="sizePolicy">
|
||||
|
Loading…
Reference in New Issue
Block a user