6#include "ui_MainWindow.h"
12#include "FrmUpdater.h"
15#include "QUIWidget/QUIWidget.h"
17#include "RabbitCommonTools.h"
18#include "RabbitCommonEncrypt.h"
19#ifdef HAVE_RABBITCOMMON_GUI
20#include "DockFolderBrowser.h"
21#include "FileBrowser.h"
23#include "RabbitCommonDir.h"
26#include <QDesktopServices>
29#include <QLoggingCategory>
41#define __FUN__ Q_FUNC_INFO
43#define __FUN__ __PRETTY_FUNCTION__
46Q_LOGGING_CATEGORY(log,
"RabbitCommon.MainWindow")
57 <<
"Q_FUNC_INFO " << Q_FUNC_INFO <<
"\n"
58 <<
"__func__ " << __func__ <<
"\n"
59 <<
"Q_FUNC_INFO " << Q_FUNC_INFO <<
"\n"
61 <<
"__FUNCDNAME__ " << __FUNCDNAME__ <<
"\n"
62 <<
"__FUNCSIG__ " << __FUNCSIG__ <<
"\n"
64 <<
"__PRETTY_FUNCTION__ " << __PRETTY_FUNCTION__ <<
"\n"
71#ifdef HAVE_RABBITCOMMON_GUI
72 RabbitCommon::CTools::AddStyleMenu(ui->menuTools);
73 ui->menuTools->addMenu(RabbitCommon::CTools::GetLogMenu(
this));
74 ui->tbLog->setMenu(RabbitCommon::CTools::GetLogMenu(
this));
78 pDock->
setRootPath(RabbitCommon::CDir::Instance()->GetDirIcons(
true));
80 addDockWidget(Qt::LeftDockWidgetArea, pDock);
82 ui->menuTools->addAction(pDock->toggleViewAction());
86#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
87 ui->leCommand->setText(
"mkdir");
88 ui->lePara->setText(
"-p /opt/RabbitCommonAdminAuthoriseTest");
91 ui->leCommand->setText(
"regedit");
95MainWindow::~MainWindow()
101void MainWindow::on_actionAbout_triggered()
105 dlg->setAttribute(Qt::WA_QuitOnClose,
true);
110void MainWindow::on_actionUpdate_triggered()
115 QIcon icon = windowIcon();
117 auto sizeList = icon.availableSizes();
118 if(!sizeList.isEmpty()) {
119 QPixmap p = icon.pixmap(*sizeList.begin());
120 m_pfrmUpdater->
SetTitle(p.toImage());
124 RC_SHOW_WINDOW(m_pfrmUpdater);
127#ifdef BUILD_QUIWidget
128 QUIWidget::setFormInCenter(m_pfrmUpdater);
132void MainWindow::on_pushButton_clicked()
136 if(!ui->lePara->text().isEmpty())
137 paras = ui->lePara->text().split(
' ');
138 qDebug(log) <<
"RabbitCommon::CTools::executeByRoot("
139 + ui->leCommand->text() +
"," + ui->lePara->text() +
");"
143void MainWindow::on_pbEncrypt_clicked()
146 e.SetPassword(ui->lePassword->text().toStdString().c_str());
148 int nRet = e.
Encode(ui->teInput->toPlainText(), out);
155 szOut = tr(
"Encrypt:") + QString(out) +
"\n" + tr(
"Source:") + szOut;
156 ui->teOutput->setPlainText(szOut);
161void MainWindow::on_pbAddFile_clicked()
163 ui->cmbDownloadFiles->addItem(ui->cmbDownloadFiles->currentText());
166void MainWindow::on_pbDownload_clicked()
169 m_pDownload->deleteLater();
171 for(
int i = 0; i < ui->cmbDownloadFiles->count(); i++)
173 urls.push_back(QUrl(ui->cmbDownloadFiles->itemText(i)));
176 bool check = connect(m_pDownload, SIGNAL(sigFinished(
const QString)),
177 this, SLOT(slotDownloadFile(
const QString)));
179 check = connect(m_pDownload, SIGNAL(sigError(
int,
const QString)),
180 this, SLOT(slotDownloadError(
int,
const QString)));
182 m_pDownload->
Start(urls);
185void MainWindow::slotDownloadFile(
const QString szFile)
187 qDebug(log) <<
"Download file:" << szFile;
188 QDesktopServices::openUrl(QUrl::fromLocalFile(szFile));
191void MainWindow::slotDownloadError(
int nErr,
const QString szErr)
193 qDebug(log) <<
"Download file error:" << nErr << szErr;
196void MainWindow::on_actionFolder_browser_triggered()
205 CCoreThread(QObject *parent =
nullptr) : QThread(parent)
207 connect(
this, SIGNAL(destroyed(QObject*)),
208 this, SLOT(deleteLater()));
212 qDebug(log) <<
"CCoreThread::~CCoreThread()";
217 virtual void run()
override;
220void CCoreThread::run()
229void MainWindow::on_pbThreadCore_clicked()
235void MainWindow::on_pbGenerateCoreFile_clicked()
void setRootPath(const QString dir)
Set root path.
QString rootPath() const
Get root path.
int SetTitle(QImage icon=QImage(), const QString &szTitle=QString())
SetTitle.
int SetInstallAutoStartup(bool bAutoStart=true)
Set install and automation startup.
Download the same file from multiple URLs.
int Start(QVector< QUrl > urls, QString szFileName=QString(), bool bSequence=false)
int Encode(const char *pIn, const int &inLen, char **pOut, int &outLen)
int Dencode(const char *pIn, const int &inLen, char **pOut, int &outLen)