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;
404 if(m_pView && pView) {
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->actionCurrent_connect_parameters->setEnabled(bEnable);
416 ui->actionDisconnect_D->setEnabled(bEnable);
417 slotLoadConnecterMenu();
420void MainWindow::slotLoadConnecterMenu()
422 qDebug(log) << Q_FUNC_INFO;
424 if(m_pActionConnecterMenu) {
425 ui->menuTools->removeAction(m_pActionConnecterMenu);
426 ui->toolBar->removeAction(m_pActionConnecterMenu);
427 m_pActionConnecterMenu =
nullptr;
434 qDebug(log) <<
"The current view is empty";
437 foreach(
auto c, m_Connecters)
439 if(c->GetViewer() == pWin)
441 qDebug(log) <<
"Load plugin menu";
442 auto m = c->GetMenu(ui->menuTools);
444 m_pActionConnecterMenu = ui->menuTools->addMenu(m);
445 ui->toolBar->insertAction(ui->actionFull_screen_F, m_pActionConnecterMenu);
446 emit sigConnecterMenuChanged(m_pActionConnecterMenu);
451void MainWindow::slotCustomContextMenuRequested(
const QPoint &pos)
457 qDebug(log) <<
"The current view is empty";
460 foreach(
auto c, m_Connecters)
462 if(c->GetViewer() == pWin)
464 qDebug(log) <<
"Load plugin menu";
465 auto m = c->GetMenu(ui->menuTools);
467 m->exec(m_pView->mapToGlobal(pos));
472void MainWindow::on_actionExit_E_triggered()
477void MainWindow::keyReleaseEvent(QKeyEvent *event)
483 on_actionFull_screen_F_triggered();
486 QMainWindow::keyReleaseEvent(event);
489void MainWindow::slotUpdateParameters(
CConnecter* pConnecter)
491 auto it = m_ConfigureFiles.find(pConnecter);
492 if(m_ConfigureFiles.end() == it)
497void MainWindow::on_actionClone_triggered()
501 foreach(
auto c, m_Connecters)
503 if(c->GetViewer() == p)
505 auto it = m_ConfigureFiles.find(c);
506 if(m_ConfigureFiles.end() == it)
508 QString szFile = it.value();
510 if(!pConnecter)
return;
511 Connect(pConnecter,
false, szFile);
517void MainWindow::slotOpenFile(
const QString& szFile,
bool bOpenSettings)
519 if(szFile.isEmpty())
return;
527 Connect(p, bOpenSettings, szFile);
530void MainWindow::on_actionOpenRRCFile_triggered()
532 QString szFile = QFileDialog::getOpenFileName(
this,
533 tr(
"Open rabbit remote control file"),
534 RabbitCommon::CDir::Instance()->GetDirUserData(),
535 tr(
"Rabbit remote control Files (*.rrc);;All files(*.*)"));
536 if(szFile.isEmpty())
return;
548void MainWindow::slotConnect()
550 if(
nullptr == m_pView)
555 QAction* pAction =
dynamic_cast<QAction*
>(this->sender());
557 if(
nullptr == p)
return;
573 qDebug(log) <<
"MainWindow::Connect: set:" << set <<
"; File:" << szFile;
576 bool check = connect(p, SIGNAL(sigConnected()),
579 check = connect(p, SIGNAL(sigDisconnect()),
580 this, SLOT(slotDisconnect()));
582 check = connect(p, SIGNAL(sigDisconnected()),
583 this, SLOT(slotDisconnected()));
585 check = connect(p, SIGNAL(sigError(
const int,
const QString &)),
586 this, SLOT(slotError(
const int,
const QString&)));
588 check = connect(p, SIGNAL(sigShowMessageBox(
const QString&,
const QString&,
589 const QMessageBox::Icon&)),
591 const QMessageBox::Icon&)));
593 check = connect(p, SIGNAL(sigInformation(
const QString&)),
596 check = connect(p, SIGNAL(sigUpdateName(
const QString&)),
597 this, SLOT(slotUpdateName(
const QString&)));
599 check = connect(p, SIGNAL(sigUpdateParameters(
CConnecter*)),
600 this, SLOT(slotUpdateParameters(
CConnecter*)));
608 case QDialog::Rejected:
611 case QDialog::Accepted:
618 szFile = RabbitCommon::CDir::Instance()->GetDirUserData()
622 m_ConfigureFiles[p] = szFile;
628 m_pRecentMenu->addRecentFile(szFile, p->
Name());
630 if(!p->
Name().isEmpty())
641 m_Connecters.push_back(p);
670 slotLoadConnecterMenu();
673 qDebug(log) <<
"MainWindow::slotConnected()" << p->
Name();
679 qDebug(log) <<
"MainWindow::slotCloseView" << pView;
681 foreach(
auto c, m_Connecters)
683 if(c->GetViewer() == pView)
686 emit c->sigUpdateParameters(c);
692void MainWindow::on_actionDisconnect_D_triggered()
694 qDebug(log) <<
"MainWindow::on_actionDisconnect_D_triggered()";
701void MainWindow::slotDisconnect()
703 qDebug(log) <<
"MainWindow::slotDisconnect()";
705 if(!pConnecter)
return;
711void MainWindow::slotDisconnected()
713 qDebug(log) <<
"MainWindow::slotDisconnected()";
715 foreach(
auto c, m_Connecters)
720 m_Connecters.removeAll(c);
721 m_ConfigureFiles.remove(c);
728void MainWindow::slotSignalConnected()
730 m_pSignalStatus->setToolTip(tr(
"ICE signal status: Connected"));
731 m_pSignalStatus->setStatusTip(m_pSignalStatus->toolTip());
732 m_pSignalStatus->setWhatsThis(m_pSignalStatus->toolTip());
734 m_pSignalStatus->setIcon(QIcon::fromTheme(
"newwork-wired"));
737void MainWindow::slotSignalDisconnected()
739 m_pSignalStatus->setToolTip(tr(
"ICE signal status: Disconnected"));
740 m_pSignalStatus->setStatusTip(m_pSignalStatus->toolTip());
741 m_pSignalStatus->setWhatsThis(m_pSignalStatus->toolTip());
743 m_pSignalStatus->setIcon(QIcon::fromTheme(
"network-wireless"));
746void MainWindow::slotSignalError(
const int nError,
const QString &szInfo)
748 slotSignalDisconnected();
752void MainWindow::slotSignalPushButtonClicked(
bool checked)
762void MainWindow::slotError(
const int nError,
const QString &szInfo)
769 const QString &title,
const QString &message,
770 const QMessageBox::Icon &icon)
773 if(!m_Parameter.GetMessageBoxDisplayInformation())
776 QMessageBox msg(icon, title, message, QMessageBox::Ok,
this);
777 QCheckBox* cb =
new QCheckBox(
778 tr(
"Use message box to display information"),
this);
779 cb->setChecked(
true);
781 RC_SHOW_WINDOW(&msg);
784 m_Parameter.SetMessageBoxDisplayInformation(
false);
791 statusBar()->showMessage(szInfo);
794void MainWindow::slotUpdateName()
796 foreach (
auto pConnecter, m_Connecters)
798 m_pView->SetWidowsTitle(pConnecter->
GetViewer(),
805void MainWindow::slotUpdateName(
const QString& szName)
808 if(!pConnecter)
return;
809 m_pView->SetWidowsTitle(pConnecter->
GetViewer(), szName,
817 QAction* p = ui->menuConnect_C->addAction(pPlug->
Protocol()
819 this, SLOT(slotConnect()));
823 p->setIcon(pPlug->Icon());
828void MainWindow::closeEvent(QCloseEvent *event)
830 qDebug(log) <<
"MainWindow::closeEvent()";
832 if(m_Parameter.GetSaveMainWindowStatus())
834 on_actionFull_screen_F_triggered();
836 SaveConnectLasterClose();
838 foreach (
auto it, m_Connecters)
841 emit it->sigUpdateParameters(it);
845 QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure(),
846 QSettings::IniFormat);
847 if(m_Parameter.GetSaveMainWindowStatus())
849 set.setValue(
"MainWindow/Status/Geometry", saveGeometry());
850 set.setValue(
"MainWindow/Status/State", saveState());
853 set.remove(
"MainWindow/Status/Geometry");
854 set.remove(
"MainWindow/Status/State");
856 QMainWindow::closeEvent(event);
862int MainWindow::LoadConnectLasterClose()
864 if(!m_Parameter.GetOpenLasterClose())
867 QFile f(RabbitCommon::CDir::Instance()->GetDirUserConfig()
868 + QDir::separator() +
"LasterClose.dat");
869 if(f.open(QFile::ReadOnly))
877 slotOpenFile(szFile);
884int MainWindow::SaveConnectLasterClose()
886 QFile f(RabbitCommon::CDir::Instance()->GetDirUserConfig()
887 + QDir::separator() +
"LasterClose.dat");
888 f.open(QFile::WriteOnly);
889 if(m_Parameter.GetOpenLasterClose())
892 foreach(
auto it, m_ConfigureFiles)
901void MainWindow::on_actionSend_ctl_alt_del_triggered()
904 m_pView->slotSystemCombination();
907void MainWindow::on_actionTabBar_B_toggled(
bool bShow)
912 p->ShowTabBar(bShow);
913 m_Parameter.SetTabBar(bShow);
917void MainWindow::on_actionMain_menu_bar_M_toggled(
bool checked)
919 qDebug(log) <<
"MainWindow::on_actionMain_menu_bar_M_triggered:" << checked;
920 if(ui->toolBar->isHidden() && !checked)
922 if( QMessageBox::StandardButton::Yes
923 == QMessageBox::information(
this, tr(
"Hide menu bar"),
924 tr(
"The menu bar will be hidden, the tool bar must be showed."),
925 QMessageBox::StandardButton::Yes
926 | QMessageBox::StandardButton::No))
928 ui->actionToolBar_T->setChecked(
true);
933 menuBar()->setVisible(checked);
934 m_Parameter.SetMenuBar(checked);
937 ui->toolBar->removeAction(ui->actionMain_menu_bar_M);
941 ui->toolBar->insertAction(ui->actionTabBar_B,
942 ui->actionMain_menu_bar_M);
946void MainWindow::on_actionToolBar_T_toggled(
bool checked)
948 qDebug(log) <<
"MainWindow::on_actionToolBar_T_triggered:" << checked;
949 if(menuBar()->isHidden() && !checked)
951 if( QMessageBox::StandardButton::Yes
952 == QMessageBox::information(
this, tr(
"Hide tool bar"),
953 tr(
"The tool bar will be hidden, the menu bar must be showed."),
954 QMessageBox::StandardButton::Yes
955 | QMessageBox::StandardButton::No))
957 ui->actionMain_menu_bar_M->setChecked(
true);
961 ui->toolBar->setVisible(checked);
964void MainWindow::on_actionStatus_bar_S_toggled(
bool checked)
966 statusBar()->setVisible(checked);
967 m_Parameter.SetStatusBar(checked);
971void MainWindow::on_actionSettings_triggered()
974 if(CParameterDlgSettings::Accepted == RC_SHOW_WINDOW(&set))
982void MainWindow::slotShortCut()
984 if(m_Parameter.GetReceiveShortCut())
986 setFocusPolicy(Qt::WheelFocus);
987#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
988 ui->actionFull_screen_F->setShortcut(
989 QKeySequence(QKeyCombination(Qt::CTRL, Qt::Key_R),
990 QKeyCombination(Qt::Key_F)));
991 ui->actionScreenshot->setShortcut(
992 QKeySequence(QKeyCombination(Qt::CTRL, Qt::Key_R),
993 QKeyCombination(Qt::Key_S)));
995 ui->actionFull_screen_F->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R, Qt::Key_F));
996 ui->actionScreenshot->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R, Qt::Key_S));
999 setFocusPolicy(Qt::NoFocus);
1000 ui->actionFull_screen_F->setShortcut(QKeySequence());
1001 ui->actionScreenshot->setShortcut(QKeySequence());
1005void MainWindow::on_actionCurrent_connect_parameters_triggered()
1007 if(!m_pView)
return;
1009 foreach(
auto c, m_Connecters)
1011 if(c->GetViewer() == p)
1013 int nRet = c->OpenDialogSettings(
this);
1014 if(QDialog::Accepted == nRet)
1016 emit c->sigUpdateParameters(c);
1023void MainWindow::on_actionOpenListConnections_triggered()
1027 bool check = connect(p, SIGNAL(sigConnect(
const QString&,
bool)),
1028 this, SLOT(slotOpenFile(
const QString&,
bool)));
1033 d.setWindowIcon(windowIcon());
1034 QGridLayout* pLayout =
new QGridLayout(&d);
1036 pLayout->addWidget(p);
1037 check = connect(p, SIGNAL(destroyed()), &d, SLOT(reject()));
1038 d.setLayout(pLayout);
1043void MainWindow::on_actionAdd_to_favorite_triggered()
1045 if(!m_pView || !m_pFavoriteView)
return;
1047 foreach(
auto c, m_Connecters)
1049 if(c->GetViewer() == p)
1051 auto it = m_ConfigureFiles.find(c);
1052 if(m_ConfigureFiles.end() == it)
1054 m_pFavoriteView->AddFavorite(c->Name(), it.value());
1059void MainWindow::dragEnterEvent(QDragEnterEvent *event)
1061 qDebug(log) <<
"dragEnterEvent";
1063 if(event->mimeData()->hasUrls())
1065 qWarning(log) <<
event->mimeData()->urls();
1066 event->acceptProposedAction();
1070void MainWindow::dragMoveEvent(QDragMoveEvent *event)
1075void MainWindow::dropEvent(QDropEvent *event)
1077 qDebug(log) <<
"dropEvent";
1078 if(!event->mimeData()->hasUrls())
1080 auto urls =
event->mimeData()->urls();
1081 foreach(
auto url, urls)
1083 if(url.isLocalFile())
1084 slotOpenFile(url.toLocalFile());
1088void MainWindow::slotSystemTrayIconActivated(QSystemTrayIcon::ActivationReason reason)
1093#if defined(Q_OS_ANDROID)
1098 case QSystemTrayIcon::Trigger:
1110void MainWindow::slotSystemTrayIconTypeChanged()
1113 if(!QSystemTrayIcon::isSystemTrayAvailable())
1115 qWarning(log) <<
"System tray is not available";
1119 if(!m_Parameter.GetEnableSystemTrayIcon())
1121 qDebug(log) <<
"Disable system tray icon";
1128 m_TrayIcon = QSharedPointer<QSystemTrayIcon>(
new QSystemTrayIcon(
this));
1129 if(QSystemTrayIcon::isSystemTrayAvailable())
1131 bool check = connect(
1133 SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
1135 SLOT(slotSystemTrayIconActivated(QSystemTrayIcon::ActivationReason)));
1137 m_TrayIcon->setIcon(this->windowIcon());
1138 m_TrayIcon->setToolTip(windowTitle());
1141 qWarning(log) <<
"System tray is not available";
1143 switch (m_Parameter.GetSystemTrayIconMenuType())
1145 case CParameterApp::SystemTrayIconMenuType::MenuBar:
1147 QMenu* pMenu =
new QMenu(
this);
1148 pMenu->addMenu(ui->menuRemote);
1149 pMenu->addMenu(ui->menuView);
1150 pMenu->addMenu(ui->menuTools);
1151 m_TrayIcon->setContextMenu(pMenu);
1154 case CParameterApp::SystemTrayIconMenuType::Remote:
1155 m_TrayIcon->setContextMenu(ui->menuRemote);
1157 case CParameterApp::SystemTrayIconMenuType::RecentOpen:
1158 m_TrayIcon->setContextMenu(m_pRecentMenu);
1160 case CParameterApp::SystemTrayIconMenuType::View:
1161 m_TrayIcon->setContextMenu(ui->menuView);
1163 case CParameterApp::SystemTrayIconMenuType::Tools:
1164 m_TrayIcon->setContextMenu(ui->menuTools);
1166 case CParameterApp::SystemTrayIconMenuType::No:
1167 m_TrayIcon->setContextMenu(
nullptr);
1172void MainWindow::slotEnableSystemTrayIcon()
1177 if(!m_Parameter.GetEnableSystemTrayIcon())
1180 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]