Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
FrmViewerOpenGL.h
1// Author: Kang Lin <kl222@126.com>
2
3#ifndef CFRMVIEWEROPENGL_H
4#define CFRMVIEWEROPENGL_H
5
6#include <QImage>
7#include <QOpenGLFunctions>
8#include <QOpenGLBuffer>
9#include <QOpenGLShaderProgram>
10#include <QOpenGLWidget>
11#include <QOpenGLTexture>
12#include <QOpenGLVertexArrayObject>
13#include <QSettings>
14#include "client_export.h"
15
16class CLIENT_EXPORT CFrmViewerOpenGL
17 : public QOpenGLWidget, protected QOpenGLFunctions
18{
19 Q_OBJECT
20 Q_PROPERTY(double ZoomFactor READ GetZoomFactor WRITE SetZoomFactor)
21
22public:
23 explicit CFrmViewerOpenGL(QWidget *parent = nullptr);
24 virtual ~CFrmViewerOpenGL() override;
25
31 Disable = 0,
33 Auto = 1,
34 Original = 2,
36 OriginalCenter = 3,
38 Zoom = 4,
40 ZoomToWindow = 5,
42 KeepAspectRationToWindow = 6,
44 };
45 void SetAdaptWindows(ADAPT_WINDOWS aw = Original);
46 ADAPT_WINDOWS GetAdaptWindows();
47
55 double GetZoomFactor() const;
56 int SetZoomFactor(double newZoomFactor);
57 QSize GetDesktopSize();
58
59 virtual int Load(QSettings &set);
60 virtual int Save(QSettings &set);
61
62 virtual QImage GrabImage(int x = 0, int y = 0, int w = -1, int h = -1);
63
64public Q_SLOTS:
70 void slotSetDesktopSize(int width, int height);
75 void slotSetName(const QString& szName);
81 void slotUpdateRect(const QRect& r, const QImage& image);
82 void slotUpdateRect(QSharedPointer<CImage> image);
87 void slotUpdateCursor(const QCursor& cursor);
92 void slotUpdateCursorPosition(const QPoint& pos);
93 void slotSystemCombination();
94
95Q_SIGNALS:
96 void sigMousePressEvent(Qt::MouseButtons, QPoint);
97 void sigMouseReleaseEvent(Qt::MouseButton, QPoint);
98 void sigMouseMoveEvent(Qt::MouseButtons buttons, QPoint pos);
99 void sigMouseMoveEvent(QMouseEvent *event);
100 void sigWheelEvent(Qt::MouseButtons buttons, QPoint pos, QPoint angleDelta);
101 void sigKeyPressEvent(int key, Qt::KeyboardModifiers modify);
102 void sigKeyReleaseEvent(int key, Qt::KeyboardModifiers modify);
103
104 // QOpenGLWidget interface
105protected:
106 virtual void initializeGL() override;
107 virtual void resizeGL(int w, int height) override;
108 virtual void paintGL() override;
109
110 virtual void mousePressEvent(QMouseEvent *event) override;
111 virtual void mouseReleaseEvent(QMouseEvent *event) override;
112 virtual void mouseMoveEvent(QMouseEvent *event) override;
113 virtual void wheelEvent(QWheelEvent *event) override;
114 virtual void keyPressEvent(QKeyEvent *event) override;
115 virtual void keyReleaseEvent(QKeyEvent *event) override;
116
117 void InitVertor();
118
119private:
120 QImage m_Desktop;
121
122 QOpenGLVertexArrayObject m_VaoQuad;
123 QOpenGLBuffer m_VboQuad;
124 QOpenGLShaderProgram m_ShaderProgram;
125 QVector<GLfloat> m_VertexData;
126
127 QOpenGLTexture* m_pTexture;
128
129 ADAPT_WINDOWS m_AdaptWindows;
130 double m_dbZoomFactor;
131
132 int ReSize(int width, int height);
133 int TranslationMousePoint(QPointF inPos, QPointF &outPos);
134 QRectF GetAspectRationRect();
135};
136
137#endif // CFRMVIEWEROPENGL_H
ADAPT_WINDOWS
The ADAPT_WINDOWS enum.