diff options
author | Loïc Collignon <loic.collignon@iot.bzh> | 2018-07-05 14:30:25 +0200 |
---|---|---|
committer | Loïc Collignon <loic.collignon@iot.bzh> | 2018-07-10 19:21:41 +0200 |
commit | d009b2e3665ab49ce8885a7d1f59d67bdaf4cd7e (patch) | |
tree | 38337c044e2c50989ffc98cc7c5d2b9598f36eca /app/mixer.cpp | |
parent | 9b2c0778e6b83591cbad1d9c76cbcad2186512d9 (diff) |
WIP better handling for slider creation
The creation of sliders is now using a template instead of a string
computation.
Also fixed some indentation and trailing spaces issues.
Change-Id: Ieb1d9f953d61fa1bac46bf1ab6904e67d09a3fa9
Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
Diffstat (limited to 'app/mixer.cpp')
-rw-r--r-- | app/mixer.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/app/mixer.cpp b/app/mixer.cpp index 6614569..6a1245c 100644 --- a/app/mixer.cpp +++ b/app/mixer.cpp @@ -61,7 +61,7 @@ void Mixer::setVolume(const QString& name, int value) QJsonObject arg; arg.insert("action", "volume"); arg.insert("value", QJsonValue(value)); - m_client.call("ahl-4a", name, arg, [this, name](bool r, const QJsonValue& v) { + m_client.call("ahl-4a", name, arg, [name](bool r, const QJsonValue& v) { if (r && v.isObject()) { // TODO: Success, update the slider @@ -82,6 +82,13 @@ void Mixer::getVolume(const QString& name) if (r && v.isObject()) { // TODO: Success, update the slider + int newVolume = v.toObject()["response"].toObject()["volnew"].toInt(); + auto currentVolume = volumes_.find(name); + if (currentVolume != volumes_.end() && *currentVolume == newVolume) + return; + + volumes_[name] = newVolume; + emit volumeChanged(name, newVolume); } else { |