This repository has been archived by the owner on Jan 28, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
light.h
51 lines (40 loc) · 1.64 KB
/
light.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef LIGHT_H
#define LIGHT_H
#include <QObject>
#include <QString>
#include <QColor>
#include <QVariant>
#include <QMetaEnum>
#include "entity.h"
#include "lightinterface.h"
class Light : public Entity, LightInterface
{
Q_OBJECT
Q_INTERFACES(LightInterface)
public:
Q_PROPERTY (int brightness READ brightness NOTIFY brightnessChanged)
Q_PROPERTY (QColor color READ color NOTIFY colorChanged)
Q_PROPERTY (int colorTemp READ colorTemp NOTIFY colorTempChanged)
// light commands
Q_INVOKABLE void toggle ();
Q_INVOKABLE void setBrightness (int value);
Q_INVOKABLE void setColor (QColor value);
Q_INVOKABLE void setColorTemp (int value);
bool updateAttrByIndex (int attrIndex, const QVariant& value) override;
int brightness() override { return m_brightness; }
QColor color() override { return m_color; }
int colorTemp() override { return m_colorTemp; }
bool isOn() override { return m_state == LightDef::ON; }
explicit Light(const QVariantMap& config, QObject* integrationObj, QObject *parent = nullptr);
signals:
void brightnessChanged();
void colorChanged();
void colorTempChanged();
public:
static QString Type;
private:
QColor m_color;
int m_brightness;
int m_colorTemp;
};
#endif // LIGHT_H