add a simple Ui for entering the pin

This commit is contained in:
Marco Martin 2014-10-30 15:29:14 +01:00
parent c7a59a1490
commit 122ada1be0
4 changed files with 203 additions and 9 deletions

View file

@ -9,12 +9,17 @@ Text {
color: dialer.textColor color: dialer.textColor
font.pixelSize: Math.floor((width - (units.largeSpacing)) / 2) font.pixelSize: Math.floor((width - (units.largeSpacing)) / 2)
property alias sub: longHold.text property alias sub: longHold.text
property var callback
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
if (callback) {
callback();
} else {
addNumber(parent.text); addNumber(parent.text);
} }
}
onPressAndHold: { onPressAndHold: {
if (longHold.visible) { if (longHold.visible) {

View file

@ -7,3 +7,5 @@ ToolBox=
[Desktop][ContainmentActions] [Desktop][ContainmentActions]
[plasmarc][Theme]
name=breeze-dark

View file

@ -25,6 +25,7 @@ import org.kde.plasma.shell 2.0 as Shell
import org.kde.satellite.components 0.1 as SatelliteComponents import org.kde.satellite.components 0.1 as SatelliteComponents
import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.components 2.0 as PlasmaComponents
import org.nemomobile.voicecall 1.0 import org.nemomobile.voicecall 1.0
import MeeGo.QOfono 0.2
import "../components" import "../components"
Item { Item {
@ -85,6 +86,41 @@ Item {
} }
} }
OfonoManager {
id: ofonoManager
}
property OfonoSimManager simManager: ofonoSimManager
OfonoSimManager {
id: ofonoSimManager
}
OfonoNetworkRegistration {
id: netreg
modemPath: ofonoManager.modems.count? ofonoManager.modems[0] : ""
function updateStrengthIcon() {
if (netreg.strength >= 100) {
strengthIcon.source = "network-mobile-100";
} else if (netreg.strength >= 80) {
strengthIcon.source = "network-mobile-80";
} else if (netreg.strength >= 60) {
strengthIcon.source = "network-mobile-60";
} else if (netreg.strength >= 40) {
strengthIcon.source = "network-mobile-40";
} else if (netreg.strength >= 20) {
strengthIcon.source = "network-mobile-20";
} else {
strengthIcon.source = "network-mobile-0";
}
}
onStrengthChanged: {
console.log("Strength changed to " + netreg.strength)
updateStrengthIcon()
}
Component.onCompleted: updateStrengthIcon()
}
property VoiceCallManager manager: VoiceCallManager { property VoiceCallManager manager: VoiceCallManager {
id: manager id: manager
@ -180,6 +216,16 @@ Item {
} }
} }
Pin {
anchors {
left: parent.left
top: statusPanel.bottom
right: parent.right
bottom: parent.bottom
}
z: 20
}
Dialer { Dialer {
id: dialer id: dialer
anchors { anchors {
@ -229,6 +275,24 @@ Item {
interval: 500 interval: 500
} }
PlasmaCore.IconItem {
id: strengthIcon
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
}
width: units.iconSizes.small
height: width
}
Text {
anchors {
left: strengthIcon.right
verticalCenter: parent.verticalCenter
}
text: netreg.strength + "% " + (netreg.name ? netreg.name : "No Provider")
color: "white"
font.pixelSize: height / 2
}
Text { Text {
id: clock id: clock
anchors.fill: parent anchors.fill: parent
@ -309,14 +373,7 @@ Item {
SatelliteStripe { SatelliteStripe {
id: stripe id: stripe
z: 1 z: 1
PlasmaComponents.Button {
z: 999
text: "bah"
onClicked: {
dialer.state = "incoming"
dialer.open()
}
}
PlasmaCore.Svg { PlasmaCore.Svg {
id: stripeIcons id: stripeIcons
imagePath: Qt.resolvedUrl("../images/homescreenicons.svg") imagePath: Qt.resolvedUrl("../images/homescreenicons.svg")
@ -332,6 +389,8 @@ PlasmaComponents.Button {
svg: stripeIcons svg: stripeIcons
elementId: "phone" elementId: "phone"
callback: function() { callback: function() {
//TODO remove
dialer.state = "disconnected"
dialer.open() dialer.open()
} }
} }

View file

@ -0,0 +1,128 @@
/*
* 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.0
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import MeeGo.QOfono 0.2
import "../components"
Rectangle {
id: pinScreen
color: "black"
opacity: 0.8
visible: simManager.pinRequired != OfonoSimManager.NoPin
property color textColor: "white"
property OfonoSimManager simManager: homescreen.simManager
function addNumber(number) {
pinLabel.text = pinLabel.text + number
}
MouseArea {
anchors.fill: parent
}
Connections {
target: simManager
onEnterPinComplete: {
print("Enter Pin complete: " + error + " " + errorString)
}
}
ColumnLayout {
id: dialPadArea
anchors {
fill: parent
margins: 20
}
Text {
Layout.fillWidth: true
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
font.pixelSize: theme.defaultFont.pixelSize
color: textColor
text: {
switch (simManager.pinRequired) {
case OfonoSimManager.NoPin: return i18n("No pin (error)");
case OfonoSimManager.SimPin: return i18n("Enter Sim PIN");
case OfonoSimManager.SimPin2: return i18n("Enter Sim PIN 2");
case OfonoSimManager.SimPuk: return i18n("Enter Sim PUK");
case OfonoSimManager.SimPuk2: return i18n("Enter Sim PUK 2");
default: return i18n("Unknown PIN type: %1", simManager.pinRequired);
}
}
}
Text {
Layout.fillWidth: true
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
font.pixelSize: theme.defaultFont.pixelSize
color: textColor
text: i18n("%1 attempts left", simManager.pinRetries);
}
Text {
id: pinLabel
Layout.fillWidth: true
horizontalAlignment: Qt.AlignRight
verticalAlignment: Qt.AlignVCenter
font.pixelSize: one.font.pixelSize
color: textColor
}
Grid {
id: pad
columns: 3
spacing: 0
property int buttonHeight: height / 5
Layout.fillWidth: true
Layout.fillHeight: true
DialerButton { id: one; text: "1" }
DialerButton { text: "2" }
DialerButton { text: "3" }
DialerButton { text: "4" }
DialerButton { text: "5" }
DialerButton { text: "6" }
DialerButton { text: "7" }
DialerButton { text: "8" }
DialerButton { text: "9" }
DialerButton { text: "*"; }
DialerButton { text: "0"; sub: "+"; }
DialerButton {
text: "#"
callback: function () {
simManager.enterPin(simManager.pinRequired, pinLabel.text)
for (var i in simManager.pinRetries) {
print("Retries object status:" + i + " " + simManager.pinRetries[i]);
}
}
}
}
}
}