shift-shell/dialer/package/contents/ui/main.qml
2015-04-26 16:42:14 +02:00

182 lines
5.1 KiB
QML

/**
* 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 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 QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
import org.nemomobile.voicecall 1.0
import MeeGo.QOfono 0.2
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
ApplicationWindow {
id: root
//BEGIN PROPERTIES
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
//END PROPERTIES
//BEGIN SIGNAL HANDLERS
onStatusChanged: {
//STATUS_INCOMING
if (status == 5) {
wasVisible = root.visible;
root.visible = true;
//Was STATUS_INCOMING now is STATUS_DISCONNECTED: Missed call!
} else if (status == 7 && previousStatus == 5) {
dialerUtils.notifyMissedCall();
root.visible = wasVisible;
}
previousStatus = status;
}
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 MODELS
OfonoManager {
id: ofonoManager
onAvailableChanged: {
console.log("Ofono is " + available)
}
onModemAdded: {
console.log("modem added " + modem)
}
onModemRemoved: console.log("modem removed")
}
OfonoConnMan {
id: ofono1
Component.onCompleted: {
console.log(ofonoManager.modems)
}
modemPath: ofonoManager.modems.length > 0 ? ofonoManager.modems[0] : ""
}
OfonoModem {
id: modem1
modemPath: ofonoManager.modems.length > 0 ? ofonoManager.modems[0] : ""
}
OfonoContextConnection {
id: context1
contextPath : ofono1.contexts.length > 0 ? ofono1.contexts[0] : ""
Component.onCompleted: {
print("Context Active: " + context1.active)
}
onActiveChanged: {
print("Context Active: " + context1.active)
}
}
OfonoNetworkRegistration {
id: netreg
Component.onCompleted: {
netreg.scan()
}
onNetworkOperatorsChanged : {
console.log("operators :"+netreg.currentOperator["Name"].toString())
}
modemPath: ofonoManager.modems.length ? ofonoManager.modems[0] : ""
}
OfonoNetworkOperator {
id: netop
}
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);
}
}
//END MODELS
//BEGIN UI
PlasmaExtras.ConditionalLoader {
anchors.fill: parent
when: root.visible && root.status == 0
source: Qt.resolvedUrl("Dialer/DialPage.qml")
z: root.status == 0 ? 2 : 0
opacity: root.status == 0 ? 1 : 0
Behavior on opacity {
OpacityAnimator {
duration: units.shortDuration
easing.type: Easing.InOutQuad
}
}
}
PlasmaExtras.ConditionalLoader {
anchors.fill: parent
when: root.status > 0
source: Qt.resolvedUrl("Call/CallPage.qml")
opacity: root.status > 0 ? 1 : 0
z: root.status > 0 ? 2 : 0
Behavior on opacity {
OpacityAnimator {
duration: units.shortDuration
easing.type: Easing.InOutQuad
}
}
}
//END UI
Component.onCompleted: {
//HACK: make sure activeVoiceCall is loaded if already existing
voiceCallmanager.voiceCalls.onVoiceCallsChanged();
voiceCallmanager.onActiveVoiceCallChanged();
}
}