shift-shell/look-and-feel/contents/lockscreen/LockScreen.qml

189 lines
4 KiB
QML
Raw Normal View History

2014-08-06 11:58:32 +00:00
import QtQuick 2.0
2014-08-19 12:08:19 +00:00
import org.kde.plasma.core 2.0 as PlasmaCore
import "../components"
2014-08-06 11:58:32 +00:00
2014-08-19 15:50:59 +00:00
Leaves {
id: lockscreen
signal tryUnlock(string code)
2014-08-19 12:08:19 +00:00
PlasmaCore.Svg {
id: symbolsSvg
imagePath: Qt.resolvedUrl("images/symbols.svgz")
}
2014-08-19 15:50:59 +00:00
MouseArea {
2014-08-06 11:58:32 +00:00
anchors.fill: parent
2014-08-19 15:50:59 +00:00
onPressed: {
2014-08-19 15:54:03 +00:00
stripe.opacity = 1;
2014-08-19 15:50:59 +00:00
}
2014-08-06 11:58:32 +00:00
}
2014-08-20 10:10:58 +00:00
PlasmaCore.DataSource {
id: dataSource
engine: "time"
connectedSources: "Local"
interval: 30000
onDataChanged: {
var date = new Date(data["Local"]["DateTime"]);
hour.text = date.getHours();
minute.text = date.getMinutes();
}
Component.onCompleted: {
onDataChanged();
}
}
Text {
id: hour
onTextChanged: {
if (text.length < 2) {
minute.text = "0" + text;
}
}
anchors {
top: parent.top
left: parent.left
right: parent.right
bottom: stripe.top
}
color: "white" // FIXME: base on wallpaper?
text: "00"
font.pixelSize: Math.floor((width - (units.largeSpacing)) / 2)
horizontalAlignment: Qt.AlignCenter
verticalAlignment: Qt.AlignVCenter
}
2014-08-19 12:08:19 +00:00
SatelliteStripe {
id: stripe
2014-08-19 15:50:59 +00:00
opacity: 0
property string code
2014-08-19 15:56:21 +00:00
function lockKeyPressed(id) {
2014-08-20 09:51:00 +00:00
hideTimer.stop();
code += id;
2014-08-19 15:56:21 +00:00
}
2014-08-19 15:50:59 +00:00
function lockKeyReleased(id) {
2014-08-20 09:51:00 +00:00
hideTimer.start();
code += id;
}
2014-08-19 15:50:59 +00:00
Behavior on opacity {
NumberAnimation {
2014-08-19 15:54:03 +00:00
duration: 500
2014-08-19 15:50:59 +00:00
easing.type: Easing.InOutQuad
}
}
2014-08-19 12:08:19 +00:00
2014-08-19 16:09:43 +00:00
MouseArea {
anchors.fill: parent
onPressed: {
2014-08-20 10:12:39 +00:00
if (stripe.opacity < 1) {
stripe.opacity = 1;
return;
}
2014-08-19 16:09:43 +00:00
stripe.lockKeyPressed(stripe.childAt(mouseX, mouseY).value);
}
2014-08-19 16:09:43 +00:00
onReleased: {
2014-08-20 10:12:39 +00:00
if (stripe.opacity < 1) {
return;
}
2014-08-19 16:09:43 +00:00
stripe.lockKeyReleased(stripe.childAt(mouseX, mouseY).value);
}
}
2014-08-19 15:54:03 +00:00
Timer {
id: hideTimer
interval: 1000
running: parent.opacity == 1
onTriggered: {
stripe.opacity = 0;
lockscreen.tryUnlock(stripe.code);
stripe.code = '';
}
2014-08-19 15:54:03 +00:00
}
LockKey {
2014-08-19 12:08:19 +00:00
id: square
value: 1
2014-08-19 16:03:20 +00:00
anchors.left: parent.left
2014-08-19 12:08:19 +00:00
elementId: "square"
}
LockKey {
2014-08-19 12:08:19 +00:00
id: circle
value: 2
2014-08-19 12:08:19 +00:00
anchors.left: square.right
elementId: "circle"
}
LockKey {
2014-08-19 12:08:19 +00:00
id: ex
value: 3
2014-08-19 12:08:19 +00:00
anchors.left: circle.right
elementId: "ex"
}
LockKey {
2014-08-19 12:08:19 +00:00
id: triangle
value: 4
2014-08-19 12:08:19 +00:00
anchors.left: ex.right
elementId: "triangle"
}
}
2014-08-20 10:10:58 +00:00
Text {
id: minute
onTextChanged: {
if (text.length < 2) {
minute.text = "0" + text;
}
}
anchors {
top: stripe.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
2014-08-28 13:21:53 +00:00
color: hour.color
2014-08-20 10:10:58 +00:00
text: "00"
font.pixelSize: Math.floor((width - (units.largeSpacing)) / 2)
horizontalAlignment: Qt.AlignCenter
verticalAlignment: Qt.AlignVCenter
}
2014-08-28 13:21:53 +00:00
Text {
id: emergencyCall
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
}
horizontalAlignment: Qt.AlignCenter
color: minute.color
text: i18n("Emergency Call")
MouseArea {
anchors.fill: parent
onClicked: { print("FIXME: Launch the dialer service!") }
}
}
}