summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2016-02-08 16:48:29 +0100
committerSimon Rettberg2016-02-08 16:48:29 +0100
commitde708185c77aa451682fa96fbca4dcc6c8091c44 (patch)
treee925e32649545dad8a4e373326da9314b4f1dd28
parent[client] Remove jpeg quality debug message (diff)
downloadpvs2-de708185c77aa451682fa96fbca4dcc6c8091c44.tar.gz
pvs2-de708185c77aa451682fa96fbca4dcc6c8091c44.tar.xz
pvs2-de708185c77aa451682fa96fbca4dcc6c8091c44.zip
[*] Use thumbnail on vnc viewer window until connection is up
-rw-r--r--src/client/net/serverconnection.cpp2
-rw-r--r--src/client/net/serverconnection.h2
-rw-r--r--src/client/toolbar/toolbar.cpp4
-rw-r--r--src/client/vnc/vncwindow.cpp36
-rw-r--r--src/client/vnc/vncwindow.h3
-rw-r--r--src/server/connectionframe/connectionframe.cpp5
-rw-r--r--src/server/connectionframe/connectionframe.h2
-rw-r--r--src/server/net/client.cpp12
-rw-r--r--src/server/net/client.h3
9 files changed, 53 insertions, 16 deletions
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();
diff --git a/src/server/connectionframe/connectionframe.cpp b/src/server/connectionframe/connectionframe.cpp
index 39aba12..82e949a 100644
--- a/src/server/connectionframe/connectionframe.cpp
+++ b/src/server/connectionframe/connectionframe.cpp
@@ -144,7 +144,7 @@ void ConnectionFrame::assignClient(Client* client)
{
assert(_client == NULL);
connect( client, SIGNAL(disconnected()), this, SLOT(onClientDisconnected()) );
- connect( client, SIGNAL(thumbUpdated(Client*, const QPixmap&)), this, SLOT(onThumbUpdated(Client*, const QPixmap&)) );
+ connect( client, SIGNAL(thumbUpdated(Client*, const QPixmap&, const QByteArray&)), this, SLOT(onThumbUpdated(Client*, const QPixmap&, const QByteArray&)) );
connect( client, SIGNAL(vncServerStateChange(Client*)), this, SLOT(updateAppearance()));
connect( client, SIGNAL(vncClientStateChange(Client*)), this, SLOT(updateAppearance()));
connect( client, SIGNAL(stateChanged()), this, SLOT(updateAppearance()));
@@ -383,10 +383,11 @@ void ConnectionFrame::onClientDisconnected()
* @param client
* @param thumb
*/
-void ConnectionFrame::onThumbUpdated(Client* client, const QPixmap& thumb)
+void ConnectionFrame::onThumbUpdated(Client* client, const QPixmap& thumb, const QByteArray&)
{
assert(client == _client);
_remoteScreen = thumb;
//_imgScreen->setPixmap(_remoteScreen);
this->repaint();
}
+
diff --git a/src/server/connectionframe/connectionframe.h b/src/server/connectionframe/connectionframe.h
index 188cdc7..42a07f0 100644
--- a/src/server/connectionframe/connectionframe.h
+++ b/src/server/connectionframe/connectionframe.h
@@ -84,7 +84,7 @@ signals:
private slots:
void onClientDisconnected();
- void onThumbUpdated(Client* client, const QPixmap& thumb);
+ void onThumbUpdated(Client* client, const QPixmap& thumb, const QByteArray& rawImage);
void updateAppearance();
};
diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp
index 5fb030e..029b88a 100644
--- a/src/server/net/client.cpp
+++ b/src/server/net/client.cpp
@@ -156,12 +156,14 @@ void Client::handleMsg()
if (id == _THUMB)
{
QPixmap pixmap;
- if (!pixmap.loadFromData(_fromClient.getFieldBytes("IMG")))
+ const QByteArray& rawImage = _fromClient.getFieldBytes("IMG");
+ if (!pixmap.loadFromData(rawImage))
{
qDebug("Could not decode thumbnail image from client.");
return;
}
- emit thumbUpdated(this, pixmap);
+ _rawRemoteScreen = QByteArray(rawImage);
+ emit thumbUpdated(this, pixmap, rawImage);
}
else if (id == _VNCSERVER)
{
@@ -298,10 +300,14 @@ void Client::startVncClient(const Client * const to)
NetworkMessage msg;
msg.setField(_ID, _VNCCLIENT);
msg.setField("HOST", to->_socket->peerAddress().toString());
- msg.setField("PORT", QString::number(to->_vncPort));
+ msg.setField(_PORT, QString::number(to->_vncPort));
msg.setField("ROPASS", to->_vncRoPass);
msg.setField("CLIENTID", QString::number(to->_id));
msg.setField("CAPTION", to->_name + " @ " + to->_host);
+ if (!to->_rawRemoteScreen.isEmpty())
+ {
+ msg.setField(_THUMB, to->_rawRemoteScreen);
+ }
sendMessage(msg);
}
diff --git a/src/server/net/client.h b/src/server/net/client.h
index 5e1b8b4..d2097ad 100644
--- a/src/server/net/client.h
+++ b/src/server/net/client.h
@@ -71,6 +71,7 @@ private:
int _projectionSource; // The source the client was or is connected to (depends on _isActiveVncClient)
bool _isActiveVncClient; // VNCclient state. indicating that the client is displaying a remote screen via VNC
bool _isTutor; // Flag indicating that the client has been set as a tutor
+ QByteArray _rawRemoteScreen;
static int _clientIdCounter;
@@ -85,7 +86,7 @@ protected:
signals:
void authenticating(Client* client, ClientLogin* request);
void authenticated(Client* client);
- void thumbUpdated(Client* client, const QPixmap& thumb);
+ void thumbUpdated(Client* client, const QPixmap& thumb, const QByteArray& rawImage);
void vncServerStateChange(Client* client);
void vncClientStateChange(Client* client);
void stateChanged();