on xenial help sign in
Added ActiveCallHint
commitc71e68414d3cf14a0ed5a1419d247d38fc8dda28 authorNick Dedekind <nicholas.dedekind@gmail.com> dateTue 29 Apr 2014, 16:01 (13 years ago) parentba71822
5 files changed+274−99
qml/Panel/ActiveCallHint.qml+143 qml/Panel/Indicators.qml+1−3 qml/Panel/Panel.qml+109−84 qml/Shell.qml+20−12 tests/qmltests/Panel/tst_Panel.qml+1
qml/Panel/ActiveCallHint.qmlnew file+143
@@ -0,0 +1,143 @@
1+/*
2+ * Copyright (C) 2014 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.Telephony 0.1 as Telephony
19+import Ubuntu.Components 0.1
20+import Unity.Application 0.1
21+import "../Components"
22+
23+Rectangle {
24+ id: callHint
25+
26+ readonly property bool active: callManager.hasCalls && ApplicationManager.focusedApplicationId !== "dialer-app"
27+
28+ Component.onCompleted: {
29+ telepathyHelper.registerChannelObserver("unity8");
30+ }
31+
32+ color: Qt.rgba(0,0.8,0,1)
33+ clip: true
34+
35+ MouseArea {
36+ anchors.fill: parent
37+ onClicked: {
38+ ApplicationManager.requestFocusApplication("dialer-app");
39+ }
40+ }
41+
42+ Column {
43+ id: column
44+
45+ anchors {
46+ left: parent.left
47+ leftMargin:units.gu(1)
48+ right: time.left
49+ }
50+ y: 0
51+ Behavior on y { StandardAnimation { duration: 400 } }
52+
53+ Label {
54+ id: label1
55+ anchors {
56+ left: parent.left
57+ right: parent.right
58+ }
59+ height: callHint.height
60+ verticalAlignment: Text.AlignVCenter
61+
62+ text: {
63+ if (!d.activeCall) {
64+ return "";
65+ } else if (d.activeCall.isConference) {
66+ return i18n.tr("Conference");
67+ } else {
68+ return contactWatcher.alias !== "" ? contactWatcher.alias : contactWatcher.phoneNumber;
69+ }
70+ }
71+ }
72+
73+ Label {
74+ id: label2
75+ anchors {
76+ left: parent.left
77+ right: parent.right
78+ }
79+ height: callHint.height
80+ verticalAlignment: Text.AlignVCenter
81+ text: i18n.tr("Tap to return to call...");
82+ }
83+ }
84+
85+ Label {
86+ id: time
87+ anchors {
88+ right: parent.right
89+ rightMargin:units.gu(1)
90+ top: parent.top
91+ }
92+ height: parent.height
93+ verticalAlignment: Text.AlignVCenter
94+ text: {
95+ if (!d.activeCall) {
96+ return "0:00";
97+ }
98+ var m = Math.round(d.activeCall.elapsedTime/60);
99+ var ss = d.activeCall.elapsedTime % 60;
100+ if (ss >= 10) {
101+ return m + ":" + ss;
102+ } else {
103+ return m + ":0" + ss;
104+ }
105+ }
106+ }
107+
108+ Telephony.ContactWatcher {
109+ id: contactWatcher
110+ phoneNumber: d.activeCall ? d.activeCall.phoneNumber : ""
111+ }
112+
113+ Timer {
114+ running: callHint.active
115+ interval: 4000
116+ repeat: true
117+
118+ property int iteration: 0
119+
120+ onRunningChanged: iteration = 0; // bit longer for the first one.
121+
122+ onTriggered: {
123+ // every 4 seconds.
124+ if (iteration % 2 == 0) {
125+ column.y = -label1.height;
126+ } else {
127+ column.y = 0;
128+ }
129+ iteration++;
130+ }
131+ }
132+
133+ QtObject {
134+ id: d
135+
136+ property QtObject activeCall: {
137+ if (callManager.foregroundCall) {
138+ return callManager.foregroundCall;
139+ }
140+ return callManager.backgroundCall;
141+ }
142+ }
143+}
qml/Panel/Indicators.qml+1−3
@@ -48,14 +48,12 @@ Showable {
4848 // use its own values. Need to ask design about this.
4949 showAnimation: StandardAnimation {
5050 property: "height"
51− duration: 350
5251 to: openedHeight
53− easing.type: Easing.OutCubic
5452
5553 // Re-size if we've changed the openHeight while shown.
5654 onToChanged: {
5755 if (indicators.shown) {
58− indicators.show();
56+ height = openedHeight;
5957 }
6058 }
6159 }
qml/Panel/Panel.qml+109−84
@@ -20,14 +20,12 @@ import "../Components"
2020
2121Item {
2222 id: root
23− readonly property real panelHeight: units.gu(3) + units.dp(2)
24− property real indicatorsMenuWidth: (shell.width > units.gu(60)) ? units.gu(40) : shell.width
23+ readonly property real panelHeight: callHint.active ? callHint.height + lowerPanelHeight : lowerPanelHeight
24+ property real indicatorsMenuWidth: (width > units.gu(60)) ? units.gu(40) : width
2525 property alias indicators: indicatorsMenu
2626 property bool fullscreenMode: false
2727 property bool searchVisible: true
28−
29− readonly property real separatorLineHeight: leftSeparatorLine.height
30− readonly property real __panelMinusSeparatorLineHeight: panelHeight - separatorLineHeight
28+ readonly property real lowerPanelHeight: indicatorsMenu.panelHeight + leftSeparatorLine.height
3129
3230 signal searchClicked
3331
@@ -53,120 +51,147 @@ Item {
5351 onShownChanged: hideTimer.stop()
5452 }
5553
56− PanelBackground {
57− id: panelBackground
54+ ActiveCallHint {
55+ id: callHint
56+
5857 anchors {
5958 left: parent.left
6059 right: parent.right
6160 }
62− height: __panelMinusSeparatorLineHeight
63− y: 0
61+ height: units.gu(3)
6462
65− Behavior on y { StandardAnimation { duration: UbuntuAnimation.FastDuration } }
66− }
63+ y: active ? 0 : -height
64+ z: 1
6765
68− PanelSeparatorLine {
69− id: leftSeparatorLine
70− anchors {
71− top: panelBackground.bottom
72− left: parent.left
73− right: indicatorsMenu.left
74− }
75− saturation: 1 - indicatorsMenu.unitProgress
66+ Behavior on y { StandardAnimation {} }
7667 }
7768
78− Rectangle {
79− id: darkenedArea
80− property real darkenedOpacity: 0.6
69+ Item {
70+ id: lowerPanel
71+
8172 anchors {
8273 left: parent.left
8374 right: parent.right
84− top: panelBackground.bottom
85− bottom: parent.bottom
8675 }
87− color: "black"
88− opacity: indicatorsMenu.unitProgress * darkenedOpacity
89− MouseArea {
90− anchors.fill: parent
91− enabled: indicatorsMenu.shown
92− onClicked: if (indicatorsMenu.fullyOpened) indicatorsMenu.hide();
76+ height: root.height - lowerPanel.y
77+ z: 0
78+
79+ PanelBackground {
80+ id: panelBackground
81+ anchors {
82+ top: parent.top
83+ left: parent.left
84+ right: parent.right
85+ }
86+ height: indicatorsMenu.panelHeight
9387 }
94− }
9588
96− Indicators {
97− id: indicatorsMenu
98− objectName: "indicators"
99−
100− anchors.right: parent.right
101− y: panelBackground.y
102− width: root.indicatorsMenuWidth
103− shown: false
104− panelHeight: __panelMinusSeparatorLineHeight
105− openedHeight: parent.height + (pinnedMode ? 0 : root.panelHeight)
106− pinnedMode: !fullscreenMode
107− overFlowWidth: search.state=="hidden" ? parent.width : parent.width - search.width
108− }
109−
110− PanelSeparatorLine {
111− id: indicatorsSeparatorLine
112− visible: true
113− anchors {
114− left: indicatorsMenu.left
115− right: indicatorsMenu.right
89+ PanelSeparatorLine {
90+ id: leftSeparatorLine
91+ anchors {
92+ top: panelBackground.bottom
93+ left: parent.left
94+ right: indicatorsMenu.left
95+ }
96+ saturation: 1 - indicatorsMenu.unitProgress
11697 }
117− y: indicatorsMenu.visualBottom
118− }
11998
120− BorderImage {
121− id: dropShadow
122− anchors {
123− top: indicators.top
124− bottom: indicatorsSeparatorLine.bottom
125− left: indicators.left
126− right: indicators.right
127− margins: -units.gu(1)
99+ Rectangle {
100+ id: darkenedArea
101+ property real darkenedOpacity: 0.6
102+ anchors {
103+ left: parent.left
104+ right: parent.right
105+ top: panelBackground.bottom
106+ bottom: parent.bottom
107+ }
108+ color: "black"
109+ opacity: indicatorsMenu.unitProgress * darkenedOpacity
110+ MouseArea {
111+ anchors.fill: parent
112+ enabled: indicatorsMenu.shown
113+ onClicked: if (indicatorsMenu.fullyOpened) indicatorsMenu.hide();
114+ }
128115 }
129− visible: indicatorsMenu.height > indicatorsMenu.panelHeight
130− source: "graphics/rectangular_dropshadow.sci"
131− }
132116
133− SearchIndicator {
134− id: search
135− objectName: "search"
136− enabled: root.searchVisible
117+ Indicators {
118+ id: indicatorsMenu
119+ objectName: "indicators"
137120
138− state: {
139− if (parent.width < indicatorsMenu.width + width) {
140− if (indicatorsMenu.state != "initial") {
141− return "hidden";
142− }
143− }
144− if (root.searchVisible && !indicatorsMenu.showAll) {
145− return "visible";
121+ anchors {
122+ top: parent.top
123+ right: parent.right
146124 }
147125
148− return "hidden";
126+ width: root.indicatorsMenuWidth
127+ shown: false
128+ panelHeight: units.gu(3)
129+ openedHeight: parent.height
130+ pinnedMode: !fullscreenMode
131+ overFlowWidth: search.state=="hidden" ? parent.width : parent.width - search.width
149132 }
150133
151− height: __panelMinusSeparatorLineHeight
152− anchors {
153− top: panelBackground.top
154− left: panelBackground.left
134+ PanelSeparatorLine {
135+ id: indicatorsSeparatorLine
136+ visible: true
137+ anchors {
138+ left: indicatorsMenu.left
139+ right: indicatorsMenu.right
140+ }
141+ y: indicatorsMenu.visualBottom
155142 }
156143
157− onClicked: root.searchClicked()
144+ BorderImage {
145+ id: dropShadow
146+ anchors {
147+ top: indicators.top
148+ bottom: indicatorsSeparatorLine.bottom
149+ left: indicators.left
150+ right: indicators.right
151+ margins: -units.gu(1)
152+ }
153+ visible: indicatorsMenu.height > indicatorsMenu.panelHeight
154+ source: "graphics/rectangular_dropshadow.sci"
155+ }
156+
157+ SearchIndicator {
158+ id: search
159+ objectName: "search"
160+ enabled: root.searchVisible
161+
162+ state: {
163+ if (parent.width < indicatorsMenu.width + width) {
164+ if (indicatorsMenu.state != "initial") {
165+ return "hidden";
166+ }
167+ }
168+ if (root.searchVisible && !indicatorsMenu.showAll) {
169+ return "visible";
170+ }
171+
172+ return "hidden";
173+ }
174+
175+ anchors {
176+ top: panelBackground.top
177+ left: panelBackground.left
178+ }
179+ height: panelBackground.height
180+
181+ onClicked: root.searchClicked()
182+ }
158183 }
159184
160185 states: [
161186 State {
162187 name: "in" //fully opaque and visible at top edge of screen
163188 when: !fullscreenMode
164− PropertyChanges { target: panelBackground; y: 0 }
189+ PropertyChanges { target: lowerPanel; y: callHint.y + callHint.height }
165190 },
166191 State {
167192 name: "out" //pushed off screen
168193 when: fullscreenMode
169− PropertyChanges { target: panelBackground; y: -panelHeight }
194+ PropertyChanges { target: lowerPanel; y: callHint.y + callHint.height - lowerPanelHeight }
170195 }
171196 ]
172197}
qml/Shell.qml+20−12
@@ -151,10 +151,10 @@ FocusScope {
151151 shown: disappearingAnimationProgress !== 1.0
152152 enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
153153
154− anchors {
155− fill: parent
156− topMargin: panel.panelHeight
157− }
154+ y: panel.panelHeight
155+ width: parent.width
156+ height: parent.height - panel.panelHeight
157+ Behavior on y { StandardAnimation {} }
158158
159159 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
160160 opacity: 1.0 - disappearingAnimationProgress
@@ -317,10 +317,13 @@ FocusScope {
317317 enabled: true
318318 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
319319 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
320+
320321 y: panel.panelHeight
321322 x: required ? 0 : - width
322323 width: parent.width
323324 height: parent.height - panel.panelHeight
325+ Behavior on y { StandardAnimation {} }
326+
324327 background: shell.background
325328 pinLength: 4
326329
@@ -375,6 +378,8 @@ FocusScope {
375378 y: panel.panelHeight
376379 width: parent.width
377380 height: parent.height - panel.panelHeight
381+ Behavior on y { StandardAnimation {} }
382+ Behavior on height { StandardAnimation {} }
378383
379384 dragHandleWidth: shell.edgeSize
380385
@@ -574,12 +579,12 @@ FocusScope {
574579 model: NotificationBackend.Model
575580 margin: units.gu(1)
576581
577− anchors {
578− top: parent.top
579− right: parent.right
580− bottom: parent.bottom
581− topMargin: panel.panelHeight
582− }
582+ y: panel.panelHeight
583+ width: parent.width
584+ height: parent.height - panel.panelHeight
585+ Behavior on y { StandardAnimation {} }
586+ Behavior on height { StandardAnimation {} }
587+
583588 states: [
584589 State {
585590 name: "narrow"
@@ -632,8 +637,11 @@ FocusScope {
632637 }
633638
634639 OSKController {
635− anchors.topMargin: panel.panelHeight
636− anchors.fill: parent // as needs to know the geometry of the shell
640+ y: panel.panelHeight
641+ width: parent.width
642+ height: parent.height - panel.panelHeight
643+ Behavior on y { StandardAnimation {} }
644+ Behavior on height { StandardAnimation {} }
637645 }
638646
639647 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
tests/qmltests/Panel/tst_Panel.qml+1
@@ -40,6 +40,7 @@ Item {
4040 Panel {
4141 id: panel
4242 anchors.fill: parent
43+ fullscreenMode: true
4344
4445 indicators {
4546 profile: "test1"