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