4#include "ui_mainwindow.h"
8#include "RabbitCommonDir.h"
9#include "RabbitCommonTools.h"
15#include "QUIWidget/QUIWidget.h"
19#include "FrmFullScreenToolBar.h"
20#include "ParameterDlgSettings.h"
21#include "FrmListRecentConnects.h"
31#include <QApplication>
33#include <QDesktopServices>
34#include <QWidgetAction>
38#include <QKeySequence>
42#include <QLoggingCategory>
45static Q_LOGGING_CATEGORY(log,
"App.MainWindow")
46static Q_LOGGING_CATEGORY(logRecord, "App.
MainWindow.Record")
49 : QMainWindow(parent),
50 m_pActionConnecterMenu(
nullptr),
51 m_pDockListConnects(
nullptr),
52 m_pSignalStatus(
nullptr),
55 m_pFullScreenToolBar(
nullptr),
56 m_pRecentMenu(
nullptr),
57 m_pDockFavorite(
nullptr),
58 m_pFavoriteView(
nullptr)
64 setFocusPolicy(Qt::NoFocus);
68 m_pDockFavorite =
new QDockWidget(
this);
74 m_pDockFavorite->setTitleBarWidget(m_pFavoriteView->m_pDockTitleBar);
75 check = connect(m_pFavoriteView, SIGNAL(sigConnect(
const QString&,
bool)),
76 this, SLOT(slotOpenFile(
const QString&,
bool)));
78 check = connect(m_pFavoriteView, SIGNAL(sigFavorite()),
79 this, SLOT(on_actionAdd_to_favorite_triggered()));
81 check = connect(&m_Parameter, SIGNAL(sigFavoriteEditChanged(
bool)),
82 m_pFavoriteView, SLOT(slotDoubleEditNode(
bool)));
84 m_pDockFavorite->setWidget(m_pFavoriteView);
85 m_pDockFavorite->setWindowTitle(m_pFavoriteView->windowTitle());
88 m_pDockFavorite->setObjectName(
"dockFavorite");
90 ui->menuView->addAction(m_pDockFavorite->toggleViewAction());
91 addDockWidget(Qt::DockWidgetArea::LeftDockWidgetArea, m_pDockFavorite);
94 m_pDockListConnects =
new QDockWidget(
this);
95 if(m_pDockListConnects)
99 if(pListConnects->m_pDockTitleBar)
100 m_pDockListConnects->setTitleBarWidget(pListConnects->m_pDockTitleBar);
101 check = connect(pListConnects, SIGNAL(sigConnect(
const QString&,
bool)),
102 this, SLOT(slotOpenFile(
const QString&,
bool)));
104 m_pDockListConnects->setWidget(pListConnects);
105 m_pDockListConnects->setWindowTitle(pListConnects->windowTitle());
108 m_pDockListConnects->setObjectName(
"dockListRecentConnects");
110 ui->menuView->addAction(m_pDockListConnects->toggleViewAction());
111 tabifyDockWidget(m_pDockFavorite, m_pDockListConnects);
114 RabbitCommon::CTools::AddStyleMenu(ui->menuTools);
115 ui->menuTools->addMenu(RabbitCommon::CTools::GetLogMenu(
this));
117 m_pRecentMenu =
new RabbitCommon::CRecentMenu(tr(
"Recently connected"),
118 QIcon::fromTheme(
"document-open-recent"),
120 check = connect(m_pRecentMenu, SIGNAL(recentFileTriggered(
const QString&)),
121 this, SLOT(slotOpenFile(
const QString&)));
123 check = connect(&m_Parameter, SIGNAL(sigRecentMenuMaxCountChanged(
int)),
124 m_pRecentMenu, SLOT(setMaxCount(
int)));
126 QAction* pRecentAction = ui->menuRemote->insertMenu(
127 ui->actionOpenListRecentConnections, m_pRecentMenu);
128 pRecentAction->setStatusTip(pRecentAction->text());
129 QToolButton* tbRecent =
new QToolButton(ui->toolBar);
130 tbRecent->setFocusPolicy(Qt::NoFocus);
131 tbRecent->setPopupMode(QToolButton::InstantPopup);
132 tbRecent->setMenu(m_pRecentMenu);
133 tbRecent->setIcon(pRecentAction->icon());
134 tbRecent->setText(pRecentAction->text());
135 tbRecent->setToolTip(pRecentAction->toolTip());
136 tbRecent->setStatusTip(pRecentAction->statusTip());
137 ui->toolBar->insertWidget(ui->actionOpenListRecentConnections, tbRecent);
141 ui->actionUpdate->setIcon(updater.windowIcon());
144 QToolButton* tbConnect =
new QToolButton(ui->toolBar);
145 tbConnect->setFocusPolicy(Qt::NoFocus);
146 tbConnect->setPopupMode(QToolButton::InstantPopup);
148 tbConnect->setMenu(ui->menuConnect_C);
149 tbConnect->setIcon(QIcon::fromTheme(
"network-wired"));
150 tbConnect->setText(tr(
"Connect"));
151 tbConnect->setToolTip(tr(
"Connect"));
152 tbConnect->setStatusTip(tr(
"Connect"));
153 m_pActionConnect = ui->toolBar->insertWidget(ui->actionDisconnect_D, tbConnect);
161 m_pView->setFocusPolicy(Qt::NoFocus);
162 check = connect(m_pView, SIGNAL(sigCloseView(
const QWidget*)),
163 this, SLOT(slotCloseView(
const QWidget*)));
165 check = connect(m_pView, SIGNAL(sigCurrentChanged(
const QWidget*)),
166 this, SLOT(slotCurrentViewChanged(
const QWidget*)));
168 check = connect(m_pView, SIGNAL(customContextMenuRequested(
const QPoint&)),
169 this, SLOT(slotCustomContextMenuRequested(
const QPoint&)));
171 this->setCentralWidget(m_pView);
174 m_Client.EnumPlugins(
this);
176 check = connect(&m_Parameter, SIGNAL(sigReceiveShortCutChanged()),
177 this, SLOT(slotShortCut()));
179 check = connect(&m_Parameter, SIGNAL(sigSystemTrayIconTypeChanged()),
181 SLOT(slotSystemTrayIconTypeChanged()));
183 check = connect(&m_Parameter, SIGNAL(sigEnableSystemTrayIcon()),
184 this, SLOT(slotEnableSystemTrayIcon()));
186 check = connect(&m_Parameter, SIGNAL(sigEnableTabToolTipChanged()),
187 this, SLOT(slotUpdateName()));
189 check = connect(&m_Parameter, SIGNAL(sigEnableTabIconChanged()),
190 this, SLOT(slotUpdateName()));
198 SIGNAL(sigConnected()),
199 this, SLOT(slotSignalConnected()));
202 SIGNAL(sigDisconnected()),
203 this, SLOT(slotSignalDisconnected()));
206 SIGNAL(sigError(
const int,
const QString&)),
207 this, SLOT(slotSignalError(
const int,
const QString&)));
211 m_pSignalStatus =
new QPushButton();
212 m_pSignalStatus->setToolTip(tr(
"ICE signal status"));
213 m_pSignalStatus->setStatusTip(m_pSignalStatus->toolTip());
214 m_pSignalStatus->setWhatsThis(m_pSignalStatus->toolTip());
215 slotSignalDisconnected();
216 statusBar()->addPermanentWidget(m_pSignalStatus);
219 if(m_Parameter.GetSaveMainWindowStatus())
221 QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure(),
222 QSettings::IniFormat);
224 = set.value(
"MainWindow/Status/Geometry").toByteArray();
225 if(!geometry.isEmpty())
226 restoreGeometry(geometry);
227 QByteArray state = set.value(
"MainWindow/Status/State").toByteArray();
231 ui->actionStatus_bar_S->setChecked(m_Parameter.GetStatusBar());
232 statusBar()->setVisible(m_Parameter.GetStatusBar());
233 ui->actionTabBar_B->setChecked(m_Parameter.GetTabBar());
234 on_actionMain_menu_bar_M_toggled(m_Parameter.GetMenuBar());
235 ui->actionMain_menu_bar_M->setChecked(m_Parameter.GetMenuBar());
236 ui->actionToolBar_T->setChecked(!ui->toolBar->isHidden());
239 slotEnableSystemTrayIcon();
241 LoadConnectLasterClose();
244MainWindow::~MainWindow()
246 qDebug(log) <<
"MainWindow::~MainWindow()";
247 if(m_pFullScreenToolBar) m_pFullScreenToolBar->close();
251void MainWindow::on_actionAbout_triggered()
254 CDlgAbout *about =
new CDlgAbout(
this);
255 QIcon icon = QIcon::fromTheme(
"app");
257 auto sizeList = icon.availableSizes();
258 if(!sizeList.isEmpty()) {
259 QPixmap p = icon.pixmap(*sizeList.begin());
260 about->m_AppIcon = p.toImage();
263 about->m_szCopyrightStartTime =
"2020";
264 about->m_szVersionRevision = RabbitRemoteControl_REVISION;
265 about->m_szDetails = m_Client.Details();
266 RC_SHOW_WINDOW(about);
270void MainWindow::on_actionUpdate_triggered()
273 CFrmUpdater* m_pfrmUpdater =
new CFrmUpdater();
274 QIcon icon = QIcon::fromTheme(
"app");
276 auto sizeList = icon.availableSizes();
277 if(!sizeList.isEmpty()) {
278 QPixmap p = icon.pixmap(*sizeList.begin());
279 m_pfrmUpdater->SetTitle(p.toImage());
282 m_pfrmUpdater->SetInstallAutoStartup();
283 RC_SHOW_WINDOW(m_pfrmUpdater);
287void MainWindow::on_actionFull_screen_F_triggered()
289 CView* pTab = qobject_cast<CView*>(this->centralWidget());
292 pTab->SetFullScreen(!isFullScreen());
297 qDebug(log) <<
"Exit full screen";
298 ui->actionFull_screen_F->setIcon(QIcon::fromTheme(
"view-fullscreen"));
299 ui->actionFull_screen_F->setText(tr(
"Full screen(&F)"));
300 ui->actionFull_screen_F->setToolTip(tr(
"Full screen"));
301 ui->actionFull_screen_F->setStatusTip(tr(
"Full screen"));
302 ui->actionFull_screen_F->setWhatsThis(tr(
"Full screen"));
304 ui->toolBar->setVisible(m_FullState.toolBar);
305 ui->statusbar->setVisible(m_FullState.statusbar);
306 ui->menubar->setVisible(m_FullState.menubar);
308 m_pDockListConnects->setVisible(m_FullState.dockListConnects);
309 m_pDockFavorite->setVisible(m_FullState.dockFavorite);
311 QDockWidget* pDockDebugLog = findChild<QDockWidget*>(
"dockDebugLog");
314 pDockDebugLog->setVisible(m_FullState.dockDebugLog);
317 if(m_pFullScreenToolBar)
320 m_pFullScreenToolBar->close();
321 m_pFullScreenToolBar =
nullptr;
324 emit sigShowNormal();
326 this->activateWindow();
331 qDebug(log) <<
"Entry full screen";
332 emit sigFullScreen();
334 this->showFullScreen();
336 ui->actionFull_screen_F->setIcon(QIcon::fromTheme(
"view-restore"));
337 ui->actionFull_screen_F->setText(tr(
"Exit full screen(&E)"));
338 ui->actionFull_screen_F->setToolTip(tr(
"Exit full screen"));
339 ui->actionFull_screen_F->setStatusTip(tr(
"Exit full screen"));
340 ui->actionFull_screen_F->setWhatsThis(tr(
"Exit full screen"));
342 m_FullState.toolBar = ui->toolBar->isVisible();
343 ui->toolBar->setVisible(
false);
344 m_FullState.statusbar = ui->statusbar->isVisible();
345 ui->statusbar->setVisible(
false);
346 m_FullState.menubar = ui->menubar->isVisible();
347 ui->menubar->setVisible(
false);
349 m_FullState.dockListConnects = m_pDockListConnects->isVisible();
350 m_pDockListConnects->setVisible(
false);
351 m_FullState.dockFavorite = m_pDockFavorite->isVisible();
352 m_pDockFavorite->setVisible(
false);
354 QDockWidget* pDockDebugLog = findChild<QDockWidget*>(
"dockDebugLog");
357 m_FullState.dockDebugLog = pDockDebugLog->isVisible();
358 pDockDebugLog->setVisible(
false);
361 if(m_pFullScreenToolBar) m_pFullScreenToolBar->close();
364 QScreen* pScreen = qApp->primaryScreen();
366 QPoint pos(pScreen->geometry().left()
367 + (pScreen->geometry().width()
368 - m_pFullScreenToolBar->frameGeometry().width()) / 2,
369 pScreen->geometry().top());
370 qDebug(log) <<
"Primary screen geometry:" << pScreen->geometry()
371 <<
"availableGeometry:" << pScreen->availableGeometry()
372 << pos << mapToGlobal(pos);
373 m_pFullScreenToolBar->move(pos);
375 bool check = connect(m_pFullScreenToolBar, SIGNAL(sigExitFullScreen()),
376 this, SLOT(on_actionFull_screen_F_triggered()));
378 check = connect(m_pFullScreenToolBar, SIGNAL(sigExit()),
379 this, SLOT(on_actionExit_E_triggered()));
381 check = connect(m_pFullScreenToolBar, SIGNAL(sigDisconnect()),
382 this, SLOT(on_actionDisconnect_D_triggered()));
384 check = connect(
this, SIGNAL(sigConnecterMenuChanged(QAction*)),
385 m_pFullScreenToolBar,
386 SLOT(slotConnecterMenuChanged(QAction*)));
391 check = connect(m_pFullScreenToolBar, SIGNAL(sigShowTabBar(
bool)),
392 SLOT(on_actionTabBar_B_toggled(
bool)));
396 m_pFullScreenToolBar->show();
399void MainWindow::slotCurrentViewChanged(
const QWidget* pView)
401 qDebug(log) << Q_FUNC_INFO;
408void MainWindow::EnableMenu(
bool bEnable)
410 qDebug(log) << Q_FUNC_INFO << bEnable;
411 ui->actionClone->setEnabled(bEnable);
412 ui->actionAdd_to_favorite->setEnabled(bEnable);
413 ui->actionDisconnect_D->setEnabled(bEnable);
414 slotLoadConnecterMenu();
417void MainWindow::slotLoadConnecterMenu()
419 qDebug(log) << Q_FUNC_INFO;
421 if(m_pActionConnecterMenu) {
422 ui->menuTools->removeAction(m_pActionConnecterMenu);
423 ui->toolBar->removeAction(m_pActionConnecterMenu);
424 m_pActionConnecterMenu =
nullptr;
431 qDebug(log) <<
"The current view is empty";
434 foreach(
auto c, m_Connecters)
436 if(c->GetViewer() == pWin)
438 qDebug(log) <<
"Load plugin menu";
439 auto m = c->GetMenu(ui->menuTools);
441 m_pActionConnecterMenu = ui->menuTools->addMenu(m);
442 ui->toolBar->insertAction(ui->actionFull_screen_F, m_pActionConnecterMenu);
443 emit sigConnecterMenuChanged(m_pActionConnecterMenu);
448void MainWindow::slotCustomContextMenuRequested(
const QPoint &pos)
454 qDebug(log) <<
"The current view is empty";
457 foreach(
auto c, m_Connecters)
459 if(c->GetViewer() == pWin)
461 qDebug(log) <<
"Load plugin menu";
462 auto m = c->GetMenu(ui->menuTools);
464 m->exec(m_pView->mapToGlobal(pos));
469void MainWindow::on_actionExit_E_triggered()
474void MainWindow::keyReleaseEvent(QKeyEvent *event)
480 on_actionFull_screen_F_triggered();
483 QMainWindow::keyReleaseEvent(event);
486void MainWindow::slotUpdateParameters(
CConnecter* pConnecter)
491void MainWindow::on_actionClone_triggered()
495 foreach(
auto c, m_Connecters)
497 if(c->GetViewer() == p)
499 QString szFile = c->GetSettingsFile();
501 if(!pConnecter)
return;
502 Connect(pConnecter,
false, szFile);
508void MainWindow::slotOpenFile(
const QString& szFile,
bool bOpenSettings)
510 if(szFile.isEmpty())
return;
518 Connect(p, bOpenSettings, szFile);
521void MainWindow::on_actionOpenRRCFile_triggered()
523 QString szFile = QFileDialog::getOpenFileName(
525 tr(
"Open rabbit remote control file"),
526 RabbitCommon::CDir::Instance()->GetDirUserData(),
527 tr(
"Rabbit remote control Files (*.rrc);;All files(*.*)"));
528 if(szFile.isEmpty())
return;
540void MainWindow::slotConnect()
542 if(
nullptr == m_pView)
547 QAction* pAction =
dynamic_cast<QAction*
>(this->sender());
549 if(
nullptr == p)
return;
565 qDebug(log) <<
"MainWindow::Connect: set:" << set <<
"; File:" << szFile;
568 bool check = connect(p, SIGNAL(sigConnected()),
571 check = connect(p, SIGNAL(sigDisconnect()),
572 this, SLOT(slotDisconnect()));
574 check = connect(p, SIGNAL(sigDisconnected()),
575 this, SLOT(slotDisconnected()));
577 check = connect(p, SIGNAL(sigError(
const int,
const QString &)),
578 this, SLOT(slotError(
const int,
const QString&)));
580 check = connect(p, SIGNAL(sigShowMessageBox(
const QString&,
const QString&,
581 const QMessageBox::Icon&)),
583 const QMessageBox::Icon&)));
585 check = connect(p, SIGNAL(sigInformation(
const QString&)),
588 check = connect(p, SIGNAL(sigUpdateName(
const QString&)),
589 this, SLOT(slotUpdateName(
const QString&)));
591 check = connect(p, SIGNAL(sigUpdateParameters(
CConnecter*)),
592 this, SLOT(slotUpdateParameters(
CConnecter*)));
600 case QDialog::Rejected:
603 case QDialog::Accepted:
610 szFile = p->GetSettingsFile();
612 p->SetSettingsFile(szFile);
618 m_pRecentMenu->addRecentFile(szFile, p->
Name());
620 if(!p->
Name().isEmpty())
624 if(-1 < m_Connecters.indexOf(p)) {
634 m_Connecters.push_back(p);
668 slotLoadConnecterMenu();
671 qDebug(log) <<
"MainWindow::slotConnected()" << p->
Name();
677 qDebug(log) <<
"MainWindow::slotCloseView" << pView;
679 foreach(
auto c, m_Connecters)
681 if(c->GetViewer() == pView)
684 emit c->sigUpdateParameters(c);
690void MainWindow::on_actionDisconnect_D_triggered()
692 qDebug(log) <<
"MainWindow::on_actionDisconnect_D_triggered()";
699void MainWindow::slotDisconnect()
701 qDebug(log) <<
"MainWindow::slotDisconnect()";
703 if(!pConnecter)
return;
709void MainWindow::slotDisconnected()
711 qDebug(log) <<
"MainWindow::slotDisconnected()";
713 foreach(
auto c, m_Connecters)
718 m_Connecters.removeAll(c);
725void MainWindow::slotSignalConnected()
727 m_pSignalStatus->setToolTip(tr(
"ICE signal status: Connected"));
728 m_pSignalStatus->setStatusTip(m_pSignalStatus->toolTip());
729 m_pSignalStatus->setWhatsThis(m_pSignalStatus->toolTip());
731 m_pSignalStatus->setIcon(QIcon::fromTheme(
"newwork-wired"));
734void MainWindow::slotSignalDisconnected()
736 m_pSignalStatus->setToolTip(tr(
"ICE signal status: Disconnected"));
737 m_pSignalStatus->setStatusTip(m_pSignalStatus->toolTip());
738 m_pSignalStatus->setWhatsThis(m_pSignalStatus->toolTip());
740 m_pSignalStatus->setIcon(QIcon::fromTheme(
"network-wireless"));
743void MainWindow::slotSignalError(
const int nError,
const QString &szInfo)
745 slotSignalDisconnected();
749void MainWindow::slotSignalPushButtonClicked(
bool checked)
759void MainWindow::slotError(
const int nError,
const QString &szInfo)
766 const QString &title,
const QString &message,
767 const QMessageBox::Icon &icon)
770 if(!m_Parameter.GetMessageBoxDisplayInformation())
773 QMessageBox msg(icon, title, message, QMessageBox::Ok,
this);
774 QCheckBox* cb =
new QCheckBox(
775 tr(
"Use message box to display information"),
this);
776 cb->setChecked(
true);
778 RC_SHOW_WINDOW(&msg);
781 m_Parameter.SetMessageBoxDisplayInformation(
false);
788 statusBar()->showMessage(szInfo);
791void MainWindow::slotUpdateName()
793 foreach (
auto pConnecter, m_Connecters)
795 m_pView->SetWidowsTitle(pConnecter->
GetViewer(),
802void MainWindow::slotUpdateName(
const QString& szName)
805 if(!pConnecter)
return;
806 m_pView->SetWidowsTitle(pConnecter->
GetViewer(), szName,
814 QAction* p = ui->menuConnect_C->addAction(pPlug->
Protocol()
816 this, SLOT(slotConnect()));
820 p->setIcon(pPlug->Icon());
825void MainWindow::closeEvent(QCloseEvent *event)
827 qDebug(log) <<
"MainWindow::closeEvent()";
829 if(m_Parameter.GetSaveMainWindowStatus())
831 on_actionFull_screen_F_triggered();
833 SaveConnectLasterClose();
835 foreach (
auto it, m_Connecters)
838 emit it->sigUpdateParameters(it);
842 QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure(),
843 QSettings::IniFormat);
844 if(m_Parameter.GetSaveMainWindowStatus())
846 set.setValue(
"MainWindow/Status/Geometry", saveGeometry());
847 set.setValue(
"MainWindow/Status/State", saveState());
850 set.remove(
"MainWindow/Status/Geometry");
851 set.remove(
"MainWindow/Status/State");
853 QMainWindow::closeEvent(event);
859int MainWindow::LoadConnectLasterClose()
861 if(!m_Parameter.GetOpenLasterClose())
864 QFile f(RabbitCommon::CDir::Instance()->GetDirUserConfig()
865 + QDir::separator() +
"LasterClose.dat");
866 if(f.open(QFile::ReadOnly))
874 slotOpenFile(szFile);
881int MainWindow::SaveConnectLasterClose()
883 QFile f(RabbitCommon::CDir::Instance()->GetDirUserConfig()
884 + QDir::separator() +
"LasterClose.dat");
885 f.open(QFile::WriteOnly);
886 if(m_Parameter.GetOpenLasterClose())
889 foreach(
auto it, m_Connecters)
891 d << it->GetSettingsFile();
898void MainWindow::on_actionSend_ctl_alt_del_triggered()
901 m_pView->slotSystemCombination();
904void MainWindow::on_actionTabBar_B_toggled(
bool bShow)
909 p->ShowTabBar(bShow);
910 m_Parameter.SetTabBar(bShow);
914void MainWindow::on_actionMain_menu_bar_M_toggled(
bool checked)
916 qDebug(log) <<
"MainWindow::on_actionMain_menu_bar_M_triggered:" << checked;
917 if(ui->toolBar->isHidden() && !checked)
919 if( QMessageBox::StandardButton::Yes
920 == QMessageBox::information(
this, tr(
"Hide menu bar"),
921 tr(
"The menu bar will be hidden, the tool bar must be showed."),
922 QMessageBox::StandardButton::Yes
923 | QMessageBox::StandardButton::No))
925 ui->actionToolBar_T->setChecked(
true);
930 menuBar()->setVisible(checked);
931 m_Parameter.SetMenuBar(checked);
934 ui->toolBar->removeAction(ui->actionMain_menu_bar_M);
938 ui->toolBar->insertAction(ui->actionTabBar_B,
939 ui->actionMain_menu_bar_M);
943void MainWindow::on_actionToolBar_T_toggled(
bool checked)
945 qDebug(log) <<
"MainWindow::on_actionToolBar_T_triggered:" << checked;
946 if(menuBar()->isHidden() && !checked)
948 if( QMessageBox::StandardButton::Yes
949 == QMessageBox::information(
this, tr(
"Hide tool bar"),
950 tr(
"The tool bar will be hidden, the menu bar must be showed."),
951 QMessageBox::StandardButton::Yes
952 | QMessageBox::StandardButton::No))
954 ui->actionMain_menu_bar_M->setChecked(
true);
958 ui->toolBar->setVisible(checked);
961void MainWindow::on_actionStatus_bar_S_toggled(
bool checked)
963 statusBar()->setVisible(checked);
964 m_Parameter.SetStatusBar(checked);
968void MainWindow::on_actionSettings_triggered()
971 if(CParameterDlgSettings::Accepted == RC_SHOW_WINDOW(&set))
979void MainWindow::slotShortCut()
981 if(m_Parameter.GetReceiveShortCut())
983 setFocusPolicy(Qt::WheelFocus);
984#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
985 ui->actionFull_screen_F->setShortcut(
986 QKeySequence(QKeyCombination(Qt::CTRL, Qt::Key_R),
987 QKeyCombination(Qt::Key_F)));
988 ui->actionScreenshot->setShortcut(
989 QKeySequence(QKeyCombination(Qt::CTRL, Qt::Key_R),
990 QKeyCombination(Qt::Key_S)));
992 ui->actionFull_screen_F->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R, Qt::Key_F));
993 ui->actionScreenshot->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R, Qt::Key_S));
996 setFocusPolicy(Qt::NoFocus);
997 ui->actionFull_screen_F->setShortcut(QKeySequence());
998 ui->actionScreenshot->setShortcut(QKeySequence());
1002void MainWindow::on_actionOpenListRecentConnections_triggered()
1006 bool check = connect(p, SIGNAL(sigConnect(
const QString&,
bool)),
1007 this, SLOT(slotOpenFile(
const QString&,
bool)));
1012 d.setWindowIcon(windowIcon());
1013 QGridLayout* pLayout =
new QGridLayout(&d);
1015 pLayout->addWidget(p);
1016 check = connect(p, SIGNAL(destroyed()), &d, SLOT(reject()));
1017 d.setLayout(pLayout);
1022void MainWindow::on_actionAdd_to_favorite_triggered()
1024 if(!m_pView || !m_pFavoriteView)
return;
1026 foreach(
auto c, m_Connecters)
1028 if(c->GetViewer() == p)
1030 m_pFavoriteView->AddFavorite(c->Name(), c->GetSettingsFile());
1035void MainWindow::dragEnterEvent(QDragEnterEvent *event)
1037 qDebug(log) <<
"dragEnterEvent";
1039 if(event->mimeData()->hasUrls())
1041 qWarning(log) <<
event->mimeData()->urls();
1042 event->acceptProposedAction();
1046void MainWindow::dragMoveEvent(QDragMoveEvent *event)
1051void MainWindow::dropEvent(QDropEvent *event)
1053 qDebug(log) <<
"dropEvent";
1054 if(!event->mimeData()->hasUrls())
1056 auto urls =
event->mimeData()->urls();
1057 foreach(
auto url, urls)
1059 if(url.isLocalFile())
1060 slotOpenFile(url.toLocalFile());
1064void MainWindow::slotSystemTrayIconActivated(QSystemTrayIcon::ActivationReason reason)
1069#if defined(Q_OS_ANDROID)
1074 case QSystemTrayIcon::Trigger:
1086void MainWindow::slotSystemTrayIconTypeChanged()
1089 if(!QSystemTrayIcon::isSystemTrayAvailable())
1091 qWarning(log) <<
"System tray is not available";
1095 if(!m_Parameter.GetEnableSystemTrayIcon())
1097 qDebug(log) <<
"Disable system tray icon";
1104 m_TrayIcon = QSharedPointer<QSystemTrayIcon>(
new QSystemTrayIcon(
this));
1105 if(QSystemTrayIcon::isSystemTrayAvailable())
1107 bool check = connect(
1109 SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
1111 SLOT(slotSystemTrayIconActivated(QSystemTrayIcon::ActivationReason)));
1113 m_TrayIcon->setIcon(this->windowIcon());
1114 m_TrayIcon->setToolTip(windowTitle());
1117 qWarning(log) <<
"System tray is not available";
1119 switch (m_Parameter.GetSystemTrayIconMenuType())
1121 case CParameterApp::SystemTrayIconMenuType::MenuBar:
1123 QMenu* pMenu =
new QMenu(
this);
1124 pMenu->addMenu(ui->menuRemote);
1125 pMenu->addMenu(ui->menuView);
1126 pMenu->addMenu(ui->menuTools);
1127 m_TrayIcon->setContextMenu(pMenu);
1130 case CParameterApp::SystemTrayIconMenuType::Remote:
1131 m_TrayIcon->setContextMenu(ui->menuRemote);
1133 case CParameterApp::SystemTrayIconMenuType::RecentOpen:
1134 m_TrayIcon->setContextMenu(m_pRecentMenu);
1136 case CParameterApp::SystemTrayIconMenuType::View:
1137 m_TrayIcon->setContextMenu(ui->menuView);
1139 case CParameterApp::SystemTrayIconMenuType::Tools:
1140 m_TrayIcon->setContextMenu(ui->menuTools);
1142 case CParameterApp::SystemTrayIconMenuType::No:
1143 m_TrayIcon->setContextMenu(
nullptr);
1148void MainWindow::slotEnableSystemTrayIcon()
1153 if(!m_Parameter.GetEnableSystemTrayIcon())
1156 slotSystemTrayIconTypeChanged();
virtual CConnecter * LoadConnecter(const QString &szFile)
New CConnecter pointer from file, the owner is caller.
virtual CConnecter * CreateConnecter(const QString &id)
New CConnecter pointer, the owner is caller.
virtual int DeleteConnecter(CConnecter *p)
Delete CConnecter.
virtual QList< QWidget * > GetSettingsWidgets(QWidget *parent)
Get parameter settings widget.
virtual int SaveConnecter(CConnecter *pConnecter)
Accept connecter parameters to file.
virtual int SaveSettings(const QString szFile=QString())
Save Client parameters to file.
virtual int DisConnect()=0
Close connect.
virtual const QIcon Icon() const
Icon.
virtual int OpenDialogSettings(QWidget *parent=nullptr)
Open settings dialog.
virtual QWidget * GetViewer()=0
Get Viewer.
virtual const QString Description()
Description.
virtual int Connect()=0
Start connect.
virtual const QString Name()
Name.
void sigUpdateParameters(CConnecter *pConnecter)
Update parameters, notify application to save or show parameters.
List the connect of be existed.
static CICE * Instance()
Single instance.
virtual const QString DisplayName() const
The plugin display name.
virtual const QString Description() const =0
Plugin description.
virtual const QString Protocol() const =0
Plugin Protocol.
virtual int AddView(QWidget *pView)=0
virtual QWidget * GetCurrentView()=0
virtual int RemoveView(QWidget *pView)=0
virtual int onProcess(const QString &id, CPluginClient *pPlug) override
Process plugins.
void slotInformation(const QString &szInfo)
Show information.
int Connect(CConnecter *p, bool set, QString szFile=QString())
Connect.
void slotConnected()
[MainWindow slotConnected]
virtual void slotShowMessageBox(const QString &title, const QString &message, const QMessageBox::Icon &icon)
Use message box display information.
void slotCloseView(const QWidget *pView)
[MainWindow slotConnected]