Lock and setting json about

This commit is contained in:
Krad
2021-12-07 14:14:20 +08:00
parent f1ab2937f9
commit 1b8809d8db
9 changed files with 309 additions and 67 deletions

52
src/locker.cpp Normal file
View File

@@ -0,0 +1,52 @@
#include "locker.h"
#include <QTimer>
#include "appvals/AppGlobalValues.h"
#include <src/event/EventCenter.h>
#include "json/jsonobject.h"
Locker* Locker::locker = Q_NULLPTR;
Locker* Locker::Instance()
{
if (locker == Q_NULLPTR)
{
locker = new Locker();
}
return locker;
}
Locker::Locker()
{
counter = JsonObject::Instance()->lockerCount();
screenTimer = new QTimer(this);
connect(screenTimer, SIGNAL(timeout()), this, SLOT(coverScreen()));
}
Locker::~Locker() {}
void Locker::start()
{
screenTimer->start(counter);
}
void Locker::coverScreen()
{
if (AppGlobalValues::InProcessing().toBool()) {
refreshTimer();
}
else
{
screenTimer->stop();
EventCenter::Default()->triggerEvent(GUIEvents::RequestLogin, nullptr, nullptr);
}
}
void Locker::setTimer(int interval)
{
this->counter = interval;
screenTimer->stop();
screenTimer->start(this->counter);
}
void Locker::refreshTimer()
{
screenTimer->stop();
screenTimer->start(counter);
}