From 2b2681187163fd487a6033e10b0f8e002d698318 Mon Sep 17 00:00:00 2001 From: Manuel Schneider Date: Fri, 25 Apr 2014 13:07:50 +0200 Subject: Now using qWidget instead of qDialog to avoid the need to handdle every dialog event (reject, done, accept, finished). No more close override necessary. --- src/client/vnc/vncthread.cpp | 14 +++++++------- src/client/vnc/vncwindow.cpp | 28 +++++----------------------- src/client/vnc/vncwindow.h | 4 ++-- 3 files changed, 14 insertions(+), 32 deletions(-) diff --git a/src/client/vnc/vncthread.cpp b/src/client/vnc/vncthread.cpp index fe52283..7d23afa 100644 --- a/src/client/vnc/vncthread.cpp +++ b/src/client/vnc/vncthread.cpp @@ -118,14 +118,14 @@ void VncThread::setTargetSize(const QSize size) } /** - * Worker thread's mainloop, connecting to the VNC server and handling the connection. - * The vnc client library is written in a blocking manner, so we just do everything in - * our own thread and just hand over the image updates to the vnc client window, which - * resides in the application's main thread. + * Worker thread's mainloop, connecting to the VNC server and handling the + * connection. The vnc client library is written in a blocking manner, so we + * just do everything in our own thread and just hand over the image updates to + * the vnc client window, which resides in the application's main thread. * - * This thread checks if the vnc window signaled us to stop and if so, it deletes itself. - * This means that you should *never* delete this thread from anywhere. Just call VncThread::stop() - * and wait for it to delete itself. + * This thread checks if the vnc window signaled us to stop and if so, it + * deletes itself. This means that you should *never* delete this thread from + * anywhere. Just call VncThread::stop() and wait for it to delete itself. */ void VncThread::run() { diff --git a/src/client/vnc/vncwindow.cpp b/src/client/vnc/vncwindow.cpp index 581d503..13ad107 100644 --- a/src/client/vnc/vncwindow.cpp +++ b/src/client/vnc/vncwindow.cpp @@ -19,7 +19,7 @@ #include "vncthread.h" VncWindow::VncWindow(QWidget *parent) : - QDialog(parent), _vncWorker(NULL), _viewOnly(true), _clientId(0), _redrawTimer(0), _tcpTimeoutTimer(0) + QWidget(parent), _vncWorker(NULL), _viewOnly(true), _clientId(0), _redrawTimer(0), _tcpTimeoutTimer(0) { // } @@ -130,16 +130,16 @@ void VncWindow::open(const QString& host, int port, const QString& passwd, bool /** * Called by Qt if the window is requested to be closed. This can either happen - * through code (this->close()), or a keypress (Alt-F4, Esc). We'll ignore the - * request and simply hide the window. + * 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. * * @param e close event data */ void VncWindow::closeEvent(QCloseEvent *e) { - e->ignore(); qDebug("Closing VNC viewer window."); - this->setVisible(false); this->terminateVncThread(); emit running(false, _clientId); } @@ -188,24 +188,6 @@ void VncWindow::onProjectionStopped() //////////////////////////////////////////////////////////////////////////////// // Protected - -/** - * Request to close the window. Overriden from QDialog/QWidget. - * If the window is already hidden, this just emits a signal that - * will tell the server that we're not watching a VNC stream - * currently. Otherwise it will just call the implementation of - * the super class. - * - * @return false - */ -bool VncWindow::close() -{ - if (this->isVisible()) - return QDialog::close(); - emit running(false, _clientId); - return false; -} - /** * Called when a Qt timer fires. * diff --git a/src/client/vnc/vncwindow.h b/src/client/vnc/vncwindow.h index f79c358..6c28b1a 100644 --- a/src/client/vnc/vncwindow.h +++ b/src/client/vnc/vncwindow.h @@ -19,7 +19,7 @@ class VncThread; class QPainter; -class VncWindow : public QDialog +class VncWindow : public QWidget { Q_OBJECT @@ -33,7 +33,7 @@ protected slots: void onProjectionStopped(); void open(const QString& host, int port, const QString& passwd, bool ro, bool fullscreen, const QString& caption, const int clientId); - bool close(); +// bool close(); signals: void running(const bool isRunning, const int clientId); -- cgit v1.2.3-55-g7522