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 0.1
20 import Unity.Application 0.1
21 import "../Components"
26 readonly property bool active: {
27 var application = ApplicationManager.findApplication("dialer-app");
29 if (callManager.callIndicatorVisible) {
30 // at the moment, callIndicatorVisible is only "valid" if dialer is in focus.
31 if (application && ApplicationManager.focusedApplicationId === "dialer-app") {
32 // Don't show if application is still starting; might get a fleeting true/false.
33 return application.state !== ApplicationInfoInterface.Starting;
36 if (ApplicationManager.focusedApplicationId !== "dialer-app") {
38 // Don't show if application is still starting; might get a fleeting true/false.
39 return application.state !== ApplicationInfoInterface.Starting && callManager.hasCalls;
41 return callManager.hasCalls;
45 readonly property QtObject contactWatcher: _contactWatcher
46 property int labelSwitchInterval: 6000
47 implicitWidth: row.x + row.width
49 Component.onCompleted: {
50 telepathyHelper.registerChannelObserver("unity8");
53 function showLiveCall() {
54 Qt.openUrlExternally("dialer:///?view=liveCall");
62 objectName: "contactColumn"
64 anchors.left: parent.left
66 Component.onCompleted: {
68 labelPathView.column1 = column;
70 labelPathView.column2 = column;
75 height: callHint.height
76 verticalAlignment: Text.AlignVCenter
77 text: i18n.tr("Tap to return to call...");
81 objectName: "contactLabel"
82 height: callHint.height
83 verticalAlignment: Text.AlignVCenter
84 width: Math.max(contentWidth, 1)
89 } else if (d.activeCall.isConference) {
90 return i18n.tr("Conference");
92 return contactWatcher.alias !== "" ? contactWatcher.alias : contactWatcher.phoneNumber;
103 bottom: parent.bottom
105 leftMargin: units.gu(1)
111 objectName: "timeLabel"
115 bottom: parent.bottom
117 verticalAlignment: Text.AlignVCenter
118 horizontalAlignment: Text.AlignRight
120 var m = Math.round(d.callTime/60);
121 var ss = d.callTime % 60;
125 return m + ":0" + ss;
132 objectName: "labelPathView"
136 bottom: parent.bottom
138 width: column1 && column2 ? Math.max(column1.width, column1.width) : 0
141 property Column column1
142 property Column column2
143 property int columnHeight: column1 ? column1.height : 0
145 delegate: contactColumn
151 startY: -labelPathView.columnHeight / 2
153 y: labelPathView.columnHeight * 1.5
161 // ensure we go faster than the label switch
162 duration: labelSwitchInterval/8
164 easing.type: Easing.InOutQuad
171 id: alternateLabelTimer
172 running: callHint.active
173 interval: labelPathView.offset % 1.0 !== 0 ? labelSwitchInterval : labelSwitchInterval/4
178 offsetBehaviour.enabled = false;
179 labelPathView.offset = 0;
180 offsetBehaviour.enabled = true;
185 labelPathView.offset = labelPathView.offset + 0.5;
189 Telephony.ContactWatcher {
191 objectName: "contactWatcher"
192 phoneNumber: d.activeCall ? d.activeCall.phoneNumber : ""
198 property QtObject activeCall: {
199 if (callManager.foregroundCall) {
200 return callManager.foregroundCall;
202 return callManager.backgroundCall;
204 property int callTime: activeCall ? activeCall.elapsedTime : 0