/*
 * scbus utils to switch card settings.
 *
 * Copyright (C) 2011 Otvos Attila oattila@onebithq.com
 *
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include <QtGui>

#include "ledstatus.h"

LedStatus::LedStatus(QWidget *parent)
    : QWidget(parent)
{
    status=0;
    setAutoFillBackground(true);
    this->brush = QBrush(QColor(255,0,0));
}

QSize LedStatus::minimumSizeHint() const
{
    return QSize(20*6+8, 28);
}

QSize LedStatus::sizeHint() const
{
    return QSize(20*6+8, 28);
}

void LedStatus::setPen(const QPen &pen)
{
    this->pen = pen;
    update();
}

void LedStatus::setBrush(const QBrush &brush)
{
    this->brush = brush;
    update();
}

void LedStatus::setStatus(char status) {
    this->status = status;
    update();
}


void LedStatus::paintEvent(QPaintEvent * /* event */)
{
    int i;

    QPainter painter(this);
    painter.setPen(pen);

    for(i=0;i<6;i++) {
        if(status & (1<<i))
            painter.setBrush(brush);
        else
            painter.setBrush(QBrush(QColor(160,160,160)));
        painter.drawEllipse(i*20+4,4,16,16);
    }

}
