118 lines
2.4 KiB
QML
118 lines
2.4 KiB
QML
import QtQuick
|
|
import QtQuick.Layouts
|
|
import QtQuick.Controls.Fusion
|
|
import Quickshell.Wayland
|
|
import Quickshell.Services.UPower
|
|
|
|
Rectangle {
|
|
id: root
|
|
required property LockContext context
|
|
|
|
Image {
|
|
anchors.fill: parent
|
|
source: "/home/ceres/.local/state/niri/wallpaper"
|
|
}
|
|
|
|
Label {
|
|
id: clock
|
|
property var date: new Date()
|
|
|
|
font.family: "Departure Mono"
|
|
color: Colours.foreground
|
|
|
|
anchors {
|
|
horizontalCenter: parent.horizontalCenter
|
|
top: parent.top
|
|
topMargin: 100
|
|
}
|
|
|
|
// The native font renderer tends to look nicer at large sizes.
|
|
renderType: Text.NativeRendering
|
|
font.pointSize: 80
|
|
|
|
// updates the clock every second
|
|
Timer {
|
|
running: true
|
|
repeat: true
|
|
interval: 1000
|
|
|
|
onTriggered: clock.date = new Date();
|
|
}
|
|
|
|
// updated when the date changes
|
|
text: {
|
|
const hours = this.date.getHours().toString().padStart(2, '0');
|
|
const minutes = this.date.getMinutes().toString().padStart(2, '0');
|
|
return `${hours}:${minutes}`;
|
|
}
|
|
}
|
|
|
|
Text {
|
|
anchors {
|
|
horizontalCenter: parent.horizontalCenter
|
|
top: parent.top
|
|
topMargin: 250
|
|
}
|
|
|
|
renderType: Text.NativeRendering
|
|
font.pointSize: 30
|
|
font.family: "Departure Mono"
|
|
color: Colours.foreground
|
|
|
|
text: Math.floor(UPower.displayDevice.percentage * 100) + "% Battery"
|
|
}
|
|
|
|
ColumnLayout {
|
|
// Uncommenting this will make the password entry invisible except on the active monitor.
|
|
// visible: Window.active
|
|
|
|
anchors {
|
|
horizontalCenter: parent.horizontalCenter
|
|
top: parent.verticalCenter
|
|
}
|
|
|
|
RowLayout {
|
|
TextField {
|
|
id: passwordBox
|
|
|
|
background: Rectangle {
|
|
color: Colours.background
|
|
opacity: 0.9
|
|
border.width: 4
|
|
border.color: Colours.colour2
|
|
radius: 20
|
|
}
|
|
|
|
implicitWidth: 400
|
|
padding: 10
|
|
color: Colours.foreground
|
|
horizontalAlignment: TextInput.AlignHCenter
|
|
|
|
focus: true
|
|
enabled: !root.context.unlockInProgress
|
|
echoMode: TextInput.Password
|
|
inputMethodHints: Qt.ImhSensitiveData
|
|
|
|
onTextChanged: root.context.currentText = this.text;
|
|
|
|
onAccepted: root.context.tryUnlock();
|
|
|
|
Connections {
|
|
target: root.context
|
|
|
|
function onCurrentTextChanged() {
|
|
passwordBox.text = root.context.currentText;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Label {
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
visible: root.context.showFailure
|
|
text: "Incorrect password"
|
|
font.family: "Departure Mono"
|
|
color: Colours.foreground
|
|
}
|
|
}
|
|
}
|