@@ -44,12 +44,20 @@ Lights::~Lights()
45void Lights::setState(Lights::State newState)
45void Lights::setState(Lights::State newState)
48+ qWarning() << "No lights device";
47 if (m_state != newState) {
52 if (m_state != newState) {
48 if (newState == Lights::On) {
53 if (newState == Lights::On) {
51 turnOff();
56 turnOff();
60+ Q_EMIT stateChanged(m_state);
@@ -115,6 +123,7 @@ bool Lights::init()
115 err = module->methods->open(module, LIGHT_ID_NOTIFICATIONS, &device);
123 err = module->methods->open(module, LIGHT_ID_NOTIFICATIONS, &device);
116 if (err == 0) {
124 if (err == 0) {
117 m_lightDevice = (light_device_t*)device;
125 m_lightDevice = (light_device_t*)device;
118 return true;
127 return true;
120 qWarning() << "Failed to access notification lights";
129 qWarning() << "Failed to access notification lights";
@@ -127,15 +136,6 @@ bool Lights::init()
128void Lights::turnOn()
137void Lights::turnOn()
131− qWarning() << "No lights device";
135− if (m_state == Lights::On) {
140 light_state_t state;
140 light_state_t state;
141 memset(&state, 0, sizeof(light_state_t));
141 memset(&state, 0, sizeof(light_state_t));
@@ -147,23 +147,11 @@ void Lights::turnOn()
148 if (m_lightDevice->set_light(m_lightDevice, &state) != 0) {
148 if (m_lightDevice->set_light(m_lightDevice, &state) != 0) {
149 qWarning() << "Failed to turn the light off";
149 qWarning() << "Failed to turn the light off";
151− m_state = Lights::On;
152− Q_EMIT stateChanged(m_state);
156void Lights::turnOff()
153void Lights::turnOff()
159− qWarning() << "No lights device";
163− if (m_state == Lights::Off) {
167 light_state_t state;
155 light_state_t state;
168 memset(&state, 0, sizeof(light_state_t));
156 memset(&state, 0, sizeof(light_state_t));
169 state.color = 0x00000000;
157 state.color = 0x00000000;
@@ -174,8 +162,5 @@ void Lights::turnOff()
175 if (m_lightDevice->set_light(m_lightDevice, &state) != 0) {
163 if (m_lightDevice->set_light(m_lightDevice, &state) != 0) {
176 qWarning() << "Failed to turn the light off";
164 qWarning() << "Failed to turn the light off";
178− m_state = Lights::Off;
179− Q_EMIT stateChanged(m_state);