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 "FrmListConnects.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(
"dockListConnects");
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->actionOpenListConnections, 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->actionOpenListConnections, 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*)));
166 check = connect(m_pView, SIGNAL(sigCurrentChanged(
const QWidget*)),
167 this, SLOT(slotCurrentViewChanged(
const QWidget*)));
169 check = connect(m_pView, SIGNAL(customContextMenuRequested(
const QPoint&)),
170 this, SLOT(slotCustomContextMenuRequested(
const QPoint&)));
172 this->setCentralWidget(m_pView);
175 m_Client.EnumPlugins(
this);
176 m_Client.LoadSettings();
178 check = connect(&m_Parameter, SIGNAL(sigReceiveShortCutChanged()),
179 this, SLOT(slotShortCut()));
181 check = connect(&m_Parameter, SIGNAL(sigSystemTrayIconTypeChanged()),
183 SLOT(slotSystemTrayIconTypeChanged()));
185 check = connect(&m_Parameter, SIGNAL(sigEnableSystemTrayIcon()),
186 this, SLOT(slotEnableSystemTrayIcon()));
188 check = connect(&m_Parameter, SIGNAL(sigEnableTabToolTipChanged()),
189 this, SLOT(slotUpdateName()));
191 check = connect(&m_Parameter, SIGNAL(sigEnableTabIconChanged()),
192 this, SLOT(slotUpdateName()));
200 SIGNAL(sigConnected()),
201 this, SLOT(slotSignalConnected()));
204 SIGNAL(sigDisconnected()),
205 this, SLOT(slotSignalDisconnected()));
208 SIGNAL(sigError(
const int,
const QString&)),
209 this, SLOT(slotSignalError(
const int,
const QString&)));
213 m_pSignalStatus =
new QPushButton();
214 m_pSignalStatus->setToolTip(tr(
"ICE signal status"));
215 m_pSignalStatus->setStatusTip(m_pSignalStatus->toolTip());
216 m_pSignalStatus->setWhatsThis(m_pSignalStatus->toolTip());
217 slotSignalDisconnected();
218 statusBar()->addPermanentWidget(m_pSignalStatus);
221 if(m_Parameter.GetSaveMainWindowStatus())
223 QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure(),
224 QSettings::IniFormat);
226 = set.value(
"MainWindow/Status/Geometry").toByteArray();
227 if(!geometry.isEmpty())
228 restoreGeometry(geometry);
229 QByteArray state = set.value(
"MainWindow/Status/State").toByteArray();
233 ui->actionStatus_bar_S->setChecked(m_Parameter.GetStatusBar());
234 statusBar()->setVisible(m_Parameter.GetStatusBar());
235 ui->actionTabBar_B->setChecked(m_Parameter.GetTabBar());
236 on_actionMain_menu_bar_M_toggled(m_Parameter.GetMenuBar());
237 ui->actionMain_menu_bar_M->setChecked(m_Parameter.GetMenuBar());
238 ui->actionToolBar_T->setChecked(!ui->toolBar->isHidden());
241 slotEnableSystemTrayIcon();
243 LoadConnectLasterClose();
246MainWindow::~MainWindow()
248 qDebug(log) <<
"MainWindow::~MainWindow()";
249 if(m_pFullScreenToolBar) m_pFullScreenToolBar->close();
253void MainWindow::on_actionAbout_triggered()
256 CDlgAbout *about =
new CDlgAbout(
this);
257 QIcon icon = QIcon::fromTheme(
"app");
259 auto sizeList = icon.availableSizes();
260 if(!sizeList.isEmpty()) {
261 QPixmap p = icon.pixmap(*sizeList.begin());
262 about->m_AppIcon = p.toImage();
265 about->m_szCopyrightStartTime =
"2020";
266 about->m_szVersionRevision = RabbitRemoteControl_REVISION;
267 about->m_szDetails = m_Client.Details();
268 RC_SHOW_WINDOW(about);
272void MainWindow::on_actionUpdate_triggered()
275 CFrmUpdater* m_pfrmUpdater =
new CFrmUpdater();
276 QIcon icon = QIcon::fromTheme(
"app");
278 auto sizeList = icon.availableSizes();
279 if(!sizeList.isEmpty()) {
280 QPixmap p = icon.pixmap(*sizeList.begin());
281 m_pfrmUpdater->SetTitle(p.toImage());
284 m_pfrmUpdater->SetInstallAutoStartup();
285 RC_SHOW_WINDOW(m_pfrmUpdater);
289void MainWindow::on_actionFull_screen_F_triggered()
291 CView* pTab = qobject_cast<CView*>(this->centralWidget());
294 pTab->SetFullScreen(!isFullScreen());
299 qDebug(log) <<
"Exit full screen";
300 ui->actionFull_screen_F->setIcon(QIcon::fromTheme(
"view-fullscreen"));
301 ui->actionFull_screen_F->setText(tr(
"Full screen(&F)"));
302 ui->actionFull_screen_F->setToolTip(tr(
"Full screen"));
303 ui->actionFull_screen_F->setStatusTip(tr(
"Full screen"));
304 ui->actionFull_screen_F->setWhatsThis(tr(
"Full screen"));
306 ui->toolBar->setVisible(m_FullState.toolBar);
307 ui->statusbar->setVisible(m_FullState.statusbar);
308 ui->menubar->setVisible(m_FullState.menubar);
310 m_pDockListConnects->setVisible(m_FullState.dockListConnects);
311 m_pDockFavorite->setVisible(m_FullState.dockFavorite);
313 QDockWidget* pDockDebugLog = findChild<QDockWidget*>(
"dockDebugLog");
316 pDockDebugLog->setVisible(m_FullState.dockDebugLog);
319 if(m_pFullScreenToolBar)
322 m_pFullScreenToolBar->close();
323 m_pFullScreenToolBar =
nullptr;
326 emit sigShowNormal();
328 this->activateWindow();
333 qDebug(log) <<
"Entry full screen";
334 emit sigFullScreen();
336 this->showFullScreen();
338 ui->actionFull_screen_F->setIcon(QIcon::fromTheme(
"view-restore"));
339 ui->actionFull_screen_F->setText(tr(
"Exit full screen(&E)"));
340 ui->actionFull_screen_F->setToolTip(tr(
"Exit full screen"));
341 ui->actionFull_screen_F->setStatusTip(tr(
"Exit full screen"));
342 ui->actionFull_screen_F->setWhatsThis(tr(
"Exit full screen"));
344 m_FullState.toolBar = ui->toolBar->isVisible();
345 ui->toolBar->setVisible(
false);
346 m_FullState.statusbar = ui->statusbar->isVisible();
347 ui->statusbar->setVisible(
false);
348 m_FullState.menubar = ui->menubar->isVisible();
349 ui->menubar->setVisible(
false);
351 m_FullState.dockListConnects = m_pDockListConnects->isVisible();
352 m_pDockListConnects->setVisible(
false);
353 m_FullState.dockFavorite = m_pDockFavorite->isVisible();
354 m_pDockFavorite->setVisible(
false);
356 QDockWidget* pDockDebugLog = findChild<QDockWidget*>(
"dockDebugLog");
359 m_FullState.dockDebugLog = pDockDebugLog->isVisible();
360 pDockDebugLog->setVisible(
false);
363 if(m_pFullScreenToolBar) m_pFullScreenToolBar->close();
366 QScreen* pScreen = qApp->primaryScreen();
368 QPoint pos(pScreen->geometry().left()
369 + (pScreen->geometry().width()
370 - m_pFullScreenToolBar->frameGeometry().width()) / 2,
371 pScreen->geometry().top());
372 qDebug(log) <<
"Primary screen geometry:" << pScreen->geometry()
373 <<
"availableGeometry:" << pScreen->availableGeometry()
374 << pos << mapToGlobal(pos);
375 m_pFullScreenToolBar->move(pos);
377 bool check = connect(m_pFullScreenToolBar, SIGNAL(sigExitFullScreen()),
378 this, SLOT(on_actionFull_screen_F_triggered()));
380 check = connect(m_pFullScreenToolBar, SIGNAL(sigExit()),
381 this, SLOT(on_actionExit_E_triggered()));
383 check = connect(m_pFullScreenToolBar, SIGNAL(sigDisconnect()),
384 this, SLOT(on_actionDisconnect_D_triggered()));
386 check = connect(
this, SIGNAL(sigConnecterMenuChanged(QAction*)),
387 m_pFullScreenToolBar,
388 SLOT(slotConnecterMenuChanged(QAction*)));
393 check = connect(m_pFullScreenToolBar, SIGNAL(sigShowTabBar(
bool)),
394 SLOT(on_actionTabBar_B_toggled(
bool)));
398 m_pFullScreenToolBar->show();
401void MainWindow::slotCurrentViewChanged(
const QWidget* pView)
403 qDebug(log) << Q_FUNC_INFO;
410void MainWindow::EnableMenu(
bool bEnable)
412 qDebug(log) << Q_FUNC_INFO << bEnable;
413 ui->actionClone->setEnabled(bEnable);
414 ui->actionAdd_to_favorite->setEnabled(bEnable);
415 ui->actionDisconnect_D->setEnabled(bEnable);
416 slotLoadConnecterMenu();
419void MainWindow::slotLoadConnecterMenu()
421 qDebug(log) << Q_FUNC_INFO;
423 if(m_pActionConnecterMenu) {
424 ui->menuTools->removeAction(m_pActionConnecterMenu);
425 ui->toolBar->removeAction(m_pActionConnecterMenu);
426 m_pActionConnecterMenu =
nullptr;
433 qDebug(log) <<
"The current view is empty";
436 foreach(
auto c, m_Connecters)
438 if(c->GetViewer() == pWin)
440 qDebug(log) <<
"Load plugin menu";
441 auto m = c->GetMenu(ui->menuTools);
443 m_pActionConnecterMenu = ui->menuTools->addMenu(m);
444 ui->toolBar->insertAction(ui->actionFull_screen_F, m_pActionConnecterMenu);
445 emit sigConnecterMenuChanged(m_pActionConnecterMenu);
450void MainWindow::slotCustomContextMenuRequested(
const QPoint &pos)
456 qDebug(log) <<
"The current view is empty";
459 foreach(
auto c, m_Connecters)
461 if(c->GetViewer() == pWin)
463 qDebug(log) <<
"Load plugin menu";
464 auto m = c->GetMenu(ui->menuTools);
466 m->exec(m_pView->mapToGlobal(pos));
471void MainWindow::on_actionExit_E_triggered()
476void MainWindow::keyReleaseEvent(QKeyEvent *event)
482 on_actionFull_screen_F_triggered();
485 QMainWindow::keyReleaseEvent(event);
488void MainWindow::slotUpdateParameters(
CConnecter* pConnecter)
490 auto it = m_ConfigureFiles.find(pConnecter);
491 if(m_ConfigureFiles.end() == it)
496void MainWindow::on_actionClone_triggered()
500 foreach(
auto c, m_Connecters)
502 if(c->GetViewer() == p)
504 auto it = m_ConfigureFiles.find(c);
505 if(m_ConfigureFiles.end() == it)
507 QString szFile = it.value();
509 if(!pConnecter)
return;
510 Connect(pConnecter,
false, szFile);
516void MainWindow::slotOpenFile(
const QString& szFile,
bool bOpenSettings)
518 if(szFile.isEmpty())
return;
526 Connect(p, bOpenSettings, szFile);
529void MainWindow::on_actionOpenRRCFile_triggered()
531 QString szFile = QFileDialog::getOpenFileName(
this,
532 tr(
"Open rabbit remote control file"),
533 RabbitCommon::CDir::Instance()->GetDirUserData(),
534 tr(
"Rabbit remote control Files (*.rrc);;All files(*.*)"));
535 if(szFile.isEmpty())
return;
547void MainWindow::slotConnect()
549 if(
nullptr == m_pView)
554 QAction* pAction =
dynamic_cast<QAction*
>(this->sender());
556 if(
nullptr == p)
return;
572 qDebug(log) <<
"MainWindow::Connect: set:" << set <<
"; File:" << szFile;
575 bool check = connect(p, SIGNAL(sigConnected()),
578 check = connect(p, SIGNAL(sigDisconnect()),
579 this, SLOT(slotDisconnect()));
581 check = connect(p, SIGNAL(sigDisconnected()),
582 this, SLOT(slotDisconnected()));
584 check = connect(p, SIGNAL(sigError(
const int,
const QString &)),
585 this, SLOT(slotError(
const int,
const QString&)));
587 check = connect(p, SIGNAL(sigShowMessageBox(
const QString&,
const QString&,
588 const QMessageBox::Icon&)),
590 const QMessageBox::Icon&)));
592 check = connect(p, SIGNAL(sigInformation(
const QString&)),
595 check = connect(p, SIGNAL(sigUpdateName(
const QString&)),
596 this, SLOT(slotUpdateName(
const QString&)));
598 check = connect(p, SIGNAL(sigUpdateParameters(
CConnecter*)),
599 this, SLOT(slotUpdateParameters(
CConnecter*)));
607 case QDialog::Rejected:
610 case QDialog::Accepted:
617 szFile = RabbitCommon::CDir::Instance()->GetDirUserData()
621 m_ConfigureFiles[p] = szFile;
627 m_pRecentMenu->addRecentFile(szFile, p->
Name());
629 if(!p->
Name().isEmpty())
640 m_Connecters.push_back(p);
669 slotLoadConnecterMenu();
672 qDebug(log) <<
"MainWindow::slotConnected()" << p->
Name();
678 qDebug(log) <<
"MainWindow::slotCloseView" << pView;
680 foreach(
auto c, m_Connecters)
682 if(c->GetViewer() == pView)
685 emit c->sigUpdateParameters(c);
691void MainWindow::on_actionDisconnect_D_triggered()
693 qDebug(log) <<
"MainWindow::on_actionDisconnect_D_triggered()";
700void MainWindow::slotDisconnect()
702 qDebug(log) <<
"MainWindow::slotDisconnect()";
704 if(!pConnecter)
return;
710void MainWindow::slotDisconnected()
712 qDebug(log) <<
"MainWindow::slotDisconnected()";
714 foreach(
auto c, m_Connecters)
719 m_Connecters.removeAll(c);
720 m_ConfigureFiles.remove(c);
727void MainWindow::slotSignalConnected()
729 m_pSignalStatus->setToolTip(tr(
"ICE signal status: Connected"));
730 m_pSignalStatus->setStatusTip(m_pSignalStatus->toolTip());
731 m_pSignalStatus->setWhatsThis(m_pSignalStatus->toolTip());
733 m_pSignalStatus->setIcon(QIcon::fromTheme(
"newwork-wired"));
736void MainWindow::slotSignalDisconnected()
738 m_pSignalStatus->setToolTip(tr(
"ICE signal status: Disconnected"));
739 m_pSignalStatus->setStatusTip(m_pSignalStatus->toolTip());
740 m_pSignalStatus->setWhatsThis(m_pSignalStatus->toolTip());
742 m_pSignalStatus->setIcon(QIcon::fromTheme(
"network-wireless"));
745void MainWindow::slotSignalError(
const int nError,
const QString &szInfo)
747 slotSignalDisconnected();
751void MainWindow::slotSignalPushButtonClicked(
bool checked)
761void MainWindow::slotError(
const int nError,
const QString &szInfo)
768 const QString &title,
const QString &message,
769 const QMessageBox::Icon &icon)
772 if(!m_Parameter.GetMessageBoxDisplayInformation())
775 QMessageBox msg(icon, title, message, QMessageBox::Ok,
this);
776 QCheckBox* cb =
new QCheckBox(
777 tr(
"Use message box to display information"),
this);
778 cb->setChecked(
true);
780 RC_SHOW_WINDOW(&msg);
783 m_Parameter.SetMessageBoxDisplayInformation(
false);
790 statusBar()->showMessage(szInfo);
793void MainWindow::slotUpdateName()
795 foreach (
auto pConnecter, m_Connecters)
797 m_pView->SetWidowsTitle(pConnecter->
GetViewer(),
804void MainWindow::slotUpdateName(
const QString& szName)
807 if(!pConnecter)
return;
808 m_pView->SetWidowsTitle(pConnecter->
GetViewer(), szName,
816 QAction* p = ui->menuConnect_C->addAction(pPlug->
Protocol()
818 this, SLOT(slotConnect()));
822 p->setIcon(pPlug->Icon());
827void MainWindow::closeEvent(QCloseEvent *event)
829 qDebug(log) <<
"MainWindow::closeEvent()";
831 if(m_Parameter.GetSaveMainWindowStatus())
833 on_actionFull_screen_F_triggered();
835 SaveConnectLasterClose();
837 foreach (
auto it, m_Connecters)
840 emit it->sigUpdateParameters(it);
844 QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure(),
845 QSettings::IniFormat);
846 if(m_Parameter.GetSaveMainWindowStatus())
848 set.setValue(
"MainWindow/Status/Geometry", saveGeometry());
849 set.setValue(
"MainWindow/Status/State", saveState());
852 set.remove(
"MainWindow/Status/Geometry");
853 set.remove(
"MainWindow/Status/State");
855 QMainWindow::closeEvent(event);
861int MainWindow::LoadConnectLasterClose()
863 if(!m_Parameter.GetOpenLasterClose())
866 QFile f(RabbitCommon::CDir::Instance()->GetDirUserConfig()
867 + QDir::separator() +
"LasterClose.dat");
868 if(f.open(QFile::ReadOnly))
876 slotOpenFile(szFile);
883int MainWindow::SaveConnectLasterClose()
885 QFile f(RabbitCommon::CDir::Instance()->GetDirUserConfig()
886 + QDir::separator() +
"LasterClose.dat");
887 f.open(QFile::WriteOnly);
888 if(m_Parameter.GetOpenLasterClose())
891 foreach(
auto it, m_ConfigureFiles)
900void MainWindow::on_actionSend_ctl_alt_del_triggered()
903 m_pView->slotSystemCombination();
906void MainWindow::on_actionTabBar_B_toggled(
bool bShow)
911 p->ShowTabBar(bShow);
912 m_Parameter.SetTabBar(bShow);
916void MainWindow::on_actionMain_menu_bar_M_toggled(
bool checked)
918 qDebug(log) <<
"MainWindow::on_actionMain_menu_bar_M_triggered:" << checked;
919 if(ui->toolBar->isHidden() && !checked)
921 if( QMessageBox::StandardButton::Yes
922 == QMessageBox::information(
this, tr(
"Hide menu bar"),
923 tr(
"The menu bar will be hidden, the tool bar must be showed."),
924 QMessageBox::StandardButton::Yes
925 | QMessageBox::StandardButton::No))
927 ui->actionToolBar_T->setChecked(
true);
932 menuBar()->setVisible(checked);
933 m_Parameter.SetMenuBar(checked);
936 ui->toolBar->removeAction(ui->actionMain_menu_bar_M);
940 ui->toolBar->insertAction(ui->actionTabBar_B,
941 ui->actionMain_menu_bar_M);
945void MainWindow::on_actionToolBar_T_toggled(
bool checked)
947 qDebug(log) <<
"MainWindow::on_actionToolBar_T_triggered:" << checked;
948 if(menuBar()->isHidden() && !checked)
950 if( QMessageBox::StandardButton::Yes
951 == QMessageBox::information(
this, tr(
"Hide tool bar"),
952 tr(
"The tool bar will be hidden, the menu bar must be showed."),
953 QMessageBox::StandardButton::Yes
954 | QMessageBox::StandardButton::No))
956 ui->actionMain_menu_bar_M->setChecked(
true);
960 ui->toolBar->setVisible(checked);
963void MainWindow::on_actionStatus_bar_S_toggled(
bool checked)
965 statusBar()->setVisible(checked);
966 m_Parameter.SetStatusBar(checked);
970void MainWindow::on_actionSettings_triggered()
973 if(CParameterDlgSettings::Accepted == RC_SHOW_WINDOW(&set))
981void MainWindow::slotShortCut()
983 if(m_Parameter.GetReceiveShortCut())
985 setFocusPolicy(Qt::WheelFocus);
986#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
987 ui->actionFull_screen_F->setShortcut(
988 QKeySequence(QKeyCombination(Qt::CTRL, Qt::Key_R),
989 QKeyCombination(Qt::Key_F)));
990 ui->actionScreenshot->setShortcut(
991 QKeySequence(QKeyCombination(Qt::CTRL, Qt::Key_R),
992 QKeyCombination(Qt::Key_S)));
994 ui->actionFull_screen_F->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R, Qt::Key_F));
995 ui->actionScreenshot->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R, Qt::Key_S));
998 setFocusPolicy(Qt::NoFocus);
999 ui->actionFull_screen_F->setShortcut(QKeySequence());
1000 ui->actionScreenshot->setShortcut(QKeySequence());
1004void MainWindow::on_actionOpenListConnections_triggered()
1008 bool check = connect(p, SIGNAL(sigConnect(
const QString&,
bool)),
1009 this, SLOT(slotOpenFile(
const QString&,
bool)));
1014 d.setWindowIcon(windowIcon());
1015 QGridLayout* pLayout =
new QGridLayout(&d);
1017 pLayout->addWidget(p);
1018 check = connect(p, SIGNAL(destroyed()), &d, SLOT(reject()));
1019 d.setLayout(pLayout);
1024void MainWindow::on_actionAdd_to_favorite_triggered()
1026 if(!m_pView || !m_pFavoriteView)
return;
1028 foreach(
auto c, m_Connecters)
1030 if(c->GetViewer() == p)
1032 auto it = m_ConfigureFiles.find(c);
1033 if(m_ConfigureFiles.end() == it)
1035 m_pFavoriteView->AddFavorite(c->Name(), it.value());
1040void MainWindow::dragEnterEvent(QDragEnterEvent *event)
1042 qDebug(log) <<
"dragEnterEvent";
1044 if(event->mimeData()->hasUrls())
1046 qWarning(log) <<
event->mimeData()->urls();
1047 event->acceptProposedAction();
1051void MainWindow::dragMoveEvent(QDragMoveEvent *event)
1056void MainWindow::dropEvent(QDropEvent *event)
1058 qDebug(log) <<
"dropEvent";
1059 if(!event->mimeData()->hasUrls())
1061 auto urls =
event->mimeData()->urls();
1062 foreach(
auto url, urls)
1064 if(url.isLocalFile())
1065 slotOpenFile(url.toLocalFile());
1069void MainWindow::slotSystemTrayIconActivated(QSystemTrayIcon::ActivationReason reason)
1074#if defined(Q_OS_ANDROID)
1079 case QSystemTrayIcon::Trigger:
1091void MainWindow::slotSystemTrayIconTypeChanged()
1094 if(!QSystemTrayIcon::isSystemTrayAvailable())
1096 qWarning(log) <<
"System tray is not available";
1100 if(!m_Parameter.GetEnableSystemTrayIcon())
1102 qDebug(log) <<
"Disable system tray icon";
1109 m_TrayIcon = QSharedPointer<QSystemTrayIcon>(
new QSystemTrayIcon(
this));
1110 if(QSystemTrayIcon::isSystemTrayAvailable())
1112 bool check = connect(
1114 SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
1116 SLOT(slotSystemTrayIconActivated(QSystemTrayIcon::ActivationReason)));
1118 m_TrayIcon->setIcon(this->windowIcon());
1119 m_TrayIcon->setToolTip(windowTitle());
1122 qWarning(log) <<
"System tray is not available";
1124 switch (m_Parameter.GetSystemTrayIconMenuType())
1126 case CParameterApp::SystemTrayIconMenuType::MenuBar:
1128 QMenu* pMenu =
new QMenu(
this);
1129 pMenu->addMenu(ui->menuRemote);
1130 pMenu->addMenu(ui->menuView);
1131 pMenu->addMenu(ui->menuTools);
1132 m_TrayIcon->setContextMenu(pMenu);
1135 case CParameterApp::SystemTrayIconMenuType::Remote:
1136 m_TrayIcon->setContextMenu(ui->menuRemote);
1138 case CParameterApp::SystemTrayIconMenuType::RecentOpen:
1139 m_TrayIcon->setContextMenu(m_pRecentMenu);
1141 case CParameterApp::SystemTrayIconMenuType::View:
1142 m_TrayIcon->setContextMenu(ui->menuView);
1144 case CParameterApp::SystemTrayIconMenuType::Tools:
1145 m_TrayIcon->setContextMenu(ui->menuTools);
1147 case CParameterApp::SystemTrayIconMenuType::No:
1148 m_TrayIcon->setContextMenu(
nullptr);
1153void MainWindow::slotEnableSystemTrayIcon()
1158 if(!m_Parameter.GetEnableSystemTrayIcon())
1161 slotSystemTrayIconTypeChanged();
virtual int SaveSettings(QString szFile=QString())
Save Client parameters to file.
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 SaveConnecter(QString szFile, CConnecter *pConnecter)
Accept connecter parameters to file.
virtual int DeleteConnecter(CConnecter *p)
Delete CConnecter.
virtual QList< QWidget * > GetSettingsWidgets(QWidget *parent)
Get parameter settings widget.
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 const QString Id()
Identity.
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]