summaryrefslogtreecommitdiffstats
path: root/app/audiorole.cpp
diff options
context:
space:
mode:
authorLoïc Collignon <loic.collignon@iot.bzh>2018-12-18 17:16:35 +0100
committerLoïc Collignon [ IoT.bzh ] <loic.collignon@iot.bzh>2018-12-19 10:06:56 +0000
commitd32d36b936cb031ba1b11c67c0d9c6afbdc280b3 (patch)
treea5a09e31bb41ced3ddea5dddf92530d187da4341 /app/audiorole.cpp
parentf8da591c53f17df877e354896dbbf18410c53b6c (diff)
Reworked the way qml create sliders
Use the qml MVC to populate a ListView with components based on a template VolumeSlider. Should now handle potential disconnections, volume changes by third-party and also fix the issue where sliders are set to 0 at startup. Change-Id: I2961d5a1584a121c473ece253faa90a747c64445 Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
Diffstat (limited to 'app/audiorole.cpp')
-rw-r--r--app/audiorole.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/app/audiorole.cpp b/app/audiorole.cpp
new file mode 100644
index 0000000..5fad48f
--- /dev/null
+++ b/app/audiorole.cpp
@@ -0,0 +1,54 @@
+#include "audiorole.hpp"
+
+AudioRole::AudioRole(QObject* parent)
+ : QObject(parent)
+ , m_Name{""}
+ , m_Value{0}
+ , m_Updating{0}
+{
+}
+
+AudioRole::AudioRole(const QString& name, int value, QObject* parent)
+ : QObject(parent)
+ , m_Name{name}
+ , m_Value{value}
+ , m_Updating{0}
+{
+}
+
+QString AudioRole::Name() const
+{
+ return m_Name;
+}
+
+void AudioRole::setName(const QString& name)
+{
+ m_Name = name;
+ emit NameChanged();
+}
+
+int AudioRole::Value() const
+{
+ return m_Value;
+}
+
+void AudioRole::setValue(int value)
+{
+ if (m_Value != value)
+ {
+ m_Value = value;
+ if (m_Updating == 0)
+ emit ValueChanged();
+ }
+}
+
+void AudioRole::BeginUpdate()
+{
+ m_Updating++;
+}
+
+void AudioRole::EndUpdate()
+{
+ if (m_Updating > 0) m_Updating--;
+ //if (m_Updating == 0) emit ValueChanged();
+}