Refactor utilities package.
This commit is contained in:
53
src/utilities/Locker.cpp
Normal file
53
src/utilities/Locker.cpp
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user