1 /***************************************************************************
2 * Copyright (C) 2010 by P. Sereno *
3 * http://www.sereno-online.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU Lesser General Public License *
7 * version 2.1 as published by the Free Software Foundation *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU Lesser General Public License for more details. *
13 * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. *
14 ***************************************************************************/
21 #include <QSvgRenderer>
27 \brief QLed: this is the QLed constructor.
28 \param parent: The Parent Widget
30 QLed::QLed(QWidget *parent)
37 setMinimumSize(QSize(50,50));
38 shapes << ":/resources/circle_" << ":/resources/square_" << ":/resources/triang_" << ":/resources/round_";
39 colors << "red.svg" << "green.svg" << "yellow.svg" << "grey.svg" << "orange.svg" << "purple.svg" << "blue.svg";
45 \brief paintEvent: painting method
49 void QLed::paintEvent(QPaintEvent *)
52 QSvgRenderer *renderer = new QSvgRenderer();
53 QString ledShapeAndColor;
54 QPainter painter(this);
55 painter.setRenderHint(QPainter::Antialiasing, true);
57 ledShapeAndColor=shapes[m_shape];
60 ledShapeAndColor.append(colors[m_onColor]);
62 ledShapeAndColor.append(colors[m_offColor]);
64 renderer->load(ledShapeAndColor);
65 renderer->render(&painter);
71 \brief setOnColor: this method allows to change the On color {Red,Green,Yellow,Grey,Orange,Purple,blue}
72 \param ledColor newColor
75 void QLed::setOnColor(ledColor newColor)
83 \brief setOffColor: this method allows to change the Off color {Red,Green,Yellow,Grey,Orange,Purple,blue}
84 \param ledColor newColor
87 void QLed::setOffColor(ledColor newColor)
95 \brief setShape: this method allows to change the led shape {Circle,Square,Triangle,Rounded rectangle}
96 \param ledColor newColor
99 void QLed::setShape(ledShape newShape)
107 \brief setValue: this method allows to set the led value {true,false}
108 \param ledColor newColor
111 void QLed::setValue(bool value)
119 \brief toggleValue: this method toggles the led value
120 \param ledColor newColor
123 void QLed::toggleValue()