forked from KangLin/RabbitRemoteControl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnecterThread.h
More file actions
142 lines (127 loc) · 4.47 KB
/
ConnecterThread.h
File metadata and controls
142 lines (127 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// Author: Kang Lin <kl222@126.com>
#ifndef CCONNECTERBACKTHREAD_H
#define CCONNECTERBACKTHREAD_H
#pragma once
#include <QSpinBox>
#include "ConnecterConnect.h"
#include "FrmScroll.h"
class CConnectThread;
/**
* \~chinese
* \brief 默认启动一个后台线程。实现一个后台线程处理一个连接。
* 可与插件接口从 CPluginClient 派生的插件一起使用,用于连接是阻塞模型的。
* \details
* 原理:在 Connect() 中启动一个后台线程 CConnectThread 。
* 在线程中调用 InstanceConnect() 实例化 CConnect ,
* 并在 CConnect::Connect() 启动定时器,
* 此定时器在后台线程中调用,通过对定时器的操作,实现一个非 Qt 事件循环(可能会阻塞),详见 CConnect 。
* 并且 CConnect 仍然支持 Qt 事件(QObject 的 信号 - 槽 机制)(非阻塞)。
*
* 序列图:\image html docs/Image/PluginClientBlockSequenceDiagram.svg
*
* \note 此接口仅由插件实现。 \n
* 此接口实例运行在主线程(UI线程)中。 \n
* 具体的插件需要实现下面接口:
* 1. 实现 InstanceConnect() ,生成连接对象。连接对象运行在后台线程中。
*
* \~english
* \brief It starts a background thread by default.
* It implements a background thread to handle a connection.
* Can be used with plugins whose plugin interface
* derives from CPluginClient for connection is blocking model.
* \details
* Principle: Start a background thread (CConnectThread) in Connect() .
* Call InstanceConnect() in the thread to instantiate CConnect,
* and start the timer in CConnect::Connect().
* This timer is called in the background thread.
* Through the operation of the timer,
* start a non-Qt event loop (that is, normal loop processing. May block), See CConnect.
* And CConnect supports the Qt event (the signal-slot mechanism of QObject. no-block).
*
* Sequen diagram: \image html docs/Image/PluginClientBlockSequenceDiagram.svg
*
* \note The interface only is implemented by plug-in \n
* The specific plug-in needs to implement the following interface.
* 1. Implement InstanceConnect() . Generate a connection object.
* The connection object runs in a background thread.
*
* \~
* \see CConnect CConnectThread CConnecter CPluginClient CFrmViewer
* \ingroup CLIENT_PLUGIN_API
*/
class CLIENT_EXPORT CConnecterThread : public CConnecterConnect
{
Q_OBJECT
public:
explicit CConnecterThread(CPluginClient *plugin);
virtual ~CConnecterThread();
virtual QWidget* GetViewer() override;
public Q_SLOTS:
/*!
* \~chinese 启动一个后台线程,并建立 CConnect 实例。在 CConnect 中触发 sigConnected()
* \~english Start a background thread, and create an instance of CConnect .
* \~
* \see CConnectThread
*/
virtual int Connect() override;
/*!
* emit sigConnected() in CConnectThread::run()
* \~
* \see CConnectThread CConnectThread::run()
*/
virtual int DisConnect() override;
virtual void slotScreenShot();
private Q_SLOTS:
//! emit by zoom menu in the class
void slotValueChanged(int v);
void slotShortcutCtlAltDel();
void slotShortcutLock();
protected:
virtual QString ServerName() override;
virtual int Initial() override;
virtual int Clean() override;
/*!
* \~chinese \brief 加载参数
* \~english \brief Load parameters
*/
virtual int Load(QSettings &set) override;
/*!
* \~chinese 保存参数
* \~english Save parameters
*/
virtual int Save(QSettings &set) override;
virtual int InitialMenu();
private:
CConnectThread* m_pThread;
CFrmViewer *m_pFrmViewer;
CFrmScroll* m_pScroll;
protected:
QAction* m_pMenuZoom;
QAction* m_pZoomToWindow;
QAction* m_pZoomAspectRatio;
QAction* m_pZoomOriginal;
QAction* m_pZoomIn;
QAction* m_pZoomOut;
QSpinBox* m_psbZoomFactor;
QAction* m_pScreenShot;
#if HAVE_QT6_RECORD
protected:
QAction* m_pRecord;
QAction* m_pRecordPause;
public Q_SLOTS:
void slotRecorderStateChanged(QMediaRecorder::RecorderState state);
Q_SIGNALS:
/*! emit by record menu in the class
* \see slotRecord
*/
void sigRecord(bool bRecord);
void sigRecordPause(bool bPause);
private Q_SLOTS:
/*!
* \brief Record action
* \param checked
*/
virtual void slotRecord(bool checked);
#endif
};
#endif // CCONNECTERBACKTHREAD_H