2024-11-06 00:39:08 +01:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2023-08-16 11:57:32 +02:00
|
|
|
|
2023-10-03 20:40:20 +02:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2024-07-30 12:55:03 -04:00
|
|
|
import StatusQ.Components 0.1
|
2023-08-16 11:57:32 +02:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Controls.Validators 0.1
|
|
|
|
|
|
|
|
import shared.controls 1.0
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property string firstTabName: qsTr("Scan QR code")
|
2024-11-06 00:39:08 +01:00
|
|
|
property string secondTabName: qsTr("Enter code")
|
|
|
|
property string firstInstructionButtonName: qsTr("How to get a pairing code")
|
|
|
|
property string secondInstructionButtonName: qsTr("How to get a pairing code")
|
|
|
|
property string syncQrErrorMessage: qsTr("This does not look like a pairing QR code")
|
|
|
|
property string syncCodeErrorMessage: qsTr("This does not look like a pairing code")
|
|
|
|
property string syncCodeLabel: qsTr("Type or paste pairing code")
|
|
|
|
property alias showBetaTag: betaTag.visible
|
2023-08-16 11:57:32 +02:00
|
|
|
|
2024-11-06 00:39:08 +01:00
|
|
|
property var validateConnectionString: function(stringValue) { return false }
|
2023-08-16 11:57:32 +02:00
|
|
|
|
2024-11-06 00:39:08 +01:00
|
|
|
readonly property bool syncViaQr: !switchTabBar.currentIndex
|
2023-08-21 12:58:21 +02:00
|
|
|
|
2023-08-16 11:57:32 +02:00
|
|
|
signal displayInstructions()
|
|
|
|
signal proceed(string connectionString)
|
|
|
|
|
2024-11-06 00:39:08 +01:00
|
|
|
spacing: Theme.halfPadding
|
2023-08-16 11:57:32 +02:00
|
|
|
|
2024-11-06 00:39:08 +01:00
|
|
|
RowLayout {
|
|
|
|
spacing: root.spacing
|
2023-08-21 12:58:21 +02:00
|
|
|
Layout.fillWidth: true
|
2024-11-06 00:39:08 +01:00
|
|
|
Layout.leftMargin: Theme.bigPadding
|
|
|
|
Layout.rightMargin: Theme.bigPadding
|
2023-08-16 11:57:32 +02:00
|
|
|
|
2024-11-06 00:39:08 +01:00
|
|
|
StatusSwitchTabBar {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: betaTag.visible ? betaTag.width : 0
|
|
|
|
id: switchTabBar
|
|
|
|
|
|
|
|
currentIndex: 0
|
|
|
|
|
|
|
|
StatusSwitchTabButton {
|
|
|
|
objectName: "firstTab_StatusSwitchTabButton"
|
|
|
|
text: root.firstTabName
|
|
|
|
}
|
2023-08-16 11:57:32 +02:00
|
|
|
|
2024-11-06 00:39:08 +01:00
|
|
|
StatusSwitchTabButton {
|
|
|
|
objectName: "secondTab_StatusSwitchTabButton"
|
|
|
|
text: root.secondTabName
|
|
|
|
}
|
2023-08-16 11:57:32 +02:00
|
|
|
}
|
|
|
|
|
2024-11-06 00:39:08 +01:00
|
|
|
StatusBetaTag {
|
|
|
|
id: betaTag
|
|
|
|
}
|
2024-07-30 12:55:03 -04:00
|
|
|
}
|
|
|
|
|
2023-08-16 11:57:32 +02:00
|
|
|
StackLayout {
|
|
|
|
Layout.fillWidth: true
|
2023-08-21 12:58:21 +02:00
|
|
|
Layout.preferredHeight: Math.max(syncQr.implicitHeight, syncCode.implicitHeight)
|
2024-11-06 00:39:08 +01:00
|
|
|
Layout.topMargin: Theme.bigPadding
|
2023-08-16 11:57:32 +02:00
|
|
|
currentIndex: switchTabBar.currentIndex
|
|
|
|
|
|
|
|
// StackLayout doesn't support alignment, so we create an `Item` wrappers
|
|
|
|
|
|
|
|
Item {
|
|
|
|
StatusSyncCodeScan {
|
2023-08-21 12:58:21 +02:00
|
|
|
id: syncQr
|
2023-08-16 11:57:32 +02:00
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
}
|
|
|
|
validators: [
|
|
|
|
StatusValidator {
|
|
|
|
name: "isSyncQrCode"
|
|
|
|
errorMessage: root.syncQrErrorMessage
|
|
|
|
validate: root.validateConnectionString
|
|
|
|
}
|
|
|
|
]
|
|
|
|
onConnectionStringFound: {
|
|
|
|
root.proceed(connectionString)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-03 20:40:20 +02:00
|
|
|
ColumnLayout {
|
2024-11-06 00:39:08 +01:00
|
|
|
Layout.topMargin: Theme.padding
|
|
|
|
spacing: Theme.padding
|
2023-08-16 11:57:32 +02:00
|
|
|
StatusSyncCodeInput {
|
2024-11-06 00:39:08 +01:00
|
|
|
objectName: "syncCodeInput"
|
2023-08-21 12:58:21 +02:00
|
|
|
id: syncCode
|
2023-10-03 20:40:20 +02:00
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2024-11-06 00:39:08 +01:00
|
|
|
Layout.preferredWidth: 440
|
2023-08-21 12:58:21 +02:00
|
|
|
|
|
|
|
mode: StatusSyncCodeInput.Mode.WriteMode
|
2023-10-03 20:40:20 +02:00
|
|
|
label: root.syncCodeLabel
|
2023-08-21 12:58:21 +02:00
|
|
|
input.placeholderText: qsTr("eg. %1").arg("0x2Ef19")
|
|
|
|
|
2023-08-16 11:57:32 +02:00
|
|
|
validators: [
|
|
|
|
StatusValidator {
|
|
|
|
name: "isSyncCode"
|
|
|
|
errorMessage: root.syncCodeErrorMessage
|
|
|
|
validate: root.validateConnectionString
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2023-10-03 20:40:20 +02:00
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
font.pixelSize: Theme.tertiaryTextFontSize
|
2024-11-06 00:39:08 +01:00
|
|
|
text: qsTr("Ensure both devices are on the same local network")
|
|
|
|
}
|
|
|
|
StatusButton {
|
|
|
|
objectName: "continue_StatusButton"
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
Layout.topMargin: Theme.padding
|
|
|
|
text: qsTr("Continue")
|
|
|
|
enabled: syncCode.input.valid
|
|
|
|
onClicked: root.proceed(syncCode.text)
|
2023-10-03 20:40:20 +02:00
|
|
|
}
|
2023-08-16 11:57:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusFlatButton {
|
2024-11-06 00:39:08 +01:00
|
|
|
Layout.topMargin: Theme.xlPadding
|
2023-08-16 11:57:32 +02:00
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2023-08-21 12:58:21 +02:00
|
|
|
visible: switchTabBar.currentIndex == 0 && !!root.firstInstructionButtonName ||
|
|
|
|
switchTabBar.currentIndex == 1 && !!root.secondInstructionButtonName
|
|
|
|
text: switchTabBar.currentIndex == 0?
|
|
|
|
root.firstInstructionButtonName :
|
|
|
|
root.secondInstructionButtonName
|
2024-11-06 00:39:08 +01:00
|
|
|
font.pixelSize: Theme.additionalTextSize
|
|
|
|
normalColor: "transparent"
|
|
|
|
borderWidth: 1
|
|
|
|
borderColor: Theme.palette.baseColor2
|
2023-08-16 11:57:32 +02:00
|
|
|
onClicked: {
|
|
|
|
root.displayInstructions()
|
|
|
|
}
|
|
|
|
}
|
2023-08-21 12:58:21 +02:00
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
2023-08-16 11:57:32 +02:00
|
|
|
}
|