Rabbit Remote Control 0.0.36
Loading...
Searching...
No Matches
FrmViewer.h
1// Author: Kang Lin <kl222@126.com>
2
3#ifndef FRMVIEWER_H
4#define FRMVIEWER_H
5
6#pragma once
7
8#include <QWidget>
9#include <QSettings>
10#include <QMutex>
11#include <QImage>
12#include <QTimer>
13#include <QSharedPointer>
14#include "client_export.h"
15
16#ifdef USE_FROM_OPENGL
17
18 #include "FrmViewerOpenGL.h"
19 #define CFrmViewer CFrmViewerOpenGL
20
21#else
22
24
47class CLIENT_EXPORT CFrmViewer : public QWidget
48{
49 Q_OBJECT
50 Q_PROPERTY(double ZoomFactor READ GetZoomFactor WRITE slotSetZoomFactor)
51
52public:
53 explicit CFrmViewer(QWidget *parent = nullptr);
54 virtual ~CFrmViewer() override;
55
60 enum class ADAPT_WINDOWS {
61 Disable = 0,
63 Auto = 1,
64 Original = 2,
66 OriginalCenter = 3,
68 Zoom = 4,
70 ZoomToWindow = 5,
72 KeepAspectRationToWindow = 6,
74 };
75 Q_ENUM(ADAPT_WINDOWS)
76 ADAPT_WINDOWS GetAdaptWindows();
77
85 double GetZoomFactor() const;
86
87 QSize GetDesktopSize();
88
89 enum LED_STATE{
90 Unknown = -1,
91 ScrollLock = 1,
92 NumLock = 1 << 1,
93 CapsLock = 1 << 2,
94 };
95 Q_ENUM(LED_STATE)
96
97public Q_SLOTS:
98 void slotSetAdaptWindows(CFrmViewer::ADAPT_WINDOWS aw = ADAPT_WINDOWS::Original);
99 int slotSetZoomFactor(double newZoomFactor);
100
101 /*================== Internal calls ==================*/
108 void slotSetDesktopSize(int width, int height);
113 void slotSetName(const QString& szName);
119 void slotUpdateRect(const QRect& r, const QImage& image);
120 void slotUpdateRect(const QImage& image);
125 void slotUpdateCursor(const QCursor& cursor);
130 void slotUpdateCursorPosition(const QPoint& pos);
131 void slotUpdateLedState(unsigned int state);
135 void slotConnected();
136
137Q_SIGNALS:
138 void sigMousePressEvent(QMouseEvent* event, QPoint pos);
139 void sigMouseReleaseEvent(QMouseEvent* event, QPoint pos);
140 void sigMouseMoveEvent(QMouseEvent* event, QPoint pos);
141 void sigMouseMoveEvent(QMouseEvent* event);
142 void sigWheelEvent(QWheelEvent *event, QPoint pos);
143 void sigKeyPressEvent(QKeyEvent *event);
144 void sigKeyReleaseEvent(QKeyEvent *event);
145
146 // Please use CConnecter::sigServerName
147 void sigServerName(const QString &szName);
148
154 void sigViewerFocusIn(QWidget* pView);
155
156 // QWidget interface
157protected:
158 virtual void paintEvent(QPaintEvent *event) override;
159
160 virtual void focusInEvent(QFocusEvent *event) override;
161 virtual void focusOutEvent(QFocusEvent *event) override;
162
163 virtual void mousePressEvent(QMouseEvent *event) override;
164 virtual void mouseReleaseEvent(QMouseEvent *event) override;
165 virtual void mouseMoveEvent(QMouseEvent *event) override;
166 virtual void wheelEvent(QWheelEvent *event) override;
167 virtual void keyPressEvent(QKeyEvent *event) override;
168 virtual void keyReleaseEvent(QKeyEvent *event) override;
169
170private:
171 QImage m_Desktop;
172 QSize m_DesktopSize;
173
174 ADAPT_WINDOWS m_AdaptWindows;
175 double m_dbZoomFactor;
176
177 int ReSize(int width, int height);
178 void paintDesktop();
179 int TranslationMousePoint(QPointF inPos, QPointF &outPos);
180 QRectF GetAspectRationRect();
181
182public:
183 virtual QImage GrabImage(int x = 0, int y = 0, int w = -1, int h = -1);
184
185public Q_SLOTS:
186 void slotRecordVideo(bool bRecord, qreal nRate = 0);
187 void slotRecordVideo();
188Q_SIGNALS:
189 void sigRecordVideo(const QImage& img);
190private:
191 QTimer m_TimerRecordVideo;
192 bool m_bRecordVideo;
193};
194
195#endif // #ifdef USE_FROM_OPENGL
196
197#endif // FRMVIEWER_H
A widget which displays output image from a CConnectDesktop and sends input keypresses and mouse acti...
Definition FrmViewer.h:48
ADAPT_WINDOWS
The ADAPT_WINDOWS enum.
Definition FrmViewer.h:60
void sigViewerFocusIn(QWidget *pView)
The view is focus.
Record video thread.
Definition RecordVideo.h:29