diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-28 15:13:40 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-28 15:13:40 +1000 |
| commit | f2b79757e26823cc1db1cf077dc03f1781562861 (patch) | |
| tree | 6b16aa6ec5e954f6eb9d7f181cf31096298d3fc1 /modules/lock/Center.qml | |
| parent | nix/hm: restart shell on config changes (#482) (diff) | |
| download | caelestia-shell-f2b79757e26823cc1db1cf077dc03f1781562861.tar.gz caelestia-shell-f2b79757e26823cc1db1cf077dc03f1781562861.tar.bz2 caelestia-shell-f2b79757e26823cc1db1cf077dc03f1781562861.zip | |
lock: add caps/num lock indicator
Closes #485
Diffstat (limited to 'modules/lock/Center.qml')
| -rw-r--r-- | modules/lock/Center.qml | 238 |
1 files changed, 148 insertions, 90 deletions
diff --git a/modules/lock/Center.qml b/modules/lock/Center.qml index 02e069a..26ba321 100644 --- a/modules/lock/Center.qml +++ b/modules/lock/Center.qml @@ -213,124 +213,182 @@ ColumnLayout { } } - StyledText { - id: message + Item { + Layout.fillWidth: true + Layout.topMargin: -Appearance.spacing.large - readonly property Pam pam: root.lock.pam - readonly property string msg: { - if (pam.fprintState === "error") - return qsTr("ERROR: %1").arg(pam.fprint.message); - if (pam.state === "error") - return qsTr("ERROR: %1").arg(pam.passwd.message); + implicitHeight: stateMessage.implicitHeight - if (pam.lockMessage) - return pam.lockMessage; + StyledText { + id: stateMessage - if (pam.state === "max" && pam.fprintState === "max") - return qsTr("Maximum password and fingerprint attempts reached."); - if (pam.state === "max") { - if (pam.fprint.available) - return qsTr("Maximum password attempts reached. Please use fingerprint."); - return qsTr("Maximum password attempts reached."); + readonly property string msg: { + if (Hypr.capsLock && Hypr.numLock) + return qsTr("Caps lock and Num lock are ON."); + if (Hypr.capsLock) + return qsTr("Caps lock is ON."); + if (Hypr.numLock) + return qsTr("Num lock is ON."); + return ""; } - if (pam.fprintState === "max") - return qsTr("Maximum fingerprint attempts reached. Please use password."); - if (pam.state === "fail") { - if (pam.fprint.available) - return qsTr("Incorrect password. Please try again or use fingerprint."); - return qsTr("Incorrect password. Please try again."); + property bool shouldBeVisible + + onMsgChanged: { + if (msg) { + if (opacity > 0) { + animate = true; + text = msg; + animate = false; + } else { + text = msg; + } + shouldBeVisible = true; + } else { + shouldBeVisible = false; + } } - if (pam.fprintState === "fail") - return qsTr("Fingerprint not recognized (%1/%2). Please try again or use password.").arg(pam.fprint.tries).arg(Config.lock.maxFprintTries); - return ""; + anchors.left: parent.left + anchors.right: parent.right + + scale: shouldBeVisible && !message.msg ? 1 : 0.7 + opacity: shouldBeVisible && !message.msg ? 1 : 0 + color: Colours.palette.m3onSurfaceVariant + animateProp: "opacity" + + font.family: Appearance.font.family.mono + horizontalAlignment: Qt.AlignHCenter + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + + Behavior on scale { + Anim {} + } + + Behavior on opacity { + Anim {} + } } - Layout.fillWidth: true - Layout.topMargin: -Appearance.spacing.large + StyledText { + id: message - scale: 0.7 - opacity: 0 - color: Colours.palette.m3error + readonly property Pam pam: root.lock.pam + readonly property string msg: { + if (pam.fprintState === "error") + return qsTr("ERROR: %1").arg(pam.fprint.message); + if (pam.state === "error") + return qsTr("ERROR: %1").arg(pam.passwd.message); - font.pointSize: Appearance.font.size.small - font.family: Appearance.font.family.mono - horizontalAlignment: Qt.AlignHCenter - wrapMode: Text.WrapAtWordBoundaryOrAnywhere + if (pam.lockMessage) + return pam.lockMessage; - onMsgChanged: { - if (msg) { - if (opacity > 0) { - animate = true; - text = msg; - animate = false; + if (pam.state === "max" && pam.fprintState === "max") + return qsTr("Maximum password and fingerprint attempts reached."); + if (pam.state === "max") { + if (pam.fprint.available) + return qsTr("Maximum password attempts reached. Please use fingerprint."); + return qsTr("Maximum password attempts reached."); + } + if (pam.fprintState === "max") + return qsTr("Maximum fingerprint attempts reached. Please use password."); - exitAnim.stop(); - if (scale < 1) - appearAnim.restart(); - else - flashAnim.restart(); - } else { - text = msg; - exitAnim.stop(); - appearAnim.restart(); + if (pam.state === "fail") { + if (pam.fprint.available) + return qsTr("Incorrect password. Please try again or use fingerprint."); + return qsTr("Incorrect password. Please try again."); } - } else { - appearAnim.stop(); - flashAnim.stop(); - exitAnim.start(); + if (pam.fprintState === "fail") + return qsTr("Fingerprint not recognized (%1/%2). Please try again or use password.").arg(pam.fprint.tries).arg(Config.lock.maxFprintTries); + + return ""; } - } - Connections { - target: root.lock.pam + anchors.left: parent.left + anchors.right: parent.right - function onFlashMsg(): void { - exitAnim.stop(); - if (message.scale < 1) - appearAnim.restart(); - else - flashAnim.restart(); - } - } + scale: 0.7 + opacity: 0 + color: Colours.palette.m3error - Anim { - id: appearAnim + font.pointSize: Appearance.font.size.small + font.family: Appearance.font.family.mono + horizontalAlignment: Qt.AlignHCenter + wrapMode: Text.WrapAtWordBoundaryOrAnywhere - target: message - properties: "scale,opacity" - to: 1 - onFinished: flashAnim.restart() - } + onMsgChanged: { + if (msg) { + if (opacity > 0) { + animate = true; + text = msg; + animate = false; - SequentialAnimation { - id: flashAnim + exitAnim.stop(); + if (scale < 1) + appearAnim.restart(); + else + flashAnim.restart(); + } else { + text = msg; + exitAnim.stop(); + appearAnim.restart(); + } + } else { + appearAnim.stop(); + flashAnim.stop(); + exitAnim.start(); + } + } - loops: 2 + Connections { + target: root.lock.pam - FlashAnim { - to: 0.3 + function onFlashMsg(): void { + exitAnim.stop(); + if (message.scale < 1) + appearAnim.restart(); + else + flashAnim.restart(); + } } - FlashAnim { + + Anim { + id: appearAnim + + target: message + properties: "scale,opacity" to: 1 + onFinished: flashAnim.restart() } - } - ParallelAnimation { - id: exitAnim + SequentialAnimation { + id: flashAnim - Anim { - target: message - property: "scale" - to: 0.7 - duration: Appearance.anim.durations.large + loops: 2 + + FlashAnim { + to: 0.3 + } + FlashAnim { + to: 1 + } } - Anim { - target: message - property: "opacity" - to: 0 - duration: Appearance.anim.durations.large + + ParallelAnimation { + id: exitAnim + + Anim { + target: message + property: "scale" + to: 0.7 + duration: Appearance.anim.durations.large + } + Anim { + target: message + property: "opacity" + to: 0 + duration: Appearance.anim.durations.large + } } } } |