2023-03-14 02:52:16 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
2023-03-30 17:57:18 +00:00
|
|
|
import StatusQ.Controls.Validators 0.1
|
2023-03-14 02:52:16 +00:00
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
2023-03-30 17:57:18 +00:00
|
|
|
Column {
|
2023-03-14 02:52:16 +00:00
|
|
|
id: root
|
|
|
|
|
2023-03-30 17:57:18 +00:00
|
|
|
property list<StatusValidator> validators
|
|
|
|
|
2023-03-14 02:52:16 +00:00
|
|
|
signal connectionStringFound(connectionString: string)
|
|
|
|
|
2023-03-30 17:57:18 +00:00
|
|
|
spacing: 12
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
2023-03-14 02:52:16 +00:00
|
|
|
|
2023-03-30 17:57:18 +00:00
|
|
|
property string errorMessage
|
|
|
|
property string lastTag
|
|
|
|
property int counter: 0
|
|
|
|
|
|
|
|
function validateConnectionString(connectionString) {
|
|
|
|
for (let i in root.validators) {
|
|
|
|
const validator = root.validators[i]
|
|
|
|
if (!validator.validate(connectionString)) {
|
|
|
|
d.errorMessage = validator.errorMessage
|
|
|
|
return
|
|
|
|
}
|
|
|
|
d.errorMessage = ""
|
|
|
|
root.connectionStringFound(connectionString)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-03-14 02:52:16 +00:00
|
|
|
|
2023-03-30 17:57:18 +00:00
|
|
|
StatusQrCodeScanner {
|
|
|
|
id: scanner
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
width: 330
|
|
|
|
height: 330
|
|
|
|
onLastTagChanged: {
|
|
|
|
d.validateConnectionString(lastTag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
width: parent.width
|
|
|
|
height: 16
|
|
|
|
}
|
2023-03-14 02:52:16 +00:00
|
|
|
|
|
|
|
StatusBaseText {
|
2023-03-30 17:57:18 +00:00
|
|
|
width: parent.width
|
|
|
|
opacity: scanner.currentTag ? 1 : 0
|
|
|
|
wrapMode: Text.WordWrap
|
2023-03-14 02:52:16 +00:00
|
|
|
color: Theme.palette.dangerColor1
|
2023-03-30 17:57:18 +00:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
text: d.errorMessage
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
width: parent.width
|
|
|
|
opacity: scanner.camera ? 1 : 0
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
text: qsTr("Ensure that the QR code is in focus to scan")
|
2023-03-14 02:52:16 +00:00
|
|
|
}
|
|
|
|
}
|