itom  4.1.0
statusLed.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom and its software development toolkit (SDK).
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  In addition, as a special exception, the Institut fuer Technische
15  Optik (ITO) gives you certain additional rights.
16  These rights are described in the ITO LGPL Exception version 1.0,
17  which can be found in the file LGPL_EXCEPTION.txt in this package.
18 
19  itom is distributed in the hope that it will be useful, but
20  WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
22  General Public Licence for more details.
23 
24  You should have received a copy of the GNU Library General Public License
25  along with itom. If not, see <http://www.gnu.org/licenses/>.
26 
27 *********************************************************************** */
28 
29 #ifndef STATUSLED_H
30 #define STATUSLED_H
31 
32 #include <QWidget>
33 #include <qpen.h>
34 
35 #include "commonWidgets.h"
36 
37 class StatusLedPrivate; // forward declare
38 
45 class ITOMWIDGETS_EXPORT StatusLed : public QWidget
46 {
47  Q_OBJECT
48 
49  Q_PROPERTY(QColor colorOnEdge READ colorOnEdge WRITE setColorOnEdge);
50  Q_PROPERTY(QColor colorOnCenter READ colorOnCenter WRITE setColorOnCenter);
51  Q_PROPERTY(QColor colorOffEdge READ colorOffEdge WRITE setColorOffEdge);
52  Q_PROPERTY(QColor colorOffCenter READ colorOffCenter WRITE setColorOffCenter);
53  Q_PROPERTY(bool checked READ checked WRITE setChecked);
54 
55 public:
56 
57  explicit StatusLed(QWidget *parent = 0);
58  virtual ~StatusLed();
59 
60  virtual QSize sizeHint() const
61  {
62  return QSize(32,32);
63  }
64 
65  virtual QSize minimumSizeHint() const
66  {
67  return QSize(16,16);
68  }
69 
70  virtual int heightForWidth(int w) const
71  {
72  return w;
73  }
74 
75  bool checked() const;
76  QColor colorOnEdge() const;
77  QColor colorOnCenter() const;
78  QColor colorOffEdge() const;
79  QColor colorOffCenter() const;
80 
81 public Q_SLOTS:
82  void setColorOnEdge(const QColor &color);
83  void setColorOnCenter(const QColor &color);
84  void setColorOffEdge(const QColor &color);
85  void setColorOffCenter(const QColor &color);
86  void setChecked(bool checked);
87 
88 protected:
89  virtual void paintEvent(QPaintEvent *event);
90 
91  QScopedPointer<StatusLedPrivate> d_ptr; // QScopedPointer to forward declared class
92 
93 private:
94  Q_DECLARE_PRIVATE(StatusLed);
95  Q_DISABLE_COPY(StatusLed);
96 };
97 
98 #endif // STATUSLED_H
Definition: statusLed.cpp:33
Round LED-style widget with gradient fill.
Definition: statusLed.h:45