qledindicator.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /***************************************************************************
  2. * Copyright (C) 2010 by Tn *
  3. * thenobody@poczta.fm *
  4. * *
  5. * This program is free software; you can redistribute it and/or modify *
  6. * it under the terms of the GNU Library General Public License as *
  7. * published by the Free Software Foundation; either version 3 of the *
  8. * License, or (at your option) any later version. *
  9. * *
  10. * This program is distributed in the hope that it will be useful, *
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13. * GNU General Public License for more details. *
  14. * *
  15. * You should have received a copy of the GNU Library General Public *
  16. * License along with this program; if not, write to the *
  17. * Free Software Foundation, Inc., *
  18. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  19. ***************************************************************************/
  20. #ifndef QLEDINDICATOR_H
  21. #define QLEDINDICATOR_H
  22. #include <QWidget>
  23. #include <QResizeEvent>
  24. #include <QColor>
  25. #include <QDebug>
  26. class QLedIndicator: public QWidget
  27. {
  28. Q_PROPERTY(QColor onColor1 WRITE setOnColor1 READ getOnColor1 );Q_PROPERTY(QColor onColor2 WRITE setOnColor2 READ getOnColor2 );Q_PROPERTY(QColor offColor1 WRITE setOffColor1 READ getOffColor1 );Q_PROPERTY(QColor offColor2 WRITE setOffColor2 READ getOffColor2 );Q_OBJECT
  29. public:
  30. QLedIndicator(QWidget *parent);
  31. void setOnColor1(QColor c)
  32. {
  33. onColor1 = c;
  34. }
  35. void setOffColor1(QColor c)
  36. {
  37. offColor1 = c;
  38. }
  39. void setOnColor2(QColor c)
  40. {
  41. onColor2 = c;
  42. }
  43. void setOffColor2(QColor c)
  44. {
  45. offColor2 = c;
  46. }
  47. QColor getOnColor1(void)
  48. {
  49. return onColor1;
  50. }
  51. QColor getOffColor1(void)
  52. {
  53. return offColor1;
  54. }
  55. QColor getOnColor2(void)
  56. {
  57. return onColor2;
  58. }
  59. QColor getOffColor2(void)
  60. {
  61. return offColor2;
  62. }
  63. void setChecked(bool checked);
  64. bool isChecked() const;
  65. protected:
  66. virtual void paintEvent(QPaintEvent *event);
  67. private:
  68. bool checked;
  69. static const qreal scaledSize;
  70. QColor onColor1, offColor1;
  71. QColor onColor2, offColor2;
  72. QPixmap ledBuffer;
  73. };
  74. #endif // QLEDINDICATOR_H