Refactor utilities package.

This commit is contained in:
sunwen
2022-06-13 13:26:49 +08:00
parent 160b0b4f4b
commit 589262781d
15 changed files with 556 additions and 583 deletions

53
src/utilities/Locker.cpp Normal file
View File

@@ -0,0 +1,53 @@
#include "Locker.h"
#include <QTimer>
#include "appvals/AppGlobalValues.h"
#include "event/EventCenter.h"
#include "json/jsonobject.h"
Locker* Locker::getInstance()
{
static Locker instance;
return &instance;
}
Locker::Locker()
: QObject()
, mScreenTimer(new QTimer(this))
, mCounter(JsonObject::Instance()->lockerCount())
{
connect(mScreenTimer, SIGNAL(timeout()), this, SLOT(coverScreen()));
}
Locker::~Locker()
{
}
void Locker::start()
{
mScreenTimer->start(mCounter);
}
void Locker::coverScreen()
{
if (AppGlobalValues::InProcessing().toBool())
{
refreshTimer();
}
else
{
mScreenTimer->stop();
EventCenter::Default()->triggerEvent(GUIEvents::RequestLogin, nullptr, nullptr);
}
}
void Locker::setTimer(int aInterval)
{
mCounter = aInterval;
mScreenTimer->stop();
mScreenTimer->start(mCounter);
}
void Locker::refreshTimer()
{
mScreenTimer->stop();
mScreenTimer->start(mCounter);
}