2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2023-09-22 10:38:44 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
|
|
|
import shared.controls 1.0
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
2023-09-25 11:23:25 +00:00
|
|
|
ApplicationWindow {
|
2023-09-22 10:38:44 +00:00
|
|
|
id: root
|
|
|
|
|
2023-09-25 11:23:25 +00:00
|
|
|
property var relatedModule
|
2023-09-22 10:38:44 +00:00
|
|
|
|
2023-09-25 11:23:25 +00:00
|
|
|
title: qsTr("Mocked Keycard Lib Controller")
|
|
|
|
minimumHeight: 600
|
|
|
|
minimumWidth: 450
|
2023-09-22 10:38:44 +00:00
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
property int btnWidth: 30
|
|
|
|
property int btnHeight: 30
|
2023-09-25 11:23:25 +00:00
|
|
|
property int margin: 16
|
|
|
|
property int spacing: 16
|
2023-09-22 10:38:44 +00:00
|
|
|
}
|
|
|
|
|
2023-09-25 11:23:25 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: commands
|
2023-09-22 10:38:44 +00:00
|
|
|
anchors.top: parent.top
|
2023-09-25 11:23:25 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.margins: d.margin
|
|
|
|
spacing: d.spacing
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
text: qsTr("Use this buttons to control the flow")
|
2023-09-22 10:38:44 +00:00
|
|
|
}
|
|
|
|
|
2023-09-25 11:23:25 +00:00
|
|
|
Flow {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
spacing: d.spacing
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
text: qsTr("Plugin Reader")
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "pluginReaderButton"
|
2023-09-25 11:23:25 +00:00
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
if (!!root.relatedModule) {
|
|
|
|
root.relatedModule.pluginMockedReaderAction()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
text: qsTr("Unplug Reader")
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "unplugReaderButton"
|
2023-09-25 11:23:25 +00:00
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
if (!!root.relatedModule) {
|
|
|
|
root.relatedModule.unplugMockedReaderAction()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
text: qsTr("Insert Keycard 1")
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "insertKeycard1Button"
|
2023-09-25 11:23:25 +00:00
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
if (!!root.relatedModule) {
|
|
|
|
root.relatedModule.insertMockedKeycardAction(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
text: qsTr("Insert Keycard 2")
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "insertKeycard2Button"
|
2023-09-25 11:23:25 +00:00
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
if (!!root.relatedModule) {
|
|
|
|
root.relatedModule.insertMockedKeycardAction(2)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
text: qsTr("Remove Keycard")
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "removeKeycardButton"
|
2023-09-25 11:23:25 +00:00
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
if (!!root.relatedModule) {
|
|
|
|
root.relatedModule.removeMockedKeycardAction()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: 1
|
2023-09-22 10:38:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MockedKeycardReaderStateSelector {
|
|
|
|
id: readerState
|
2023-09-25 11:23:25 +00:00
|
|
|
anchors.top: commands.bottom
|
2023-09-22 10:38:44 +00:00
|
|
|
anchors.left: parent.left
|
2023-09-25 11:23:25 +00:00
|
|
|
anchors.margins: d.margin
|
|
|
|
anchors.topMargin: 3 * d.margin
|
|
|
|
title: qsTr("Set initial reader state (refers to keycard 1 only)")
|
2023-09-22 10:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusTabBar {
|
|
|
|
id: tabBar
|
|
|
|
anchors.top: readerState.bottom
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2023-09-25 11:23:25 +00:00
|
|
|
anchors.margins: d.margin
|
|
|
|
anchors.topMargin: 3 * d.margin
|
2023-09-22 10:38:44 +00:00
|
|
|
|
|
|
|
StatusTabButton {
|
|
|
|
width: implicitWidth
|
|
|
|
leftPadding: 0
|
|
|
|
text: qsTr("Keycard-1")
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "keycard1Button"
|
2023-09-22 10:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusTabButton {
|
|
|
|
width: implicitWidth
|
|
|
|
text: qsTr("Keycard-2")
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "keycard2Button"
|
2023-09-22 10:38:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StackLayout {
|
|
|
|
anchors.top: tabBar.bottom
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.margins: Theme.halfPadding
|
2023-09-22 10:38:44 +00:00
|
|
|
currentIndex: tabBar.currentIndex
|
|
|
|
|
|
|
|
KeycardSettingsTab {
|
|
|
|
cardIndex: 1
|
|
|
|
|
|
|
|
onRegisterKeycard: {
|
2023-09-25 11:23:25 +00:00
|
|
|
if (!!root.relatedModule) {
|
|
|
|
relatedModule.registerMockedKeycard(cardIndex, readerState.selectedState, kcState, kc, kcHelper)
|
|
|
|
}
|
2023-09-22 10:38:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
KeycardSettingsTab {
|
|
|
|
cardIndex: 2
|
|
|
|
|
|
|
|
onRegisterKeycard: {
|
2023-09-25 11:23:25 +00:00
|
|
|
if (!!root.relatedModule) {
|
|
|
|
relatedModule.registerMockedKeycard(cardIndex, MockedKeycardReaderStateSelector.NoKeycard, kcState, kc, kcHelper)
|
|
|
|
}
|
2023-09-22 10:38:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
component KeycardSettingsTab: StatusScrollView {
|
|
|
|
id: keycardSettingsTabRoot
|
|
|
|
|
|
|
|
property int cardIndex
|
|
|
|
|
|
|
|
signal registerKeycard(int kcState, string kc, string kcHelper)
|
|
|
|
|
|
|
|
ColumnLayout {
|
2023-09-25 11:23:25 +00:00
|
|
|
spacing: d.spacing
|
2023-09-22 10:38:44 +00:00
|
|
|
|
|
|
|
MockedKeycardStateSelector {
|
|
|
|
id: keycardState
|
|
|
|
title: qsTr("Keycard %1 - initial keycard state").arg(keycardSettingsTabRoot.cardIndex)
|
|
|
|
}
|
|
|
|
|
|
|
|
Column {
|
|
|
|
id: customSection
|
|
|
|
visible: keycardState.selectedState === MockedKeycardStateSelector.CustomKeycard
|
2023-09-25 11:23:25 +00:00
|
|
|
spacing: d.spacing
|
2023-09-22 10:38:44 +00:00
|
|
|
|
|
|
|
StatusInput {
|
|
|
|
id: mockedKeycard
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "mockedKeycardInput"
|
2023-09-22 10:38:44 +00:00
|
|
|
label: qsTr("Mocked Keycard")
|
|
|
|
implicitWidth: 400
|
|
|
|
minimumHeight: 200
|
|
|
|
maximumHeight: 200
|
|
|
|
input.multiline: true
|
|
|
|
input.verticalAlignment: TextEdit.AlignTop
|
|
|
|
placeholderText: qsTr("Enter json form of status-go MockedKeycard")
|
|
|
|
errorMessageCmp.text: qsTr("Invalid json format")
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusInput {
|
|
|
|
id: mockedKeycardHelper
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "specificKeycardDetailsInput"
|
2023-09-22 10:38:44 +00:00
|
|
|
label: qsTr("Specific keycard details")
|
|
|
|
implicitWidth: 400
|
|
|
|
minimumHeight: 200
|
|
|
|
maximumHeight: 200
|
|
|
|
input.multiline: true
|
|
|
|
input.verticalAlignment: TextEdit.AlignTop
|
|
|
|
placeholderText: qsTr("Enter json form of status-go MockedKeycard")
|
|
|
|
errorMessageCmp.text: qsTr("Invalid json format")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
text: qsTr("Register Keycard")
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "registerKeycardButton"
|
2023-09-22 10:38:44 +00:00
|
|
|
onClicked: {
|
|
|
|
if (customSection.visible) {
|
|
|
|
mockedKeycard.input.valid = true
|
|
|
|
mockedKeycardHelper.input.valid = true
|
|
|
|
|
|
|
|
if (mockedKeycard.text != "") {
|
|
|
|
try {
|
|
|
|
JSON.parse(mockedKeycard.text)
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
mockedKeycard.input.valid = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mockedKeycardHelper.text != "") {
|
|
|
|
try {
|
|
|
|
JSON.parse(mockedKeycardHelper.text)
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
mockedKeycardHelper.input.valid = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mockedKeycard.input.valid || !mockedKeycardHelper.input.valid) {
|
|
|
|
return
|
|
|
|
}
|
2023-11-14 15:45:26 +00:00
|
|
|
|
|
|
|
keycardSettingsTabRoot.registerKeycard(keycardState.selectedState,
|
|
|
|
mockedKeycard.text,
|
|
|
|
mockedKeycardHelper.text)
|
2023-09-22 10:38:44 +00:00
|
|
|
}
|
|
|
|
|
2023-11-14 15:45:26 +00:00
|
|
|
keycardSettingsTabRoot.registerKeycard(keycardState.selectedState, "", "")
|
2023-09-22 10:38:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|