2 * Copyright 2016 Konsulko Group
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 // BUG: ValueChanged event is raised by sliders when you are moving the caret, should be raised only when you release it.
18 // TODO: Call mixer.setVolume(sliderName, Value) on value change
19 // TODO: Call mixer.getVolume(sliderName) on load
22 import QtQuick.Layouts 1.1
23 import QtQuick.Controls 2.0
24 import AGL.Demo.Controls 1.0
31 property Component volumeSlider
39 signal sliderVolumeChanged(string role, int value)
46 onSliderVolumeChanged: {
47 console.log("======role: " + role + ", volume: " + value);
48 mixer.setVolume(role, value);
51 Component.onCompleted: {
52 root.volumeSlider = Qt.createComponent("VolumeSlider.qml");
53 if (root.VolumeSlider.status !== Component.Ready) {
54 console.log("Failed to load the VolumeSlider.qml component: " + root.volumeSlider.errorString());
56 mixer.open(bindingAddress);
60 // Remove existing sliders
61 for(var i = sliders.children.length; i > 0 ; --i) {
62 console.log("destroying: " + i);
63 sliders.children[i-1].destroy();
66 // Add slider for each role
67 for(var j = 0; j < mixer.roles.length; ++j) {
68 addSlider(mixer.roles[j]);
73 console.log("onVolumeChanged(\"" + name + "\", " + value + ")");
74 for(var i = 0; i < sliders.children.length ; i++) {
75 var sld = sliders.children[i];
76 console.log(i + " - Slider found:" + sld + "[\"" + sld.role + "\"] = " + sld.value);
77 if (sld.role === name) {
84 function addSlider(name) {
85 var sld = root.volumeSlider.createObject(sliders)
87 sld.onSliderValueChanged.connect(mixer.sliderVolumeChanged)
88 mixer.getVolume(name); // Update volume
91 function deleteChilds(item) {
92 for(var i = item.children.length; i > 0 ; i--) {
93 deleteChilds(item.children[i-1]);
103 anchors.horizontalCenter: parent.horizontalCenter
109 anchors.top: title.bottom
110 anchors.left: parent.left
111 anchors.right: parent.right