ifw-fcf  5.0.0-pre2
qeled.hpp
Go to the documentation of this file.
1 
11 #ifndef QELED_H
12 #define QELED_H
13 
14 #include <QWidget>
15 //#include <QtSvg>
16 #include <QtSvg/QSvgRenderer>
17 #include <QColor>
18 #include <QXmlStreamReader>
19 #include <QFile>
20 #include <QPainter>
21 #include <QDebug>
22 
23 
24 class QeLed : public QWidget
25 {
26  Q_OBJECT
27 
28  Q_PROPERTY(QColor colorOn READ getColorOn WRITE setColorOn NOTIFY colorOnChanged)
29  Q_PROPERTY(bool lit READ isLit WRITE setLit NOTIFY toggled)
30  Q_PROPERTY(bool negate READ isNegated WRITE setNegate NOTIFY negated)
31 
32 public:
33  explicit QeLed(QWidget *parent = nullptr);
34 
35  QColor getColorOn() { return this->m_colorOn;}
36  bool isLit() { return this->m_lit;}
37  bool isNegated(){ return this->m_negate;}
38 
39 public slots:
40  void setColorOn(QColor arg){this->m_colorOn = arg; this->updateColor(); emit colorOnChanged(arg);}
41  void setLit(bool arg){ this->m_lit = arg; this->updateColor(); emit toggled(arg);}
42  void setNegate(bool arg){ this->m_negate = arg; this->updateColor(); emit negated(arg);}
43 
44 signals:
45  void colorOnChanged(QColor newColorOn);
46  void toggled(bool newValue);
47  void negated(bool newValue);
48 
49 protected:
50  void paintEvent(QPaintEvent *event) override;
51 
52 private:
53  bool m_lit = false;
54  bool m_negate = false;
55  QColor m_colorOn;
56  QSvgRenderer m_svg;
57  QString m_originalXml;
58  QString m_modifiedXml;
59  const QString c_ledImagePath = ":/led.svg";
60 
61  void updateColor();
62  QColor calculateColor();
63 };
64 
65 #endif // EULED_H
Definition: qeled.hpp:25
void negated(bool newValue)
void setColorOn(QColor arg)
Definition: qeled.hpp:40
void toggled(bool newValue)
void setLit(bool arg)
Definition: qeled.hpp:41
QColor colorOn
Definition: qeled.hpp:28
void setNegate(bool arg)
Definition: qeled.hpp:42
bool lit
Definition: qeled.hpp:29
bool negate
Definition: qeled.hpp:30
void paintEvent(QPaintEvent *event) override
Definition: qeled.cpp:32
QColor getColorOn()
Definition: qeled.hpp:35
QeLed(QWidget *parent=nullptr)
Definition: qeled.cpp:17
void colorOnChanged(QColor newColorOn)
bool isLit()
Definition: qeled.hpp:36
bool isNegated()
Definition: qeled.hpp:37