mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 10:15:38 +08:00
refs #239, added a helper class for timer based pulls
* changed user componet to use new component * all new components (aircraft, ATC stations) will use this timer * it is implemented as "has a" timer based component, as inheriting from 2 QObjects would be problematic
This commit is contained in:
29
src/blackgui/timerbasedcomponent.cpp
Normal file
29
src/blackgui/timerbasedcomponent.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "timerbasedcomponent.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
|
||||
CTimerBasedComponent::CTimerBasedComponent(const char *slot, QObject *parent) :
|
||||
QObject(parent), m_timer(nullptr)
|
||||
{
|
||||
this->m_timer = new QTimer(this);
|
||||
this->connect(this->m_timer, SIGNAL(timeout()), parent, slot);
|
||||
}
|
||||
|
||||
CTimerBasedComponent::~CTimerBasedComponent()
|
||||
{
|
||||
this->m_timer->stop();
|
||||
this->disconnect(this->parent());
|
||||
}
|
||||
|
||||
void CTimerBasedComponent::setUpdateInterval(int milliSeconds)
|
||||
{
|
||||
if (milliSeconds < 100)
|
||||
this->m_timer->stop();
|
||||
else
|
||||
{
|
||||
this->m_timer->setInterval(milliSeconds);
|
||||
if (!this->m_timer->isActive()) this->m_timer->start();
|
||||
}
|
||||
}
|
||||
} // guard
|
||||
Reference in New Issue
Block a user