summaryrefslogtreecommitdiffstats
path: root/app/Mixer.qml
diff options
context:
space:
mode:
authorLoïc Collignon <loic.collignon@iot.bzh>2018-06-15 23:31:34 +0200
committerLoïc Collignon <loic.collignon@iot.bzh>2018-06-16 18:44:22 +0200
commit62bb1f0ceab710c594021c715017560f4e5f25da (patch)
treeb3a656bea2adce533b4336e246a3fd60e6b173df /app/Mixer.qml
parent2aabd6ae0f05d91253f492ff1659626d3090cabe (diff)
WIP version based on 4a High Level APIeel_5.1.0eel/5.1.05.1.0eel
This is a non-completly working version based on the 4a High Level API. It displays one slider per audio role, should be able to set volume on roles, but sliders are not in sync and moving a slider cause a lot of calls due to bug. Supposed to be fixed soon. Also, had to hack the autobuild script cause it make cmake to fail. Obsiously, target 'package' should run 'make widget'... Change-Id: Ic16ed484e090ebc853e59b836ff1570afdcfce3b Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
Diffstat (limited to 'app/Mixer.qml')
-rw-r--r--app/Mixer.qml130
1 files changed, 53 insertions, 77 deletions
diff --git a/app/Mixer.qml b/app/Mixer.qml
index 2b6d5cc..8b1ba06 100644
--- a/app/Mixer.qml
+++ b/app/Mixer.qml
@@ -14,6 +14,10 @@
* limitations under the License.
*/
+// BUG: ValueChanged event is raised by sliders when you are moving the caret, should be raised only when you release it.
+// TODO: Call mixer.setVolume(sliderName, Value) on value change
+// TODO: Call mixer.getVolume(sliderName) on load
+
import QtQuick 2.6
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.0
@@ -21,111 +25,83 @@ import AGL.Demo.Controls 1.0
import Mixer 1.0
ApplicationWindow {
- id: root
+ id: root
Mixer {
id: mixer
Component.objectName: {
mixer.open(bindingAddress)
}
- onMasterVolumeChanged: sliderMasterVolume.value = masterVolume
- onPcmVolumeChanged: sliderPcmVolume.value = pcmVolume
- onMicrophoneVolumeChanged: sliderMicrophoneVolume.value = microphoneVolume
- }
-
- Label {
- id: title
- font.pixelSize: 48
- text: "Mixer"
- anchors.horizontalCenter: parent.horizontalCenter
- }
-
- ColumnLayout {
- anchors.margins: 80
- anchors.top: title.bottom
- anchors.left: parent.left
- anchors.right: parent.right
+ onRolesChanged: {
+ // Remove existing sliders
+ for(var i = sliders.children.length; i > 0 ; --i) {
+ console.log("destroying: " + i)
+ sliders.children[i-1].destroy()
+ }
- ComboBox {
- id: soundCardSelector
- anchors.left: parent.left
- anchors.right: parent.right
- model: mixer.hals
- onCurrentIndexChanged: mixer.ActiveHal = currentIndex
+ // Add slider for each role
+ for(var j = 0; j < mixer.roles.length; ++j) {
+ addSlider(mixer.roles[j])
+ }
}
- RowLayout {
+ function addSlider(name) {
+ Qt.createQmlObject("
+import QtQuick.Layouts 1.1
+import QtQuick.Controls 2.0
+RowLayout {
+ property int value
+ id: slider_" + name + "
Layout.minimumHeight: 75
Label {
font.pixelSize: 24
- text: "Master"
+ text: \"" + name+ "\"
Layout.minimumWidth: 150
}
Label {
- id: textMasterVolume
+ id: slider_" + name + "_textvalue
font.pixelSize: 24
- text: "0 %"
+ text: \"0 %\"
}
Slider {
- id: sliderMasterVolume
+ id: slider_" + name + "_slider
Layout.fillWidth: true
from: 0
to: 100
stepSize: 1
snapMode: Slider.SnapOnRelease
onValueChanged: {
- textMasterVolume.text = value + " %"
- mixer.masterVolume = value
+ slider_" + name + "_textvalue.text = value + \" %\"
+ mixer.setVolume(\"" + name + "\", value)
+ }
+ Component.objectName: {
+ mixer.getVolume(\"" + name + "\")
}
}
+ }", sliders, "volumeslider")
}
-/*
- RowLayout {
- Layout.minimumHeight: 75
- Label {
- font.pixelSize: 24
- text: "PCM"
- Layout.minimumWidth: 150
- }
- Label {
- font.pixelSize: 24
- text: "0 %"
- }
- Slider {
- id: sliderPcmVolume
- Layout.fillWidth: true
- from: 0
- to: 100
- stepSize: 1
- snapMode: Slider.SnapOnRelease
- onValueChanged: mixer.pcmVolume = value
- }
- }
-*/
- RowLayout {
- Layout.minimumHeight: 75
- Label {
- font.pixelSize: 24
- text: "Microphone"
- Layout.minimumWidth: 150
- }
- Label {
- id: textMicrophoneVolume
- font.pixelSize: 24
- text: "0 %"
- }
- Slider {
- id: sliderMicrophoneVolume
- Layout.fillWidth: true
- from: 0
- to: 100
- stepSize: 1
- snapMode: Slider.SnapOnRelease
- onValueChanged: {
- textMicrophoneVolume.text = value + " %"
- mixer.microphoneVolume = value
- }
+
+ function deleteChilds(item) {
+ for(var i = item.children.length; i > 0 ; i--) {
+ deleteChilds(item.children[i-1])
}
+ item.destroy()
}
}
+
+ Label {
+ id: title
+ font.pixelSize: 48
+ text: "Mixer"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ ColumnLayout {
+ id: sliders
+ anchors.margins: 80
+ anchors.top: title.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ }
}
+