slightly larger password font size and add clear function

This commit is contained in:
Han Young 2020-09-16 15:00:36 +00:00
parent d797e88aee
commit eda8fadb12

View file

@ -37,6 +37,12 @@ Rectangle {
indexWithNumber = -2; indexWithNumber = -2;
root.password = root.password.substr(0, root.password.length - 1); root.password = root.password.substr(0, root.password.length - 1);
} }
function clear() {
lastKeyPressValue = "0";
indexWithNumber = -2;
root.password = "";
}
function enter() { function enter() {
authenticator.tryUnlock(root.password); authenticator.tryUnlock(root.password);
@ -100,7 +106,7 @@ Rectangle {
// pin dot display // pin dot display
Item { Item {
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignCenter
Layout.minimumHeight: units.gridUnit * 0.5 Layout.minimumHeight: units.gridUnit * 0.5
Layout.maximumWidth: parent.width Layout.maximumWidth: parent.width
@ -114,37 +120,38 @@ Rectangle {
RowLayout { RowLayout {
id: dotDisplay id: dotDisplay
anchors.centerIn: parent anchors.centerIn: parent
height: units.gridUnit // maintain height when letter is shown height: units.gridUnit * 1.5// maintain height when letter is shown
spacing: 6 spacing: 6
Repeater { Repeater {
model: root.password.length model: root.password.length
delegate: Rectangle { // dot delegate: Rectangle { // dot
visible: index !== indexWithNumber // hide dot if number is shown visible: index !== indexWithNumber // hide dot if number is shown
Layout.preferredWidth: units.gridUnit * 0.25 Layout.preferredWidth: units.gridUnit * 0.35
Layout.preferredHeight: Layout.preferredWidth Layout.preferredHeight: Layout.preferredWidth
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter Layout.alignment: Qt.AlignVCenter
radius: width radius: width
color: "#424242" color: "#424242"
} }
} }
Label { // number/letter Label { // number/letter
visible: root.password.length-1 === indexWithNumber // hide label if no label needed visible: root.password.length-1 === indexWithNumber // hide label if no label needed
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
color: "#424242" color: "#424242"
text: lastKeyPressValue text: lastKeyPressValue
font.pointSize: 10 font.pointSize: 12
} }
} }
} }
// separator // separator
Rectangle { Rectangle {
Layout.fillWidth: true Layout.fillWidth: true
height: 1 height: 1
color: "#eeeeee" color: "#eeeeee"
} }
// number keys // number keys
GridLayout { GridLayout {
property string thePw property string thePw
@ -154,15 +161,15 @@ Rectangle {
Layout.maximumWidth: units.gridUnit * 22 Layout.maximumWidth: units.gridUnit * 22
Layout.maximumHeight: units.gridUnit * 12.5 Layout.maximumHeight: units.gridUnit * 12.5
columns: 4 columns: 4
// 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: Item {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
Rectangle { Rectangle {
id: keyRect id: keyRect
anchors.centerIn: parent anchors.centerIn: parent
@ -185,9 +192,14 @@ Rectangle {
keyPress(modelData); keyPress(modelData);
} }
} }
onPressAndHold: {
if (modelData === "R") {
clear();
}
}
} }
} }
DropShadow { DropShadow {
anchors.fill: keyRect anchors.fill: keyRect
source: keyRect source: keyRect
@ -210,14 +222,14 @@ Rectangle {
PlasmaCore.IconItem { PlasmaCore.IconItem {
visible: modelData === "R" visible: modelData === "R"
anchors.centerIn: parent anchors.centerIn: parent
// colorGroup: PlasmaCore.ColorScope.backgroundColor // colorGroup: PlasmaCore.ColorScope.backgroundColor
source: "edit-clear" source: "edit-clear"
} }
PlasmaCore.IconItem { PlasmaCore.IconItem {
visible: modelData === "E" visible: modelData === "E"
anchors.centerIn: parent anchors.centerIn: parent
// colorGroup: PlasmaCore.ColorScope.backgroundColor // colorGroup: PlasmaCore.ColorScope.backgroundColor
source: "go-next" source: "go-next"
} }
} }