diff options
Diffstat (limited to 'src/client/vnc/vncwindow.cpp')
-rw-r--r-- | src/client/vnc/vncwindow.cpp | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/src/client/vnc/vncwindow.cpp b/src/client/vnc/vncwindow.cpp index f7b6a3e..0947112 100644 --- a/src/client/vnc/vncwindow.cpp +++ b/src/client/vnc/vncwindow.cpp @@ -19,7 +19,11 @@ #include "vncthread.h" #include "../clientapp/clientapp.h" +#include <QGuiApplication> #include <QTimer> +#include <QPainter> +#include <QScreen> +#include <QKeyEvent> /** * Calc greatest common divisor. @@ -39,15 +43,12 @@ VncWindow::VncWindow(QWidget *parent) : QWidget(parent), _srcStepX(1), _srcStepY(1), _dstStepX(1), _dstStepY(1), _vncWorker(nullptr), _viewOnly(true), _multiScreen(false), _clientId(0), _redrawTimer(0), _tcpTimeoutTimer(0) { - QTimer *upper = new QTimer(this); - connect(upper, SIGNAL(timeout()), this, SLOT(timer_moveToTop())); + auto *upper = new QTimer(this); + connect(upper, &QTimer::timeout, this, &VncWindow::timer_moveToTop); upper->start(1111); } -VncWindow::~VncWindow() -{ - // -} +VncWindow::~VncWindow() = default; //////////////////////////////////////////////////////////////////////////////// // Private @@ -64,10 +65,9 @@ void VncWindow::terminateVncThread() if (_vncWorker == nullptr) return; - disconnect(_vncWorker, SIGNAL(projectionStopped()), this, SLOT(onProjectionStopped())); - disconnect(_vncWorker, SIGNAL(projectionStarted()), this, SLOT(onProjectionStarted())); - disconnect(_vncWorker, SIGNAL(imageUpdated(const int, const int, const int, const int)), this, - SLOT(onUpdateImage(const int, const int, const int, const int))); + disconnect(_vncWorker, &VncThread::projectionStopped, this, &VncWindow::onProjectionStopped); + disconnect(_vncWorker, &VncThread::projectionStarted, this, &VncWindow::onProjectionStarted); + disconnect(_vncWorker, &VncThread::imageUpdated, this, &VncWindow::onUpdateImage); _vncWorker->stop(); _vncWorker = nullptr; if (_redrawTimer != 0) { @@ -188,12 +188,10 @@ void VncWindow::open(const QString& host, int port, const QString& passwd, bool this->terminateVncThread(); _clientId = clientId; _vncWorker = new VncThread(host, port, passwd, 1); - connect(_vncWorker, SIGNAL(projectionStopped()), this, SLOT(onProjectionStopped()), Qt::QueuedConnection); - connect(_vncWorker, SIGNAL(projectionStarted()), this, SLOT(onProjectionStarted()), Qt::QueuedConnection); - connect(_vncWorker, SIGNAL(imageUpdated(const int, const int, const int, const int)), this, - SLOT(onUpdateImage(const int, const int, const int, const int)), - Qt::QueuedConnection); - connect(_vncWorker, SIGNAL(finished()), this, SLOT(deleteVncThread()), Qt::QueuedConnection); + connect(_vncWorker, &VncThread::projectionStopped, this, &VncWindow::onProjectionStopped, Qt::QueuedConnection); + connect(_vncWorker, &VncThread::projectionStarted, this, &VncWindow::onProjectionStarted, Qt::QueuedConnection); + connect(_vncWorker, &VncThread::imageUpdated, this, &VncWindow::onUpdateImage, Qt::QueuedConnection); + connect(_vncWorker, &VncThread::finished, this, &VncWindow::deleteVncThread, Qt::QueuedConnection); setWindowTitle(caption); @@ -201,22 +199,18 @@ void VncWindow::open(const QString& host, int port, const QString& passwd, bool _remoteThumb.loadFromData(rawThumb); - QSize size; if (fullscreen) { setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::Tool); // | Qt::X11BypassWindowManagerHint); <- better, but window won't get any keyboard input // Show projection on rightmost screen - QDesktopWidget *desktop = QApplication::desktop(); - int ns = desktop->numScreens(); QRect best; - for (int i = 0; i < ns; ++i) { - QRect r = desktop->screenGeometry(i); + for (auto *screen : QGuiApplication::screens()) { + QRect r = screen->geometry(); if (best.isNull() || r.left() > best.left()) { best = r; } } - _multiScreen = ns > 1; - qDebug() << "Spawning at" << best; - size = best.size(); + _multiScreen = QGuiApplication::screens().size() > 1; + qDebug() << "Spawning VNC viewer at" << best; show(); setGeometry(best); raise(); @@ -226,8 +220,7 @@ void VncWindow::open(const QString& host, int port, const QString& passwd, bool move(best.topLeft()); } else { setWindowFlags(Qt::Tool | Qt::WindowMaximizeButtonHint); - size = QSize(800, 600); - resize(size); + resize(800, 600); showNormal(); } |