diff options
author | Simon Rettberg | 2017-12-01 17:12:52 +0100 |
---|---|---|
committer | Simon Rettberg | 2017-12-01 17:12:52 +0100 |
commit | edb818aa42c9bb2e9c5ae437a16aa5f168c0c1a7 (patch) | |
tree | d5b2cd33e79a49f4a90ea608abf8cb789dd1091c /src/client | |
parent | [client] Use polling when checking whether to hide the bar (diff) | |
download | pvs2-edb818aa42c9bb2e9c5ae437a16aa5f168c0c1a7.tar.gz pvs2-edb818aa42c9bb2e9c5ae437a16aa5f168c0c1a7.tar.xz pvs2-edb818aa42c9bb2e9c5ae437a16aa5f168c0c1a7.zip |
Fix connection problems qith Qt5 (again)
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/net/serverconnection.cpp | 24 | ||||
-rw-r--r-- | src/client/net/serverdiscovery.cpp | 4 |
2 files changed, 11 insertions, 17 deletions
diff --git a/src/client/net/serverconnection.cpp b/src/client/net/serverconnection.cpp index d79c7c3..b2a6b0d 100644 --- a/src/client/net/serverconnection.cpp +++ b/src/client/net/serverconnection.cpp @@ -1,8 +1,7 @@ #include "serverconnection.h" #include <QtCore> #include <QPixmap> -#include <QApplication> -#include <QDesktopWidget> +#include <QGuiApplication> #include <QHostInfo> #include <unistd.h> #include <cstdlib> @@ -190,9 +189,8 @@ void ServerConnection::handleMsg() int x = _fromServer.getFieldString(_X).toInt(); int y = _fromServer.getFieldString(_Y).toInt(); - // Get rect of primary screen - const QDesktopWidget primary; - const QRect primaryRect = primary.screenGeometry(); + QRect primaryRect = QGuiApplication::primaryScreen()->geometry(); + qDebug() << primaryRect; // Limit requested size so it won't easily leak sensitive information if (x < 32) { x = 32; @@ -206,16 +204,10 @@ void ServerConnection::handleMsg() } QPixmap desktop( - QPixmap::grabWindow( - QApplication::desktop()->winId(), - primaryRect.x(), - primaryRect.y(), - primaryRect.width(), - primaryRect.height() - ).scaled( - x, y, - Qt::KeepAspectRatio, - Qt::SmoothTransformation)); + QGuiApplication::primaryScreen()->grabWindow(0, + primaryRect.x(), primaryRect.y(), primaryRect.width(), primaryRect.height() + ).scaled(x, y, Qt::KeepAspectRatio, Qt::SmoothTransformation + )); QByteArray bytes; QBuffer jpgBuffer(&bytes); jpgBuffer.open(QIODevice::WriteOnly); @@ -365,6 +357,7 @@ void ServerConnection::onVncViewerStartStop(const bool started, const int client */ void ServerConnection::sslErrors(const QList<QSslError> & errors) { + _socket->ignoreSslErrors(); for (QList<QSslError>::const_iterator it = errors.begin(); it != errors.end(); it++) { const QSslError &err = *it; qDebug("Connect SSL: %s", qPrintable(err.errorString())); @@ -375,6 +368,7 @@ void ServerConnection::sslErrors(const QList<QSslError> & errors) if (err.error() == QSslError::CertificateNotYetValid || err.error() == QSslError::CertificateExpired) continue; // Some other SSL error - do not ignore + qDebug() << "FATAL!"; _socket->ignoreSslErrors(QList<QSslError>()); return; } diff --git a/src/client/net/serverdiscovery.cpp b/src/client/net/serverdiscovery.cpp index 5ca0eba..33ddbf5 100644 --- a/src/client/net/serverdiscovery.cpp +++ b/src/client/net/serverdiscovery.cpp @@ -21,8 +21,8 @@ ServerDiscovery::ServerDiscovery(QObject *parent) /* Try to get a UDP port for server discovery */ int tries = 10; while (tries-- != 0) { - const quint16 port = (quint16)(qrand() % 10000 + 10000); - if (_discoverySocket.bind(QHostAddress::Any, port)) + quint16 port = (quint16)(16384 + qrand() % 32768); + if (_discoverySocket.bind(QHostAddress::AnyIPv4, port)) break; if (tries == 0) qFatal("Could not bind to any UDP port for server discovery."); |