agl-compositor: Conversion to agl-compositor
[apps/homescreen.git] / homescreen / qml / MediaAreaBlank.qml
1 /*
2  * Copyright (C) 2016 The Qt Company Ltd.
3  * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 import QtQuick 2.2
19 import QtQuick.Layouts 1.1
20 import QtQuick.Controls 2.0
21 import AGL.Demo.Controls 1.0
22 import MasterVolume 1.0
23
24 Image {
25     anchors.fill: parent
26     source: './images/Utility_Logo_Background-01.svg'
27     property bool displayVolume: false;
28
29     MouseArea {
30         anchors.fill: parent
31         function enableVolumeDisplay() {
32             if (!displayVolume) {
33                 displayVolume = true
34                 master_volume.visible = true
35                 volume_timer.restart()
36             }
37         }
38         onClicked: enableVolumeDisplay()
39     }
40
41     Image {
42         id: logo_image
43         anchors.centerIn: parent
44         source: './images/Utility_Logo_Grey-01.svg'
45     }
46
47     Timer {
48         id: volume_timer
49         interval: 3000; running: false; repeat: false
50         onTriggered: displayVolume = false
51     }
52
53     states: [
54     State { when: displayVolume;
55     PropertyChanges { target: master_volume; opacity: 1.0 }
56     PropertyChanges { target: slider; enabled: true }
57     PropertyChanges { target: logo_image; opacity: 0.0 }
58     PropertyChanges { target: speech_chrome; visible: false }
59     },
60     State { when: !displayVolume;
61     PropertyChanges { target: master_volume; opacity: 0.0 }
62     PropertyChanges { target: slider; enabled: false }
63     PropertyChanges { target: logo_image; opacity: 1.0 }
64     PropertyChanges { target: speech_chrome; visible: speech_chrome.agentPresent }
65     }
66     ]
67
68     transitions: Transition {
69     NumberAnimation { property: "opacity"; duration: 500}
70     }
71
72     MasterVolume {
73         id: mv
74         objectName: "mv"
75         onVolumeChanged: slider.value = volume
76         Component.onCompleted: {
77             mv.open(bindingAddress);
78         }
79     }
80
81     Item {
82         id: master_volume
83         anchors.fill: parent
84         anchors.centerIn: parent
85         visible: false
86
87         Label {
88             font.pixelSize: 36
89             anchors.horizontalCenter: parent.horizontalCenter
90             color: "white"
91             text: qsTr("Master Volume")
92         }
93
94         RowLayout {
95             anchors.fill: parent
96             anchors.centerIn: parent
97             anchors.margins: 20
98             spacing: 20
99             Label {
100                 font.pixelSize: 36
101                 color: "white"
102                 text: "0 %"
103             }
104             Slider {
105                 id: slider
106                 Layout.fillWidth: true
107                 from: 0
108                 to: 100
109                 stepSize: 1
110                 snapMode: Slider.SnapOnRelease
111                 onValueChanged: mv.volume = value
112                 Component.onCompleted: value = mv.volume
113                 onPressedChanged: {
114                     if (pressed) {volume_timer.stop()}
115                     else {volume_timer.restart()}
116                 }
117             }
118             Label {
119                 font.pixelSize: 36
120                 color: "white"
121                 text: "100 %"
122             }
123         }
124     }
125
126     SpeechChrome {
127         id: speech_chrome
128         anchors.left: parent.left
129         anchors.right: parent.right
130         anchors.bottom: parent.bottom
131         height: parent.height
132     }
133 }