mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
wrap voiceCall calls to a single qml file
this will make easier to port to $whatever if needed
This commit is contained in:
parent
248095bdf3
commit
e640d7f33f
4 changed files with 227 additions and 104 deletions
|
|
@ -22,17 +22,15 @@ import QtQuick 2.0
|
|||
import QtQuick.Layouts 1.1
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||
import org.nemomobile.voicecall 1.0
|
||||
|
||||
import "../Dialpad"
|
||||
|
||||
Item {
|
||||
id: callPage
|
||||
|
||||
state: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.statusText : "disconnected"
|
||||
property int status: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.status : 0
|
||||
property string status: ofonoWrapper.status
|
||||
|
||||
property string providerId: voiceCallmanager.providers.id(0)
|
||||
property string providerId: ofonoWrapper.providerId
|
||||
|
||||
function secondsToTimeString(seconds) {
|
||||
seconds = Math.floor(seconds/1000)
|
||||
|
|
@ -46,7 +44,7 @@ Item {
|
|||
}
|
||||
|
||||
onStatusChanged: {
|
||||
if (status != 1) {
|
||||
if (status != "active") {
|
||||
dialerButton.checked = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -68,7 +66,7 @@ Item {
|
|||
|
||||
contentWidth: topContents.width
|
||||
contentHeight: topContents.height
|
||||
interactive: status == 1;
|
||||
interactive: status == "active";
|
||||
Row {
|
||||
id: topContents
|
||||
Avatar {
|
||||
|
|
@ -80,9 +78,7 @@ Item {
|
|||
height: topFlickable.height
|
||||
|
||||
callback: function (string) {
|
||||
if (voiceCallmanager.activeVoiceCall) {
|
||||
voiceCallmanager.activeVoiceCall.sendDtmf(string);
|
||||
}
|
||||
ofonoWrapper.sendToneToCall(string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -113,7 +109,7 @@ Item {
|
|||
horizontalAlignment: Qt.AlignHCenter
|
||||
verticalAlignment: Qt.AlignVCenter
|
||||
font.pointSize: theme.defaultFont.pointSize * 2
|
||||
text: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.lineId : ""
|
||||
text: ofonoWrapper.lineId
|
||||
}
|
||||
PlasmaComponents.Label {
|
||||
Layout.fillWidth: true
|
||||
|
|
@ -121,29 +117,29 @@ Item {
|
|||
horizontalAlignment: Qt.AlignHCenter
|
||||
verticalAlignment: Qt.AlignVCenter
|
||||
text: {
|
||||
if (!voiceCallmanager.activeVoiceCall) {
|
||||
if (!ofonoWrapper.hasActiveCall) {
|
||||
return '';
|
||||
//STATUS_DIALING
|
||||
} else if (voiceCallmanager.activeVoiceCall.status == 3) {
|
||||
} else if (ofonoWrapper.status == "dialing") {
|
||||
return i18n("Calling...");
|
||||
} else if (voiceCallmanager.activeVoiceCall.duration > 0) {
|
||||
return secondsToTimeString(voiceCallmanager.activeVoiceCall.duration);
|
||||
} else if (ofonoWrapper.duration > 0) {
|
||||
return secondsToTimeString(ofonoWrapper.duration);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
PlasmaComponents.ButtonRow {
|
||||
opacity: status == 1 ? 1 : 0
|
||||
opacity: status == "active" ? 1 : 0
|
||||
exclusive: false
|
||||
spacing: 0
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
PlasmaComponents.ToolButton {
|
||||
id: muteButton
|
||||
flat: false
|
||||
iconSource: voiceCallmanager.isMicrophoneMuted ? "audio-volume-muted" : "audio-volume-high"
|
||||
iconSource: ofonoWrapper.isMicrophoneMuted ? "audio-volume-muted" : "audio-volume-high"
|
||||
onClicked: {
|
||||
voiceCallmanager.isMicrophoneMuted = !voiceCallmanager.isMicrophoneMuted;
|
||||
ofonoWrapper.isMicrophoneMuted = !ofonoWrapper.isMicrophoneMuted;
|
||||
}
|
||||
}
|
||||
PlasmaComponents.ToolButton {
|
||||
|
|
@ -170,30 +166,24 @@ Item {
|
|||
AnswerSwipe {
|
||||
anchors.fill: parent
|
||||
//STATUS_INCOMING
|
||||
visible: status == 5
|
||||
visible: status == "incoming"
|
||||
onAccepted: {
|
||||
if (voiceCallmanager.activeVoiceCall) {
|
||||
voiceCallmanager.activeVoiceCall.answer();
|
||||
}
|
||||
ofonoWrapper.answer();
|
||||
}
|
||||
onRejected: {
|
||||
if (voiceCallmanager.activeVoiceCall) {
|
||||
voiceCallmanager.activeVoiceCall.hangup();
|
||||
}
|
||||
ofonoWrapper.hangup();
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaComponents.Button {
|
||||
anchors.fill: parent
|
||||
//STATUS_INCOMING
|
||||
visible: status != 5
|
||||
visible: status != "incoming"
|
||||
iconSource: "call-stop"
|
||||
Layout.fillWidth: true
|
||||
text: i18n("End Call")
|
||||
onClicked: {
|
||||
if (voiceCallmanager.activeVoiceCall) {
|
||||
voiceCallmanager.activeVoiceCall.hangup();
|
||||
}
|
||||
ofonoWrapper.hangup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import QtQuick 2.0
|
|||
import QtQuick.Layouts 1.1
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||
import org.nemomobile.voicecall 1.0
|
||||
import "../Dialpad"
|
||||
|
||||
Item {
|
||||
|
|
@ -30,7 +29,7 @@ Item {
|
|||
|
||||
property alias numberEntryText: status.text
|
||||
|
||||
property string providerId: voiceCallmanager.providers.id(0)
|
||||
property string providerId: ofonoWrapper.providerId
|
||||
|
||||
function addNumber(number) {
|
||||
status.text = status.text + number
|
||||
|
|
@ -59,10 +58,10 @@ Item {
|
|||
addNumber(string);
|
||||
}
|
||||
pressedCallback: function (string) {
|
||||
voiceCallmanager.startDtmfTone(string);
|
||||
ofonoWrapper.startTone(string);
|
||||
}
|
||||
releasedCallback: function (string) {
|
||||
voiceCallmanager.stopDtmfTone();
|
||||
ofonoWrapper.stopTone();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
195
dialer/package/contents/ui/OfonoWrapper.qml
Normal file
195
dialer/package/contents/ui/OfonoWrapper.qml
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
/**
|
||||
* Copyright 2015 Marco Martin <mart@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
import QtQuick 2.3
|
||||
import org.nemomobile.voicecall 1.0
|
||||
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
//BEGIN PROPERTIES
|
||||
property string status: "idle"
|
||||
|
||||
//support a single provider for now
|
||||
property string providerId: voiceCallmanager.providers.id(0)
|
||||
|
||||
//was the last call an incoming one?
|
||||
property bool isIncoming: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.isIncoming : false
|
||||
|
||||
//is there a call in progress?
|
||||
property bool hasActiveCall: voiceCallmanager.activeVoiceCall ? true : false
|
||||
|
||||
//if there is an active call, to what number?
|
||||
property string lineId: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.lineId : ""
|
||||
|
||||
//if there is a call, for how long?
|
||||
property int duration: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.duration : 0
|
||||
|
||||
//microphone muted?
|
||||
property alias isMicrophoneMuted: voiceCallmanager.isMicrophoneMuted
|
||||
//END PROPERTIES
|
||||
|
||||
//BEGIN SIGNAL HANDLERS
|
||||
Connections {
|
||||
target: dialerUtils
|
||||
onMissedCallsActionTriggered: {
|
||||
root.visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
//reset missed calls if the status is not STATUS_INCOMING when got visible
|
||||
if (visible && status != 5) {
|
||||
dialerUtils.resetMissedCalls();
|
||||
}
|
||||
}
|
||||
//END SIGNAL HANDLERS
|
||||
|
||||
//BEGIN FUNCTIONS
|
||||
function call(number) {
|
||||
if (!voiceCallmanager.activeVoiceCall) {
|
||||
console.log("Calling: " + providerId + " " + number);
|
||||
voiceCallmanager.dial(providerId, number);
|
||||
|
||||
} else {
|
||||
console.log("Hanging up: " + voiceCallmanager.activeVoiceCall.lineId);
|
||||
status.text = '';
|
||||
var call = voiceCallmanager.activeVoiceCall;
|
||||
if (call) {
|
||||
call.hangup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function answer() {
|
||||
if (voiceCallmanager.activeVoiceCall) {
|
||||
voiceCallmanager.activeVoiceCall.answer();
|
||||
}
|
||||
}
|
||||
|
||||
function hangup() {
|
||||
if (voiceCallmanager.activeVoiceCall) {
|
||||
voiceCallmanager.activeVoiceCall.hangup();
|
||||
}
|
||||
}
|
||||
|
||||
function sendToneToCall(key) {
|
||||
if (voiceCallmanager.activeVoiceCall) {
|
||||
voiceCallmanager.activeVoiceCall.sendDtmf(key);
|
||||
}
|
||||
}
|
||||
|
||||
function startTone(string) {
|
||||
voiceCallmanager.startDtmfTone(string);
|
||||
}
|
||||
|
||||
function stopTone() {
|
||||
voiceCallmanager.stopDtmfTone();
|
||||
}
|
||||
//END FUNCTIONS
|
||||
|
||||
//BEGIN DATABASE
|
||||
Component.onCompleted: {
|
||||
//HACK: make sure activeVoiceCall is loaded if already existing
|
||||
voiceCallmanager.voiceCalls.onVoiceCallsChanged();
|
||||
voiceCallmanager.onActiveVoiceCallChanged();
|
||||
}
|
||||
//END DATABASE
|
||||
|
||||
//BEGIN MODELS
|
||||
|
||||
VoiceCallManager {
|
||||
id: voiceCallmanager
|
||||
|
||||
property int status: activeVoiceCall ? activeVoiceCall.status : 0
|
||||
//keep track of the status we were in
|
||||
property int previousStatus
|
||||
onStatusChanged: {
|
||||
//STATUS_INCOMING
|
||||
if (status == 5) {
|
||||
wasVisible = root.visible;
|
||||
root.visible = true;
|
||||
dialerUtils.notifyRinging();
|
||||
//Was STATUS_INCOMING now is STATUS_DISCONNECTED: Missed call!
|
||||
} else if (status == 7 && previousStatus == 5) {
|
||||
var prettyDate = Qt.formatTime(voiceCallmanager.activeVoiceCall.startedAt, Qt.locale().timeFormat(Locale.ShortFormat));
|
||||
dialerUtils.notifyMissedCall(voiceCallmanager.activeVoiceCall.lineId, i18n("%1 called at %2", voiceCallmanager.activeVoiceCall.lineId, prettyDate));
|
||||
root.visible = wasVisible;
|
||||
insertCallInHistory(voiceCallmanager.activeVoiceCall.lineId, 0, 0);
|
||||
//STATUS_DISCONNECTED
|
||||
} else if (status == 7) {
|
||||
insertCallInHistory(voiceCallmanager.activeVoiceCall.lineId, voiceCallmanager.activeVoiceCall.duration, voiceCallmanager.activeVoiceCall.isIncoming ? 1 : 2);
|
||||
}
|
||||
|
||||
//status not STATUS_INCOMING
|
||||
if (status != 5) {
|
||||
dialerUtils.stopRinging();
|
||||
}
|
||||
|
||||
previousStatus = status;
|
||||
switch (status) {
|
||||
case 1:
|
||||
root.status = "active";
|
||||
break;
|
||||
case 2:
|
||||
root.status = "held";
|
||||
break;
|
||||
case 3:
|
||||
root.status = "dialing";
|
||||
break;
|
||||
case 4:
|
||||
root.status = "alerting";
|
||||
break;
|
||||
case 5:
|
||||
root.status = "incoming";
|
||||
break;
|
||||
case 6:
|
||||
root.status = "waiting";
|
||||
break;
|
||||
case 7:
|
||||
root.status = "disconnected";
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
root.status = "idle";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
onActiveVoiceCallChanged: {
|
||||
if (activeVoiceCall) {
|
||||
//main.activeVoiceCallPerson = people.personByPhoneNumber(activeVoiceCall.lineId);
|
||||
// dialerOverlay.item.numberEntryText = activeVoiceCall.lineId;
|
||||
|
||||
} else {
|
||||
// dialerOverlay.item.numberEntryText = '';
|
||||
|
||||
//main.activeVoiceCallPerson = null;
|
||||
}
|
||||
}
|
||||
|
||||
onError: {
|
||||
console.log('*** QML *** VCM ERROR: ' + message);
|
||||
}
|
||||
}
|
||||
|
||||
//END MODELS
|
||||
|
||||
}
|
||||
|
|
@ -22,7 +22,6 @@ import QtQuick 2.3
|
|||
import QtQuick.Controls 1.3
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtQuick.LocalStorage 2.0
|
||||
import org.nemomobile.voicecall 1.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
||||
|
||||
|
|
@ -33,44 +32,15 @@ ApplicationWindow {
|
|||
width: 600
|
||||
height: 800
|
||||
|
||||
property int status: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.status : 0
|
||||
//keep track of the status we were in
|
||||
property int previousStatus
|
||||
//keep track if we were visible when ringing
|
||||
property bool wasVisible
|
||||
//support a single provider for now
|
||||
property string providerId: voiceCallmanager.providers.id(0)
|
||||
property string providerId: ofonoWrapper.providerId
|
||||
//was the last call an incoming one?
|
||||
property bool isIncoming
|
||||
//END PROPERTIES
|
||||
|
||||
//BEGIN SIGNAL HANDLERS
|
||||
onStatusChanged: {
|
||||
//STATUS_ACTIVE
|
||||
if (status == 1) {
|
||||
root.isIncoming = voiceCallmanager.activeVoiceCall.isIncoming;
|
||||
//STATUS_INCOMING
|
||||
} else if (status == 5) {
|
||||
wasVisible = root.visible;
|
||||
root.visible = true;
|
||||
dialerUtils.notifyRinging();
|
||||
//Was STATUS_INCOMING now is STATUS_DISCONNECTED: Missed call!
|
||||
} else if (status == 7 && previousStatus == 5) {
|
||||
var prettyDate = Qt.formatTime(voiceCallmanager.activeVoiceCall.startedAt, Qt.locale().timeFormat(Locale.ShortFormat));
|
||||
dialerUtils.notifyMissedCall(voiceCallmanager.activeVoiceCall.lineId, i18n("%1 called at %2", voiceCallmanager.activeVoiceCall.lineId, prettyDate));
|
||||
root.visible = wasVisible;
|
||||
insertCallInHistory(voiceCallmanager.activeVoiceCall.lineId, 0, 0);
|
||||
} else if (status == 7) {
|
||||
insertCallInHistory(voiceCallmanager.activeVoiceCall.lineId, voiceCallmanager.activeVoiceCall.duration, isIncoming ? 1 : 2);
|
||||
}
|
||||
|
||||
if (status != 5) {
|
||||
dialerUtils.stopRinging();
|
||||
}
|
||||
|
||||
previousStatus = status;
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: dialerUtils
|
||||
onMissedCallsActionTriggered: {
|
||||
|
|
@ -80,7 +50,7 @@ ApplicationWindow {
|
|||
|
||||
onVisibleChanged: {
|
||||
//reset missed calls if the status is not STATUS_INCOMING when got visible
|
||||
if (visible && status != 5) {
|
||||
if (visible && ofonoWrapper.status != "incoming") {
|
||||
dialerUtils.resetMissedCalls();
|
||||
}
|
||||
}
|
||||
|
|
@ -88,18 +58,7 @@ ApplicationWindow {
|
|||
|
||||
//BEGIN FUNCTIONS
|
||||
function call(number) {
|
||||
if (!voiceCallmanager.activeVoiceCall) {
|
||||
console.log("Calling: " + providerId + " " + number);
|
||||
voiceCallmanager.dial(providerId, number);
|
||||
|
||||
} else {
|
||||
console.log("Hanging up: " + voiceCallmanager.activeVoiceCall.lineId);
|
||||
status.text = '';
|
||||
var call = voiceCallmanager.activeVoiceCall;
|
||||
if (call) {
|
||||
call.hangup();
|
||||
}
|
||||
}
|
||||
ofonoWrapper.call(number);
|
||||
}
|
||||
|
||||
function insertCallInHistory(number, duration, callType) {
|
||||
|
|
@ -157,10 +116,6 @@ ApplicationWindow {
|
|||
|
||||
//BEGIN DATABASE
|
||||
Component.onCompleted: {
|
||||
//HACK: make sure activeVoiceCall is loaded if already existing
|
||||
voiceCallmanager.voiceCalls.onVoiceCallsChanged();
|
||||
voiceCallmanager.onActiveVoiceCallChanged();
|
||||
|
||||
//DATABSE
|
||||
var db = LocalStorage.openDatabaseSync("PlasmaPhoneDialer", "1.0", "Call history of the Plasma Phone dialer", 1000000);
|
||||
|
||||
|
|
@ -188,24 +143,8 @@ ApplicationWindow {
|
|||
id: historyModel
|
||||
}
|
||||
|
||||
VoiceCallManager {
|
||||
id: voiceCallmanager
|
||||
|
||||
onActiveVoiceCallChanged: {
|
||||
if (activeVoiceCall) {
|
||||
//main.activeVoiceCallPerson = people.personByPhoneNumber(activeVoiceCall.lineId);
|
||||
// dialerOverlay.item.numberEntryText = activeVoiceCall.lineId;
|
||||
|
||||
} else {
|
||||
// dialerOverlay.item.numberEntryText = '';
|
||||
|
||||
//main.activeVoiceCallPerson = null;
|
||||
}
|
||||
}
|
||||
|
||||
onError: {
|
||||
console.log('*** QML *** VCM ERROR: ' + message);
|
||||
}
|
||||
OfonoWrapper {
|
||||
id: ofonoWrapper
|
||||
}
|
||||
|
||||
//END MODELS
|
||||
|
|
@ -213,10 +152,10 @@ ApplicationWindow {
|
|||
//BEGIN UI
|
||||
PlasmaExtras.ConditionalLoader {
|
||||
anchors.fill: parent
|
||||
when: root.visible && root.status == 0
|
||||
when: root.visible && ofonoWrapper.status == "idle"
|
||||
source: Qt.resolvedUrl("Dialer/DialPage.qml")
|
||||
z: root.status == 0 ? 2 : 0
|
||||
opacity: root.status == 0 ? 1 : 0
|
||||
z: ofonoWrapper.status == "idle" ? 2 : 0
|
||||
opacity: ofonoWrapper.status == "idle" ? 1 : 0
|
||||
Behavior on opacity {
|
||||
OpacityAnimator {
|
||||
duration: units.shortDuration
|
||||
|
|
@ -227,10 +166,10 @@ ApplicationWindow {
|
|||
|
||||
PlasmaExtras.ConditionalLoader {
|
||||
anchors.fill: parent
|
||||
when: root.status > 0
|
||||
when: ofonoWrapper.status != "idle"
|
||||
source: Qt.resolvedUrl("Call/CallPage.qml")
|
||||
opacity: root.status > 0 ? 1 : 0
|
||||
z: root.status > 0 ? 2 : 0
|
||||
opacity: ofonoWrapper.status != "idle" ? 1 : 0
|
||||
z: ofonoWrapper.status != "idle" ? 2 : 0
|
||||
Behavior on opacity {
|
||||
OpacityAnimator {
|
||||
duration: units.shortDuration
|
||||
|
|
|
|||
Loading…
Reference in a new issue