diff options
author | Loïc Collignon <loic.collignon@iot.bzh> | 2018-12-18 17:16:35 +0100 |
---|---|---|
committer | Loïc Collignon <loic.collignon@iot.bzh> | 2018-12-19 18:26:34 +0100 |
commit | 449ae663fadf654bbe46f6e4c927a60e8d1a61bb (patch) | |
tree | 4cb17287002965e1f661ff521221d607982caea7 /app/audiorole.cpp | |
parent | 34ff9f8c02a90fa0cce8ee6c1d4b87c300771bdc (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.cpp | 54 |
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(); +} |