ignitionicon.cpp 1.13 KB
#include "ignitionicon.h"

#include "udphandler.h"
#include "config.h"

QPixmap *IgnitionIcon::icon = Q_NULLPTR;

IgnitionIcon::IgnitionIcon(QWidget *parent) : QLabel(parent)
{
    connect(&timer, SIGNAL(timeout()), SLOT(check()));
    timer.start(1000);

    setPixmap(QPixmap(":/images/symbol/ignited.png"));

    check();
}

void IgnitionIcon::check()
{
    bool ignition = false;

    UdpHandler *udp = UdpHandler::getInstance();

    switch (Config::getInstance()->getConfigValue(Define::config_model).d32)
    {
    case Define::model_electric_10:
    case Define::model_electric_20:
    case Define::model_electric_24:
    case Define::model_electric_40:
        ignition = udp->heater();
        break;

    case Define::model_gas_lpg_10:
    case Define::model_gas_lpg_20:
    case Define::model_gas_lpg_24:
    case Define::model_gas_lpg_40:

    case Define::model_gas_lng_10:
    case Define::model_gas_lng_20:
    case Define::model_gas_lng_24:
    case Define::model_gas_lng_40:
        ignition = udp->burnerState(1) || udp->burnerState(2) || udp->burnerState(3);
        break;
    }

    if (ignition)
        show();
    else
        hide();
}