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
31 width: container.width * container.scale
32 height: container.height * container.scale
37 signal sliderVolumeChanged(string role, int value)
44 onSliderVolumeChanged: {
45 console.log("======role: " + role + ", volume: " + value);
46 mixer.setVolume(role, value);
49 Component.onCompleted: {
50 var vs = Qt.createComponent("VolumeSlider.qml");
51 if (vs.status !== Component.Ready) {
52 console.log("Failed to load the VolumeSlider.qml component: " + vs.errorString());
54 root.volumeSlider = vs
55 mixer.open(bindingAddress);
59 // Remove existing sliders
60 for(var i = sliders.children.length; i > 0 ; --i) {
61 console.log("destroying: " + i);
62 sliders.children[i-1].destroy();
65 // Add slider for each role
66 for(var j = 0; j < mixer.roles.length; ++j) {
67 addSlider(mixer.roles[j]);
72 console.log("onVolumeChanged(\"" + name + "\", " + value + ")");
73 for(var i = 0; i < sliders.children.length ; i++) {
74 var sld = sliders.children[i];
75 console.log(i + " - Slider found:" + sld + "[\"" + sld.role + "\"] = " + sld.value);
76 if (sld.role === name) {
83 function addSlider(name) {
84 var sld = root.volumeSlider.createObject(sliders)
86 sld.onSliderValueChanged.connect(mixer.sliderVolumeChanged)
87 mixer.getVolume(name); // Update volume
90 function deleteChilds(item) {
91 for(var i = item.children.length; i > 0 ; i--) {
92 deleteChilds(item.children[i-1]);
100 anchors.centerIn: parent
103 scale: screenInfo.scale_factor()
109 anchors.horizontalCenter: parent.horizontalCenter
115 anchors.top: title.bottom
116 anchors.left: parent.left
117 anchors.right: parent.right