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/net/serverconnection.cpp | 2 +- src/client/net/serverconnection.h | 2 +- src/client/toolbar/toolbar.cpp | 4 ++-- src/client/vnc/vncwindow.cpp | 36 ++++++++++++++++++++++++++++++++---- src/client/vnc/vncwindow.h | 3 ++- 5 files changed, 38 insertions(+), 9 deletions(-) (limited to 'src/client') diff --git a/src/client/net/serverconnection.cpp b/src/client/net/serverconnection.cpp index 807b6a0..c6ffd8c 100644 --- a/src/client/net/serverconnection.cpp +++ b/src/client/net/serverconnection.cpp @@ -256,7 +256,7 @@ void ServerConnection::handleMsg() } else { - emit openVnc(host, port, _fromServer.getFieldString("ROPASS"), true, true, _fromServer.getFieldString("CAPTION"), _fromServer.getFieldString("CLIENTID").toInt()); + emit openVnc(host, port, _fromServer.getFieldString("ROPASS"), true, true, _fromServer.getFieldString("CAPTION"), _fromServer.getFieldString("CLIENTID").toInt(), _fromServer.getFieldBytes(_THUMB)); } } else if (id == _LOCK) diff --git a/src/client/net/serverconnection.h b/src/client/net/serverconnection.h index 6d53c52..5e2631f 100644 --- a/src/client/net/serverconnection.h +++ b/src/client/net/serverconnection.h @@ -59,7 +59,7 @@ private slots: void onVncViewerStartStop(const bool started, const int clientId); signals: - void openVnc(const QString& host, int port, const QString& passwd, bool ro, bool fullscreen, const QString& caption, const int clientId); + void openVnc(const QString& host, int port, const QString& passwd, bool ro, bool fullscreen, const QString& caption, const int clientId, const QByteArray& rawThumb); void closeVnc(); void stateChange(ConnectWindow::ConnectionState state); void disconnected(); diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp index f8da738..964561e 100644 --- a/src/client/toolbar/toolbar.cpp +++ b/src/client/toolbar/toolbar.cpp @@ -309,8 +309,8 @@ void Toolbar::onConnected(ServerConnection* connection) } _connection = connection; connect(_connection, SIGNAL(disconnected()), this, SLOT(onDisconnected())); - connect(_connection, SIGNAL(openVnc(const QString&, int, const QString&, bool, bool, const QString&, const int)), - _vnc, SLOT(open(const QString&, int, const QString&, bool, bool, const QString&, const int))); + connect(_connection, SIGNAL(openVnc(const QString&, int, const QString&, bool, bool, const QString&, const int, const QByteArray&)), + _vnc, SLOT(open(const QString&, int, const QString&, bool, bool, const QString&, const int, const QByteArray&))); connect(_connection, SIGNAL(closeVnc()), _vnc, SLOT(close())); connect(_vnc, SIGNAL(running(const bool, const int)), _connection, SLOT(onVncViewerStartStop(const bool, const int))); } 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(); } + diff --git a/src/client/vnc/vncwindow.h b/src/client/vnc/vncwindow.h index 6c28b1a..797ca90 100644 --- a/src/client/vnc/vncwindow.h +++ b/src/client/vnc/vncwindow.h @@ -32,7 +32,7 @@ protected slots: void onProjectionStarted(); void onProjectionStopped(); - void open(const QString& host, int port, const QString& passwd, bool ro, bool fullscreen, const QString& caption, const int clientId); + void open(const QString& host, int port, const QString& passwd, bool ro, bool fullscreen, const QString& caption, const int clientId, const QByteArray& rawThumb); // bool close(); signals: @@ -50,6 +50,7 @@ private: int _clientId; int _redrawTimer; int _tcpTimeoutTimer; + QPixmap _remoteThumb; void draw(const int x, const int y, const int w, const int h); void terminateVncThread(); -- cgit v1.2.3-55-g7522