commicon.cpp 687 Bytes
#include "commicon.h"

#include <QPainter>
#include <QPaintEvent>

#include "udphandler.h"

CommIcon::CommIcon(QWidget *parent) : QWidget(parent)
{
    isFault = false;

    UdpHandler *udp = UdpHandler::getInstance();
    connect(udp, SIGNAL(timeout()), SLOT(setFault()));
    connect(udp, SIGNAL(recovered()), SLOT(setOK()));
}

void CommIcon::setFault()
{
    isFault = true;
    update();
}

void CommIcon::setOK()
{
    isFault = false;
    update();
}

void CommIcon::paintEvent(QPaintEvent *event)
{
    if (isFault)
        return;

    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setBrush(Qt::blue);
    painter.drawEllipse(rect());
}