mixer: add clearer pulseaudio control naming
[apps/mixer.git] / app / Mixer.qml
1 /*
2  * Copyright 2016 Konsulko Group
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 import QtQuick 2.6
18 import QtQuick.Layouts 1.1
19 import QtQuick.Controls 2.0
20 import AGL.Demo.Controls 1.0
21 import PaControlModel 1.0
22
23 ApplicationWindow {
24         id: root
25
26         Label { 
27                 id: title
28                 font.pixelSize: 48
29                 text: "Mixer"
30                 anchors.horizontalCenter: parent.horizontalCenter
31         }
32
33         Component {
34                 id: ctldesc
35                 Label {
36                         font.pixelSize: 32
37                         width: listView.width
38                         wrapMode: Text.WordWrap
39                         property var typeString: {modelType ? "Output" : "Input"}
40                         text: "[" + typeString + " #" + modelCIndex + "]: " + modelDesc
41                 }
42         }
43
44         Component {
45                 id: empty
46                 Item {
47                 }
48         }
49
50         ListView {
51                 id: listView
52                 anchors.left: parent.left
53                 anchors.top: title.bottom
54                 anchors.margins: 80
55                 anchors.fill: parent
56                 model: PaControlModel { objectName: "pacm" }
57                 delegate: ColumnLayout {
58                         width: parent.width
59                         spacing: 40
60                         Connections {
61                                 target: listView.model
62                                 onDataChanged: slider.value = volume
63                         }
64                         Loader {
65                                 property int modelType: type
66                                 property int modelCIndex: cindex
67                                 property string modelDesc: name
68                                 sourceComponent: (channel == 0) ? ctldesc : empty
69                         }
70                         RowLayout {
71                                 Layout.minimumHeight: 75
72                                 Label {
73                                         font.pixelSize: 24
74                                         text: cdesc
75                                         Layout.minimumWidth: 150
76                                 }
77                                 Label {
78                                         font.pixelSize: 24
79                                         text: "0 %"
80                                 }
81                                 Slider {
82                                         id: slider
83                                         Layout.fillWidth: true
84                                         from: 0
85                                         to: 65536
86                                         stepSize: 256
87                                         snapMode: Slider.SnapOnRelease
88                                         onValueChanged: volume = value
89                                         Component.onCompleted: value = volume
90                                 }
91                                 Label {
92                                         font.pixelSize: 24
93                                         text: "100 %"
94                                 }
95                         }
96                 }
97         }
98 }