From de708185c77aa451682fa96fbca4dcc6c8091c44 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 8 Feb 2016 16:48:29 +0100 Subject: [*] Use thumbnail on vnc viewer window until connection is up --- src/client/vnc/vncwindow.cpp | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'src/client/vnc/vncwindow.cpp') diff --git a/src/client/vnc/vncwindow.cpp b/src/client/vnc/vncwindow.cpp index 53877e1..f18fadc 100644 --- a/src/client/vnc/vncwindow.cpp +++ b/src/client/vnc/vncwindow.cpp @@ -93,7 +93,7 @@ void VncWindow::draw(const int x, const int y, const int w, const int h) * @param caption caption of window (only visible if not running in fullscreen mode) * @param clientId the ID of the client we're connecting to (echoed back to server, not used locally) */ -void VncWindow::open(const QString& host, int port, const QString& passwd, bool ro, bool fullscreen, const QString& caption, const int clientId) +void VncWindow::open(const QString& host, int port, const QString& passwd, bool ro, bool fullscreen, const QString& caption, const int clientId, const QByteArray& rawThumb) { this->terminateVncThread(); _clientId = clientId; @@ -108,6 +108,8 @@ void VncWindow::open(const QString& host, int port, const QString& passwd, bool setAttribute(Qt::WA_OpaquePaintEvent); + _remoteThumb.loadFromData(rawThumb); + if (fullscreen) { setWindowFlags(Qt::WindowStaysOnTopHint); @@ -121,6 +123,7 @@ void VncWindow::open(const QString& host, int port, const QString& passwd, bool showNormal(); } + this->repaint(); this->show(); _vncWorker->setTargetSize(this->size()); @@ -170,6 +173,7 @@ void VncWindow::onUpdateImage(const int x, const int y, const int w, const int h */ void VncWindow::onProjectionStarted() { + _remoteThumb = QPixmap(); if (_tcpTimeoutTimer != 0) { killTimer(_tcpTimeoutTimer); _tcpTimeoutTimer = 0; @@ -233,8 +237,27 @@ void VncWindow::timerEvent(QTimerEvent *event) */ void VncWindow::paintEvent(QPaintEvent *event) { - const QRect &r = event->rect(); - this->draw(r.left(), r.top(), r.width(), r.height()); + if (_vncWorker == NULL || !_vncWorker->isConnected()) + { + QPainter painter(this); + if (!_remoteThumb.isNull() && _remoteThumb.height() > 0) + { + painter.drawPixmap(0, 0, this->width(), this->height(), _remoteThumb); + } + else + { + painter.fillRect(event->rect(), QColor(60, 63, 66)); + } + QFontInfo fi = painter.fontInfo(); + painter.setPen(QColor(200, 100, 10)); + painter.setFont(QFont(fi.family(), 28, fi.weight(), fi.italic())); + painter.drawText(this->contentsRect(), Qt::AlignCenter, tr("Connecting...")); + } + else + { + const QRect &r = event->rect(); + this->draw(r.left(), r.top(), r.width(), r.height()); + } event->accept(); } @@ -245,5 +268,10 @@ void VncWindow::paintEvent(QPaintEvent *event) */ void VncWindow::resizeEvent(QResizeEvent* event) { - _vncWorker->setTargetSize(event->size()); + if (_vncWorker != NULL) + { + _vncWorker->setTargetSize(event->size()); + } + this->repaint(); } + -- cgit v1.2.3-55-g7522