mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
better answer/hangup ui
This commit is contained in:
parent
67c41ecd4d
commit
b669fa97a0
3 changed files with 140 additions and 39 deletions
77
dialer/contents/ui/Call/AnswerSwipe.qml
Normal file
77
dialer/contents/ui/Call/AnswerSwipe.qml
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -28,8 +28,9 @@ Item {
|
||||||
id: callPage
|
id: callPage
|
||||||
|
|
||||||
state: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.statusText : "disconnected"
|
state: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.statusText : "disconnected"
|
||||||
|
property int status: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.status : 0
|
||||||
|
|
||||||
property color textColor: "white"
|
property color textColor: "white"
|
||||||
property bool enableButtons: calling
|
|
||||||
|
|
||||||
property string providerId: voiceCallmanager.providers.id(0)
|
property string providerId: voiceCallmanager.providers.id(0)
|
||||||
|
|
||||||
|
|
@ -78,7 +79,7 @@ Item {
|
||||||
Layout.minimumHeight: implicitHeight
|
Layout.minimumHeight: implicitHeight
|
||||||
horizontalAlignment: Qt.AlignHCenter
|
horizontalAlignment: Qt.AlignHCenter
|
||||||
verticalAlignment: Qt.AlignVCenter
|
verticalAlignment: Qt.AlignVCenter
|
||||||
font.pixelSize: one.font.pixelSize
|
font.pixelSize: theme.defaultFont.pixelSize * 2
|
||||||
color: textColor
|
color: textColor
|
||||||
text: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.lineId : ""
|
text: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.lineId : ""
|
||||||
}
|
}
|
||||||
|
|
@ -87,11 +88,20 @@ Item {
|
||||||
Layout.minimumHeight: implicitHeight
|
Layout.minimumHeight: implicitHeight
|
||||||
horizontalAlignment: Qt.AlignHCenter
|
horizontalAlignment: Qt.AlignHCenter
|
||||||
verticalAlignment: Qt.AlignVCenter
|
verticalAlignment: Qt.AlignVCenter
|
||||||
font.pixelSize: theme.smallestFont.pixelSize
|
|
||||||
color: textColor
|
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 {
|
PlasmaComponents.ButtonRow {
|
||||||
|
opacity: status == 1 ? 1 : 0
|
||||||
exclusive: false
|
exclusive: false
|
||||||
spacing: 0
|
spacing: 0
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
|
@ -114,21 +124,37 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Item {
|
||||||
|
Layout.minimumHeight: units.gridUnit * 5
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
//TODO: swipe thing instead
|
AnswerSwipe {
|
||||||
PlasmaComponents.Button {
|
anchors.fill: parent
|
||||||
text: "Answer"
|
//STATUS_INCOMING
|
||||||
onClicked: {
|
visible: status == 5
|
||||||
if (voiceCallmanager.activeVoiceCall) {
|
onAccepted: {
|
||||||
voiceCallmanager.activeVoiceCall.answer();
|
if (voiceCallmanager.activeVoiceCall) {
|
||||||
|
voiceCallmanager.activeVoiceCall.answer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onRejected: {
|
||||||
|
if (voiceCallmanager.activeVoiceCall) {
|
||||||
|
voiceCallmanager.activeVoiceCall.hangup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
PlasmaComponents.Button {
|
PlasmaComponents.Button {
|
||||||
text: "Hangup"
|
anchors.fill: parent
|
||||||
onClicked: {
|
//STATUS_INCOMING
|
||||||
if (voiceCallmanager.activeVoiceCall) {
|
visible: status != 5
|
||||||
voiceCallmanager.activeVoiceCall.hangup();
|
iconSource: "call-stop"
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: i18n("End Call")
|
||||||
|
onClicked: {
|
||||||
|
if (voiceCallmanager.activeVoiceCall) {
|
||||||
|
voiceCallmanager.activeVoiceCall.hangup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,24 +22,21 @@ import QtQuick.Controls 1.3
|
||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
import org.nemomobile.voicecall 1.0
|
import org.nemomobile.voicecall 1.0
|
||||||
import MeeGo.QOfono 0.2
|
import MeeGo.QOfono 0.2
|
||||||
|
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
||||||
|
|
||||||
ApplicationWindow {
|
ApplicationWindow {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
//BEGIN PROPERTIES
|
||||||
width: 600
|
width: 600
|
||||||
height: 800
|
height: 800
|
||||||
visible: true
|
visible: true
|
||||||
color: Qt.rgba(0, 0, 0, 0.9)
|
color: Qt.rgba(0, 0, 0, 0.9)
|
||||||
|
|
||||||
property int status: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.status : 0
|
property int status: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.status : 0
|
||||||
|
//END PROPERTIES
|
||||||
|
|
||||||
onStatusChanged: {
|
//BEGIN MODELS
|
||||||
if (status > 0) {
|
|
||||||
stackView.push(Qt.resolvedUrl("Call/CallPage.qml"));
|
|
||||||
} else {
|
|
||||||
stackView.pop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OfonoManager {
|
OfonoManager {
|
||||||
id: ofonoManager
|
id: ofonoManager
|
||||||
onAvailableChanged: {
|
onAvailableChanged: {
|
||||||
|
|
@ -91,15 +88,7 @@ ApplicationWindow {
|
||||||
OfonoNetworkOperator {
|
OfonoNetworkOperator {
|
||||||
id: netop
|
id: netop
|
||||||
}
|
}
|
||||||
Button {
|
|
||||||
z: 99
|
|
||||||
text: "bah"
|
|
||||||
onClicked: {
|
|
||||||
print(voiceCallmanager.activeVoiceCall)
|
|
||||||
print(voiceCallmanager.voiceCalls.count)
|
|
||||||
print(voiceCallmanager.activeVoiceCall.status)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
VoiceCallManager {
|
VoiceCallManager {
|
||||||
id: voiceCallmanager
|
id: voiceCallmanager
|
||||||
|
|
||||||
|
|
@ -119,18 +108,27 @@ Button {
|
||||||
console.log('*** QML *** VCM ERROR: ' + message);
|
console.log('*** QML *** VCM ERROR: ' + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//END MODELS
|
||||||
|
|
||||||
StackView {
|
//BEGIN UI
|
||||||
id: stackView
|
PlasmaExtras.ConditionalLoader {
|
||||||
anchors.fill: parent
|
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: {
|
Component.onCompleted: {
|
||||||
//HACK: make sure activeVoiceCall is the proper one
|
//HACK: make sure activeVoiceCall is loaded if already existing
|
||||||
voiceCallmanager.voiceCalls.onVoiceCallsChanged();
|
voiceCallmanager.voiceCalls.onVoiceCallsChanged();
|
||||||
voiceCallmanager.onActiveVoiceCallChanged();
|
voiceCallmanager.onActiveVoiceCallChanged();
|
||||||
|
|
||||||
//start with the dialer view
|
|
||||||
stackView.push(Qt.resolvedUrl("Dialer.qml"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue