on 67dc769 help sign in
unity8/qml/Panel/Panel.qml
213 lines 5.9 kB history raw
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19import Unity.Application 0.1
20import "../Components"
21import "../Components/ListItems"
23Item {
24 id: root
25 readonly property real panelHeight: indicatorArea.y + d.indicatorHeight
26 property alias indicators: __indicators
27 property alias callHint: __callHint
28 property bool fullscreenMode: false
30 function hideIndicatorMenu(delay) {
31 if (delay !== undefined) {
32 hideTimer.interval = delay;
33 hideTimer.start();
34 } else {
35 indicators.hide();
36 }
37 }
39 Timer {
40 id: hideTimer
41 running: false
42 onTriggered: {
43 indicators.hide();
44 }
45 }
47 Connections {
48 target: indicators
49 onShownChanged: hideTimer.stop()
50 }
52 Rectangle {
53 id: darkenedArea
54 property real darkenedOpacity: 0.6
55 anchors {
56 top: parent.top
57 topMargin: panelHeight
58 left: parent.left
59 right: parent.right
60 bottom: parent.bottom
61 }
62 color: "black"
63 opacity: indicators.unitProgress * darkenedOpacity
65 MouseArea {
66 anchors.fill: parent
67 enabled: indicators.shown
68 onClicked: if (indicators.fullyOpened) indicators.hide();
69 }
70 }
72 Item {
73 id: indicatorArea
74 objectName: "indicatorArea"
76 anchors.fill: parent
78 Behavior on anchors.topMargin { StandardAnimation {} }
80 BorderImage {
81 id: dropShadow
82 anchors {
83 fill: indicators
84 leftMargin: -units.gu(1)
85 bottomMargin: -units.gu(1)
86 }
87 visible: indicators.height > indicators.panelHeight
88 source: "graphics/rectangular_dropshadow.sci"
89 }
91 VerticalThinDivider {
92 id: indicatorDividor
93 anchors {
94 top: indicators.top
95 bottom: indicators.bottom
96 right: indicators.left
98 topMargin: indicatorArea.anchors.topMargin + indicators.panelHeight
99 }
101 width: units.dp(2)
102 source: "graphics/VerticalDivider.png"
103 }
105 Rectangle {
106 id: indicatorAreaBackground
107 color: callHint.visible ? "green" : "black"
108 anchors {
109 top: parent.top
110 left: parent.left
111 right: parent.right
112 }
113 height: indicators.panelHeight
115 Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration } }
116 }
118 PanelSeparatorLine {
119 id: nonIndicatorAreaSeparatorLine
120 anchors {
121 top: indicatorAreaBackground.bottom
122 left: parent.left
123 right: indicators.left
124 }
125 saturation: 1 - indicators.unitProgress
126 }
128 MouseArea {
129 anchors {
130 top: parent.top
131 left: parent.left
132 right: indicators.left
133 }
134 height: indicators.panelHeight
135 enabled: callHint.visible
136 onClicked: callHint.showLiveCall()
137 }
139 Indicators {
140 id: __indicators
141 objectName: "indicators"
143 anchors {
144 top: parent.top
145 right: parent.right
146 }
148 width: root.width
149 shown: false
150 panelHeight: units.gu(3)
151 openedHeight: root.height
152 overFlowWidth: {
153 if (callHint.visible) {
154 return Math.max(root.width - (callHint.width + units.gu(2)), 0)
155 }
156 return root.width
157 }
159 enableHint: !callHint.active && !fullscreenMode
160 showHintBottomMargin: fullscreenMode ? -panelHeight : 0
162 onShowTapped: {
163 if (callHint.active) {
164 callHint.showLiveCall();
165 }
166 }
167 }
169 ActiveCallHint {
170 id: __callHint
171 anchors {
172 top: parent.top
173 left: parent.left
174 }
175 height: indicators.panelHeight
176 visible: active && indicators.state == "initial"
177 }
179 PanelSeparatorLine {
180 id: indicatorsSeparatorLine
181 visible: true
182 anchors {
183 top: indicators.bottom
184 left: indicatorDividor.left
185 right: indicators.right
186 }
187 }
188 }
190 QtObject {
191 id: d
192 readonly property real indicatorHeight: indicators.panelHeight + indicatorsSeparatorLine.height
193 }
195 states: [
196 State {
197 name: "onscreen" //fully opaque and visible at top edge of screen
198 when: !fullscreenMode
199 PropertyChanges {
200 target: indicatorArea;
201 anchors.topMargin: 0
202 }
203 },
204 State {
205 name: "offscreen" //pushed off screen
206 when: fullscreenMode
207 PropertyChanges {
208 target: indicatorArea;
209 anchors.topMargin: indicators.state === "initial" ? -d.indicatorHeight : 0
210 }
211 }
212 ]