Rabbit Remote Control 0.1.0-bate16
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 "plugin_export.h"
15
16#ifdef USE_FROM_OPENGL
17
18 #include "FrmViewerOpenGL.h"
19 #define CFrmViewer CFrmViewerOpenGL
20
21#else
22
24class QTouchEvent;
25class QGestureEvent;
26
49class PLUGIN_EXPORT CFrmViewer : public QWidget
50{
51 Q_OBJECT
52 Q_PROPERTY(double ZoomFactor READ GetZoomFactor WRITE slotSetZoomFactor)
53
54public:
55 explicit CFrmViewer(QWidget *parent = nullptr);
56 virtual ~CFrmViewer() override;
57
62 enum class ADAPT_WINDOWS {
63 Disable = 0,
65 Auto = 1,
66 Original = 2,
68 OriginalCenter = 3,
70 Zoom = 4,
72 ZoomToWindow = 5,
74 KeepAspectRationToWindow = 6,
76 };
77 Q_ENUM(ADAPT_WINDOWS)
78 ADAPT_WINDOWS GetAdaptWindows();
79
87 double GetZoomFactor() const;
88
89 QSize GetDesktopSize();
90
91 enum LED_STATE{
92 Unknown = -1,
93 ScrollLock = 1,
94 NumLock = 1 << 1,
95 CapsLock = 1 << 2,
96 };
97 Q_ENUM(LED_STATE)
98
99public Q_SLOTS:
100 void slotSetAdaptWindows(CFrmViewer::ADAPT_WINDOWS aw = ADAPT_WINDOWS::Original);
101 int slotSetZoomFactor(double newZoomFactor);
102
103 /*================== Internal calls ==================*/
110 void slotSetDesktopSize(int width, int height);
115 void slotSetName(const QString& szName);
121 void slotUpdateRect(const QRect& r, const QImage& image);
122 void slotUpdateRect(const QImage& image);
127 void slotUpdateCursor(const QCursor& cursor);
132 void slotUpdateCursorPosition(const QPoint& pos);
133 void slotUpdateLedState(unsigned int state);
137 void slotRunning();
141 void slotEnableInputMethod(bool bEnable);
142
144 Q_INVOKABLE int OnFullScreen(bool bFull);
145
146Q_SIGNALS:
147 void sigMousePressEvent(QMouseEvent* event, QPoint pos);
148 void sigMouseReleaseEvent(QMouseEvent* event, QPoint pos);
149 void sigMouseMoveEvent(QMouseEvent* event, QPoint pos);
150 void sigMouseMoveEvent(QMouseEvent* event);
151 void sigWheelEvent(QWheelEvent *event, QPoint pos);
152 void sigKeyPressEvent(QKeyEvent *event);
153 void sigKeyReleaseEvent(QKeyEvent *event);
154 void sigInputMethodEvent(QInputMethodEvent *event);
155
156 // Please use CConnecter::sigServerName
157 void sigServerName(const QString &szName);
158
164 void sigViewerFocusIn(QWidget* pView);
165
166 // QWidget interface
167protected:
168 virtual bool event(QEvent *event) override;
169 virtual void paintEvent(QPaintEvent *event) override;
170
171 virtual void focusInEvent(QFocusEvent *event) override;
172 virtual void focusOutEvent(QFocusEvent *event) override;
173
174 virtual void mousePressEvent(QMouseEvent *event) override;
175 virtual void mouseReleaseEvent(QMouseEvent *event) override;
176 virtual void mouseMoveEvent(QMouseEvent *event) override;
177 virtual void wheelEvent(QWheelEvent *event) override;
178 virtual void keyPressEvent(QKeyEvent *event) override;
179 virtual void keyReleaseEvent(QKeyEvent *event) override;
180 virtual void inputMethodEvent(QInputMethodEvent *event) override;
181 virtual QVariant inputMethodQuery( Qt::InputMethodQuery query ) const override;
182
183 virtual bool touchEvent(QTouchEvent* event);
184 virtual bool gestureEvent(QGestureEvent* event);
185
186private:
187 QImage m_Desktop;
188 QSize m_DesktopSize;
189
190 ADAPT_WINDOWS m_AdaptWindows;
191 double m_dbZoomFactor;
192
193 int ReSize(int width, int height);
194 void paintDesktop();
195 int PointToRemote(const QPointF &inPos, QPointF &outPos);
196 int PointFromRemote(const QPointF &inPos, QPointF &outPos);
197 QRectF GetAspectRationRect();
198
199public:
200 virtual QImage GrabImage(int x = 0, int y = 0, int w = -1, int h = -1);
201
202public Q_SLOTS:
203 void slotRecordVideo(bool bRecord, qreal nRate = 0);
204 void slotRecordVideo();
205Q_SIGNALS:
206 void sigRecordVideo(const QImage& img);
207private:
208 QTimer m_TimerRecordVideo;
209 bool m_bRecordVideo;
210};
211
212#endif // #ifdef USE_FROM_OPENGL
213
214#endif // FRMVIEWER_H
virtual bool event(QEvent *event) override
[Full Screen]
ADAPT_WINDOWS
The ADAPT_WINDOWS enum.
Definition FrmViewer.h:62
void sigViewerFocusIn(QWidget *pView)
The view is focus.
double GetZoomFactor() const
Adjust the zoom factor.
Record video thread.
Definition RecordVideo.h:29