Pool Video Switch v2
Software video switch for distributed remote display in a lecture environment
Public Slots | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
VncWindow Class Reference

#include "vncwindow.h"

+ Inheritance diagram for VncWindow:
+ Collaboration diagram for VncWindow:

Public Slots

void open (const QString &host, int port, const QString &passwd, bool ro, bool fullscreen, const QString &caption, const int clientId, const QByteArray &rawThumb)
 Show the VNC client window and connect to the given VNC server. More...
 

Signals

void running (const bool isRunning, const int clientId)
 

Public Member Functions

 VncWindow (QWidget *parent=0)
 
virtual ~VncWindow ()
 

Protected Slots

void onUpdateImage (const int x, const int y, const int w, const int h)
 Triggered by imageUpdate signal from the _vncWorker thread telling that the given region of the image changed. More...
 
void onProjectionStarted ()
 Triggered by _vncWorker after successfully connecting to the VNC server. More...
 
void onProjectionStopped ()
 Triggered by _vncWorker when the connection to the VNC server is lost. More...
 
void timer_moveToTop ()
 
void deleteVncThread ()
 

Protected Member Functions

void paintEvent (QPaintEvent *event)
 Called by Qt when a part of the window should be redrawn. More...
 
void resizeEvent (QResizeEvent *)
 
void closeEvent (QCloseEvent *e)
 Called by Qt if the window is requested to be closed. More...
 
void timerEvent (QTimerEvent *event)
 Called when a Qt timer fires. More...
 
void keyReleaseEvent (QKeyEvent *event)
 Called when user releases a pressed key and the window has focus. More...
 

Private Member Functions

void draw (const int x, const int y, const int w, const int h)
 Draws given part of the current VNC frame buffer to the window. More...
 
void terminateVncThread ()
 Terminates the vnc worker thread and stops all related timers. More...
 
bool calcScaling (const QImage *remote)
 When using image scaling, calc matching pixel borders for both resolutions to prevent artifacts through bilinear scaling. More...
 

Private Attributes

int _srcStepX
 
int _srcStepY
 
int _dstStepX
 
int _dstStepY
 
VncThread_vncWorker
 
bool _viewOnly
 
bool _multiScreen
 
int _clientId
 
int _redrawTimer
 
int _tcpTimeoutTimer
 
QPixmap _remoteThumb
 
QSize _remoteSize
 
QSize _desiredSize
 

Detailed Description

Definition at line 25 of file vncwindow.h.

Constructor & Destructor Documentation

VncWindow::VncWindow ( QWidget parent = 0)

Definition at line 42 of file vncwindow.cpp.

+ Here is the call graph for this function:

VncWindow::~VncWindow ( )
virtualdefault

Member Function Documentation

bool VncWindow::calcScaling ( const QImage *  remote)
private

When using image scaling, calc matching pixel borders for both resolutions to prevent artifacts through bilinear scaling.

If you simply round to the nearest number when scaling, you would slightly stretch or shrink the image area, which leads to strange sub-pixel-movements of parts of the image when being updated. The values calculated here are used to determine a larger area around the area that should actually be updated, that will not cause any artifacts when scaling down/up.

Returns
whether scaling factors changed

Definition at line 147 of file vncwindow.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void VncWindow::closeEvent ( QCloseEvent *  e)
protected

Called by Qt if the window is requested to be closed.

This can either happen through code (this->close()), or a keypress (Alt-F4). As long as Qt::WA_DeleteOnClose is not set the QWidget gets just hidden and not quit. See http://qt-project.org/doc/qt-4.8/qcloseevent.html#details for more details.

Parameters
eclose event data

Definition at line 242 of file vncwindow.cpp.

+ Here is the call graph for this function:

void VncWindow::deleteVncThread ( )
protectedslot

Definition at line 83 of file vncwindow.cpp.

+ Here is the caller graph for this function:

void VncWindow::draw ( const int  x,
const int  y,
const int  w,
const int  h 
)
private

Draws given part of the current VNC frame buffer to the window.

Parameters
xX offset of the region to draw
yY offset of the region to draw
wwidth of the region to draw
hheight of the region to draw

Definition at line 97 of file vncwindow.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void VncWindow::keyReleaseEvent ( QKeyEvent *  event)
protected

Called when user releases a pressed key and the window has focus.

Definition at line 379 of file vncwindow.cpp.

void VncWindow::onProjectionStarted ( )
protectedslot

Triggered by _vncWorker after successfully connecting to the VNC server.

This emits a signal that will eventually lead to the ServerConnection telling the server that we're now watching another client.

Definition at line 288 of file vncwindow.cpp.

+ Here is the caller graph for this function:

void VncWindow::onProjectionStopped ( )
protectedslot

Triggered by _vncWorker when the connection to the VNC server is lost.

We'll terminate the thread (detached) and close the window. A signal telling the server that we're not watching a VNC stream anymore will eventually be emited by the closeEvent.

Definition at line 305 of file vncwindow.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void VncWindow::onUpdateImage ( const int  x,
const int  y,
const int  w,
const int  h 
)
protectedslot

Triggered by imageUpdate signal from the _vncWorker thread telling that the given region of the image changed.

Simply repaints the given area of the window. Since these are client coordinates we might have to do some scaling.

Parameters
xX offset of the region to update
yY offset of the region to update
wwidth of the region to update
hheight of the region to update

Definition at line 264 of file vncwindow.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void VncWindow::open ( const QString &  host,
int  port,
const QString &  passwd,
bool  ro,
bool  fullscreen,
const QString &  caption,
const int  clientId,
const QByteArray &  rawThumb 
)
slot

Show the VNC client window and connect to the given VNC server.

Any currently active VNC client connection is signaled to terminate, and a new VNC client worker thread is created for the new connection.

Parameters
hostIP address of VNC server to connect to
portPort of VNC server to connect to
passwd(view only) password of VNC server to connect to
rocurrently unused
fullscreendisplay VNC image in fullscreen mode
captioncaption of window (only visible if not running in fullscreen mode)
clientIdthe ID of the client we're connecting to (echoed back to server, not used locally)

Definition at line 186 of file vncwindow.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void VncWindow::paintEvent ( QPaintEvent *  event)
protected

Called by Qt when a part of the window should be redrawn.

This can either be caused by Qt (or the underlying graphical subsystem), or by an explicit call to QWidget::repaint()

Parameters
eventthe paint event, containing data like location and size area that should be repainted

Definition at line 356 of file vncwindow.cpp.

+ Here is the call graph for this function:

void VncWindow::resizeEvent ( QResizeEvent *  )
inlineprotected

Definition at line 48 of file vncwindow.h.

void VncWindow::running ( const bool  isRunning,
const int  clientId 
)
signal

+ Here is the caller graph for this function:

void VncWindow::terminateVncThread ( )
private

Terminates the vnc worker thread and stops all related timers.

The thread will be signalled to stop, but we don't wait for it to actually terminate. All signals of the thread are blocked, and we nullptr our reference to it. It will finish running in a detached state and finally delete itself upon completion.

Definition at line 63 of file vncwindow.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void VncWindow::timer_moveToTop ( )
protectedslot

Definition at line 311 of file vncwindow.cpp.

+ Here is the caller graph for this function:

void VncWindow::timerEvent ( QTimerEvent *  event)
protected

Called when a Qt timer fires.

redrawTimer: Redraw whole viewer window.

tcpTimeoutTimer: Check if we're connected, close window if not.

Parameters
eventthe timer event

Definition at line 332 of file vncwindow.cpp.

+ Here is the call graph for this function:

Member Data Documentation

int VncWindow::_clientId
private

Definition at line 58 of file vncwindow.h.

QSize VncWindow::_desiredSize
private

Definition at line 63 of file vncwindow.h.

int VncWindow::_dstStepX
private

Definition at line 54 of file vncwindow.h.

int VncWindow::_dstStepY
private

Definition at line 54 of file vncwindow.h.

bool VncWindow::_multiScreen
private

Definition at line 57 of file vncwindow.h.

int VncWindow::_redrawTimer
private

Definition at line 59 of file vncwindow.h.

QSize VncWindow::_remoteSize
private

Definition at line 62 of file vncwindow.h.

QPixmap VncWindow::_remoteThumb
private

Definition at line 61 of file vncwindow.h.

int VncWindow::_srcStepX
private

Definition at line 54 of file vncwindow.h.

int VncWindow::_srcStepY
private

Definition at line 54 of file vncwindow.h.

int VncWindow::_tcpTimeoutTimer
private

Definition at line 60 of file vncwindow.h.

bool VncWindow::_viewOnly
private

Definition at line 56 of file vncwindow.h.

VncThread* VncWindow::_vncWorker
private

Definition at line 55 of file vncwindow.h.


The documentation for this class was generated from the following files: