Here is a complete listing of the example source file.
import QtQuick 2.11
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.1
import CuteHMI.Workarounds.Qt.labs.settings 1.0
ColumnLayout {
anchors.fill: parent
GridLayout {
Layout.alignment:
Qt.AlignCenter
columns: 2
Button {
text: qsTr("Lock")
onClicked: lockPopup.open()
}
Switch {
text: qsTr("Enabled")
checked: lockPopup.enabled
onCheckedChanged: lockPopup.enabled = checked
}
Label {
Layout.alignment:
Qt.AlignRight
text: qsTr("Inactivity lock [s]:")
}
SpinBox {
id: timeoutSpinBox
from: 1
to: 300
value: lockPopup.timeout
editable: true
onValueChanged: lockPopup.timeout = value
}
Button {
text: qsTr("Delete settings")
onClicked: deleteSettingsDialog.open()
Dialog {
id: deleteSettingsDialog
anchors.centerIn: parent
width: 300
focus: true
modal: true
title: qsTr("Delete settings?")
standardButtons: Dialog.Yes | Dialog.No
onAccepted: settings.remove("")
Text {
width: parent.width
wrapMode: Text.Wrap
text: qsTr("Are you sure you want to delete all the stored settings including password? Defaults will be loaded upon restart.")
}
}
}
Button {
text: qsTr("Change password")
onClicked: changePasswordWizard.open()
}
}
LockPopup {
id: lockPopup
z: Number.MAX_VALUE
width: parent.width
height: parent.height
lockItem: CustomLockImage {
anchors.fill: parent
}
property int timeout: 5
}
Settings {
id: settings
category: "CuteHMI.Examples.LockScreen.2/lockPopup"
property alias enabled: lockPopup.enabled
property alias timeout: lockPopup.timeout
property alias secret: lockPopup.lockItem.secret
}
Binding {
target: CuteApplication
property: "idleMeasureEnabled"
value: lockPopup.enabled
}
Connections {
target: CuteApplication
function onIdleChanged() {
if (lockPopup.enabled && CuteApplication.idle >= lockPopup.timeout)
lockPopup.open()
}
}
Popup {
id: changePasswordWizard
width: parent.width
height: parent.height
ChangePasswordWizard {
anchors.fill: parent
secret: lockPopup.lockItem.secret
lockItem: CustomLockImage {
anchors.fill: parent
passwordInput.autoAccept: false
passwordInput.discretion: false
}
onAccepted: {
lockPopup.lockItem.secret = lockItem.secret
changePasswordWizard.close()
}
onRejected: changePasswordWizard.close()
}
}
}