4#include <QLoggingCategory>
8static Q_LOGGING_CATEGORY(log,
"Operate")
12 , m_bStopSignal(bStopSignal)
14 qDebug(log) << Q_FUNC_INFO;
20 qDebug(log) << Q_FUNC_INFO;
23int CBackend::SetConnect(
COperate *pOperate)
25 qDebug(log) << Q_FUNC_INFO;
26 if(!pOperate)
return -1;
35 check = connect(
this, SIGNAL(
sigStop()),
38 check = connect(
this, SIGNAL(
sigError(
const int,
const QString&)),
39 pOperate, SIGNAL(
sigError(
const int,
const QString&)));
46 const QMessageBox::Icon&)),
48 const QMessageBox::Icon&)));
51 const QString&,
const QString&,
52 QMessageBox::StandardButtons,
53 QMessageBox::StandardButton&,
55 pOperate, SLOT(slotBlockShowMessageBox(
56 const QString&,
const QString&,
57 QMessageBox::StandardButtons,
58 QMessageBox::StandardButton&,
60 Qt::BlockingQueuedConnection);
66 pOperate, SLOT(slotBlockInputDialog(
const QString&,
70 Qt::BlockingQueuedConnection);
75 pOperate, SLOT(slotBlockShowWidget(
const QString&,
int&,
void*)),
76 Qt::BlockingQueuedConnection);
83 qDebug(log) << Q_FUNC_INFO;
85 nRet =
static_cast<int>(
OnInit());
86 if(nRet < 0)
return nRet;
95 qDebug(log) << Q_FUNC_INFO;
116 QTimer::singleShot(nTime,
this, SLOT(
slotTimeOut()));
119 qDebug(log) <<
"Process fail(< -1) or stop(= -1):" << nTime;
121 qCritical(log) <<
"Process fail:" << nTime;
122 emit
sigError(nTime,
"Process fail or stop");
124 }
catch(std::exception e) {
125 qCritical(log) <<
"Process fail:" << e.what();
128 qCritical(log) <<
"Process fail";
140 qWarning(log) <<
"Need to implement CConnect::OnProcess()";
void sigInformation(const QString &szInfo)
Triggering from a background thread displays information in the main thread without blocking the back...
virtual int WakeUp()
Wake up.
virtual int OnProcess()
Specific operation processing of plug-in.
void sigStop()
Notify the user to stop.
virtual OnInitReturnValue OnInit()=0
Initialization.
virtual int OnClean()=0
Clean.
void sigShowMessageBox(const QString &szTitle, const QString &szMessage, const QMessageBox::Icon &icon=QMessageBox::Information)
Trigger the display of a message dialog (QMessageBox) in the main thread from a background thread wit...
virtual int Start()
Start.
void sigError(const int nError, const QString &szError=QString())
Triggered when an error is generated.
void sigBlockShowMessageBox(const QString &szTitle, const QString &szMessage, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton &nRet, bool &checkBox, QString checkBoxContext=QString())
Block background threads and display message dialogs in foreground threads (QMessageBox)
void sigRunning()
Emitted when the plugin is successfully started.
void sigFinished()
Successful stopped signal.
virtual void slotTimeOut()
a non-Qt event loop (that is, normal loop processing), It call OnProcess(), and start timer.
void sigBlockShowWidget(const QString &className, int &nRet, void *pContext)
Blocks the background thread and displays the window in the foreground thread.
bool m_bStopSignal
When an error occurs, emit a COperate::sigStop() signal.
void sigBlockInputDialog(const QString &szTitle, const QString &szLable, const QString &szMessage, QString &szText)
Block background threads and display input dialogs in foreground threads (QInputDialog)