Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
ConnecterPlayer.cpp
1// Author: Kang Lin <kl222@126.com>
2
3#include <QLoggingCategory>
4#include "ConnecterPlayer.h"
5#include "ConnectPlayer.h"
6#include "DlgPlayer.h"
7#include "PluginClient.h"
8
9static Q_LOGGING_CATEGORY(log, "Player.Connecter")
10
12 : CConnecterThread(plugin)
13{
14 qDebug(log) << Q_FUNC_INFO;
15}
16
17CConnecterPlayer::~CConnecterPlayer()
18{
19 qDebug(log) << Q_FUNC_INFO;
20}
21
23{
24 return 0;
25}
26
28{
29 qDebug(log) << Q_FUNC_INFO;
30 bool check = false;
31 int nRet = 0;
33 if(nRet) return nRet;
34
35 nRet = SetParameter(&m_Parameters);
36 if(nRet) return nRet;
37
38 m_Menu.clear();
39#ifdef HAVE_QVideoWidget
40 m_Menu.addAction(m_Player.m_paStart);
41 m_Menu.addAction(m_Player.m_paPause);
42#if HAVE_QT6_RECORD
43 m_Menu.addAction(m_Player.m_paRecord);
44 m_Menu.addAction(m_Player.m_paRecordPause);
45#endif
46 m_Menu.addAction(m_Player.m_paScreenShot);
47 m_Menu.addSeparator();
48 m_Menu.addAction(m_Player.m_paSettings);
49 check = connect(this, &CConnecterPlayer::sigConnected,
50 m_Player.m_paStart, &QAction::toggle);
51 Q_ASSERT(check);
52 check = connect(m_Player.m_paStart, SIGNAL(toggled(bool)),
53 this, SIGNAL(sigStart(bool)));
54 Q_ASSERT(check);
55 check = connect(m_Player.m_paPause, SIGNAL(toggled(bool)),
56 this, SIGNAL(sigPause(bool)));
57 Q_ASSERT(check);
58#if HAVE_QT6_RECORD
59 check = connect(m_Player.m_paRecord, SIGNAL(toggled(bool)),
60 m_pRecord ,SIGNAL(toggled(bool)));
61 Q_ASSERT(check);
62 check = connect(m_Player.m_paRecordPause, SIGNAL(toggled(bool)),
63 m_pRecordPause, SIGNAL(toggled(bool)));
64 Q_ASSERT(check);
65#endif
66 check = connect(m_Player.m_paScreenShot, &QAction::triggered,
67 m_pScreenShot, &QAction::triggered);
68 Q_ASSERT(check);
69 check = connect(m_Player.m_paSettings, &QAction::triggered,
70 m_pSettings, &QAction::trigger);
71 Q_ASSERT(check);
72 check = connect(this, &CConnecterPlayer::sigConnected,
73 this, [&](){
74 m_Player.SetParameter(&m_Parameters);
75 });
76 Q_ASSERT(check);
77 check = connect(&m_Player, SIGNAL(sigChangePosition(qint64)),
78 this, SIGNAL(sigChangePosition(qint64)));
79 Q_ASSERT(check);
80#else
81 QAction* pStart = m_Menu.addAction(
82 QIcon::fromTheme("media-playback-start"), tr("Start"));
83 pStart->setCheckable(true);
84 check = connect(this, &CConnecterPlayer::sigConnected,
85 pStart, &QAction::toggle);
86 Q_ASSERT(check);
87 check = connect(pStart, &QAction::toggled,
88 this, [&](bool checked){
89 QAction* p = qobject_cast<QAction*>(sender());
90 if(!p) return;
91 if(p->isChecked()) {
92 p->setIcon(QIcon::fromTheme("media-playback-stop"));
93 p->setText(tr("Stop"));
94 m_pPause->setEnabled(true);
95 m_pPause->setChecked(false);
96 m_pScreenShot->setEnabled(true);
97#if HAVE_QT6_RECORD
98 m_pRecord->setEnabled(true);
99 m_pRecord->setChecked(false);
100 m_pRecordPause->setEnabled(true);
101 m_pRecordPause->setChecked(false);
102#endif
103 } else {
104 p->setIcon(QIcon::fromTheme("media-playback-start"));
105 p->setText(tr("Start"));
106 m_pPause->setEnabled(false);
107 m_pPause->setChecked(false);
108 m_pScreenShot->setEnabled(false);
109#if HAVE_QT6_RECORD
110 m_pRecord->setEnabled(false);
111 m_pRecord->setChecked(false);
112 m_pRecordPause->setEnabled(false);
113 m_pRecordPause->setChecked(false);
114#endif
115 }
116 emit sigStart(checked);
117 });
118 Q_ASSERT(check);
119 m_pPause = m_Menu.addAction(
120 QIcon::fromTheme("media-playback-pause"), tr("pause"));
121 m_pPause->setCheckable(true);
122 check = connect(m_pPause, SIGNAL(toggled(bool)),
123 this, SIGNAL(sigPause(bool)));
124 Q_ASSERT(check);
125#if HAVE_QT6_RECORD
126 m_Menu.addAction(m_pRecord);
127 m_Menu.addAction(m_pRecordPause);
128#endif
129 m_Menu.addAction(m_pScreenShot);
130 m_Menu.addSeparator();
131 m_Menu.addAction(m_pSettings);
132#endif
133 return nRet;
134}
135
137{
138 qDebug(log) << Q_FUNC_INFO;
139 int nRet = 0;
141 return nRet;
142}
143
145{
146 QDialog* pDlg = new CDlgPlayer(&m_Parameters, parent);
147 return pDlg;
148}
149
151{
152 CConnect* p = new CConnectPlayer(this);
153 return p;
154}
155
156void CConnecterPlayer::slotScreenShot()
157{
158 emit sigScreenShot();
159}
160
161#if HAVE_QVideoWidget
163{
164 return &m_Player;
165}
166
167QVideoSink *CConnecterPlayer::GetVideoSink()
168{
169 return m_Player.videoSink();
170}
171
172void CConnecterPlayer::slotPositionChanged(qint64 pos, qint64 duration)
173{
174 m_Player.slotPositionChanged(pos, duration);
175}
176
177void CConnecterPlayer::slotPlaybackStateChanged(QMediaPlayer::PlaybackState state)
178{
179 if(QMediaPlayer::StoppedState == state
180 && m_Player.m_paStart->isChecked())
181 m_Player.m_paStart->setChecked(false);
182}
183
184#if HAVE_QT6_RECORD
185void CConnecterPlayer::slotRecordStateChanged(QMediaRecorder::RecorderState state)
186{
187
188 if(QMediaRecorder::StoppedState == state
189 && m_Player.m_paRecord->isCheckable())
190 m_Player.m_paRecord->setChecked(false);
191}
192#endif
193
194#endif
Connect interface.
Definition Connect.h:45
virtual qint16 Version() override
Version.
virtual int Clean() override
Clean parameters and resource.
virtual CConnect * InstanceConnect() override
New connect.
virtual QDialog * OnOpenDialogSettings(QWidget *parent) override
Open settgins dialog.
virtual int Initial() override
Initial parameters and resource.
It starts a background thread by default.
virtual int Initial() override
Initial parameters and resource.
virtual int Clean() override
Clean parameters and resource.
void sigConnected()
Successful connection signal.
virtual QWidget * GetViewer()=0
Get Viewer.
The plugin interface.