Rabbit Remote Control 0.1.0-bate8
Loading...
Searching...
No Matches
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
86const QString COperateDesktop::Name()
87{
88 QString szName;
89 // Show the name of parameter
90 if(GetParameter() && !(GetParameter()->GetName().isEmpty()))
91 szName += GetParameter()->GetName();
92 else {
93 // Show the prefix of protocol
94 if(GetParameter() && GetParameter()->GetGlobalParameters()
95 && (GetParameter()->GetGlobalParameters()->GetNameStyles()
96 & CParameterPlugin::NameStyle::Protocol)
97 && !Protocol().isEmpty())
98 szName = Protocol() + ":";
99 // Show the server name
100 szName += ServerName();
101 }
102
103 // Show the prefix of security level
104 QString szSecurityLevel;
106 if((GetParameter()->GetGlobalParameters()->GetNameStyles()
107 & CParameterPlugin::NameStyle::SecurityLevel)
108 && !(GetSecurityLevel() & CSecurityLevel::Level::No)
109 && !sl.GetUnicodeIcon().isEmpty())
110 szSecurityLevel = sl.GetUnicodeIcon().left(2);
111
112 return szSecurityLevel + szName;
113}
115
118{
119 QString szDescription;
120 if(!Name().isEmpty())
121 szDescription = tr("Name: ") + Name() + "\n";
122
123 if(!GetTypeName().isEmpty())
124 szDescription += tr("Type: ") + GetTypeName() + "\n";
125
126 if(!Protocol().isEmpty()) {
127 szDescription += tr("Protocol: ") + Protocol();
128#ifdef DEBUG
129 if(!GetPlugin()->DisplayName().isEmpty())
130 szDescription += " - " + GetPlugin()->DisplayName();
131#endif
132 szDescription += "\n";
133 }
134
135 if(!ServerName().isEmpty())
136 szDescription += tr("Server name: ") + ServerName() + "\n";
137
138 if(GetParameter()) {
139 if(!GetParameter()->m_Net.GetHost().isEmpty())
140 szDescription += tr("Server address: ") + GetParameter()->m_Net.GetHost() + ":"
141 + QString::number(GetParameter()->m_Net.GetPort()) + "\n";
142
143 QString szProxy(tr("Proxy") + " ");
144 auto &proxy = GetParameter()->m_Proxy;
145 switch(proxy.GetUsedType()) {
146 case CParameterProxy::TYPE::SSHTunnel:
147 {
148 auto &sshNet = proxy.m_SSH.m_Net;
149 szProxy += "(" + tr("SSH tunnel") + "): " + sshNet.GetHost() + ":"
150 + QString::number(sshNet.GetPort());
151 break;
152 }
153 case CParameterProxy::TYPE::SockesV5:
154 {
155 auto &sockesV5 = proxy.m_SockesV5;
156 szProxy += "(" + tr("Sockes v5") + "): " + sockesV5.GetHost() + ":"
157 + QString::number(sockesV5.GetPort());
158 break;
159 }
160 default:
161 szProxy.clear();
162 break;
163 }
164
165 if(!szProxy.isEmpty())
166 szDescription += szProxy + "\n";
167 }
168
170 if(!(GetSecurityLevel() & CSecurityLevel::Level::No)) {
171 szDescription += tr("Security level: ");
172 if(!sl.GetUnicodeIcon().isEmpty())
173 szDescription += sl.GetUnicodeIcon() + " ";
174 szDescription += sl.GetString() + "\n";
175 }
176
177 if(!GetPlugin()->Description().isEmpty())
178 szDescription += tr("Description: ") + GetPlugin()->Description();
179
180 return szDescription;
181}
183
184const qint16 COperateDesktop::Version() const
185{
186 return 0;
187}
188
190{
191 qDebug(log) << Q_FUNC_INFO;
192 int nRet = 0;
193 bool check = false;
194
195 nRet = COperate::Initial();
196 if(nRet)
197 return nRet;
198
199 Q_ASSERT(!(m_pFrmViewer && m_pScroll));
200 m_pFrmViewer = new CFrmViewer(); // The owner is m_pScroll
201 m_pScroll = new CFrmScroll(m_pFrmViewer);
202
203 check = connect(m_pFrmViewer, SIGNAL(sigViewerFocusIn(QWidget*)),
204 this, SIGNAL(sigViewerFocusIn(QWidget*)));
205 Q_ASSERT(check);
206
207 nRet = InitialMenu();
208
209 return nRet;
210}
211
213{
214 qDebug(log) << Q_FUNC_INFO;
215 int nRet = 0;
216 if(m_pScroll)
217 {
218 delete m_pScroll;
219 m_pScroll = nullptr;
220 }
221 nRet = COperate::Clean();
222 return nRet;
223}
224
225int COperateDesktop::InitialMenu()
226{
227 int nRet = 0;
228 bool check = false;
229
230 QMenu* pMenuZoom = new QMenu(&m_Menu);
231 pMenuZoom->setTitle(tr("Zoom"));
232 pMenuZoom->setIcon(QIcon::fromTheme("zoom"));
233 pMenuZoom->setStatusTip(tr("Zoom"));
234 m_pMenuZoom = m_Menu.addMenu(pMenuZoom);
235 m_pZoomToWindow = pMenuZoom->addAction(
236 QIcon::fromTheme("zoom-fit-best"), tr("Zoom to window"));
237 m_pZoomToWindow->setCheckable(true);
238 m_pZoomToWindow->setStatusTip(tr("Zoom to window"));
239 m_pZoomToWindow->setToolTip(tr("Zoom to window"));
240 check = connect(m_pZoomToWindow, &QAction::triggered, this,
241 [&](){
242 m_pScroll->slotSetAdaptWindows(
244 });
245 Q_ASSERT(check);
246 m_pZoomAspectRatio = pMenuZoom->addAction(
247 QIcon::fromTheme("zoom-aspect-ratio"),
248 tr("Keep aspect ratio to window"));
249 m_pZoomAspectRatio->setCheckable(true);
250 m_pZoomAspectRatio->setStatusTip(tr("Keep aspect ratio to window"));
251 m_pZoomAspectRatio->setToolTip(tr("Keep aspect ratio to window"));
252 check = connect(m_pZoomAspectRatio, &QAction::triggered, this,
253 [&](){
254 m_pScroll->slotSetAdaptWindows(
256 });
257 Q_ASSERT(check);
258 m_pZoomOriginal = pMenuZoom->addAction(
259 QIcon::fromTheme("zoom-original"), tr("Original"));
260 m_pZoomOriginal->setCheckable(true);
261 m_pZoomOriginal->setStatusTip(tr("Original"));
262 m_pZoomOriginal->setToolTip(tr("Original"));
263 check = connect(m_pZoomOriginal, &QAction::triggered, this,
264 [&](){
265 m_pScroll->slotSetAdaptWindows(
267 });
268 Q_ASSERT(check);
269 m_pZoomIn = pMenuZoom->addAction(QIcon::fromTheme("zoom-in"), tr("Zoom in"));
270 m_pZoomIn->setCheckable(true);
271 m_pZoomIn->setStatusTip(tr("Zoom in"));
272 m_pZoomIn->setToolTip(tr("Zoom in"));
273 check = connect(
274 m_pZoomIn, &QAction::triggered, this,
275 [&](){
276 double factor = 0;
277 if(m_psbZoomFactor) {
278 factor = (m_pFrmViewer->GetZoomFactor() + 0.1) * 100;
279 qDebug(log) << "Zoom in:" << factor;
280 m_psbZoomFactor->setValue(factor);
281 }
282 });
283 Q_ASSERT(check);
284 m_pZoomOut = pMenuZoom->addAction(
285 QIcon::fromTheme("zoom-out"), tr("Zoom out"));
286 m_pZoomOut->setCheckable(true);
287 m_pZoomOut->setStatusTip(tr("Zoom out"));
288 m_pZoomOut->setToolTip(tr("Zoom out"));
289 check = connect(
290 m_pZoomOut, &QAction::triggered, this,
291 [&](){
292 double factor = 100;
293 if(m_psbZoomFactor) {
294 factor = (m_pFrmViewer->GetZoomFactor() - 0.1) * 100;
295 qDebug(log) << "Zoom out:" << factor;
296 m_psbZoomFactor->setValue(factor);
297 }
298 });
299 Q_ASSERT(check);
300 QActionGroup* pGBViewZoom = new QActionGroup(this);
301 if(pGBViewZoom) {
302 pGBViewZoom->addAction(m_pZoomToWindow);
303 pGBViewZoom->addAction(m_pZoomAspectRatio);
304 pGBViewZoom->addAction(m_pZoomOriginal);
305 pGBViewZoom->addAction(m_pZoomIn);
306 pGBViewZoom->addAction(m_pZoomOut);
307 check = connect(pGBViewZoom, &QActionGroup::triggered,
308 this, [&](QAction* a){
309 if(a == m_pZoomIn || a == m_pZoomOut)
310 m_psbZoomFactor->setEnabled(true);
311 else {
312 m_psbZoomFactor->setEnabled(false);
313 }
314 });
315 }
316 m_psbZoomFactor = new QSpinBox(pMenuZoom);
317 m_psbZoomFactor->setRange(0, 9999999);
318 m_psbZoomFactor->setValue(100);
319 m_psbZoomFactor->setSuffix("%");
320 m_psbZoomFactor->setEnabled(false);
321 //m_psbZoomFactor->setFocusPolicy(Qt::NoFocus);
322 check = connect(
323 m_psbZoomFactor, SIGNAL(valueChanged(int)),
324 this, SLOT(slotValueChanged(int)));
325 Q_ASSERT(check);
326 QWidgetAction* pFactor = new QWidgetAction(pMenuZoom);
327 pFactor->setDefaultWidget(m_psbZoomFactor);
328 pMenuZoom->insertAction(m_pZoomOut, pFactor);
329
330 QMenu* pMenuShortCut = new QMenu(&m_Menu);
331 pMenuShortCut->setTitle(tr("Send shortcut key"));
332 m_Menu.addMenu(pMenuShortCut);
333 pMenuShortCut->addAction(
334 tr("Send Ctl+Alt+Del"), this, SLOT(slotShortcutCtlAltDel()));
335 pMenuShortCut->addAction(
336 tr("Send lock screen (Win+L)"), this, SLOT(slotShortcutLock()));
337
338 m_Menu.addSeparator();
339 m_pScreenShot = new QAction(QIcon::fromTheme("camera-photo"),
340 tr("ScreenShot"), &m_Menu);
341 m_pScreenShot->setStatusTip(tr("ScreenShot"));
342 m_pScreenShot->setToolTip(tr("ScreenShot"));
343 check = connect(m_pScreenShot, SIGNAL(triggered()),
344 this, SLOT(slotScreenShot()));
345 Q_ASSERT(check);
346 m_Menu.addAction(m_pScreenShot);
347#if HAVE_QT6_RECORD
348 m_pRecord = new QAction(
349 QIcon::fromTheme("media-record"), tr("Start record"), &m_Menu);
350 m_pRecord->setCheckable(true);
351 m_pRecord->setStatusTip(tr("Start record"));
352 m_pRecord->setToolTip(tr("Start record"));
353 check = connect(m_pRecord, SIGNAL(triggered(bool)),
354 this, SLOT(slotRecord(bool)));
355 Q_ASSERT(check);
356 m_Menu.addAction(m_pRecord);
357 m_pRecordPause = new QAction(
358 QIcon::fromTheme("media-playback-pause"), tr("Record pause"), &m_Menu);
359 m_pRecordPause->setToolTip(tr("Record pause"));
360 m_pRecordPause->setStatusTip(tr("Record pause"));
361 m_pRecordPause->setCheckable(true);
362 m_pRecordPause->setEnabled(false);
363 check = connect(m_pRecordPause, SIGNAL(triggered(bool)),
364 this, SIGNAL(sigRecordPause(bool)));
365 Q_ASSERT(check);
366 m_Menu.addAction(m_pRecordPause);
367#endif
368
369 m_Menu.addSeparator();
370 if(m_pActionSettings)
371 m_Menu.addAction(m_pActionSettings);
372
373 return nRet;
374}
375
377{
378 return m_pScroll;
379}
380
381int COperateDesktop::Start()
382{
383 qDebug(log) << Q_FUNC_INFO;
384 int nRet = 0;
385 m_pThread = new CBackendThread(this);
386 if(!m_pThread) {
387 qCritical(log) << "new CBackendThread fail";
388 return -1;
389 }
390
391 m_pThread->start();
392
393 return nRet;
394}
395
396int COperateDesktop::Stop()
397{
398 qDebug(log) << Q_FUNC_INFO;
399 int nRet = 0;
400 if(m_pThread)
401 {
402 m_pThread->quit();
403 //Don't delete m_pThread, See CBackendThread
404 m_pThread = nullptr;
405 }
406 return nRet;
407}
408
411{
412 if(GetParameter()) {
413 GetParameter()->SetGlobalParameters(pPara);
414
415 if(pPara) {
416 bool check = connect(pPara, SIGNAL(sigNameStylesChanged()),
417 this, SLOT(slotUpdateName()));
418 Q_ASSERT(check);
419 }
420
421 LoadAdaptWindows();
422 return 0;
423 } else {
424 QString szMsg = "There is not parameters! "
425 "please first create parameters, "
426 "then call SetParameter() in the ";
427 szMsg += metaObject()->className() + QString("::")
428 + metaObject()->className();
429 szMsg += QString("() or ") + metaObject()->className()
430 + QString("::") + "Initial()";
431 szMsg += " to set the parameters pointer. "
432 "Default set CParameterClient for the parameters of operate "
433 "(CParameterOperate or its derived classes) "
434 "See CManager::CreateOperate. "
435 "If you are sure the parameter of operate "
436 "does not need CParameterClient. "
437 "Please overload the SetGlobalParameters() in the ";
438 szMsg += QString(metaObject()->className()) + " . don't set it";
439 qCritical(log) << szMsg.toStdString().c_str();
440 Q_ASSERT(false);
441 }
442 return -1;
443}
445
447{
448 return m_pPara;
449}
450
452{
453 Q_ASSERT(!m_pPara);
454 m_pPara = p;
455 if(GetParameter())
456 {
457 bool check = false;
458 check = connect(GetParameter(), SIGNAL(sigNameChanged()),
459 this, SLOT(slotUpdateName()));
460 Q_ASSERT(check);
461 check = connect(GetParameter(), SIGNAL(sigShowServerNameChanged()),
462 this, SLOT(slotUpdateName()));
463 Q_ASSERT(check);
464 check = connect(GetParameter(), &CParameter::sigChanged,
465 this, [&](){
466 emit this->sigUpdateParameters(this);
467 });
468 Q_ASSERT(check);
469 CFrmViewer* pViewer = m_pFrmViewer;
470 if(pViewer) {
471 check = connect(GetParameter(), SIGNAL(sigZoomFactorChanged(double)),
472 pViewer, SLOT(slotSetZoomFactor(double)));
473 Q_ASSERT(check);
474 check = connect(
475 GetParameter(),
476 SIGNAL(sigAdaptWindowsChanged(CFrmViewer::ADAPT_WINDOWS)),
477 pViewer, SLOT(slotSetAdaptWindows(CFrmViewer::ADAPT_WINDOWS)));
478 Q_ASSERT(check);
479 check = connect(GetParameter(), SIGNAL(sigEnableInputMethod(bool)),
480 pViewer, SLOT(slotEnableInputMethod(bool)));
481 Q_ASSERT(check);
482 }
483 }
484 return 0;
485}
486
487int COperateDesktop::LoadAdaptWindows()
488{
489 if(m_pFrmViewer && GetParameter())
490 {
491 m_pFrmViewer->slotSetZoomFactor(GetParameter()->GetZoomFactor());
492 if(m_psbZoomFactor)
493 m_psbZoomFactor->setValue(m_pFrmViewer->GetZoomFactor() * 100);
494 CFrmViewer::ADAPT_WINDOWS aw = GetParameter()->GetAdaptWindows();
496 if(m_pZoomToWindow) {
497 m_pZoomToWindow->trigger();
498 }
500 if(m_pZoomAspectRatio) {
501 m_pZoomAspectRatio->trigger();
502 }
503 } else if(CFrmViewer::ADAPT_WINDOWS::Original == aw) {
504 if(m_pZoomOriginal) {
505 m_pZoomOriginal->trigger();
506 }
507 } else if(CFrmViewer::ADAPT_WINDOWS::Zoom == aw) {
508 if(m_pZoomIn) {
509 m_pZoomIn->trigger();
510 }
511 }
512 }
513 return 0;
514}
515
516int COperateDesktop::Load(QSettings &set)
517{
518 int nRet = 0;
519 Q_ASSERT(m_pFrmViewer);
520 if(m_pPara)
521 nRet = m_pPara->Load(set);
522 else {
523 QString szMsg = "There is not parameters! "
524 "please first create parameters, "
525 "then call SetParameter() in the ";
526 szMsg += metaObject()->className() + QString("::")
527 + metaObject()->className();
528 szMsg += QString("() or ") + metaObject()->className()
529 + QString("::") + "Initial()";
530 szMsg += " to set the parameters pointer. ";
531 qWarning(log) << szMsg.toStdString().c_str();
532 Q_ASSERT_X(false, "COperateDesktop", szMsg.toStdString().c_str());
533 }
534
535 LoadAdaptWindows();
536 return nRet;
537}
538
539int COperateDesktop::Save(QSettings &set)
540{
541 int nRet = 0;
542 Q_ASSERT(GetParameter());
543 if(GetParameter() && m_pFrmViewer)
544 {
545 GetParameter()->SetAdaptWindows(m_pFrmViewer->GetAdaptWindows());
546 GetParameter()->SetZoomFactor(m_pFrmViewer->GetZoomFactor());
547 }
548 if(m_pPara)
549 nRet = m_pPara->Save(set);
550 return nRet;
551}
552
553#if HAVE_QT6_RECORD
554void COperateDesktop::slotRecord(bool checked)
555{
556 qDebug(log) << Q_FUNC_INFO << checked;
557 QAction* pRecord = qobject_cast<QAction*>(sender());
558 if(pRecord)
559 {
560 if(checked) {
561 //pRecord->setIcon(QIcon::fromTheme("media-playback-stop"));
562 pRecord->setText(tr("Stop record"));
563 } else {
564 //pRecord->setIcon(QIcon::fromTheme("media-playback-start"));
565 pRecord->setText(tr("Start record"));
566 }
567 m_pRecordPause->setEnabled(checked);
568 emit sigRecord(checked);
569 }
570}
571
572void COperateDesktop::slotRecorderStateChanged(
573 QMediaRecorder::RecorderState state)
574{
575 qDebug(log) << Q_FUNC_INFO << state;
576 if(QMediaRecorder::StoppedState == state)
577 {
578 m_pRecord->setChecked(false);
579 m_pRecordPause->setChecked(false);
580 }
581}
582#endif
583
585{
586 qDebug(log) << "zoom:" << v;
587 if(!m_pScroll || !m_pFrmViewer) return;
588 m_pFrmViewer->slotSetZoomFactor(((double)v) / 100);
589 m_pScroll->slotSetAdaptWindows(CFrmViewer::ADAPT_WINDOWS::Zoom);
590}
591
592void COperateDesktop::slotScreenShot()
593{
594 if(!GetParameter() || !m_pFrmViewer)
595 return;
596 auto &record = GetParameter()->m_Record;
597 QString szFile = record.GetImageFile(true);
598 bool bRet = m_pFrmViewer->GrabImage().save(szFile);
599 if(bRet)
600 qDebug(log) << "Success: save screenshot to" << szFile;
601 else
602 qCritical(log) << "Fail: save screenshot to" << szFile;
603 if(record.GetEndAction() != CParameterRecord::ENDACTION::No)
604 QDesktopServices::openUrl(QUrl::fromLocalFile(szFile));
605}
606
607void COperateDesktop::slotShortcutCtlAltDel()
608{
609 if(!m_pFrmViewer)
610 return;
611 // Send ctl+alt+del
612 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyPress, Qt::Key_Control, Qt::ControlModifier));
613 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyPress, Qt::Key_Alt, Qt::AltModifier));
614 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyPress, Qt::Key_Delete, Qt::ControlModifier | Qt::AltModifier));
615 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyRelease, Qt::Key_Control, Qt::ControlModifier));
616 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyRelease, Qt::Key_Alt, Qt::AltModifier));
617 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyRelease, Qt::Key_Delete, Qt::ControlModifier | Qt::AltModifier));
618}
619
620void COperateDesktop::slotShortcutLock()
621{
622 if(!m_pFrmViewer)
623 return;
624 // Send ctl+alt+del
625 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyPress, Qt::Key_Super_L, Qt::NoModifier));
626 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyPress, Qt::Key_L, Qt::NoModifier));
627 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyRelease, Qt::Key_Super_L, Qt::NoModifier));
628 emit m_pFrmViewer->sigKeyPressEvent(new QKeyEvent(QKeyEvent::KeyRelease, Qt::Key_L, Qt::NoModifier));
629}
630
633{
634 // Show IP:Port without server name
635 if(GetParameter())
636 if(!GetParameter()->GetShowServerName()
637 || m_szServerName.isEmpty())
638 {
639 if(!GetParameter()->m_Net.GetHost().isEmpty())
640 return GetParameter()->m_Net.GetHost() + ":"
641 + QString::number(GetParameter()->m_Net.GetPort());
642 }
643 if(GetParameter() && GetParameter()->GetGlobalParameters()
644 && !(GetParameter()->GetGlobalParameters()->GetNameStyles()
645 & CParameterPlugin::NameStyle::ServerName))
646 {
647 return GetParameter()->m_Net.GetHost()
648 + ":" + QString::number(GetParameter()->m_Net.GetPort());
649 }
650 // Show the server name of parameter
651 if(m_szServerName.isEmpty() && GetParameter())
652 return GetParameter()->GetServerName();
653 // Show the server name
654 return m_szServerName;
655}
657
658void COperateDesktop::slotSetServerName(const QString& szName)
659{
660 do{
661 if(m_szServerName == szName)
662 break;
663
664 m_szServerName = szName;
665 if(GetParameter())
666 {
667 if(GetParameter()->GetServerName() == szName)
668 break;
669 GetParameter()->SetServerName(szName);
670 }
671 } while(0);
672 slotUpdateName();
673}
The backend thread.
virtual void quit()
Quit.
The scroll form class.
Definition FrmScroll.h:17
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
@ Original
Original desktop size, the left-top of the desktop is aligned with the left-top of the window.
@ Zoom
zoom windows = desktop size * factor
@ KeepAspectRationToWindow
Keep desktop aspectration adapt to windows.
@ ZoomToWindow
Desktop adapt to windows.
double GetZoomFactor() const
Adjust the zoom factor.
Remote desktop operate interface.
virtual QString ServerName()
Current connect server name (remote desktop name, if not present, then IP:PORT).
virtual CParameterBase * GetParameter() const
Get parameter.
virtual int SetParameter(CParameterBase *p)
Set parameter pointer.
virtual void slotSetServerName(const QString &szName)
[Get server name]
virtual Q_INVOKABLE int Save(QSettings &set) override
Save parameters.
virtual const QString Name() override
[The name of the desktop operate]
virtual const qint16 Version() const override
[The description of the desktop operate]
virtual Q_INVOKABLE int Load(QSettings &set) override
Load parameters.
virtual int Initial() override
Initial parameters and resource.
virtual QWidget * GetViewer() override
Get Viewer.
void slotValueChanged(int v)
emit by zoom menu in the class
virtual int SetGlobalParameters(CParameterPlugin *pPara) override
Set Global Parameters.
virtual const QString Description() override
[The name of the desktop operate]
virtual int Clean() override
Clean parameters and resource.
Operate interface.
Definition Operate.h:51
virtual CSecurityLevel::Levels GetSecurityLevel() const
Get Security Level.
Definition Operate.cpp:129
virtual Q_INVOKABLE int Initial()
Initial parameters and resource.
Definition Operate.cpp:190
virtual Q_INVOKABLE int Clean()
Clean parameters and resource.
Definition Operate.cpp:207
void sigViewerFocusIn(QWidget *pView)
The view is focus.
Q_INVOKABLE CPlugin * GetPlugin() const
Get plugin.
Definition Operate.cpp:219
void sigUpdateParameters(COperate *pOperate)
Update parameters, notify application to save or show parameters.
The interface of connecter parameters.
Basic network parameters.
Global parameters of plugins.
virtual int Save(QString szFile=QString(), bool bForce=true)
Save to file.
Definition Parameter.cpp:47
void sigChanged()
emit when the parameter changes Usually if required, the corresponding parameter corresponds to a cha...
virtual int Load(QString szFile=QString())
Load from file.
Definition Parameter.cpp:35
Plugin interface.
Definition Plugin.h:15
virtual const QString DisplayName() const
The plugin display name.
Definition Plugin.cpp:76
virtual const QString Description() const =0
Plugin description.
Security level.
Definition Stats.h:79