better answer/hangup ui

This commit is contained in:
Marco Martin 2015-04-20 21:05:28 +02:00
parent 67c41ecd4d
commit b669fa97a0
3 changed files with 140 additions and 39 deletions

View file

@ -0,0 +1,77 @@
/*
* Copyright 2014 Aaron Seigo <aseigo@kde.org>
* Copyright 2014 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 Library 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.4
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
MouseArea {
id: root
signal accepted
signal rejected
Layout.minimumHeight: units.gridUnit * 5
Layout.fillWidth: true
property int handlePosition: (answerHandle.x + answerHandle.width/2)
drag {
target: answerHandle
axis: Drag.XAxis
minimumX: 0
maximumX: width - answerHandle.width
}
Rectangle {
anchors.fill: parent
radius: height
color: Qt.rgba((handlePosition > root.width/2 ? 0.6 : 0)+0.2, (handlePosition < root.width/2 ? 0.6 : 0)+0.2, 0.2, Math.abs(handlePosition - (root.width/2)) / answerHandle.width/2);
Rectangle {
id: answerHandle
x: parent.width/2 - width/2
height: parent.height
width: height
radius: width
color: Qt.rgba(0.2, 0.8, 0.2, 1)
PlasmaCore.IconItem {
source: "call-start"
width: parent.width * 0.7
height: width
anchors.centerIn: parent
}
Behavior on x {
enabled: root.pressed
XAnimator {
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}
}
}
onReleased: {
if (answerHandle.x <= answerHandle.width) {
root.accepted();
} else if (answerHandle.x + answerHandle.width >= root.width - answerHandle.width) {
root.rejected();
}
answerHandle.x = width/2 - answerHandle.width/2
}
}

View file

@ -28,8 +28,9 @@ Item {
id: callPage
state: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.statusText : "disconnected"
property int status: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.status : 0
property color textColor: "white"
property bool enableButtons: calling
property string providerId: voiceCallmanager.providers.id(0)
@ -78,7 +79,7 @@ Item {
Layout.minimumHeight: implicitHeight
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
font.pixelSize: one.font.pixelSize
font.pixelSize: theme.defaultFont.pixelSize * 2
color: textColor
text: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.lineId : ""
}
@ -87,11 +88,20 @@ Item {
Layout.minimumHeight: implicitHeight
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
font.pixelSize: theme.smallestFont.pixelSize
color: textColor
text: voiceCallmanager.activeVoiceCall ? secondsToTimeString(voiceCallmanager.activeVoiceCall.duration) : ''
text: {
if (!voiceCallmanager.activeVoiceCall) {
return '';
//STATUS_DIALING
} else if (voiceCallmanager.activeVoiceCall.status == 3) {
return i18n("Calling...");
} else {
return secondsToTimeString(voiceCallmanager.activeVoiceCall.duration);
}
}
}
PlasmaComponents.ButtonRow {
opacity: status == 1 ? 1 : 0
exclusive: false
spacing: 0
Layout.alignment: Qt.AlignHCenter
@ -114,21 +124,37 @@ Item {
}
Item {
Layout.minimumHeight: units.gridUnit * 5
Layout.fillWidth: true
//TODO: swipe thing instead
PlasmaComponents.Button {
text: "Answer"
onClicked: {
if (voiceCallmanager.activeVoiceCall) {
voiceCallmanager.activeVoiceCall.answer();
AnswerSwipe {
anchors.fill: parent
//STATUS_INCOMING
visible: status == 5
onAccepted: {
if (voiceCallmanager.activeVoiceCall) {
voiceCallmanager.activeVoiceCall.answer();
}
}
onRejected: {
if (voiceCallmanager.activeVoiceCall) {
voiceCallmanager.activeVoiceCall.hangup();
}
}
}
}
PlasmaComponents.Button {
text: "Hangup"
onClicked: {
if (voiceCallmanager.activeVoiceCall) {
voiceCallmanager.activeVoiceCall.hangup();
PlasmaComponents.Button {
anchors.fill: parent
//STATUS_INCOMING
visible: status != 5
iconSource: "call-stop"
Layout.fillWidth: true
text: i18n("End Call")
onClicked: {
if (voiceCallmanager.activeVoiceCall) {
voiceCallmanager.activeVoiceCall.hangup();
}
}
}
}

View file

@ -22,24 +22,21 @@ import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
import org.nemomobile.voicecall 1.0
import MeeGo.QOfono 0.2
import org.kde.plasma.extras 2.0 as PlasmaExtras
ApplicationWindow {
id: root
//BEGIN PROPERTIES
width: 600
height: 800
visible: true
color: Qt.rgba(0, 0, 0, 0.9)
property int status: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.status : 0
//END PROPERTIES
onStatusChanged: {
if (status > 0) {
stackView.push(Qt.resolvedUrl("Call/CallPage.qml"));
} else {
stackView.pop();
}
}
//BEGIN MODELS
OfonoManager {
id: ofonoManager
onAvailableChanged: {
@ -91,15 +88,7 @@ ApplicationWindow {
OfonoNetworkOperator {
id: netop
}
Button {
z: 99
text: "bah"
onClicked: {
print(voiceCallmanager.activeVoiceCall)
print(voiceCallmanager.voiceCalls.count)
print(voiceCallmanager.activeVoiceCall.status)
}
}
VoiceCallManager {
id: voiceCallmanager
@ -119,18 +108,27 @@ Button {
console.log('*** QML *** VCM ERROR: ' + message);
}
}
//END MODELS
StackView {
id: stackView
//BEGIN UI
PlasmaExtras.ConditionalLoader {
anchors.fill: parent
when: root.visible && root.status == 0
source: Qt.resolvedUrl("Dialer.qml")
opacity: root.status == 0 ? 1 : 0
}
PlasmaExtras.ConditionalLoader {
anchors.fill: parent
when: root.status > 0
source: Qt.resolvedUrl("Call/CallPage.qml")
opacity: root.status > 0 ? 1 : 0
}
//END UI
Component.onCompleted: {
//HACK: make sure activeVoiceCall is the proper one
//HACK: make sure activeVoiceCall is loaded if already existing
voiceCallmanager.voiceCalls.onVoiceCallsChanged();
voiceCallmanager.onActiveVoiceCallChanged();
//start with the dialer view
stackView.push(Qt.resolvedUrl("Dialer.qml"));
}
}