Unity 8
Lights.h
1 /*
2  * Copyright (C) 2014 Canonical, Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Author: Renato Araujo Oliveira Filho <renato.filho@canonical.com>
17  */
18 
19 #ifndef UNITY_LIGHTS_H
20 #define UNITY_LIGHTS_H
21 
22 #include <QtCore/QObject>
23 #include <QtGui/QColor>
24 
25 class Lights: public QObject
26 {
27  Q_OBJECT
28  Q_PROPERTY(State state READ state WRITE setState NOTIFY stateChanged)
29  Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
30  Q_PROPERTY(int onMillisec READ onMillisec WRITE setOnMillisec NOTIFY onMillisecChanged)
31  Q_PROPERTY(int offMillisec READ offMillisec WRITE setOffMillisec NOTIFY offMillisecChanged)
32 
33 public:
34  enum State {
35  Off,
36  On,
37  };
38  Q_ENUM(State)
39 
40  explicit Lights(QObject *parent = 0);
41 
42  void setState(State newState);
43  State state() const;
44 
45  void setColor(const QColor &color);
46  QColor color() const;
47 
48  int onMillisec() const;
49  void setOnMillisec(int onMs);
50 
51  int offMillisec() const;
52  void setOffMillisec(int offMs);
53 
54 Q_SIGNALS:
55  void stateChanged(State newState);
56  void colorChanged(const QColor &color);
57  void onMillisecChanged(int onMs);
58  void offMillisecChanged(int offMs);
59 
60 protected:
61  QColor m_color;
62  State m_state;
63  int m_onMs;
64  int m_offMs;
65 
66  virtual bool init() = 0;
67  virtual void turnOff() = 0;
68  virtual void turnOn() = 0;
69 };
70 
71 #endif