From 56828d5411e4642e4147ec128d9c1ff66c62d7f9 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Tue, 19 Aug 2014 18:02:23 +0200 Subject: [PATCH] pull out the key as a shared component -> less duplication --- look-and-feel/contents/lockscreen/LockKey.qml | 21 ++++++ .../contents/lockscreen/LockScreen.qml | 64 ++++--------------- 2 files changed, 34 insertions(+), 51 deletions(-) create mode 100644 look-and-feel/contents/lockscreen/LockKey.qml diff --git a/look-and-feel/contents/lockscreen/LockKey.qml b/look-and-feel/contents/lockscreen/LockKey.qml new file mode 100644 index 00000000..31e855d9 --- /dev/null +++ b/look-and-feel/contents/lockscreen/LockKey.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 +import org.kde.plasma.core 2.0 as PlasmaCore + +PlasmaCore.SvgItem { + id: square + property int value: 0 + width: parent.width/4 + height: parent.height + + svg: symbolsSvg + + MouseArea { + anchors.fill: parent + onPressed: { + stripe.lockKeyPressed(parent.elementId); + } + onReleased: { + stripe.lockKeyReleased(parent.elementId); + } + } +} diff --git a/look-and-feel/contents/lockscreen/LockScreen.qml b/look-and-feel/contents/lockscreen/LockScreen.qml index 2605671b..fa7e0932 100644 --- a/look-and-feel/contents/lockscreen/LockScreen.qml +++ b/look-and-feel/contents/lockscreen/LockScreen.qml @@ -26,6 +26,11 @@ Leaves { console.log(id); } + function lockKeyReleased(id) { + hideTimer.restart(); + console.log(id); + } + Behavior on opacity { NumberAnimation { duration: 500 @@ -40,81 +45,38 @@ Leaves { onTriggered: parent.opacity = 0 } - PlasmaCore.SvgItem { + LockKey { id: square - property int value: 1 - opacity: 1 - anchors.top: parent.top - anchors.left: parent.left - width: parent.width/4 - height: parent.height - - svg: symbolsSvg + value: 1 elementId: "square" - - MouseArea { - anchors.fill: parent - onPressed: { - stripe.lockKeyPressed("square"); - } - } } - PlasmaCore.SvgItem { + LockKey { id: circle - property int value: 2 + value: 2 anchors.top: parent.top anchors.left: square.right - width: square.width - height: square.height - svg: symbolsSvg elementId: "circle" - - MouseArea { - anchors.fill: parent - onPressed: { - stripe.lockKeyPressed("circle"); - } - } } - PlasmaCore.SvgItem { + LockKey { id: ex - property int value: 3 + value: 3 anchors.top: parent.top anchors.left: circle.right - width: square.width - height: square.height - svg: symbolsSvg elementId: "ex" - MouseArea { - anchors.fill: parent - onPressed: { - stripe.lockKeyPressed("ex"); - } - } } - PlasmaCore.SvgItem { + LockKey { id: triangle - property int value: 4 + value: 4 anchors.top: parent.top anchors.left: ex.right - width: parent.width - (square.width * 3) - height: square.height - svg: symbolsSvg elementId: "triangle" - - MouseArea { - anchors.fill: parent - onPressed: { - stripe.lockKeyPressed("triangle"); - } - } } } }