Rabbit Remote Control 0.0.37
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
24
47class PLUGIN_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 slotRunning();
139 void slotEnableInputMethod(bool bEnable);
140
141Q_SIGNALS:
142 void sigMousePressEvent(QMouseEvent* event, QPoint pos);
143 void sigMouseReleaseEvent(QMouseEvent* event, QPoint pos);
144 void sigMouseMoveEvent(QMouseEvent* event, QPoint pos);
145 void sigMouseMoveEvent(QMouseEvent* event);
146 void sigWheelEvent(QWheelEvent *event, QPoint pos);
147 void sigKeyPressEvent(QKeyEvent *event);
148 void sigKeyReleaseEvent(QKeyEvent *event);
149 void sigInputMethodEvent(QInputMethodEvent *event);
150
151 // Please use CConnecter::sigServerName
152 void sigServerName(const QString &szName);
153
159 void sigViewerFocusIn(QWidget* pView);
160
161 // QWidget interface
162protected:
163 virtual void paintEvent(QPaintEvent *event) override;
164
165 virtual void focusInEvent(QFocusEvent *event) override;
166 virtual void focusOutEvent(QFocusEvent *event) override;
167
168 virtual void mousePressEvent(QMouseEvent *event) override;
169 virtual void mouseReleaseEvent(QMouseEvent *event) override;
170 virtual void mouseMoveEvent(QMouseEvent *event) override;
171 virtual void wheelEvent(QWheelEvent *event) override;
172 virtual void keyPressEvent(QKeyEvent *event) override;
173 virtual void keyReleaseEvent(QKeyEvent *event) override;
174 virtual void inputMethodEvent(QInputMethodEvent *event) override;
175 virtual QVariant inputMethodQuery( Qt::InputMethodQuery query ) const override;
176
177private:
178 QImage m_Desktop;
179 QSize m_DesktopSize;
180
181 ADAPT_WINDOWS m_AdaptWindows;
182 double m_dbZoomFactor;
183
184 int ReSize(int width, int height);
185 void paintDesktop();
186 int TranslationMousePoint(QPointF inPos, QPointF &outPos);
187 QRectF GetAspectRationRect();
188
189public:
190 virtual QImage GrabImage(int x = 0, int y = 0, int w = -1, int h = -1);
191
192public Q_SLOTS:
193 void slotRecordVideo(bool bRecord, qreal nRate = 0);
194 void slotRecordVideo();
195Q_SIGNALS:
196 void sigRecordVideo(const QImage& img);
197private:
198 QTimer m_TimerRecordVideo;
199 bool m_bRecordVideo;
200};
201
202#endif // #ifdef USE_FROM_OPENGL
203
204#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