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.
18 import QtQuick.Layouts 1.1
19 import QtQuick.Controls 2.0
20 import AGL.Demo.Controls 1.0
27 property Component volumeSlider
35 signal sliderVolumeChanged(string role, int value)
42 onSliderVolumeChanged: {
43 console.log("======role: " + role + ", volume: " + value);
44 mixer.setVolume(role, value);
47 Component.onCompleted: {
48 var vs = Qt.createComponent("VolumeSlider.qml");
49 if (vs.status !== Component.Ready) {
50 console.log("Failed to load the VolumeSlider.qml component: " + vs.errorString());
52 root.volumeSlider = vs
53 mixer.open(bindingAddress);
57 // Remove existing sliders
58 for(var i = sliders.children.length; i > 0 ; --i) {
59 console.log("destroying: " + i);
60 sliders.children[i-1].destroy();
63 // Add slider for each role
64 for(var j = 0; j < mixer.roles.length; ++j) {
65 addSlider(mixer.roles[j]);
70 console.log("onVolumeChanged(\"" + name + "\", " + value + ")");
71 for(var i = 0; i < sliders.children.length ; i++) {
72 var sld = sliders.children[i];
73 console.log(i + " - Slider found:" + sld + "[\"" + sld.role + "\"] = " + sld.value);
74 if (sld.role === name) {
81 function addSlider(name) {
82 var sld = root.volumeSlider.createObject(sliders)
84 sld.onSliderValueChanged.connect(mixer.sliderVolumeChanged)
85 mixer.getVolume(name); // Update volume
88 function deleteChilds(item) {
89 for(var i = item.children.length; i > 0 ; i--) {
90 deleteChilds(item.children[i-1]);
100 anchors.horizontalCenter: parent.horizontalCenter
106 anchors.top: title.bottom
107 anchors.left: parent.left
108 anchors.right: parent.right