2024-10-14 18:55:01 +02:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
|
|
|
ApplicationWindow {
|
|
|
|
id: window
|
|
|
|
|
2024-10-16 17:00:37 +02:00
|
|
|
property var windowWidth: Math.round(fontMetrics.height * 32.2856)
|
|
|
|
property var windowHeight: Math.round(fontMetrics.height * 13.9528)
|
2024-11-01 23:25:26 +01:00
|
|
|
property var heightSafeMargin: 15
|
2024-10-14 18:55:01 +02:00
|
|
|
|
2024-11-01 23:25:26 +01:00
|
|
|
minimumWidth: Math.max(windowWidth, mainLayout.Layout.minimumWidth) + mainLayout.anchors.margins * 2
|
|
|
|
minimumHeight: Math.max(windowHeight, mainLayout.Layout.minimumHeight) + mainLayout.anchors.margins * 2 + heightSafeMargin
|
|
|
|
maximumWidth: minimumWidth
|
|
|
|
maximumHeight: minimumHeight
|
2024-10-14 18:55:01 +02:00
|
|
|
visible: true
|
2024-10-16 16:05:32 +02:00
|
|
|
onClosing: {
|
|
|
|
hpa.setResult("fail");
|
|
|
|
}
|
2024-10-14 18:55:01 +02:00
|
|
|
|
|
|
|
FontMetrics {
|
|
|
|
id: fontMetrics
|
|
|
|
}
|
|
|
|
|
|
|
|
SystemPalette {
|
|
|
|
id: system
|
|
|
|
|
|
|
|
colorGroup: SystemPalette.Active
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
2024-11-01 23:25:26 +01:00
|
|
|
id: mainLayout
|
|
|
|
|
2024-10-14 18:55:01 +02:00
|
|
|
anchors.fill: parent
|
|
|
|
Keys.onEscapePressed: (e) => {
|
|
|
|
hpa.setResult("fail");
|
|
|
|
}
|
|
|
|
Keys.onReturnPressed: (e) => {
|
|
|
|
hpa.setResult("auth:" + passwordField.text);
|
|
|
|
}
|
2024-11-29 00:44:14 +01:00
|
|
|
Keys.onEnterPressed: (e) => {
|
|
|
|
hpa.setResult("auth:" + passwordField.text);
|
|
|
|
}
|
2024-10-14 18:55:01 +02:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 4
|
|
|
|
|
2024-10-16 16:06:12 +02:00
|
|
|
Label {
|
2024-10-14 18:55:01 +02:00
|
|
|
color: Qt.darker(system.windowText, 0.8)
|
|
|
|
font.bold: true
|
|
|
|
font.pointSize: Math.round(fontMetrics.height * 1.05)
|
|
|
|
text: "Authenticating for " + hpa.getUser()
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2024-11-01 23:25:26 +01:00
|
|
|
Layout.maximumWidth: parent.width
|
|
|
|
elide: Text.ElideRight
|
|
|
|
wrapMode: Text.WordWrap
|
2024-10-14 18:55:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
HSeparator {
|
|
|
|
Layout.topMargin: fontMetrics.height / 2
|
|
|
|
Layout.bottomMargin: fontMetrics.height / 2
|
|
|
|
}
|
|
|
|
|
2024-10-16 16:06:12 +02:00
|
|
|
Label {
|
2024-10-16 16:54:31 +02:00
|
|
|
color: system.windowText
|
2024-10-14 18:55:01 +02:00
|
|
|
text: hpa.getMessage()
|
2024-11-01 23:25:26 +01:00
|
|
|
Layout.maximumWidth: parent.width
|
|
|
|
elide: Text.ElideRight
|
|
|
|
wrapMode: Text.WordWrap
|
2024-10-14 18:55:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TextField {
|
|
|
|
id: passwordField
|
|
|
|
|
|
|
|
Layout.topMargin: fontMetrics.height / 2
|
|
|
|
placeholderText: "Password"
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
hoverEnabled: true
|
|
|
|
persistentSelection: true
|
|
|
|
echoMode: TextInput.Password
|
|
|
|
focus: true
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: hpa
|
2024-11-25 19:07:52 +01:00
|
|
|
function onFocusField() {
|
2024-10-14 18:55:01 +02:00
|
|
|
passwordField.focus = true;
|
|
|
|
}
|
2024-11-25 19:07:52 +01:00
|
|
|
function onBlockInput(block) {
|
2024-10-16 16:05:32 +02:00
|
|
|
passwordField.readOnly = block;
|
|
|
|
if (!block) {
|
|
|
|
passwordField.focus = true;
|
|
|
|
passwordField.selectAll();
|
|
|
|
}
|
|
|
|
}
|
2024-10-14 18:55:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-10-16 16:06:12 +02:00
|
|
|
Label {
|
2024-10-14 18:55:01 +02:00
|
|
|
id: errorLabel
|
|
|
|
|
|
|
|
color: "red"
|
|
|
|
font.italic: true
|
2024-10-16 17:00:37 +02:00
|
|
|
Layout.topMargin: 0
|
2024-10-14 18:55:01 +02:00
|
|
|
text: ""
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: hpa
|
2024-11-25 19:07:52 +01:00
|
|
|
function onSetErrorString(e) {
|
2024-10-14 18:55:01 +02:00
|
|
|
errorLabel.text = e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
color: "transparent"
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
|
|
|
|
|
|
|
HSeparator {
|
|
|
|
Layout.topMargin: fontMetrics.height / 2
|
|
|
|
Layout.bottomMargin: fontMetrics.height / 2
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
Layout.rightMargin: fontMetrics.height / 2
|
|
|
|
|
|
|
|
Button {
|
|
|
|
text: "Cancel"
|
|
|
|
onClicked: (e) => {
|
|
|
|
hpa.setResult("fail");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
text: "Authenticate"
|
|
|
|
onClicked: (e) => {
|
|
|
|
hpa.setResult("auth:" + passwordField.text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
component Separator: Rectangle {
|
|
|
|
color: Qt.darker(window.palette.text, 1.5)
|
|
|
|
}
|
|
|
|
|
|
|
|
component HSeparator: Separator {
|
|
|
|
implicitHeight: 1
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: fontMetrics.height * 8
|
|
|
|
Layout.rightMargin: fontMetrics.height * 8
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|