status-desktop/ui/app/AppLayouts/Onboarding/views/sync/SyncDeviceFromMobile.qml
Igor Sirotin 14c264e350
feature(Syncing): Embed QR code scanner for syncing devices on onboarding (#9981)
* fix(StatusQrCodeScanner): Improve QR code scanner
- Almost async loading
- Added camera selector
- Added `captureRectangle` property
- Add component info to sandbox qr code scanner page
- Embed QrCodeScanner into desktop app
* Compile and link qzxing as shared library
* Hardcode settingCurrentNetwork. Propagate inputConnectionString errors.
* Added qzxing libdir to e2e tests ld_library_path
2023-03-30 20:57:18 +03:00

73 lines
1.8 KiB
QML

import QtQuick 2.13
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.13
import StatusQ.Controls 0.1
import StatusQ.Controls.Validators 0.1
import StatusQ.Components 0.1
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
Column {
id: root
property list<StatusValidator> validators
signal connectionStringFound(connectionString: string)
spacing: 12
QtObject {
id: d
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)
}
}
}
StatusQrCodeScanner {
id: scanner
anchors.horizontalCenter: parent.horizontalCenter
width: 330
height: 330
onLastTagChanged: {
d.validateConnectionString(lastTag)
}
}
Item {
width: parent.width
height: 16
}
StatusBaseText {
width: parent.width
opacity: scanner.currentTag ? 1 : 0
wrapMode: Text.WordWrap
color: Theme.palette.dangerColor1
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")
}
}