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