mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 01:45:38 +08:00
* 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
30 lines
756 B
C++
30 lines
756 B
C++
#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
|