Implemented timeout for restoring original state.

Former-commit-id: 925b063aba1a859b592ead9b75ce67d90fb81e28
This commit is contained in:
ntim
2014-05-03 10:12:41 +02:00
parent 9220c346bb
commit 8cca280fdc
3 changed files with 16 additions and 5 deletions

View File

@@ -13,6 +13,9 @@
LedDevicePhilipsHue::LedDevicePhilipsHue(const std::string& output) :
host(output.c_str()), username("newdeveloper") {
http = new QHttp(host);
timer.setInterval(1000);
timer.setSingleShot(true);
connect(&timer, SIGNAL(timeout()), this, SLOT(restoreStates()()));
}
LedDevicePhilipsHue::~LedDevicePhilipsHue() {
@@ -37,10 +40,12 @@ int LedDevicePhilipsHue::write(const std::vector<ColorRgb> & ledValues) {
// Next light id.
lightId++;
}
timer.start();
return 0;
}
int LedDevicePhilipsHue::switchOff() {
timer.stop();
// If light states have been saved before, ...
if (statesSaved()) {
// ... restore them.