2 * Copyright (C) 2014 Canonical, Ltd.
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.
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.
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/>.
18 import Ubuntu.Telephony 0.1 as Telephony
19 import Ubuntu.Components 1.3
20 import Unity.Application 0.1
21 import "../Components"
26 property bool greeterShown: false
28 readonly property bool active: {
29 var application = ApplicationManager.findApplication("dialer-app");
31 if (callManager.callIndicatorVisible) {
32 // at the moment, callIndicatorVisible is only "valid" if dialer is in focus.
33 if (application && ApplicationManager.focusedApplicationId === "dialer-app") {
34 // Don't show if application is still starting; might get a fleeting true/false.
35 return application.state !== ApplicationInfoInterface.Starting;
38 if (greeterShown || ApplicationManager.focusedApplicationId !== "dialer-app") {
40 // Don't show if application is still starting; might get a fleeting true/false.
41 return application.state !== ApplicationInfoInterface.Starting && callManager.hasCalls;
43 return callManager.hasCalls;
47 readonly property QtObject contactWatcher: _contactWatcher
48 property int labelSwitchInterval: 6000
49 implicitWidth: row.x + row.width
51 Component.onCompleted: {
52 telepathyHelper.registerChannelObserver("unity8");
55 function showLiveCall() {
56 Qt.openUrlExternally("dialer:///?view=liveCall");
64 objectName: "contactColumn"
66 anchors.left: parent.left
68 Component.onCompleted: {
70 labelPathView.column1 = column;
72 labelPathView.column2 = column;
77 height: callHint.height
78 verticalAlignment: Text.AlignVCenter
79 text: i18n.tr("Tap to return to call...");
83 objectName: "contactLabel"
84 height: callHint.height
85 verticalAlignment: Text.AlignVCenter
86 width: Math.max(contentWidth, 1)
91 } else if (d.activeCall.isConference) {
92 return i18n.tr("Conference");
94 return contactWatcher.alias !== "" ? contactWatcher.alias : contactWatcher.phoneNumber;
105 bottom: parent.bottom
107 leftMargin: units.gu(1)
113 objectName: "timeLabel"
117 bottom: parent.bottom
119 verticalAlignment: Text.AlignVCenter
120 horizontalAlignment: Text.AlignRight
122 var m = Math.floor(d.callTime/60);
123 var ss = d.callTime % 60;
127 return m + ":0" + ss;
134 objectName: "labelPathView"
138 bottom: parent.bottom
140 width: column1 && column2 ? Math.max(column1.width, column1.width) : 0
143 property Column column1
144 property Column column2
145 property int columnHeight: column1 ? column1.height : 0
147 delegate: contactColumn
153 startY: -labelPathView.columnHeight / 2
155 y: labelPathView.columnHeight * 1.5
163 // ensure we go faster than the label switch
164 duration: labelSwitchInterval/8
166 easing.type: Easing.InOutQuad
173 id: alternateLabelTimer
174 running: callHint.active
175 interval: labelPathView.offset % 1.0 !== 0 ? labelSwitchInterval : labelSwitchInterval/4
180 offsetBehaviour.enabled = false;
181 labelPathView.offset = 0;
182 offsetBehaviour.enabled = true;
187 labelPathView.offset = labelPathView.offset + 0.5;
191 Telephony.ContactWatcher {
193 objectName: "contactWatcher"
194 phoneNumber: d.activeCall ? d.activeCall.phoneNumber : ""
200 property QtObject activeCall: {
201 if (callManager.foregroundCall) {
202 return callManager.foregroundCall;
204 return callManager.backgroundCall;
206 property int callTime: activeCall ? activeCall.elapsedTime : 0