玉兔远程控制 0.1.0-bate4
载入中...
搜索中...
未找到
OperateDesktop.cpp
1// Author: Kang Lin <kl222@126.com>
2
3#include <QLoggingCategory>
4#include <QDesktopServices>
5#include <QUrl>
6#include <QWidgetAction>
7#include <QActionGroup>
8
9#include "OperateDesktop.h"
10#include "BackendThread.h"
11#include "Plugin.h"
12
13static Q_LOGGING_CATEGORY(log, "Operate.Desktop")
14
16 , m_pPara(nullptr)
17 , m_pThread(nullptr)
18 , m_pFrmViewer(nullptr)
19 , m_pScroll(nullptr)
20 , m_pZoomToWindow(nullptr)
21 , m_pZoomAspectRatio(nullptr)
22 , m_pZoomOriginal(nullptr)
23 , m_pZoomIn(nullptr)
24 , m_pZoomOut(nullptr)
25 , m_psbZoomFactor(nullptr)
26 , m_pScreenShot(nullptr)
27#if HAVE_QT6_RECORD
28 , m_pRecord(nullptr)
29 , m_pRecordPause(nullptr)
30#endif
31{
32 qDebug(log) << Q_FUNC_INFO;
33}
34
35COperateDesktop::~COperateDesktop()
36{
37 qDebug(log) << Q_FUNC_INFO;
38}
39
40const QString COperateDesktop::Id()
41{
42 QString szId = COperate::Id();
43 if(GetParameter()) {
44 if(GetParameter()->GetName().isEmpty()) {
45 if(!GetParameter()->m_Net.GetHost().isEmpty())
46 szId += "_" + GetParameter()->m_Net.GetHost()
47 + "_" + QString::number(GetParameter()->m_Net.GetPort());
48 CParameterNet* net = nullptr;
49 QString szType;
50 switch(GetParameter()->m_Proxy.GetUsedType())
51 {
52 case CParameterProxy::TYPE::Http: {
53 net = &GetParameter()->m_Proxy.m_Http;
54 szType = "http";
55 break;
56 }
57 case CParameterProxy::TYPE::SockesV5:
58 {
59 net = &GetParameter()->m_Proxy.m_SockesV5;
60 szType = "sockesv5";
61 break;
62 }
63 case CParameterProxy::TYPE::SSHTunnel:
64 {
65 net = &GetParameter()->m_Proxy.m_SSH.m_Net;
66 szType = "ssh";
67 break;
68 }
69 default:
70 break;
71 }
72 if(!szType.isEmpty() && !net->GetHost().isEmpty()) {
73 szId += "_" + szType + "_";
74 szId += net->GetHost() + "_" + QString::number(net->GetPort());
75 }
76 } else {
77 szId += "_" + GetParameter()->GetName();
78 }
79 }
80 static QRegularExpression exp("[-@:/#%!^&* \\.]");
81 szId = szId.replace(exp, "_");
82 return szId;
83}
84
85const QString COperateDesktop::Name()
86{
87 QString szName;
88
89 if(GetParameter() && !(GetParameter()->GetName().isEmpty()))
90 szName += GetParameter()->GetName();
91 else {
92 if(GetParameter() && GetParameter()->GetGlobalParameters()
93 && GetParameter()->GetGlobalParameters()->GetShowProtocolPrefix()
94 && !Protocol().isEmpty())
95 szName = Protocol() + ":";
96 szName += ServerName();
97 }
98
99 return szName;
100}
101
103{
104 QString szDescription;
105 if(!Name().isEmpty())
106 szDescription = tr("Name: ") + Name() + "\n";
107
108 if(!GetTypeName().isEmpty())
109 szDescription += tr("Type: ") + GetTypeName() + "\n";
110
111 if(!Protocol().isEmpty()) {
112 szDescription += tr("Protocol: ") + Protocol();
113#ifdef DEBUG
114 if(!GetPlugin()->DisplayName().isEmpty())
115 szDescription += " - " + GetPlugin()->DisplayName();
116#endif
117 szDescription += "\n";
118 }
119
120 if(!ServerName().isEmpty())
121 szDescription += tr("Server name: ") + ServerName() + "\n";
122
123 if(GetParameter()) {
124 if(!GetParameter()->m_Net.GetHost().isEmpty())
125 szDescription += tr("Server address: ") + GetParameter()->m_Net.GetHost() + ":"
126 + QString::number(GetParameter()->m_Net.GetPort()) + "\n";
127
128 QString szProxy(tr("Proxy") + " ");
129 auto &proxy = GetParameter()->m_Proxy;
130 switch(proxy.GetUsedType()) {
131 case CParameterProxy::TYPE::SSHTunnel:
132 {
133 auto &sshNet = proxy.m_SSH.m_Net;
134 szProxy += "(" + tr("SSH tunnel") + "): " + sshNet.GetHost() + ":"
135 + QString::number(sshNet.GetPort());
136 break;
137 }
138 case CParameterProxy::TYPE::SockesV5:
139 {
140 auto &sockesV5 = proxy.m_SockesV5;
141 szProxy += "(" + tr("Sockes v5") + "): " + sockesV5.GetHost() + ":"
142 + QString::number(sockesV5.GetPort());
143 break;
144 }
145 default:
146 szProxy.clear();
147 break;
148 }
149
150 if(!szProxy.isEmpty())
151 szDescription += szProxy + "\n";
152 }
153
154 if(GetSecurityLevel() != SecurityLevel::No)
155 szDescription += tr("Security level: ") + GetSecurityLevelString() + "\n";
156
157 if(!GetPlugin()->Description().isEmpty())
158 szDescription += tr("Description: ") + GetPlugin()->Description();
159
160 return szDescription;
161}
162
163const qint16 COperateDesktop::Version() const
164{
165 return 0;
166}
167
169{
170 qDebug(log) << Q_FUNC_INFO;
171 int nRet = 0;
172 bool check = false;
173
174 nRet = COperate::Initial();
175 if(nRet)
176 return nRet;
177
178 Q_ASSERT(!(m_pFrmViewer && m_pScroll));
179 m_pFrmViewer = new CFrmViewer(); // The owner is m_pScroll
180 m_pScroll = new CFrmScroll(m_pFrmViewer);
181
182 check = connect(m_pFrmViewer, SIGNAL(sigViewerFocusIn(QWidget*)),
183 this, SIGNAL(sigViewerFocusIn(QWidget*)));
184 Q_ASSERT(check);
185
186 nRet = InitialMenu();
187
188 return nRet;
189}
190
192{
193 qDebug(log) << Q_FUNC_INFO;
194 int nRet = 0;
195 if(m_pScroll)
196 {
197 delete m_pScroll;
198 m_pScroll = nullptr;
199 }
200 nRet = COperate::Clean();
201 return nRet;
202}
203
204int COperateDesktop::InitialMenu()
205{
206 int nRet = 0;
207 bool check = false;
208
209 QMenu* pMenuZoom = new QMenu(&m_Menu);
210 pMenuZoom->setTitle(tr("Zoom"));
211 pMenuZoom->setIcon(QIcon::fromTheme("zoom"));
212 pMenuZoom->setStatusTip(tr("Zoom"));
213 m_pMenuZoom = m_Menu.addMenu(pMenuZoom);
214 m_pZoomToWindow = pMenuZoom->addAction(
215 QIcon::fromTheme("zoom-fit-best"), tr("Zoom to window"));
216 m_pZoomToWindow->setCheckable(true);
217 m_pZoomToWindow->setStatusTip(tr("Zoom to window"));
218 m_pZoomToWindow->setToolTip(tr("Zoom to window"));
219 check = connect(m_pZoomToWindow, &QAction::triggered, this,
220 [&](){
221 m_pScroll->slotSetAdaptWindows(
223 });
224 Q_ASSERT(check);
225 m_pZoomAspectRatio = pMenuZoom->addAction(
226 QIcon::fromTheme("zoom-aspect-ratio"),
227 tr("Keep aspect ratio to window"));
228 m_pZoomAspectRatio->setCheckable(true);
229 m_pZoomAspectRatio->setStatusTip(tr("Keep aspect ratio to window"));
230 m_pZoomAspectRatio->setToolTip(tr("Keep aspect ratio to window"));
231 check = connect(m_pZoomAspectRatio, &QAction::triggered, this,
232 [&](){
233 m_pScroll->slotSetAdaptWindows(
235 });
236 Q_ASSERT(check);
237 m_pZoomOriginal = pMenuZoom->addAction(
238 QIcon::fromTheme("zoom-original"), tr("Original"));
239 m_pZoomOriginal->setCheckable(true);
240 m_pZoomOriginal->setStatusTip(tr("Original"));
241 m_pZoomOriginal->setToolTip(tr("Original"));
242 check = connect(m_pZoomOriginal, &QAction::triggered, this,
243 [&](){
244 m_pScroll->slotSetAdaptWindows(
246 });
247 Q_ASSERT(check);
248 m_pZoomIn = pMenuZoom->addAction(QIcon::fromTheme("zoom-in"), tr("Zoom in"));
249 m_pZoomIn->setCheckable(true);
250 m_pZoomIn->setStatusTip(tr("Zoom in"));
251 m_pZoomIn->setToolTip(tr("Zoom in"));
252 check = connect(
253 m_pZoomIn, &QAction::triggered, this,
254 [&](){
255 double factor = 0;
256 if(m_psbZoomFactor) {
257 factor = (m_pFrmViewer->GetZoomFactor() + 0.1) * 100;
258 qDebug(log) << "Zoom in:" << factor;
259 m_psbZoomFactor->setValue(factor);
260 }
261 });
262 Q_ASSERT(check);
263 m_pZoomOut = pMenuZoom->addAction(
264 QIcon::fromTheme("zoom-out"), tr("Zoom out"));
265 m_pZoomOut->setCheckable(true);
266 m_pZoomOut->setStatusTip(tr("Zoom out"));
267 m_pZoomOut->setToolTip(tr("Zoom out"));
268 check = connect(
269 m_pZoomOut, &QAction::triggered, this,
270 [&](){
271 double factor = 100;
272 if(m_psbZoomFactor) {
273 factor = (m_pFrmViewer->GetZoomFactor() - 0.1) * 100;
274 qDebug(log) << "Zoom out:" << factor;
275 m_psbZoomFactor->setValue(factor);
276 }
277 });
278 Q_ASSERT(check);
279 QActionGroup* pGBViewZoom = new QActionGroup(this);
280 if(pGBViewZoom) {
281 pGBViewZoom->addAction(m_pZoomToWindow);
282 pGBViewZoom->addAction(m_pZoomAspectRatio);
283 pGBViewZoom->addAction(m_pZoomOriginal);
284 pGBViewZoom->addAction(m_pZoomIn);
285 pGBViewZoom->addAction(m_pZoomOut);
286 check = connect(pGBViewZoom, &QActionGroup::triggered,
287 this, [&](QAction* a){
288 if(a == m_pZoomIn || a == m_pZoomOut)
289 m_psbZoomFactor->setEnabled(true);
290 else {
291 m_psbZoomFactor->setEnabled(false);
292 }
293 });
294 }
295 m_psbZoomFactor = new QSpinBox(pMenuZoom);
296 m_psbZoomFactor->setRange(0, 9999999);
297 m_psbZoomFactor->setValue(100);
298 m_psbZoomFactor->setSuffix("%");
299 m_psbZoomFactor->setEnabled(false);
300 //m_psbZoomFactor->setFocusPolicy(Qt::NoFocus);
301 check = connect(
302 m_psbZoomFactor, SIGNAL(valueChanged(int)),
303 this, SLOT(slotValueChanged(int)));
304 Q_ASSERT(check);
305 QWidgetAction* pFactor = new QWidgetAction(pMenuZoom);
306 pFactor->setDefaultWidget(m_psbZoomFactor);
307 pMenuZoom->insertAction(m_pZoomOut, pFactor);
308
309 QMenu* pMenuShortCut = new QMenu(&m_Menu);
310 pMenuShortCut->setTitle(tr("Send shortcut key"));
311 m_Menu.addMenu(pMenuShortCut);
312 pMenuShortCut->addAction(
313 tr("Send Ctl+Alt+Del"), this, SLOT(slotShortcutCtlAltDel()));
314 pMenuShortCut->addAction(
315 tr("Send lock screen (Win+L)"), this, SLOT(slotShortcutLock()));
316
317 m_Menu.addSeparator();
318 m_pScreenShot = new QAction(QIcon::fromTheme("camera-photo"),
319 tr("ScreenShot"), &m_Menu);
320 m_pScreenShot->setStatusTip(tr("ScreenShot"));
321 m_pScreenShot->setToolTip(tr("ScreenShot"));
322 check = connect(m_pScreenShot, SIGNAL(triggered()),
323 this, SLOT(slotScreenShot()));
324 Q_ASSERT(check);
325 m_Menu.addAction(m_pScreenShot);
326#if HAVE_QT6_RECORD
327 m_pRecord = new QAction(
328 QIcon::fromTheme("media-record"), tr("Start record"), &m_Menu);
329 m_pRecord->setCheckable(true);
330 m_pRecord->setStatusTip(tr("Start record"));
331 m_pRecord->setToolTip(tr("Start record"));
332 check = connect(m_pRecord, SIGNAL(triggered(bool)),
333 this, SLOT(slotRecord(bool)));
334 Q_ASSERT(check);
335 m_Menu.addAction(m_pRecord);
336 m_pRecordPause = new QAction(
337 QIcon::fromTheme("media-playback-pause"), tr("Record pause"), &m_Menu);
338 m_pRecordPause->setToolTip(tr("Record pause"));
339 m_pRecordPause->setStatusTip(tr("Record pause"));
340 m_pRecordPause->setCheckable(true);
341 m_pRecordPause->setEnabled(false);
342 check = connect(m_pRecordPause, SIGNAL(triggered(bool)),
343 this, SIGNAL(sigRecordPause(bool)));
344 Q_ASSERT(check);
345 m_Menu.addAction(m_pRecordPause);
346#endif
347
348 m_Menu.addSeparator();
349 if(m_pActionSettings)
350 m_Menu.addAction(m_pActionSettings);
351
352 return nRet;
353}
354
356{
357 return m_pScroll;
358}
359
360int COperateDesktop::Start()
361{
362 qDebug(log) << Q_FUNC_INFO;
363 int nRet = 0;
364 m_pThread = new CBackendThread(this);
365 if(!m_pThread) {
366 qCritical(log) << "new CBackendThread fail";
367 return -2;
368 }
369
370 m_pThread->start();
371
372 return nRet;
373}
374
375int COperateDesktop::Stop()
376{
377 qDebug(log) << Q_FUNC_INFO;
378 int nRet = 0;
379 if(m_pThread)
380 {
381 m_pThread->quit();
382 //Don't delete m_pThread, See CConnectThread
383 m_pThread = nullptr;
384 }
385 return nRet;
386}
387
389{
390 if(GetParameter())
391 {
392 GetParameter()->SetGlobalParameters(pPara);
393
394 if(pPara)
395 {
396 bool check = connect(pPara, SIGNAL(sigShowProtocolPrefixChanged()),
397 this, SLOT(slotUpdateName()));
398 Q_ASSERT(check);
399 check = connect(pPara, SIGNAL(sigSHowIpPortInNameChanged()),
400 this, SLOT(slotUpdateName()));
401 Q_ASSERT(check);
402 }
403
404 LoadAdaptWindows();
405 return 0;
406 } else {
407 QString szMsg = "There is not parameters! "
408 "please first create parameters, "
409 "then call SetParameter() in the ";
410 szMsg += metaObject()->className() + QString("::")
411 + metaObject()->className();
412 szMsg += QString("() or ") + metaObject()->className()
413 + QString("::") + "Initial()";
414 szMsg += " to set the parameters pointer. "
415 "Default set CParameterClient for the parameters of operate "
416 "(CParameterOperate or its derived classes) "
417 "See CManager::CreateOperate. "
418 "If you are sure the parameter of operate "
419 "does not need CParameterClient. "
420 "Please overload the SetGlobalParameters() in the ";
421 szMsg += QString(metaObject()->className()) + " . don't set it";
422 qCritical(log) << szMsg.toStdString().c_str();
423 Q_ASSERT(false);
424 }
425 return -1;
426}
427
429{
430 return m_pPara;
431}
432
434{
435 Q_ASSERT(!m_pPara);
436 m_pPara = p;
437 if(GetParameter())
438 {
439 bool check = false;
440 check = connect(GetParameter(), SIGNAL(sigNameChanged()),
441 this, SLOT(slotUpdateName()));
442 Q_ASSERT(check);
443 check = connect(GetParameter(), SIGNAL(sigShowServerNameChanged()),
444 this, SLOT(slotUpdateName()));
445 Q_ASSERT(check);
446 check = connect(GetParameter(), &CParameter::sigChanged,
447 this, [&](){
448 emit this->sigUpdateParameters(this);
449 });
450 Q_ASSERT(check);
451 CFrmViewer* pViewer = m_pFrmViewer;
452 if(pViewer) {
453 check = connect(GetParameter(), SIGNAL(sigZoomFactorChanged(double)),
454 pViewer, SLOT(slotSetZoomFactor(double)));
455 Q_ASSERT(check);
456 check = connect(
457 GetParameter(),
458 SIGNAL(sigAdaptWindowsChanged(CFrmViewer::ADAPT_WINDOWS)),
459 pViewer, SLOT(slotSetAdaptWindows(CFrmViewer::ADAPT_WINDOWS)));
460 Q_ASSERT(check);
461 check = connect(GetParameter(), SIGNAL(sigEnableInputMethod(bool)),
462 pViewer, SLOT(slotEnableInputMethod(bool)));
463 Q_ASSERT(check);
464 }
465 }
466 return 0;
467}
468
469int COperateDesktop::LoadAdaptWindows()
470{
471 if(m_pFrmViewer && GetParameter())
472 {
473 m_pFrmViewer->slotSetZoomFactor(GetParameter()->GetZoomFactor());
474 if(m_psbZoomFactor)
475 m_psbZoomFactor->setValue(m_pFrmViewer->GetZoomFactor() * 100);
476 CFrmViewer::ADAPT_WINDOWS aw = GetParameter()->GetAdaptWindows();
478 if(m_pZoomToWindow) {
479 m_pZoomToWindow->trigger();
480 }
482 if(m_pZoomAspectRatio) {
483 m_pZoomAspectRatio->trigger();
484 }
485 } else if(CFrmViewer::ADAPT_WINDOWS::Original == aw) {
486 if(m_pZoomOriginal) {
487 m_pZoomOriginal->trigger();
488 }
489 } else if(CFrmViewer::ADAPT_WINDOWS::Zoom == aw) {
490 if(m_pZoomIn) {
491 m_pZoomIn->trigger();
492 }
493 }
494 }
495 return 0;
496}
497
498int COperateDesktop::Load(QSettings &set)
499{
500 int nRet = 0;
501 Q_ASSERT(m_pFrmViewer);
502 nRet = COperate::Load(set);
503 if(m_pPara)
504 nRet = m_pPara->Load(set);
505 else {
506 QString szMsg = "There is not parameters! "
507 "please first create parameters, "
508 "then call SetParameter() in the ";
509 szMsg += metaObject()->className() + QString("::")
510 + metaObject()->className();
511 szMsg += QString("() or ") + metaObject()->className()
512 + QString("::") + "Initial()";
513 szMsg += " to set the parameters pointer. ";
514 qWarning(log) << szMsg.toStdString().c_str();
515 Q_ASSERT(false);//TODO: delete it
516 }
517
518 LoadAdaptWindows();
519 return nRet;
520}
521
522int COperateDesktop::Save(QSettings &set)
523{
524 int nRet = 0;
525 Q_ASSERT(GetParameter());
526 if(GetParameter() && m_pFrmViewer)
527 {
528 GetParameter()->SetAdaptWindows(m_pFrmViewer->GetAdaptWindows());
529 GetParameter()->SetZoomFactor(m_pFrmViewer->GetZoomFactor());
530 }
531 nRet = COperate::Save(set);
532 if(m_pPara)
533 nRet = m_pPara->Save(set);
534 return nRet;
535}
536
537#if HAVE_QT6_RECORD
538void COperateDesktop::slotRecord(bool checked)
539{
540 qDebug(log) << Q_FUNC_INFO << checked;
541 QAction* pRecord = qobject_cast<QAction*>(sender());
542 if(pRecord)
543 {
544 if(checked) {
545 //pRecord->setIcon(QIcon::fromTheme("media-playback-stop"));
546 pRecord->setText(tr("Stop record"));
547 } else {
548 //pRecord->setIcon(QIcon::fromTheme("media-playback-start"));
549 pRecord->setText(tr("Start record"));
550 }
551 m_pRecordPause->setEnabled(checked);
552 emit sigRecord(checked);
553 }
554}
555
556void COperateDesktop::slotRecorderStateChanged(
557 QMediaRecorder::RecorderState state)
558{
559 qDebug(log) << Q_FUNC_INFO << state;
560 if(QMediaRecorder::StoppedState == state)
561 {
562 m_pRecord->setChecked(false);
563 m_pRecordPause->setChecked(false);
564 }
565}
566#endif
567
569{
570 qDebug(log) << "zoom:" << v;
571 if(!m_pScroll || !m_pFrmViewer) return;
572 m_pFrmViewer->slotSetZoomFactor(((double)v) / 100);
573 m_pScroll->slotSetAdaptWindows(CFrmViewer::ADAPT_WINDOWS::Zoom);
574}
575
576void COperateDesktop::slotScreenShot()
577{
578 if(!GetParameter() || !m_pFrmViewer)
579 return;
580 auto &record = GetParameter()->m_Record;
581 QString szFile = record.GetImageFile(true);
582 bool bRet = m_pFrmViewer->GrabImage().save(szFile);
583 if(bRet)
584 qDebug(log) << "Success: save screenshot to" << szFile;
585 else
586 qCritical(log) << "Fail: save screenshot to" << szFile;
587 if(record.GetEndAction() != CParameterRecord::ENDACTION::No)
588 QDesktopServices::openUrl(QUrl::fromLocalFile(szFile));
589}
590
591void COperateDesktop::slotShortcutCtlAltDel()
592{
593 if(!m_pFrmViewer)
594 return;
595 // Send ctl+alt+del
596 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyPress, Qt::Key_Control, Qt::ControlModifier));
597 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyPress, Qt::Key_Alt, Qt::AltModifier));
598 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyPress, Qt::Key_Delete, Qt::ControlModifier | Qt::AltModifier));
599 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyRelease, Qt::Key_Control, Qt::ControlModifier));
600 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyRelease, Qt::Key_Alt, Qt::AltModifier));
601 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyRelease, Qt::Key_Delete, Qt::ControlModifier | Qt::AltModifier));
602}
603
604void COperateDesktop::slotShortcutLock()
605{
606 if(!m_pFrmViewer)
607 return;
608 // Send ctl+alt+del
609 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyPress, Qt::Key_Super_L, Qt::NoModifier));
610 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyPress, Qt::Key_L, Qt::NoModifier));
611 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyRelease, Qt::Key_Super_L, Qt::NoModifier));
612 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyRelease, Qt::Key_L, Qt::NoModifier));
613}
614
615
617{
618 if(GetParameter())
619 if(!GetParameter()->GetShowServerName()
620 || m_szServerName.isEmpty())
621 {
622 if(!GetParameter()->m_Net.GetHost().isEmpty())
623 return GetParameter()->m_Net.GetHost() + ":"
624 + QString::number(GetParameter()->m_Net.GetPort());
625 }
626 if(GetParameter() && GetParameter()->GetGlobalParameters()
627 && GetParameter()->GetGlobalParameters()->GetShowIpPortInName())
628 {
629 return GetParameter()->m_Net.GetHost()
630 + ":" + QString::number(GetParameter()->m_Net.GetPort());
631 }
632 if(m_szServerName.isEmpty() && GetParameter())
633 return GetParameter()->GetServerName();
634 return m_szServerName;
635}
636
637void COperateDesktop::slotSetServerName(const QString& szName)
638{
639 if(m_szServerName == szName)
640 return;
641
642 m_szServerName = szName;
643 if(GetParameter())
644 {
645 if(GetParameter()->GetServerName() == szName)
646 return;
647 GetParameter()->SetServerName(szName);
648 }
649
650 slotUpdateName();
651}
The backend thread
virtual void quit()
Quit
The scroll form class
Definition FrmScroll.h:17
用于显示从 CConnectDesktop 输出的图像,和向 CConnectDesktop 发送键盘、鼠标事件。
Definition FrmViewer.h:48
ADAPT_WINDOWS
窗口适配枚举常量
Definition FrmViewer.h:60
@ Original
原始桌面大小,桌面的左上点与窗口的左上点对齐
@ Zoom
缩放窗口大小等于桌面大小 * 系数
@ KeepAspectRationToWindow
保持长宽比缩放到窗口大小,窗口是固定的
@ ZoomToWindow
桌面缩放到窗口大小,窗口是固定的
double GetZoomFactor() const
调整缩放系数。 调整完成后需要调用 SetAdaptWindows(FrmViewer::Zoom) 缩放窗口大小。
远程桌面操作接口
virtual QString ServerName()
当前连接名(远程桌面的名称,如果没有,则是 IP:端口)。例如:服务名或 IP:端口
virtual int SetParameter(CParameterBase *p)
设置参数指针
virtual void slotSetServerName(const QString &szName)
virtual int Save(QSettings &set) override
保存参数
virtual const QString Name() override
Name
virtual const qint16 Version() const override
Version
virtual int Load(QSettings &set) override
加载参数
virtual const QString Id() override
Identity
virtual int Initial() override
Initial parameters and resource
virtual QWidget * GetViewer() override
得到显示视图
void slotValueChanged(int v)
emit by zoom menu in the class
virtual int SetGlobalParameters(CParameterPlugin *pPara) override
应用插件全局参数
virtual const QString Description() override
Description
virtual int Clean() override
Clean parameters and resource
virtual CParameterBase * GetParameter()
Get parameter
操作接口。
Definition Operate.h:51
virtual int Save(QSettings &set)=0
保存参数
Definition Operate.cpp:223
virtual int Load(QSettings &set)=0
加载参数
Definition Operate.cpp:216
virtual Q_INVOKABLE int Initial()
Initial parameters and resource
Definition Operate.cpp:230
virtual const QString Protocol() const
Protocol
Definition Operate.cpp:71
virtual Q_INVOKABLE int Clean()
Clean parameters and resource
Definition Operate.cpp:247
void sigViewerFocusIn(QWidget *pView)
视图获得焦点
Q_INVOKABLE CPlugin * GetPlugin() const
Get plugin
Definition Operate.cpp:259
void sigUpdateParameters(COperate *pOperate)
更新参数,通知应用程序保存或显示参数
virtual const QString Id()
Identity
Definition Operate.cpp:33
virtual const QString GetTypeName() const
Get type name
Definition Operate.cpp:76
连接基础参数接口。包括基本参数(网络参数等)。 所有插件的连接参数都应从此类派生。
网络连接参数接口。此类仅在插件内有效。 其界面为 CParameterNetUI
插件的全局参数。
virtual int Save(QString szFile=QString(), bool bForce=true)
Save to file
Definition Parameter.cpp:46
void sigChanged()
当参数改变时,触发 通常如果需要,则相应的参数会对应一个改变事件。
virtual int Load(QString szFile=QString())
Load from file
Definition Parameter.cpp:35
插件接口
Definition Plugin.h:15
virtual const QString DisplayName() const
在界面上显示的名称
Definition Plugin.cpp:73
virtual const QString Description() const =0
描述