summaryrefslogtreecommitdiffstats
path: root/app/Mixer.qml
diff options
context:
space:
mode:
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
+ }
}
+