4#include "ui_MainWindow.h"
6#include "RabbitCommonDir.h"
7#include "RabbitCommonTools.h"
13#include <QDesktopServices>
14#include <QLoggingCategory>
20Q_DECLARE_LOGGING_CATEGORY(App)
22CMainWindow::CMainWindow(QWidget *parent) : QMainWindow(parent),
28 RabbitCommon::CTools::AddStyleMenu(ui->menuView);
29 ui->menuService->addMenu(RabbitCommon::CTools::GetLogMenu(ui->menuView));
35CMainWindow::~CMainWindow()
38 foreach(
auto plugin, m_Plugins.m_Plugins)
41 foreach(
auto service, m_Service)
43 service->deleteLater();
46void CMainWindow::on_pbCancel_clicked()
51void CMainWindow::on_pbSave_clicked()
54 foreach(
auto service, m_Service)
56 service->SaveConfigure();
59 QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure(), QSettings::IniFormat);
64int CMainWindow::InitTab()
66 QWidget* pIce =
nullptr;
68 QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure(), QSettings::IniFormat);
74 bool check = connect(
this, SIGNAL(
sigAccept()), pIce, SLOT(slotAccept()));
77 qCritical(App) <<
"Class" << pIce->metaObject()->className()
78 <<
"must has slot slotAccept(), please add it";
81 int nIndex = ui->twConfigure->addTab(pIce, pIce->windowIcon(),
84 qCritical(App) <<
"addTab ice fail";
88 foreach(
auto plugin, m_Plugins.m_Plugins)
90 CService* pService = plugin->NewService();
91 if(!pService)
continue;
92 pService->LoadConfigure();
93 m_Service.push_back(pService);
94 QWidget* w = pService->GetParameterWidget(ui->twConfigure);
98 bool check = connect(
this, SIGNAL(
sigAccept()), w, SLOT(slotAccept()));
102 qCritical(App) <<
"Class" << pIce->metaObject()->className()
103 <<
"must has slot slotAccept(), please add it";
106 int nIndex = ui->twConfigure->addTab(w, plugin->Icon(),
107 plugin->DisplayName());
109 qCritical(App) <<
"addTab fail";
116int CMainWindow::Clean()
118 ui->twConfigure->clear();
122void CMainWindow::on_actionStart_triggered()
124 foreach(
auto plugin, m_Plugins.m_Plugins)
141 ui->actionStart->setIcon(QIcon::fromTheme(
"media-playback-start"));
142 ui->actionStart->setText(tr(
"Start"));
143 SetStatusText(tr(
"Start service"));
144 ui->actionStart->setChecked(
false);
148 ui->actionStart->setIcon(QIcon::fromTheme(
"media-playback-stop"));
149 ui->actionStart->setText(tr(
"Stop"));
150 SetStatusText(tr(
"Stop service"));
151 ui->actionStart->setChecked(
true);
153 m_bStart = !m_bStart;
156int CMainWindow::SetStatusText(QString szText)
158 ui->actionStart->setToolTip(szText);
159 ui->actionStart->setStatusTip(szText);
160 ui->actionStart->setWhatsThis(szText);
164void CMainWindow::on_actionAbout_triggered()
167 CDlgAbout *about =
new CDlgAbout(
this);
168 QIcon icon = QIcon::fromTheme(
"system-settings");
169 if(icon.isNull())
return;
170 auto sizeList = icon.availableSizes();
171 if(sizeList.isEmpty())
return;
172 QPixmap p = icon.pixmap(*sizeList.begin());
173 about->m_AppIcon = p.toImage();
174 about->m_szCopyrightStartTime =
"2020";
175 about->m_szVersionRevision = RabbitRemoteControl_REVISION;
176 if(about->isHidden())
178#ifdef BUILD_QUIWidget
180 quiwidget.setMainWidget(about);
181 quiwidget.setPixmap(QUIWidget::Lab_Ico,
":/image/App");
182 #if defined (Q_OS_ANDROID)
183 quiwidget.showMaximized();
187 #if defined (Q_OS_ANDROID)
188 about->showMaximized();
196void CMainWindow::on_actionOpen_folder_triggered()
200 szFile = RabbitCommon::CDir::Instance()->GetFileUserConfigure();
201 QSettings set(szFile, QSettings::IniFormat);
202 szFolder = set.value(
"Configure/Folder",
203 RabbitCommon::CDir::Instance()->GetDirUserConfig()).toString();
204 if(szFolder.isEmpty())
return;
205 QDesktopServices::openUrl(QUrl::fromLocalFile(szFolder));
static CICE * Instance()
Single instance.
void sigAccept()
Notifies the plugin settings window that parameters have changed.