lockscreen: Refactor and cleanup keypad

This commit is contained in:
Devin Lin 2022-10-27 20:37:31 -04:00
parent f4b15f922f
commit 11aaad0546

View file

@ -46,6 +46,7 @@ Rectangle {
PlasmaCore.Units.smallSpacing * 2 + Qt.inputMethod.keyboardRectangle.height + passwordBar.implicitHeight); PlasmaCore.Units.smallSpacing * 2 + Qt.inputMethod.keyboardRectangle.height + passwordBar.implicitHeight);
} }
} }
Behavior on implicitHeight { Behavior on implicitHeight {
NumberAnimation { NumberAnimation {
duration: Kirigami.Units.longDuration duration: Kirigami.Units.longDuration
@ -103,52 +104,50 @@ Rectangle {
spacing: PlasmaCore.Units.gridUnit spacing: PlasmaCore.Units.gridUnit
GridLayout { GridLayout {
property string thePw id: grid
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
Layout.leftMargin: PlasmaCore.Units.gridUnit * 0.5 Layout.leftMargin: PlasmaCore.Units.gridUnit * 0.5
Layout.rightMargin: PlasmaCore.Units.gridUnit * 0.5 Layout.rightMargin: PlasmaCore.Units.gridUnit * 0.5
Layout.maximumWidth: PlasmaCore.Units.gridUnit * 22 Layout.maximumWidth: PlasmaCore.Units.gridUnit * 22
Layout.maximumHeight: PlasmaCore.Units.gridUnit * 12.5 Layout.maximumHeight: PlasmaCore.Units.gridUnit * 12.5
opacity: (Math.sin(2*((Math.PI / 2) * keypadRoot.swipeProgress + 1.5 * Math.PI)) + 1)
columns: 4 columns: 4
readonly property real keyRadius: 5
// numpad keys // numpad keys
Repeater { Repeater {
model: ["1", "2", "3", "R", "4", "5", "6", "0", "7", "8", "9", "E"] model: ["1", "2", "3", "R", "4", "5", "6", "0", "7", "8", "9", "E"]
delegate: Item { delegate: AbstractButton {
id: button
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
visible: modelData.length > 0
opacity: (Math.sin(2*((Math.PI / 2) * keypadRoot.swipeProgress + 1.5 * Math.PI)) + 1)
background: Rectangle {
id: keyRect
radius: grid.keyRadius
color: button.pressed ? keypadRoot.buttonPressedColor : keypadRoot.buttonColor
RectangularGlow { RectangularGlow {
anchors.topMargin: 1 anchors.topMargin: 1
anchors.fill: keyRect anchors.fill: parent
z: -1
cornerRadius: keyRect.radius * 2 cornerRadius: keyRect.radius * 2
cached: true cached: true
glowRadius: 2 glowRadius: 2
spread: 0.2 spread: 0.2
color: keypadRoot.dropShadowColor color: button.pressed ? keypadRoot.buttonPressedColor : keypadRoot.dropShadowColor
opacity: (Math.sin(2*((Math.PI / 2) * keypadRoot.swipeProgress + 1.5 * Math.PI)) + 1) }
} }
Rectangle {
id: keyRect
anchors.centerIn: parent
width: parent.width
height: parent.height
radius: 5
color: keypadRoot.buttonColor
visible: modelData.length > 0
opacity: (Math.sin(2*((Math.PI / 2) * keypadRoot.swipeProgress + 1.5 * Math.PI)) + 1)
AbstractButton {
anchors.fill: parent
onPressedChanged: { onPressedChanged: {
if (pressed) { if (pressed) {
MobileShell.Haptics.buttonVibrate(); MobileShell.Haptics.buttonVibrate();
parent.color = keypadRoot.buttonPressedColor;
} else {
parent.color = keypadRoot.buttonColor;
} }
} }
@ -167,9 +166,8 @@ Rectangle {
passwordBar.clear(); passwordBar.clear();
} }
} }
}
}
contentItem: Item {
PlasmaComponents.Label { PlasmaComponents.Label {
visible: modelData !== "R" && modelData !== "E" visible: modelData !== "R" && modelData !== "E"
text: modelData text: modelData
@ -194,4 +192,5 @@ Rectangle {
} }
} }
} }
}
} }