2
* This file is part of uvolman.dfiloni
4
* Copyright (C) 2016 Devid Antonio Filoni https://launchpad.net/~d.filoni
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
import Ubuntu.Components 1.3
24
\brief MainView with a Label and Button elements.
28
// objectName for functional testing purposes (autopilot-qt5)
30
objectName: "mainView"
32
// Note! applicationName needs to match the "name" field of the click manifest
33
applicationName: "uvolman.dfiloni"
34
property string applicationVersion: "0.1"
41
Component.onCompleted: push(mainPage)
48
anchors.top: mainPage.top
50
title: i18n.tr("uVolMan")
52
foregroundColor: UbuntuColors.orange
53
backgroundColor: UbuntuColors.porcelain
54
dividerColor: UbuntuColors.warmGrey//UbuntuColors.slate
60
text: i18n.tr("About")
61
onTriggered: mainStack.push(Qt.resolvedUrl("AboutPage.qml"))
68
IndicatorSoundService {
69
id: indicatorSoundService
70
property real cachedVolume: indicatorSoundService.getVolume();
71
property real cachedMicVolume: indicatorSoundService.getMicVolume();
73
if (cachedVolume !== newValue)
75
cachedVolume = newValue;
76
if (volumeSlider.slider.value !== cachedVolume)
77
volumeSlider.slider.value = cachedVolume;
81
if (cachedMicVolume !== newValue)
83
cachedMicVolume = newValue;
84
if (micVolumeSlider.slider.value !== cachedMicVolume)
85
micVolumeSlider.slider.value = cachedMicVolume;
91
id: pulseStreamRestore
95
anchors.top: pageHeader.bottom
96
anchors.left: parent.left
97
anchors.right: parent.right
98
height: parent.height-pageHeader.height
99
contentHeight: mainColumn.height
100
flickableDirection: Flickable.VerticalFlick
104
anchors.left: parent.left
105
anchors.right: parent.right
106
anchors.top: parent.top
109
id: indicatorSoundLabel
113
leftMargin: units.gu(2)
114
topMargin: units.gu(3);
115
bottomMargin: units.gu(2);
117
horizontalAlignment: Text.AlignLeft
118
text: i18n.tr("Indicator.Sound")
119
font.pixelSize: units.gu(2);
121
divider.visible: false
126
property bool firstValueChange: false
127
labelText: i18n.tr("Speakers")
128
slider.value: indicatorSoundService.cachedVolume
129
slider.onValueChanged: {
130
if (indicatorSoundService.cachedVolume !== slider.value)
131
indicatorSoundService.setVolume(slider.value);
133
enabled: (indicatorSoundService.cachedVolume != -1)
134
divider.visible: (indicatorSoundService.cachedVolume != -1)
137
id: volumeSliderError
138
visible: (indicatorSoundService.cachedVolume == -1)
139
height: visible ? units.gu(3) : 0
144
leftMargin: units.gu(2)
146
horizontalAlignment: Text.AlignLeft
147
text: i18n.tr("Speakers configuration not available!")
153
property bool firstValueChange: false
154
labelText: i18n.tr("Microphone")
155
slider.value: indicatorSoundService.cachedMicVolume
156
slider.onValueChanged: {
157
if (indicatorSoundService.cachedMicVolume !== slider.value)
158
indicatorSoundService.setMicVolume(slider.value);
160
enabled: (indicatorSoundService.cachedMicVolume != -1)
161
divider.visible: (indicatorSoundService.cachedMicVolume != -1)
164
id: micVolumeSliderError
165
visible: (indicatorSoundService.cachedMicVolume == -1)
166
height: visible ? units.gu(3) : 0
171
leftMargin: units.gu(2)
173
horizontalAlignment: Text.AlignLeft
174
text: i18n.tr("Microphone configuration not available!")
181
id: streamRestoreEntriesLabel
182
anchors.left: parent.left
183
anchors.right: parent.right
188
leftMargin: units.gu(2)
189
topMargin: units.gu(3);
190
bottomMargin: units.gu(2);
192
horizontalAlignment: Text.AlignLeft
193
text: i18n.tr("PulseAudio.Ext.StreamRestore1")
194
font.pixelSize: units.gu(2);
198
id: streamRestoreEntriesCheckbox
199
property bool checked: false
200
onClicked: checked = !checked;
204
anchors.margins: units.gu(0.1);
206
color: streamRestoreEntriesCheckbox.checked ? "white" : "#808080"
212
rightMargin: units.gu(2);
213
topMargin: units.gu(2.75);
218
defaultColor: streamRestoreEntriesCheckbox.checked ? "#808080" : "white"
220
visible: (pulseStreamRestore.isConnected())
223
id: streamRestoreEntriesCheckbox
228
rightMargin: units.gu(2);
229
topMargin: units.gu(3);
231
visible: (pulseStreamRestore.isConnected())
234
divider.visible: false
238
id: streamRestoreEntriesList
239
anchors.left: parent.left
240
anchors.right: parent.right
242
function extractEntriesKeys()
245
for (var entry in pulseStreamRestore.getEntries())
251
model: streamRestoreEntriesList.extractEntriesKeys()
253
property variant entryObj: false
254
slider.onValueChanged: {
255
entryObj.setVolume(slider.value);
260
ignoreUnknownSignals: true
262
slider.value = newValue;
267
var entries = pulseStreamRestore.getEntries();
268
var entries_keys = streamRestoreEntriesList.extractEntriesKeys();
269
item.entryObj = entries[entries_keys[index]];
270
item.labelText = item.entryObj.getName();
271
item.slider.value = item.entryObj.getVolume();
274
enabled: (pulseStreamRestore.isConnected() && streamRestoreEntriesCheckbox.checked)
275
visible: pulseStreamRestore.isConnected()
278
id: streamRestoreEntriesListError
284
topMargin: units.gu(1)
285
leftMargin: units.gu(2)
287
horizontalAlignment: Text.AlignLeft
288
text: i18n.tr("StreamRestore1 configuration not available!")
289
visible: (!pulseStreamRestore.isConnected())
291
divider.visible: (!pulseStreamRestore.isConnected())