on xenial help sign in
removed old panel
commit42c319d1028b6c97514297f6a5348998a670a5c4 authorNick Dedekind <nick.dedekind@canonical.com> dateTue 30 Sep 2014, 15:55 (12 years ago) parent61c6e38
8 files changed−1638
qml/Panel/Old/IndicatorItem.qml−47 qml/Panel/Old/IndicatorRow.qml−162 qml/Panel/Old/Indicators.qml−416 qml/Panel/Old/Panel.qml−191 tests/qmltests/Panel/Old/tst_IndicatorItem.qml−196 tests/qmltests/Panel/Old/tst_IndicatorRow.qml−160 tests/qmltests/Panel/Old/tst_Indicators.qml−230 tests/qmltests/Panel/Old/tst_Panel.qml−236
qml/Panel/Old/IndicatorItem.qmldeleted−47
@@ -1,47 +0,0 @@
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− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 0.1
19−import Unity.Indicators 0.1 as Indicators
20−import "../Components"
21−
22−Loader {
23− id: root
24−
25− property alias widgetSource: root.source
26− property bool dimmed: false
27− property var indicatorProperties: undefined
28− property bool indicatorVisible: item ? item.enabled : false
29− property string identifier
30−
31− opacity: dimmed ? 0.4 : 1
32− Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.BriskDuration } }
33−
34− onLoaded: {
35− for(var pName in indicatorProperties) {
36− if (item.hasOwnProperty(pName)) {
37− item[pName] = indicatorProperties[pName];
38− }
39− }
40− }
41−
42− Binding {
43− target: item
44− property: "objectName"
45− value: identifier + "-widget"
46− }
47−}
qml/Panel/Old/IndicatorRow.qmldeleted−162
@@ -1,162 +0,0 @@
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− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 0.1
19−import Unity.Indicators 0.1 as Indicators
20−import "../Components"
21−
22−Item {
23− id: indicatorRow
24−
25− readonly property alias currentItem : itemView.currentItem
26− readonly property alias currentItemIndex: itemView.currentIndex
27− readonly property alias row: itemView
28− property QtObject indicatorsModel: null
29− property int overFlowWidth: width
30− property bool showAll: false
31− property real currentItemOffset: 0.0
32− property real unitProgress: 0.0
33−
34− width: units.gu(40)
35− height: units.gu(3)
36−
37− function setDefaultItem() {
38− // The leftmost indicator
39− setCurrentItemIndex(0);
40− }
41−
42− function setCurrentItemIndex(index) {
43− itemView.currentIndex = index;
44− }
45−
46− function setCurrentItem(item) {
47− if (item && item.hasOwnProperty("ownIndex")) {
48− itemView.currentIndex = item.ownIndex;
49− } else {
50− itemView.currentIndex = -1;
51− }
52− }
53−
54− Timer {
55− id: allVisible
56− interval: 1000
57−
58− onTriggered: {
59− showAll = false;
60− }
61− }
62−
63− ListView {
64− id: itemView
65− objectName: "indicatorRowItems"
66− interactive: false
67− model: indicatorsModel ? indicatorsModel : null
68−
69− width: childrenRect.width
70− height: indicatorRow.height
71− anchors.right: parent.right
72− orientation: ListView.Horizontal
73−
74− property int lastCount: 0
75− onCountChanged: {
76− if (lastCount < count) {
77− showAll = true;
78− allVisible.start();
79− }
80− lastCount = count;
81− }
82−
83− delegate: Item {
84− id: itemWrapper
85− objectName: "item" + index
86− height: indicatorRow.height
87− width: indicatorItem.width
88− opacity: 1 - indicatorRow.unitProgress
89− y: 0
90− state: "standard"
91−
92− property int ownIndex: index
93− property bool highlighted: indicatorRow.unitProgress > 0 ? ListView.isCurrentItem : false
94− property bool dimmed: indicatorRow.unitProgress > 0 ? !ListView.isCurrentItem : false
95−
96− property bool hidden: !showAll && !highlighted && (indicatorRow.state == "locked" || indicatorRow.state == "commit")
97− property bool overflow: row.width - itemWrapper.x > overFlowWidth
98−
99− IndicatorItem {
100− id: indicatorItem
101− identifier: model.identifier
102− height: parent.height
103−
104− dimmed: itemWrapper.dimmed
105−
106− widgetSource: model.widgetSource
107− indicatorProperties : model.indicatorProperties
108− }
109−
110− states: [
111− State {
112− name: "standard"
113− when: !hidden && !overflow && !highlighted
114− },
115− State {
116− name: "highlighted"
117− when: highlighted
118− PropertyChanges { target: itemWrapper; opacity: 1.0 }
119− },
120− State {
121− name: "hidden"
122− when: hidden || overflow
123− PropertyChanges { target: itemWrapper; opacity: 0.0 }
124− }
125− ]
126−
127− Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.BriskDuration } }
128− }
129− }
130−
131−
132− Rectangle {
133− id: highlight
134− color: Theme.palette.selected.foreground
135− objectName: "highlight"
136− height: units.dp(2)
137− anchors.top: row.bottom
138− visible: indicatorRow.currentItem != null
139−
140− property real intendedX: row.x + (indicatorRow.currentItem != null ? (indicatorRow.currentItem.x - row.originX) + centerOffset : 0)
141− x: intendedX >= row.x ? (intendedX + width <= row.x + row.width ? intendedX : row.x + row.width - width) : row.x // listview boundaries
142− width: indicatorRow.currentItem != null ? indicatorRow.currentItem.width : 0
143−
144− property real centerOffset: {
145− if (indicatorRow.currentItemOffset > 0.1) {
146− return (indicatorRow.currentItemOffset - 0.1) * units.gu(0.4);
147− } else if (indicatorRow.currentItemOffset < -0.1) {
148− return (indicatorRow.currentItemOffset + 0.1) * units.gu(0.4);
149− }
150− return 0.0;
151− }
152−
153− Behavior on width {
154− enabled: unitProgress > 0;
155− UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
156− }
157− Behavior on x {
158− enabled: unitProgress > 0;
159− UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
160− }
161− }
162−}
qml/Panel/Old/Indicators.qmldeleted−416
@@ -1,416 +0,0 @@
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− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 0.1
19−import Ubuntu.Gestures 0.1
20−import Unity.Indicators 0.1 as Indicators
21−
22−import "../Components"
23−import "../Components/ListItems"
24−import "Indicators"
25−
26−Showable {
27− id: indicators
28−
29− property real openedHeight: units.gu(71)
30− property int panelHeight: units.gu(3)
31− property alias overFlowWidth: indicatorRow.overFlowWidth
32− property alias showAll: indicatorRow.showAll
33− // TODO: This should be sourced by device type (eg "desktop", "tablet", "phone"...)
34− property string profile: indicatorProfile
35−
36− readonly property real hintValue: panelHeight + menuContent.headerHeight
37− readonly property int lockThreshold: openedHeight / 2
38− property bool fullyOpened: height == openedHeight
39− property bool partiallyOpened: height > panelHeight && !fullyOpened
40− property bool fullyClosed: height <= panelHeight
41− property bool contentEnabled: true
42− property bool initalizeItem: true
43− readonly property alias content: menuContent
44− property real unitProgress: (height - panelHeight) / (openedHeight - panelHeight)
45− property bool enableHint: true
46− property real showHintBottomMargin: 0
47−
48− signal showTapped(point position)
49−
50− // TODO: Perhaps we need a animation standard for showing/hiding? Each showable seems to
51− // use its own values. Need to ask design about this.
52− showAnimation: StandardAnimation {
53− property: "height"
54− to: openedHeight
55− }
56−
57− hideAnimation: StandardAnimation {
58− property: "height"
59− duration: 350
60− to: panelHeight
61− easing.type: Easing.OutCubic
62− }
63−
64− onOpenedHeightChanged: {
65− if (showAnimation.running) {
66− showAnimation.restart();
67− } else if (indicators.shown) {
68− height = openedHeight;
69− }
70− }
71−
72− height: panelHeight
73− onHeightChanged: updateRevealProgressState(indicators.height - panelHeight - showHintBottomMargin, true)
74−
75− function updateRevealProgressState(revealProgress, enableRelease) {
76− if (!showAnimation.running && !hideAnimation.running) {
77− if (revealProgress === 0) {
78− indicators.state = "initial";
79− } else if (enableHint && revealProgress > 0 && revealProgress <= hintValue) {
80− indicators.state = "hint";
81− } else if ((!enableHint || revealProgress > hintValue) && revealProgress < lockThreshold) {
82− indicators.state = "reveal";
83− } else if (revealProgress >= lockThreshold && lockThreshold > 0) {
84− indicators.state = "locked";
85− }
86− }
87− }
88−
89− function calculateCurrentItem(xValue, useBuffer) {
90− var rowCoordinates;
91− var itemCoordinates;
92− var currentItem;
93− var distanceFromRightEdge;
94− var bufferExceeded = false;
95−
96− if (indicators.state == "commit" || indicators.state == "locked" || showAnimation.running || hideAnimation.running) return;
97−
98− /*
99− If user drags the indicator handle bar down a distance hintValue or less, this is 0.
100− If bar is dragged down a distance greater than or equal to lockThreshold, this is 1.
101− Otherwise it contains the bar's location as a fraction of the distance between hintValue (is 0) and lockThreshold (is 1).
102− */
103− var verticalProgress =
104− MathUtils.clamp((indicators.height - handle.height - hintValue) /
105− (lockThreshold - hintValue), 0, 1);
106−
107− /*
108− Vertical velocity check. Don't change the indicator if we're moving too quickly.
109− */
110− var verticalSpeed = Math.abs(yVelocityCalculator.calculate());
111− if (verticalSpeed >= 0.05 && !initalizeItem) {
112− return;
113− }
114−
115− /*
116− Percentage of an indicator icon's width the user's press can stray horizontally from the
117− focused icon before we change focus to another icon. E.g. a value of 0.5 means you must
118− go right a distance of half an icon's width before focus moves to the icon on the right
119− */
120− var maxBufferThreshold = 0.5;
121−
122− /*
123− To help users find the indicator of their choice while opening the indicators, we add logic to add a
124− left/right buffer to each icon so it is harder for the focus to be moved accidentally to another icon,
125− as the user moves their finger down, but yet allows them to switch indicator if they want.
126− This buffer is wider the further the user's finger is from the top of the screen.
127− */
128− var effectiveBufferThreshold = maxBufferThreshold * verticalProgress;
129−
130− rowCoordinates = indicatorRow.mapToItem(indicatorRow.row, xValue, 0);
131− // get the current delegate
132− currentItem = indicatorRow.row.itemAt(rowCoordinates.x, 0);
133− if (currentItem) {
134− itemCoordinates = indicatorRow.row.mapToItem(currentItem, rowCoordinates.x, 0);
135− distanceFromRightEdge = (currentItem.width - itemCoordinates.x) / (currentItem.width);
136− console.log(distanceFromRightEdge);
137− if (currentItem != indicatorRow.currentItem) {
138− if (Math.abs(currentItem.ownIndex - indicatorRow.currentItemIndex) > 1) {
139− bufferExceeded = true;
140− } else {
141− if (indicatorRow.currentItemIndex < currentItem.ownIndex && distanceFromRightEdge < (1 - effectiveBufferThreshold)) {
142− bufferExceeded = true;
143− } else if (indicatorRow.currentItemIndex > currentItem.ownIndex && distanceFromRightEdge > effectiveBufferThreshold) {
144− bufferExceeded = true;
145− }
146− }
147− if ((!useBuffer || (useBuffer && bufferExceeded)) || indicatorRow.currentItemIndex < 0 || indicatorRow.currentItem == null) {
148− indicatorRow.setCurrentItem(currentItem);
149− }
150−
151− // need to re-init the distanceFromRightEdge for offset calculation
152− itemCoordinates = indicatorRow.row.mapToItem(indicatorRow.currentItem, rowCoordinates.x, 0);
153− distanceFromRightEdge = (indicatorRow.currentItem.width - itemCoordinates.x) / (indicatorRow.currentItem.width);
154− }
155− indicatorRow.currentItemOffset = 1 - (distanceFromRightEdge * 2);
156− } else if (initalizeItem) {
157− indicatorRow.setDefaultItem();
158− indicatorRow.currentItemOffset = 0;
159− }
160− initalizeItem = indicatorRow.currentItem == null;
161− }
162−
163− // eater
164− MouseArea {
165− anchors {
166− top: parent.top
167− bottom: handle.bottom
168− left: parent.left
169− right: parent.right
170− }
171− }
172−
173− VisibleIndicators {
174− id: visibleIndicators
175− }
176−
177− MenuContent {
178− id: menuContent
179− objectName: "menuContent"
180−
181− anchors {
182− left: parent.left
183− right: parent.right
184− top: indicatorRow.bottom
185− bottom: handle.top
186− }
187− indicatorsModel: visibleIndicators.model
188− visible: indicators.partiallyOpened || indicators.fullyOpened
189− clip: indicators.partiallyOpened
190− enabled: contentEnabled
191−
192− //small shadow gradient at bottom of menu
193− Rectangle {
194− anchors {
195− left: parent.left
196− right: parent.right
197− bottom: parent.bottom
198− }
199− height: units.gu(0.5)
200− gradient: Gradient {
201− GradientStop { position: 0.0; color: "transparent" }
202− GradientStop { position: 1.0; color: "black" }
203− }
204− opacity: 0.4
205− }
206− }
207−
208− Rectangle {
209− id: handle
210−
211− color: menuContent.color
212−
213− anchors {
214− left: parent.left
215− right: parent.right
216− bottom: parent.bottom
217− }
218− height: Math.max(Math.min(handleImage.height, indicators.height - handleImage.height), 0)
219− clip: height < handleImage.height
220− visible: menuContent.visible
221−
222− BorderImage {
223− id: handleImage
224− source: "graphics/handle.sci"
225− height: panelHeight
226− anchors {
227− left: parent.left
228− right: parent.right
229− bottom: parent.bottom
230− }
231− }
232− MouseArea { //prevent clicks passing through
233− anchors.fill: parent
234− }
235− }
236−
237− IndicatorRow {
238− id: indicatorRow
239− objectName: "indicatorRow"
240− anchors {
241− left: parent.left
242− right: parent.right
243− }
244− height: indicators.panelHeight
245− indicatorsModel: visibleIndicators.model
246− state: indicators.state
247− unitProgress: indicators.unitProgress
248−
249− EdgeDragArea {
250− id: rowDragArea
251− anchors.fill: indicatorRow
252− direction: Direction.Downwards
253− maxSilenceTime: 2000
254− distanceThreshold: 0
255−
256− enabled: fullyOpened
257− onDraggingChanged: {
258− if (dragging) {
259− initalizeItem = true;
260− updateRevealProgressState(Math.max(touchSceneY - panelHeight, hintValue), false);
261− indicators.calculateCurrentItem(touchX, false);
262− } else {
263− indicators.state = "commit";
264− indicatorRow.currentItemOffset = 0;
265− }
266− }
267−
268− onTouchXChanged: {
269− indicators.calculateCurrentItem(touchX, true);
270− }
271− onTouchSceneYChanged: {
272− updateRevealProgressState(Math.max(touchSceneY - panelHeight, hintValue), false);
273− yVelocityCalculator.trackedPosition = touchSceneY;
274− }
275− }
276− }
277−
278− Connections {
279− target: showAnimation
280− onRunningChanged: {
281− if (showAnimation.running) {
282− indicators.state = "commit";
283− indicatorRow.currentItemOffset = 0;
284− }
285− }
286− }
287−
288− Connections {
289− target: hideAnimation
290− onRunningChanged: {
291− if (hideAnimation.running) {
292− indicators.state = "initial";
293− initalizeItem = true;
294− indicatorRow.currentItemOffset = 0;
295− }
296− }
297− }
298−
299− QtObject {
300− id: d
301− property bool enableIndexChangeSignal: true
302− property var activeDragHandle: showDragHandle.dragging ? showDragHandle : hideDragHandle.dragging ? hideDragHandle : null
303− }
304−
305− Connections {
306− target: menuContent
307− onCurrentMenuIndexChanged: {
308− var oldActive = d.enableIndexChangeSignal;
309− if (!oldActive) return;
310− d.enableIndexChangeSignal = false;
311−
312− indicatorRow.setCurrentItemIndex(menuContent.currentMenuIndex);
313−
314− d.enableIndexChangeSignal = oldActive;
315− }
316− }
317−
318− Connections {
319− target: indicatorRow
320− onCurrentItemIndexChanged: {
321− var oldActive = d.enableIndexChangeSignal;
322− if (!oldActive) return;
323− d.enableIndexChangeSignal = false;
324−
325− menuContent.setCurrentMenuIndex(indicatorRow.currentItemIndex, fullyOpened || partiallyOpened);
326−
327− d.enableIndexChangeSignal = oldActive;
328− }
329− }
330− // connections to the active drag handle
331− Connections {
332− target: d.activeDragHandle
333− onTouchXChanged: {
334− indicators.calculateCurrentItem(d.activeDragHandle.touchX, true);
335− }
336− onTouchSceneYChanged: {
337− yVelocityCalculator.trackedPosition = d.activeDragHandle.touchSceneY;
338− }
339− }
340−
341− DragHandle {
342− id: showDragHandle
343− anchors.bottom: parent.bottom
344− // go beyond parent so that it stays reachable, at the top of the screen.
345− anchors.bottomMargin: showHintBottomMargin
346− anchors.left: parent.left
347− anchors.right: parent.right
348− height: panelHeight
349− direction: Direction.Downwards
350− enabled: !indicators.shown && indicators.available
351− hintDisplacement: enableHint ? indicators.hintValue : 0
352− autoCompleteDragThreshold: maxTotalDragDistance / 2
353− stretch: true
354− maxTotalDragDistance: openedHeight - panelHeight
355− distanceThreshold: panelHeight
356−
357− onTapped: showTapped(Qt.point(touchSceneX, touchSceneY));
358− }
359−
360− DragHandle {
361− id: hideDragHandle
362− anchors.fill: handle
363− direction: Direction.Upwards
364− enabled: indicators.shown && indicators.available
365− hintDisplacement: indicators.hintValue
366− autoCompleteDragThreshold: maxTotalDragDistance / 6
367− stretch: true
368− maxTotalDragDistance: openedHeight - panelHeight
369− distanceThreshold: 0
370− }
371−
372− AxisVelocityCalculator {
373− id: yVelocityCalculator
374− }
375−
376− states: [
377− State {
378− name: "initial"
379− },
380− State {
381− name: "hint"
382− StateChangeScript {
383− script: {
384− if (d.activeDragHandle) {
385− calculateCurrentItem(d.activeDragHandle.touchX, false);
386− }
387− }
388− }
389− },
390− State {
391− name: "reveal"
392− extend: "hint"
393− },
394− State {
395− name: "locked"
396− extend: "hint"
397− },
398− State {
399− name: "commit"
400− extend: "hint"
401− }
402− ]
403− state: "initial"
404−
405− transitions: [
406− Transition {
407− NumberAnimation {targets: [indicatorRow, menuContent]; property: "y"; duration: 300; easing.type: Easing.OutCubic}
408− }
409− ]
410−
411− Component.onCompleted: initialise();
412− function initialise() {
413− visibleIndicators.load(profile);
414− indicatorRow.setDefaultItem();
415− }
416−}
qml/Panel/Old/Panel.qmldeleted−191
@@ -1,191 +0,0 @@
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− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 0.1
19−import Unity.Application 0.1
20−import "../Components"
21−import "../Components/ListItems"
22−
23−Item {
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
29−
30− Rectangle {
31− id: darkenedArea
32− property real darkenedOpacity: 0.6
33− anchors {
34− top: parent.top
35− topMargin: panelHeight
36− left: parent.left
37− right: parent.right
38− bottom: parent.bottom
39− }
40− color: "black"
41− opacity: indicators.unitProgress * darkenedOpacity
42−
43− MouseArea {
44− anchors.fill: parent
45− enabled: indicators.shown
46− onClicked: if (indicators.fullyOpened) indicators.hide();
47− }
48− }
49−
50− Item {
51− id: indicatorArea
52− objectName: "indicatorArea"
53−
54− anchors.fill: parent
55−
56− Behavior on anchors.topMargin { StandardAnimation {} }
57−
58− BorderImage {
59− id: dropShadow
60− anchors {
61− fill: indicators
62− leftMargin: -units.gu(1)
63− bottomMargin: -units.gu(1)
64− }
65− visible: indicators.height > indicators.panelHeight
66− source: "graphics/rectangular_dropshadow.sci"
67− }
68−
69− VerticalThinDivider {
70− id: indicatorDividor
71− anchors {
72− top: indicators.top
73− bottom: indicators.bottom
74− right: indicators.left
75−
76− topMargin: indicatorArea.anchors.topMargin + indicators.panelHeight
77− }
78−
79− width: units.dp(2)
80− source: "graphics/VerticalDivider.png"
81− }
82−
83− Rectangle {
84− id: indicatorAreaBackground
85− color: callHint.visible ? "green" : "black"
86− anchors {
87− top: parent.top
88− left: parent.left
89− right: parent.right
90− }
91− height: indicators.panelHeight
92−
93− Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration } }
94− }
95−
96− PanelSeparatorLine {
97− id: nonIndicatorAreaSeparatorLine
98− anchors {
99− top: indicatorAreaBackground.bottom
100− left: parent.left
101− right: indicators.left
102− }
103− saturation: 1 - indicators.unitProgress
104− }
105−
106− MouseArea {
107− anchors {
108− top: parent.top
109− left: parent.left
110− right: indicators.left
111− }
112− height: indicators.panelHeight
113− enabled: callHint.visible
114− onClicked: callHint.showLiveCall()
115− }
116−
117− Indicators {
118− id: __indicators
119− objectName: "indicators"
120−
121− anchors {
122− top: parent.top
123− right: parent.right
124− }
125−
126− width: root.width
127− shown: false
128− panelHeight: units.gu(3)
129− openedHeight: root.height
130− overFlowWidth: {
131− if (callHint.visible) {
132− return Math.max(root.width - (callHint.width + units.gu(2)), 0)
133− }
134− return root.width
135− }
136−
137− enableHint: !callHint.active && !fullscreenMode
138− showHintBottomMargin: fullscreenMode ? -panelHeight : 0
139−
140− onShowTapped: {
141− if (callHint.active) {
142− callHint.showLiveCall();
143− }
144− }
145− }
146−
147− ActiveCallHint {
148− id: __callHint
149− anchors {
150− top: parent.top
151− left: parent.left
152− }
153− height: indicators.panelHeight
154− visible: active && indicators.state == "initial"
155− }
156−
157− PanelSeparatorLine {
158− id: indicatorsSeparatorLine
159− visible: true
160− anchors {
161− top: indicators.bottom
162− left: indicatorDividor.left
163− right: indicators.right
164− }
165− }
166− }
167−
168− QtObject {
169− id: d
170− readonly property real indicatorHeight: indicators.panelHeight + indicatorsSeparatorLine.height
171− }
172−
173− states: [
174− State {
175− name: "onscreen" //fully opaque and visible at top edge of screen
176− when: !fullscreenMode
177− PropertyChanges {
178− target: indicatorArea;
179− anchors.topMargin: 0
180− }
181− },
182− State {
183− name: "offscreen" //pushed off screen
184− when: fullscreenMode
185− PropertyChanges {
186− target: indicatorArea;
187− anchors.topMargin: indicators.state === "initial" ? -d.indicatorHeight : 0
188− }
189− }
190− ]
191−}
tests/qmltests/Panel/Old/tst_IndicatorItem.qmldeleted−196
@@ -1,196 +0,0 @@
1−/*
2− * Copyright 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− */
16−
17−import QtQuick 2.1
18−import QtQuick.Layouts 1.1
19−import QtTest 1.0
20−import Ubuntu.Components 0.1
21−import Unity.Test 0.1 as UT
22−import "../../../../qml/Panel"
23−
24−Rectangle {
25− width: units.gu(80)
26− height: units.gu(30)
27− color: "white"
28−
29− RowLayout {
30− anchors.fill: parent
31− anchors.margins: units.gu(1)
32−
33− Rectangle {
34− id: itemArea
35− color: "blue"
36− Layout.fillWidth: true
37− Layout.fillHeight: true
38−
39− Rectangle {
40− color: "black"
41− anchors.fill: indicatorItem
42− }
43−
44− IndicatorItem {
45− id: indicatorItem
46− height: expanded ? units.gu(7) : units.gu(3)
47− anchors.centerIn: parent
48− identifier: "indicator-test"
49−
50− rootActionState {
51− title: titleLabel.text
52− leftLabel : leftLabel.text
53− rightLabel : rightLabel.text
54− icons : {
55− var icons = [];
56− var i = 0;
57− if (iconEnabled.checked) {
58− for (i = 0; i < String(iconCount.text); i++) {
59− icons.push("image://theme/audio-volume-high");
60− }
61− }
62− return icons;
63− }
64− }
65−
66− Behavior on height {
67− NumberAnimation {
68− id: heightAnimation
69− duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing
70− }
71− }
72− }
73− }
74−
75− ColumnLayout {
76− Layout.alignment: Qt.AlignTop
77− Layout.fillWidth: false
78−
79− Button {
80− id: expandButton
81− Layout.fillWidth: true
82− text: indicatorItem.expanded ? "Collapse" : "Expand"
83− onClicked: indicatorItem.expanded = !indicatorItem.expanded
84− }
85−
86− Button {
87− id: selectButton
88− Layout.fillWidth: true
89− text: indicatorItem.selected ? "Unselect" : "Select"
90− onClicked: indicatorItem.selected = !indicatorItem.selected
91− }
92−
93− Rectangle {
94− Layout.preferredHeight: units.dp(1);
95− Layout.fillWidth: true;
96− color: "black"
97− }
98−
99− RowLayout {
100− CheckBox { id: iconEnabled; checked: true }
101− Label { text: "icons Count:" }
102− TextField { id: iconCount; text: "1"; enabled: iconEnabled.checked }
103− }
104−
105− RowLayout {
106− Label { text: "Left Label:" }
107− TextField { id: leftLabel; text: "Left"}
108− }
109−
110− RowLayout {
111− Label { text: "Right Label:" }
112− TextField { id: rightLabel; text: "Right"}
113− }
114−
115− RowLayout {
116− Label { text: "Title:" }
117− TextField { id: titleLabel; text: "Title"}
118− }
119− }
120− }
121−
122− UT.UnityTestCase {
123− name: "IndicatorItem"
124− when: windowShown
125−
126− function init() {
127− indicatorItem.selected = false;
128− indicatorItem.expanded = false;
129− indicatorItem.rootActionState.title = "Test Title";
130− indicatorItem.rootActionState.leftLabel = "TestRightLabel";
131− indicatorItem.rootActionState.rightLabel = "TestRightLabel";
132− indicatorItem.rootActionState.icons = [ "image://theme/audio-volume-high" ];
133−
134− tryCompare(heightAnimation, "running", false);
135− }
136−
137− function test_expand() {
138− indicatorItem.expanded = true;
139− tryCompare(indicatorItem, "height", units.gu(7));
140− indicatorItem.expanded = false;
141− tryCompare(indicatorItem, "height", units.gu(3));
142− }
143−
144− function test_minimizedVisibility() {
145− compare(findChild(indicatorItem, "leftLabel").opacity, 1.0);
146− compare(findChild(indicatorItem, "rightLabel").opacity, 1.0);
147− compare(findChild(indicatorItem, "icons").opacity, 1.0);
148− compare(findChild(indicatorItem, "indicatorName").opacity, 0.0);
149− }
150−
151− function test_expandcon() {
152− indicatorItem.expanded = true;
153−
154− tryCompare(findChild(indicatorItem, "leftLabel"), "opacity", 0.0);
155− tryCompare(findChild(indicatorItem, "rightLabel"), "opacity", 0.0);
156− tryCompare(findChild(indicatorItem, "icons"), "opacity", 1.0);
157− tryCompare(findChild(indicatorItem, "indicatorName"), "opacity", 1.0);
158− }
159−
160− function test_expandRightLabel() {
161− indicatorItem.expanded = true;
162−
163− indicatorItem.rootActionState.icons = [];
164−
165− tryCompare(findChild(indicatorItem, "leftLabel"), "opacity", 0.0);
166− tryCompare(findChild(indicatorItem, "rightLabel"), "opacity", 1.0);
167− tryCompare(findChild(indicatorItem, "icons"), "opacity", 0.0);
168− tryCompare(findChild(indicatorItem, "indicatorName"), "opacity", 1.0);
169− }
170−
171− function test_expandLeftLabel() {
172− indicatorItem.expanded = true;
173−
174− indicatorItem.rootActionState.rightLabel = "";
175− indicatorItem.rootActionState.icons = [];
176−
177− tryCompare(findChild(indicatorItem, "rightLabel"), "opacity", 0.0);
178− tryCompare(findChild(indicatorItem, "leftLabel"), "opacity", 1.0);
179− tryCompare(findChild(indicatorItem, "icons"), "opacity", 0.0);
180− tryCompare(findChild(indicatorItem, "indicatorName"), "opacity", 1.0);
181− }
182−
183− function test_select() {
184− tryCompare(findChild(indicatorItem, "leftLabel"), "color", Theme.palette.normal.foregroundText);
185− tryCompare(findChild(indicatorItem, "rightLabel"), "color", Theme.palette.normal.foregroundText);
186−
187− indicatorItem.expanded = true;
188− tryCompare(findChild(indicatorItem, "leftLabel"), "color", Theme.palette.selected.backgroundText);
189− tryCompare(findChild(indicatorItem, "rightLabel"), "color", Theme.palette.selected.backgroundText);
190−
191− indicatorItem.selected = true;
192− tryCompare(findChild(indicatorItem, "leftLabel"), "color", Theme.palette.normal.foregroundText);
193− tryCompare(findChild(indicatorItem, "rightLabel"), "color", Theme.palette.normal.foregroundText);
194− }
195− }
196−}
tests/qmltests/Panel/Old/tst_IndicatorRow.qmldeleted−160
@@ -1,160 +0,0 @@
1−/*
2− * Copyright 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− */
16−
17−import QtQuick 2.0
18−import QtTest 1.0
19−import Unity.Test 0.1 as UT
20−import ".."
21−import "../../../qml/Panel"
22−import Unity.Indicators 0.1 as Indicators
23−
24−/*
25− This tests the IndicatorRow component by using a fake model to stage data in the indicators
26− A view will show with indicators at the top, as does in the shell.
27−*/
28−Item {
29− id: rootItem
30− width: units.gu(40)
31− height: units.gu(60)
32−
33− function init_test()
34− {
35− indicatorModel.load("test1");
36−
37− indicatorRow.state = "initial";
38− indicatorRow.setCurrentItemIndex(-1);
39− indicatorRow.unitProgress = 0.0;
40− }
41−
42− PanelBackground {
43− anchors.fill: indicatorRow
44− }
45−
46− IndicatorRow {
47− id: indicatorRow
48− anchors {
49− left: parent.left
50− right: parent.right
51− }
52−
53− indicatorsModel: indicatorModel
54−
55− Component.onCompleted: indicatorModel.load("test1")
56− }
57−
58− Indicators.IndicatorsModel {
59− id: indicatorModel
60− }
61−
62− UT.UnityTestCase {
63− name: "IndicatorRow"
64− when: windowShown
65−
66− function get_indicator_item(index) {
67− return findChild(indicatorRow.row, "item" + index);
68− }
69−
70− function test_set_current_item() {
71− init_test();
72− indicatorRow.setCurrentItemIndex(0);
73− compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier), "indicator-fake1", "Incorrect item at position 0");
74−
75− indicatorRow.setCurrentItemIndex(1);
76− compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier), "indicator-fake2", "Incorrect item at position 1");
77−
78− indicatorRow.setCurrentItemIndex(2);
79− compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier), "indicator-fake3", "Incorrect item at position 2");
80− }
81−
82− function test_highlight_data() {
83− return [
84− { index: 0, progress: 0.0, current: false, other: false },
85− { index: 0, progress: 0.1, current: true, other: false },
86− { index: 0, progress: 0.5, current: true, other: false },
87− { index: 0, progress: 1.0, current: true, other: false },
88− { index: 2, progress: 0.0, current: false, other: false },
89− { index: 2, progress: 0.1, current: true, other: false },
90− { index: 2, progress: 0.5, current: true, other: false },
91− { index: 2, progress: 1.0, current: true, other: false }
92− ];
93− }
94−
95− function test_highlight(data) {
96− init_test();
97−
98− indicatorRow.unitProgress = data.progress;
99− indicatorRow.setCurrentItemIndex(data.index);
100−
101− compare(indicatorRow.currentItem.highlighted, data.current, "Indicator hightlight did not match for current item");
102−
103− for (var i = 0; i < indicatorRow.row.count; i++) {
104− compare(get_indicator_item(i).highlighted, i === data.index ? data.current: data.other, "Indicator hightlight did not match for item iter");
105− }
106− }
107−
108− function test_opacity_data() {
109− return [
110− { index: 0, progress: 0.0, current: 1.0, other: 1.0 },
111− { index: 0, progress: 0.1, current: 1.0, other: 0.9 },
112− { index: 0, progress: 0.5, current: 1.0, other: 0.5 },
113− { index: 0, progress: 1.0, current: 1.0, other: 0.0 },
114− { index: 2, progress: 0.0, current: 1.0, other: 1.0 },
115− { index: 2, progress: 0.1, current: 1.0, other: 0.9 },
116− { index: 2, progress: 0.5, current: 1.0, other: 0.5 },
117− { index: 2, progress: 1.0, current: 1.0, other: 0.0 }
118− ];
119− }
120−
121− function test_opacity(data) {
122− init_test();
123−
124− indicatorRow.unitProgress = data.progress;
125− indicatorRow.setCurrentItemIndex(data.index);
126−
127− tryCompare(indicatorRow.currentItem, "opacity", data.current);
128−
129− for (var i = 0; i < indicatorRow.row.count; i++) {
130− tryCompare(get_indicator_item(i), "opacity", i === data.index ? data.current: data.other);
131− }
132− }
133−
134− function test_dimmed_data() {
135− return [
136− { index: 0, progress: 0.0, current: false, other: false },
137− { index: 0, progress: 0.1, current: false, other: true },
138− { index: 0, progress: 0.5, current: false, other: true },
139− { index: 0, progress: 1.0, current: false, other: true },
140− { index: 2, progress: 0.0, current: false, other: false },
141− { index: 2, progress: 0.1, current: false, other: true },
142− { index: 2, progress: 0.5, current: false, other: true },
143− { index: 2, progress: 1.0, current: false, other: true }
144− ];
145− }
146−
147− function test_dimmed(data) {
148− init_test();
149−
150− indicatorRow.unitProgress = data.progress;
151− indicatorRow.setCurrentItemIndex(data.index);
152−
153− compare(indicatorRow.currentItem.dimmed, data.current, "Indicator dim did not match for current item");
154−
155− for (var i = 0; i < indicatorRow.row.count; i++) {
156− compare(get_indicator_item(i).dimmed, i === data.index ? data.current: data.other, "Indicator dim did not match for item iter");
157− }
158− }
159− }
160−}
tests/qmltests/Panel/Old/tst_Indicators.qmldeleted−230
@@ -1,230 +0,0 @@
1−/*
2− * Copyright 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− */
16−
17−import QtQuick 2.0
18−import QtTest 1.0
19−import Unity.Test 0.1 as UT
20−import Ubuntu.Components 0.1 as UC
21−import ".."
22−import "../../../qml/Panel"
23−import "../../../qml/Components"
24−
25−/*
26− This tests the Indicators component by using a fake model to stage data in the indicators
27− A view will show with indicators at the top, as does in the shell. There is a clickable area
28− marked "Click Me" which can be used to expose the indicators.
29−*/
30−Item {
31− id: shell
32− width: units.gu(40)
33− height: units.gu(80)
34−
35− PanelBackground {
36− anchors.fill: indicators
37− }
38−
39− Indicators {
40− id: indicators
41− anchors {
42− right: parent.right
43− }
44− width: (shell.width > units.gu(60)) ? units.gu(40) : shell.width
45− y: 0
46− shown: false
47− profile: "test1"
48−
49− openedHeight: parent.height - button.height
50− }
51−
52− UC.Button {
53− id: button
54− text: indicators.shown ? "Hide" : "Show"
55− anchors {
56− bottom: shell.bottom
57− left: parent.left
58− right: parent.right
59− }
60− height: 50
61−
62− onClicked: {
63− if (!indicators.shown) {
64− indicators.show();
65− } else {
66− indicators.hide();
67− }
68− }
69− }
70−
71− UT.UnityTestCase {
72− name: "Indicators"
73− when: windowShown
74−
75− function init() {
76− indicators.initialise();
77−
78− indicators.hide();
79− tryCompare(indicators.hideAnimation, "running", false);
80− tryCompare(indicators, "state", "initial");
81− }
82−
83− // Showing the indicators should fully open the indicator panel.
84− function test_show() {
85− indicators.show()
86− tryCompare(indicators, "fullyOpened", true);
87− }
88−
89− // Test the change in the revealer lateral position changes the current panel menu to fit the position
90− // of the indicator in the row.
91− function test_change_revealer_lateral_position()
92− {
93− // tests changing the lateral position of the revealer activates the correct indicator items.
94−
95− var indicatorRow = findChild(indicators, "indicatorRow")
96− verify(indicatorRow !== null);
97− var indicatorRowItems = findChild(indicatorRow, "indicatorRowItems");
98− verify(indicatorRowItems !== null);
99−
100− for (var i = 0; i < indicatorRowItems.count; i++) {
101− var indicatorItem = findChild(indicatorRowItems, "item" + i);
102−
103− if (!indicatorItem.visible)
104− continue;
105−
106− var indicatorPosition = indicators.mapFromItem(indicatorItem,
107− indicatorItem.width/2, indicatorItem.height/2);
108−
109− touchFlick(indicators,
110− indicatorPosition.x, indicatorPosition.y,
111− indicatorPosition.x, indicators.openedHeight * 0.4,
112− true /* beginTouch */, false /* endTouch */);
113−
114− compare(indicatorRow.currentItem, indicatorItem,
115− "Incorrect item activated at position " + i);
116−
117− touchFlick(indicators,
118− indicatorPosition.x, indicators.openedHeight * 0.4,
119− indicatorPosition.x, indicatorPosition.y,
120− false /* beginTouch */, true /* endTouch */);
121−
122− // wait until fully closed
123− tryCompare(indicators, "height", indicators.panelHeight);
124− }
125− }
126−
127− // values for specific state changes are subject to internal decisions, so we can't
128− // determine the true height value which would cause the state to change without making
129− // too many assuptyions
130− // However, we can assume that a partially opened panel will not be initial, and fully
131− // opened panel will be locked.
132−
133− function test_progress_changes_state_to_not_initial() {
134− indicators.height = indicators.openedHeight / 2
135− compare(indicators.state!="initial", true,
136− "Indicators should not be in initial state when partially opened.");
137− }
138−
139− function test_progress_changes_state_to_locked() {
140− indicators.height = indicators.openedHeight - indicators.panelHeight
141− compare(indicators.state, "locked", "Indicators should be locked when fully opened.");
142− }
143−
144− function test_partially_open() {
145− indicators.height = indicators.openedHeight / 2
146− compare(indicators.partiallyOpened, true,
147− "Indicator should show as partially opened when height is half of openedHeight");
148− compare(indicators.fullyOpened, false,
149− "Indicator should not show as fully opened when height is half of openedHeight");
150− }
151−
152− function test_fully_open() {
153− indicators.height = indicators.openedHeight
154− compare(indicators.partiallyOpened, false);
155− compare(indicators.fullyOpened, true);
156− }
157−
158− function init_invisible_indicator(identifier) {
159− tryCompareFunction(function() { return findChild(indicators, identifier+"-delegate") !== undefined }, true);
160− var item = findChild(indicators, identifier+"-delegate");
161−
162− item.enabled = false;
163− }
164−
165− function test_row_visible_menuContent_visible_data() { return [
166− {tag: "first", visible: [false, true, true, true, true] },
167− {tag: "adjacent", visible: [true, false, false, true, true] },
168− {tag: "bounds", visible: [false, true, true, true, false] },
169− {tag: "disjoint", visible: [true, false, true, false, true] },
170− {tag: "last", visible: [true, true, true, true, false] }];
171− }
172−
173− function test_row_visible_menuContent_visible(data) {
174− indicators.show();
175−
176− var contentListView = findChild(indicators, "indicatorsContentListView");
177− var indicatorRowItems = findChild(indicators, "indicatorRowItems");
178−
179− var count = data.visible.length
180− for (var i = 0; i< data.visible.length; i++) {
181− if (data.visible[i] === false) {
182− init_invisible_indicator("indicator-fake" + (i + 1));
183− count--;
184− }
185− }
186−
187− tryCompare(indicatorRowItems, "count", count);
188−
189− for (i = 0; i < data.visible.length; i++) {
190− var widgetName = "indicator-fake" + (i + 1 + "-widget");
191− var pageName = "indicator-fake" + (i + 1 + "-page");
192−
193− // check for item
194− tryCompareFunction(function() { return findChild(indicatorRowItems, widgetName) !== null }, data.visible[i]);
195−
196− // check for tab
197− tryCompareFunction(function() { return findChild(contentListView, pageName) !== null }, data.visible[i]);
198− }
199− }
200−
201− function test_indicator_visible_correct_menu_data() { return [
202− {tag: "current-first", currentIndex: 0, visible: [false, true, true, true, true], expectedIndex: 0, expextedMenu: "indicator-fake2" },
203− {tag: "current-last", currentIndex: 4, visible: [true, true, true, true, false], expectedIndex: 3, expextedMenu: "indicator-fake4" },
204− {tag: "after", currentIndex: 0, visible: [true, false, true, true, true], expectedIndex: 0, expextedMenu: "indicator-fake1" },
205− {tag: "before", currentIndex: 1, visible: [false, true, true, true, true], expectedIndex: 1, expextedMenu: "indicator-fake2" }];
206− }
207−
208− function test_indicator_visible_correct_menu(data) {
209− var contentListView = findChild(indicators, "indicatorsContentListView");
210− var indicatorRow = findChild(indicators, "indicatorRow");
211−
212− indicators.show();
213− indicatorRow.setCurrentItemIndex(data.currentIndex);
214− tryCompare(indicators, "fullyOpened", true);
215−
216− for (var i = 0; i< data.visible.length; i++) {
217− if (data.visible[i] === false) {
218− init_invisible_indicator("indicator-fake" + (i + 1));
219− }
220− }
221−
222− // check for current selected item
223− tryCompare(indicatorRow, "currentItemIndex", data.expectedIndex);
224−
225− // check for current selected tab
226− tryCompareFunction(function() { return findChild(contentListView, data.expextedMenu) === contentListView.currentItem }, true);
227−
228− }
229− }
230−}
tests/qmltests/Panel/Old/tst_Panel.qmldeleted−236
@@ -1,236 +0,0 @@
1−/*
2− * Copyright 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− */
16−
17−import QtQuick 2.1
18−import QtQuick.Layouts 1.1
19−import QtTest 1.0
20−import Unity.Test 0.1 as UT
21−import Ubuntu.Components 0.1
22−import Unity.Indicators 0.1 as Indicators
23−import Ubuntu.Telephony 0.1 as Telephony
24−import "../../../../qml/Panel"
25−
26−IndicatorTest {
27− id: root
28− width: units.gu(100)
29− height: units.gu(71)
30− color: "white"
31−
32− property string indicatorProfile: "phone"
33−
34− RowLayout {
35− anchors.fill: parent
36− anchors.margins: units.gu(1)
37− clip: true
38−
39− Rectangle {
40− Layout.fillWidth: true
41− Layout.fillHeight: true
42−
43− id: itemArea
44− color: "blue"
45−
46− Panel {
47− id: panel
48− anchors.fill: parent
49− indicators {
50− width: parent.width > units.gu(60) ? units.gu(40) : parent.width
51− indicatorsModel: root.indicatorsModel
52− }
53−
54− property real panelAndSeparatorHeight: panel.indicators.minimizedPanelHeight + units.dp(2)
55− }
56− }
57−
58− ColumnLayout {
59− Layout.alignment: Qt.AlignTop
60− Layout.fillWidth: false
61−
62− Button {
63− Layout.fillWidth: true
64− text: panel.indicators.shown ? "Hide" : "Show"
65− onClicked: {
66− if (panel.indicators.shown) {
67− panel.indicators.hide();
68− } else {
69− panel.indicators.show();
70− }
71− }
72− }
73−
74− Button {
75− text: panel.fullscreenMode ? "Maximize" : "FullScreen"
76− Layout.fillWidth: true
77− onClicked: panel.fullscreenMode = !panel.fullscreenMode
78− }
79−
80− Button {
81− Layout.fillWidth: true
82− text: callManager.hasCalls ? "Called" : "No Calls"
83− onClicked: {
84− if (callManager.foregroundCall) {
85− callManager.foregroundCall = null;
86− } else {
87− callManager.foregroundCall = phoneCall;
88− }
89− }
90− }
91−
92− Rectangle {
93− Layout.preferredHeight: units.dp(1);
94− Layout.fillWidth: true;
95− color: "black"
96− }
97−
98− Repeater {
99− model: indicatorsModel.originalModelData
100− RowLayout {
101− CheckBox {
102− checked: true
103− onCheckedChanged: checked ? insertIndicator(index) : removeIndicator(index);
104− }
105− Label { text: modelData["identifier"] }
106− }
107− }
108− }
109− }
110−
111− Telephony.CallEntry {
112− id: phoneCall
113− phoneNumber: "+447812221111"
114− }
115−
116− UT.UnityTestCase {
117− name: "Panel"
118− when: windowShown
119−
120− function init() {
121− panel.fullscreenMode = false;
122− callManager.foregroundCall = null;
123−
124− panel.indicators.hide();
125− // Wait for animation to complete
126− tryCompare(panel.indicators.hideAnimation, "running", false);
127−
128− // Wait for the indicators to get into position.
129− // (switches between normal and fullscreen modes are animated)
130− var indicatorArea = findChild(panel, "indicatorArea");
131− tryCompare(indicatorArea, "y", 0);
132− }
133−
134− function get_indicator_item(index) {
135− var indicatorItem = findChild(panel, indicatorsModel.originalModelData[index]["identifier"]+"-panelItem");
136− verify(indicatorItem !== null);
137−
138− return indicatorItem;
139− }
140−
141− function test_drag_show_data() {
142− return [
143− { tag: "pinned", fullscreen: false, call: null,
144− indicatorY: 0 },
145− { tag: "fullscreen", fullscreen: true, call: null,
146− indicatorY: -panel.panelAndSeparatorHeight },
147− { tag: "pinned-callActive", fullscreen: false, call: phoneCall,
148− indicatorY: 0},
149− { tag: "fullscreen-callActive", fullscreen: true, call: phoneCall,
150− indicatorY: -panel.panelAndSeparatorHeight }
151− ];
152− }
153−
154− // Dragging from a indicator item in the panel will gradually expose the
155− // indicators, first by running the hint animation, then after dragging down will
156− // expose more of the panel, binding it to the selected indicator and opening it's menu.
157− function test_drag_show(data) {
158− panel.fullscreenMode = data.fullscreen;
159− callManager.foregroundCall = data.call;
160−
161− var indicatorRow = findChild(panel.indicators, "indicatorItemRow");
162− verify(indicatorRow !== null);
163−
164− var menuContent = findChild(panel.indicators, "menuContent");
165− verify(menuContent !== null);
166−
167− var indicatorArea = findChild(panel, "indicatorArea");
168− verify(indicatorArea !== null);
169−
170− // Wait for the indicators to get into position.
171− // (switches between normal and fullscreen modes are animated)
172− tryCompareFunction(function() { return indicatorArea.y }, data.indicatorY);
173−
174− for (var i = 0; i < indicatorsModel.originalModelData.length; i++) {
175− var indicatorItem = get_indicator_item(i);
176− var mappedPosition = root.mapFromItem(indicatorItem, indicatorItem.width / 2, indicatorItem.height / 2);
177−
178− touchFlick(panel,
179− mappedPosition.x, panel.indicators.minimizedPanelHeight / 2,
180− mappedPosition.x, panel.height,
181− true /* beginTouch */, false /* endTouch */, units.gu(5), 15);
182−
183− // Indicators height should follow the drag, and therefore increase accordingly.
184− // They should be at least half-way through the screen
185− tryCompareFunction(
186− function() {return panel.indicators.height >= panel.height * 0.5},
187− true);
188−
189− touchRelease(panel, mappedPosition.x, panel.height);
190−
191− compare(indicatorRow.currentItemIndex, i, "Indicator item should be activated at position " + i);
192− compare(menuContent.currentMenuIndex, i, "Menu conetent should be activated for item at position " + i);
193−
194− // init for next indicatorItem
195− panel.indicators.hide();
196− tryCompare(panel.indicators.hideAnimation, "running", false);
197− tryCompare(panel.indicators, "state", "initial");
198− }
199− }
200−
201− function test_hint_data() {
202− return [
203− { tag: "normal", fullscreen: false, call: null, hintExpected: true},
204− { tag: "fullscreen", fullscreen: true, call: null, hintExpected: false},
205− { tag: "call hint", fullscreen: false, call: phoneCall, hintExpected: false},
206− ];
207− }
208−
209− function test_hint(data) {
210− panel.fullscreenMode = data.fullscreen;
211− callManager.foregroundCall = data.call;
212−
213− if (data.fullscreen) {
214− // Wait for the indicators to get into position.
215− // (switches between normal and fullscreen modes are animated)
216− var indicatorArea = findChild(panel, "indicatorArea");
217− tryCompare(indicatorArea, "y", -panel.panelHeight);
218− }
219−
220− var indicatorItem = get_indicator_item(0);
221− var mappedPosition = root.mapFromItem(indicatorItem, indicatorItem.width / 2, indicatorItem.height / 2);
222−
223− touchPress(panel, mappedPosition.x, panel.indicators.minimizedPanelHeight / 2);
224−
225− // Give some time for a hint animation to change things, if any
226− wait(500);
227−
228− // no hint animation when fullscreen
229− compare(panel.indicators.fullyClosed, !data.hintExpected, "Indicator should be fully closed");
230− compare(panel.indicators.partiallyOpened, data.hintExpected, "Indicator should be partialy opened");
231− compare(panel.indicators.fullyOpened, false, "Indicator should not be fully opened");
232−
233− touchRelease(panel, mappedPosition.x, panel.minimizedPanelHeight / 2);
234− }
235− }
236−}