mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
Ref T149, use new signals/functions to directly change status bar
* timer private * some formatting
This commit is contained in:
committed by
Mathew Sutcliffe
parent
8c68f2302c
commit
2d8c2ea930
@@ -36,12 +36,16 @@ namespace BlackGui
|
||||
m_timer.setInterval(30 * 1000);
|
||||
m_timer.start();
|
||||
m_timer.setObjectName("CInfoBarWebReadersStatusBase::CheckSwiftDbTimer");
|
||||
bool c = connect(&m_timer, &QTimer::timeout, this, &CInfoBarWebReadersStatusBase::ps_checkServerAndData);
|
||||
bool c = connect(&m_timer, &QTimer::timeout, this, &CInfoBarWebReadersStatusBase::checkServerAndData);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Failed connect");
|
||||
c = connect(sGui, &CGuiApplication::changedInternetAccessibility, this, &CInfoBarWebReadersStatusBase::accessibilityChanged);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Failed connect");
|
||||
c = connect(sGui, &CGuiApplication::changedSwiftDbAccessibility, this, &CInfoBarWebReadersStatusBase::accessibilityChanged);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Failed connect");
|
||||
|
||||
if (sGui->hasWebDataServices())
|
||||
{
|
||||
c = connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CInfoBarWebReadersStatusBase::ps_dataRead);
|
||||
c = connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CInfoBarWebReadersStatusBase::dataRead);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Failed connect");
|
||||
}
|
||||
|
||||
@@ -67,22 +71,25 @@ namespace BlackGui
|
||||
this->led_Distributors->setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape, "reading", "idle", "failed", 14);
|
||||
}
|
||||
|
||||
void CInfoBarWebReadersStatusBase::ps_dataRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count)
|
||||
void CInfoBarWebReadersStatusBase::dataRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count)
|
||||
{
|
||||
Q_UNUSED(count);
|
||||
QList<CLedWidget *> leds = this->entityToLeds(entity);
|
||||
if (!leds.isEmpty()) { this->setLedReadStates(leds, readState); }
|
||||
}
|
||||
|
||||
void CInfoBarWebReadersStatusBase::ps_checkServerAndData()
|
||||
void CInfoBarWebReadersStatusBase::accessibilityChanged(bool accessible)
|
||||
{
|
||||
const bool swift =
|
||||
sGui &&
|
||||
sGui->hasWebDataServices() &&
|
||||
sGui->getWebDataServices()->hasConnectedSwiftDb();
|
||||
Q_UNUSED(accessible);
|
||||
this->checkServerAndData();
|
||||
}
|
||||
|
||||
void CInfoBarWebReadersStatusBase::checkServerAndData()
|
||||
{
|
||||
const bool swift = sGui && sGui->isSwiftDbAccessible();
|
||||
this->led_SwiftDb->setOn(swift);
|
||||
|
||||
bool allData = hasAllData();
|
||||
const bool allData = hasAllData();
|
||||
this->led_DataReady->setOn(allData);
|
||||
}
|
||||
|
||||
@@ -97,7 +104,7 @@ namespace BlackGui
|
||||
void CInfoBarWebReadersStatusBase::setLedReadState(CLedWidget *led, CEntityFlags::ReadState readState)
|
||||
{
|
||||
Q_ASSERT_X(led, Q_FUNC_INFO, "no LED");
|
||||
int blinkTime = 2.5 * 1000;
|
||||
const int blinkTime = 2.5 * 1000;
|
||||
switch (readState)
|
||||
{
|
||||
case CEntityFlags::ReadFinished:
|
||||
|
||||
@@ -37,14 +37,12 @@ namespace BlackGui
|
||||
|
||||
public:
|
||||
//!Destructor
|
||||
~CInfoBarWebReadersStatusBase();
|
||||
virtual ~CInfoBarWebReadersStatusBase();
|
||||
|
||||
//! Init the LEDs
|
||||
void initLeds();
|
||||
|
||||
protected:
|
||||
QTimer m_timer { this }; //!< check timer
|
||||
|
||||
//! Constructor
|
||||
explicit CInfoBarWebReadersStatusBase(QWidget *parent = nullptr);
|
||||
|
||||
@@ -68,14 +66,17 @@ namespace BlackGui
|
||||
BlackGui::CLedWidget *led_IcaoAircraft, BlackGui::CLedWidget *led_IcaoAirline, BlackGui::CLedWidget *led_Countries,
|
||||
BlackGui::CLedWidget *led_Distributors, BlackGui::CLedWidget *led_Liveries, BlackGui::CLedWidget *led_Models);
|
||||
|
||||
private slots:
|
||||
//! Data have been read
|
||||
void ps_dataRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count);
|
||||
void dataRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count);
|
||||
|
||||
//! DB or network accessibility changed
|
||||
void accessibilityChanged(bool accessible);
|
||||
|
||||
//! Check server status
|
||||
void ps_checkServerAndData();
|
||||
void checkServerAndData();
|
||||
|
||||
private:
|
||||
QTimer m_timer { this }; //!< check timer
|
||||
BlackGui::CLedWidget *led_SwiftDb = nullptr;
|
||||
BlackGui::CLedWidget *led_DataReady = nullptr;
|
||||
BlackGui::CLedWidget *led_IcaoAircraft = nullptr;
|
||||
@@ -96,7 +97,7 @@ namespace BlackGui
|
||||
explicit CInfoBarWebReadersStatusComponent(QWidget *parent = nullptr);
|
||||
|
||||
//!Destructor
|
||||
~CInfoBarWebReadersStatusComponent();
|
||||
virtual ~CInfoBarWebReadersStatusComponent();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CInfoBarWebReadersStatusComponent> ui;
|
||||
|
||||
Reference in New Issue
Block a user