This commit is contained in:
Aaron Seigo 2014-09-26 21:05:59 +02:00
parent e601a8200b
commit 45977acb2e
4 changed files with 204 additions and 0 deletions

View file

@ -0,0 +1,41 @@
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
Text {
width: parent.width / parent.columns
height: parent.buttonHeight
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
font.pixelSize: Math.floor((width - (units.largeSpacing)) / 2)
property alias sub: longHold.text;
MouseArea {
anchors.fill: parent
onClicked: {
addNumber(parent.text);
}
onPressAndHold: {
if (longHold.visible) {
addNumber(longHold.text);
} else {
addNumber(parent.text);
}
}
}
Text {
id: longHold
visible: text.length > 0
opacity: 0.7
height: parent.height
width: parent.width / 3
verticalAlignment: Qt.AlignVCenter
anchors {
top: parent.top
right: parent.right
}
font.pixelSize: parent.pixelSize * .8
}
}

View file

@ -0,0 +1,37 @@
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
Item {
width: parent.width / parent.columns
height: parent.buttonHeight
property var callback
property string text
property string sub
property alias source: icon.source
PlasmaCore.IconItem {
id: icon
width: units.iconSizes.medium
height: width
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
if (callback) {
callback();
} else {
addNumber(parent.text);
}
}
onPressAndHold: {
if (longHold.visible) {
addNumber(longHold.text);
} else {
addNumber(parent.text);
}
}
}
}

View file

@ -0,0 +1,37 @@
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
Item {
width: parent.width / parent.columns
height: parent.buttonHeight
property var callback
property string text
property string sub
property alias svg: icon.svg
PlasmaCore.SvgItem{
id: icon
width: units.iconSizes.medium
height: width
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
if (callback) {
callback();
} else {
addNumber(parent.text);
}
}
onPressAndHold: {
if (longHold.visible) {
addNumber(longHold.text);
} else {
addNumber(parent.text);
}
}
}
}

View file

@ -0,0 +1,89 @@
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import "../components"
Rectangle {
id: dialer
anchors.fill: parent;
color: "white"
opacity: 0.5
property bool calling: false // needs to be connected to a system service
property bool enableButtons: calling
function addNumber(number) {
status.text = status.text + number
}
function call() {
if (!calling) {
console.log("Calling: " + status.text);
} else {
console.log("Hanging up: " + status.text);
status.text = '';
}
dialer.calling = !dialer.calling;
}
function fromContacts() {
console.log("Should get from contacts!");
status.text = "+41 76 555 5555"
}
Text {
id: status
height: parent.height / 6
width: parent.width
horizontalAlignment: Qt.AlignRight
verticalAlignment: Qt.AlignVCenter
font.pixelSize: one.font.pixelSize
}
Grid {
id: pad
columns: 3
spacing: 0
property int buttonHeight: height / 5
anchors {
top: status.bottom
bottom: parent.bottom
left: parent.left
right: parent.right
}
height: parent.height - status.height
width: parent.width
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: "#" }
DialerIconButton {
source: "im-user"
callback: fromContacts
}
DialerIconButton {
id: callButton
source: dialer.calling ? "call-stop" : "call-start"
callback: call
}
DialerIconButton {
source: "edit-clear"
callback: function() { status.text = status.text.substr(0, status.text.length - 1); }
}
//DialerSvgButton { svg: PlasmaCore.Svg { imagePath: "edit-clear.svg" } }
}
}