first commit
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include "SecondThread.h"
|
||||
#include "VerBVersion.h"
|
||||
|
||||
SecondThread::SecondThread(QObject* par) : QThread(par)
|
||||
,m_runCount(20)
|
||||
{
|
||||
pDdlgShowMsg = new DlgShowMsg;
|
||||
pDdlgShowMsg->hide();
|
||||
pTimer10s = new QTimer();
|
||||
pTimer10s->setInterval(10000);
|
||||
//connect(pTimer10s, SIGNAL(timeout()), this, &SecondThread::timeoutSlot);
|
||||
connect(pTimer10s, SIGNAL(timeout()), this, SLOT(timeoutSlot()),Qt::QueuedConnection);
|
||||
pUpLicManager = new LicenseManger();
|
||||
licState = pUpLicManager->getLicState();
|
||||
if(licState)
|
||||
{
|
||||
//pDdlgShowMsg->showMsg(tr("license file was invalid,error code:%1").arg(licState));
|
||||
emit printerLicErr(licState);
|
||||
qDebug()<<"asdfsdf";
|
||||
}
|
||||
bLicFileUpdating = false;
|
||||
}
|
||||
|
||||
SecondThread::~SecondThread()
|
||||
{
|
||||
qDebug() << "SecondThread::~SecondThread()";
|
||||
}
|
||||
|
||||
void SecondThread::setSomething()
|
||||
{
|
||||
msleep(500);
|
||||
QString str = QString("%1->%2,thread id:%3").arg(__FUNCTION__).arg(__FILE__).arg((int)QThread::currentThreadId());
|
||||
emit message(str);
|
||||
}
|
||||
|
||||
void SecondThread::getSomething()
|
||||
{
|
||||
msleep(500);
|
||||
emit message(QString("%1->%2,thread id:%3").arg(__FUNCTION__).arg(__FILE__).arg((int)QThread::currentThreadId()));
|
||||
}
|
||||
|
||||
void SecondThread::setRunCount(int count)
|
||||
{
|
||||
m_runCount = count;
|
||||
emit message(QString("%1->%2,thread id:%3").arg(__FUNCTION__).arg(__FILE__).arg((int)QThread::currentThreadId()));
|
||||
}
|
||||
|
||||
void SecondThread::timeoutSlot()
|
||||
{
|
||||
QTime curTime=QTime::currentTime();
|
||||
qDebug()<<curTime.toString()<<"second thread";
|
||||
qint32 remaining_time;
|
||||
if(!bLicFileUpdating)
|
||||
{
|
||||
if(licState == LICENSE_STATE_OK)
|
||||
{
|
||||
remaining_time = pUpLicManager->CheckRemainingTime();
|
||||
if(remaining_time <= 3)
|
||||
{
|
||||
licState = -LICENSE_STATE_REMAIN_TIME_REARCH;
|
||||
emit printerLicErr(licState);
|
||||
}
|
||||
}
|
||||
emit printerLicErr(licState);
|
||||
}
|
||||
}
|
||||
void SecondThread::update_license_file()
|
||||
{
|
||||
pUpLicManager->UpdateLicenseFileData();
|
||||
licState = pUpLicManager->getLicState();
|
||||
}
|
||||
void SecondThread::update_license_process()
|
||||
{
|
||||
qint8 updateFileState = pUpLicManager->CheckUpdateFileState();
|
||||
if(updateFileState != UPDATE_LICENSE_FILE_OK)
|
||||
{
|
||||
//QMessageBox::critical(this,tr("错误"),tr("升级软件错误,错误码:%1").arg(updateState));
|
||||
emit update_license_complete(updateFileState);
|
||||
}
|
||||
else
|
||||
{
|
||||
bLicFileUpdating = true;
|
||||
update_license_file();
|
||||
emit update_license_complete(UPDATE_LICENSE_FILE_OK);
|
||||
bLicFileUpdating = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SecondThread::set_serial_number_process(quint32 serial_number)
|
||||
{
|
||||
qDebug()<<"set_serial_number_process"<<serial_number;
|
||||
pUpLicManager->setMachineInfo(serial_number);
|
||||
}
|
||||
void SecondThread::run()
|
||||
{
|
||||
qDebug()<<"second thread run";
|
||||
pTimer10s->start();
|
||||
this->exec();
|
||||
}
|
||||
|
||||
void SecondThread::doSomething()
|
||||
{
|
||||
msleep(500);
|
||||
emit message(QString("%1->%2,thread id:%3").arg(__FUNCTION__).arg(__FILE__).arg((int)QThread::currentThreadId()));
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef SECONDTHREADFROMQTHREAD_H
|
||||
#define SECONDTHREADFROMQTHREAD_H
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
#include "LicenseManger/LicenseManger.h"
|
||||
#include "dlgshowmsg.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
class SecondThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void message(const QString& info);
|
||||
void progress(int present);
|
||||
void printerLicErr(qint8);
|
||||
void update_license_complete(qint8);
|
||||
|
||||
public:
|
||||
SecondThread(QObject* par);
|
||||
~SecondThread();
|
||||
void setSomething();
|
||||
void getSomething();
|
||||
void setRunCount(int count);
|
||||
void run();
|
||||
void doSomething();
|
||||
void update_license_file();
|
||||
private:
|
||||
int m_runCount;
|
||||
QTimer *pTimer10s;
|
||||
LicenseManger *pUpLicManager;
|
||||
QDate curDate;
|
||||
TAesClass *pAes;
|
||||
qint8 licState;
|
||||
DlgShowMsg *pDdlgShowMsg;
|
||||
bool bLicFileUpdating;
|
||||
|
||||
private slots:
|
||||
void timeoutSlot();
|
||||
void update_license_process();
|
||||
void set_serial_number_process(quint32);
|
||||
};
|
||||
|
||||
#endif // THREADFROMQTHREAD_H
|
||||
Reference in New Issue
Block a user