138 lines
3.4 KiB
C++
Executable File
138 lines
3.4 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
#pragma once
|
|
|
|
#include <LtsWidgets/lts_dialog.h>
|
|
#include <Plugins/ProjectionWorkstation/Common/pws_rfb_protocol.h>
|
|
#include <Plugins/ProjectionWorkstation/Common/pws_vnc_handler.h>
|
|
|
|
#include <QMutex>
|
|
#include <QOpenGLFramebufferObject>
|
|
#include <QOpenGLTextureBlitter>
|
|
#include <QOpenGLWidget>
|
|
#include <QOpenGLFunctions>
|
|
#include <QHostAddress>
|
|
|
|
namespace Ui { class VncViewerDialog; }
|
|
|
|
namespace ProjectionWorkstation
|
|
{
|
|
|
|
class VncRenderAreaWorker : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit VncRenderAreaWorker();
|
|
|
|
void setImageSize(QSize s);
|
|
void setScaledSize(QSize s);
|
|
QImage renderedImage() const;
|
|
|
|
public Q_SLOTS:
|
|
void onRfbFrameBufferUpdate(const QVector<RfbProtocol::RfbRectangle> &rectangles);
|
|
Q_SIGNALS:
|
|
void newImageAvailable();
|
|
void newScaleSizeAspectRatio(QSize s);
|
|
private:
|
|
QImage m_renderedImage; // store pixeldata
|
|
QImage m_scaledImage;
|
|
mutable QMutex m_mutex;
|
|
QSize m_scaledSize;
|
|
QSize m_scaledSizeAspectRatio;
|
|
LtsProjectionWorkstation::LOGGER_T m_logger;
|
|
};
|
|
|
|
class VncRenderArea : public QOpenGLWidget, protected QOpenGLFunctions
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit VncRenderArea(const QSize remoteResolution, QWidget *parent);
|
|
~VncRenderArea();
|
|
// QOpenGLWidget interface
|
|
|
|
void clear();
|
|
|
|
QSize frameSize() const { return m_frameSize; }
|
|
QSize scaledSize() const { return m_scaledSizeAspectRatio; }
|
|
void maybeResized();
|
|
|
|
protected:
|
|
void initializeGL() override final;
|
|
void paintGL() override final;
|
|
|
|
Q_SIGNALS:
|
|
void frameBufferUpdateReceived(const QVector<RfbProtocol::RfbRectangle> &rectangles);
|
|
public slots:
|
|
void prepareRender();
|
|
private:
|
|
void rebuildFbo(QSize newSize);
|
|
private:
|
|
QThread *m_imageRenderThread;
|
|
VncRenderAreaWorker *m_renderAreaWorker;
|
|
QSize m_scaledSizeAspectRatio;
|
|
QSize m_frameSize;
|
|
QOpenGLFramebufferObject *m_fbo;
|
|
QOpenGLTextureBlitter m_blitter;
|
|
|
|
LtsProjectionWorkstation::LOGGER_T m_logger;
|
|
}; // VncRenderArea
|
|
|
|
|
|
class VncViewerDialog : public LtsWidgets::LtsDialog
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
VncViewerDialog(const QString &name, QWidget *parent = nullptr);
|
|
~VncViewerDialog();
|
|
|
|
bool init(const QHostAddress &host, quint16 port, const QSize &remoteResolution);
|
|
|
|
// LtsDialog interface
|
|
void retranslate() override final;
|
|
|
|
signals:
|
|
void disconnected();
|
|
|
|
private slots:
|
|
void handleServerCuttext(const QString &cutText);
|
|
void slotOnDisconnected();
|
|
void onScrollRelease();
|
|
void onSlotConnected();
|
|
|
|
protected:
|
|
// QWidget interface
|
|
void focusInEvent(QFocusEvent *event) override final;
|
|
void focusOutEvent(QFocusEvent *event) override final;
|
|
void mousePressEvent(QMouseEvent *event) override final;
|
|
void mouseReleaseEvent(QMouseEvent *event) override final;
|
|
void mouseMoveEvent(QMouseEvent *event) override final;
|
|
void keyPressEvent(QKeyEvent *event) override final;
|
|
void keyReleaseEvent(QKeyEvent *event) override final;
|
|
void wheelEvent(QWheelEvent *event) override final;
|
|
void resizeEvent(QResizeEvent *event) override final;
|
|
void showEvent(QShowEvent *event) override final;
|
|
|
|
private:
|
|
QPoint mapMousePosition(const QPoint &point) const;
|
|
|
|
Ui::VncViewerDialog *m_ui;
|
|
|
|
VncHandler *m_handler;
|
|
VncRenderArea *m_renderArea;
|
|
|
|
quint8 m_mouseButtonMask;
|
|
QTimer *m_mouseScrollReleaseTimer;
|
|
QPoint m_lastScrollPos;
|
|
QSize m_remoteResolution;
|
|
QString m_name;
|
|
bool m_isConnected;
|
|
|
|
LtsProjectionWorkstation::LOGGER_T m_logger;
|
|
}; // VncViewerDialog
|
|
|
|
} // ProjectionWorkstation
|