nixnew/modules/user/modules/quickshell/lockscreen/Lockscreen.qml
2024-03-20 06:25:08 -07:00

105 lines
1.9 KiB
QML

import QtQuick
import QtQuick.Controls.Basic
Item {
required property AuthContext context
Item {
anchors.centerIn: parent
scale: 2
Text {
id: timeText
anchors {
bottom: entryBox.top
bottomMargin: 50
horizontalCenter: parent.horizontalCenter
}
font {
pointSize: 60
hintingPreference: Font.PreferFullHinting
family: "Noto Sans"
}
color: "white"
text: {
const hours = LockGlobals.time.getHours().toString().padStart(2, '0');
const minutes = LockGlobals.time.getMinutes().toString().padStart(2, '0');
return `${hours}:${minutes}`;
}
}
Text {
anchors {
top: timeText.bottom
topMargin: -10
horizontalCenter: parent.horizontalCenter
}
font {
pointSize: 20
}
color: "#50ffffff"
text: "Locked"
}
TextField {
id: entryBox
anchors.centerIn: parent
width: 300
enabled: context.status != AuthContext.Status.Authenticating
focus: true
horizontalAlignment: TextInput.AlignHCenter
echoMode: TextInput.Password
inputMethodHints: Qt.ImhSensitiveData
onCursorVisibleChanged: {
if (cursorVisible) cursorVisible = false;
}
cursorVisible: false
color: "white"
background: Rectangle {
color: "#20ffffff"
border.color: "#30ffffff"
radius: height / 2
}
text: LockGlobals.text
onTextChanged: {
LockGlobals.text = text
}
onAccepted: {
if (text != "") context.tryLogin(text)
}
onEnabledChanged: {
if (enabled) text = ""
}
}
Text {
id: status
color: "white"
anchors {
horizontalCenter: entryBox.horizontalCenter
top: entryBox.bottom
topMargin: 20
}
text: {
switch (context.status) {
case AuthContext.Status.FirstLogin: return ""
case AuthContext.Status.Authenticating: return "Authenticating"
case AuthContext.Status.LoginFailed: return "Login Failed"
}
}
}
}
}