2023-09-22 10:38:44 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property string title
|
|
|
|
property int selectedState: MockedKeycardStateSelector.State.EmptyKeycard
|
|
|
|
|
|
|
|
enum State {
|
|
|
|
NotStatusKeycard,
|
|
|
|
EmptyKeycard,
|
|
|
|
MaxPairingSlotsReached,
|
|
|
|
MaxPINRetriesReached,
|
|
|
|
MaxPUKRetriesReached,
|
|
|
|
KeycardWithMnemonicOnly,
|
|
|
|
KeycardWithMnemonicAndMedatada,
|
|
|
|
CustomKeycard // should be always the last option
|
|
|
|
}
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property string kcStateNotStatusKeycard: qsTr("Not Status Keycard")
|
|
|
|
readonly property string kcStateEmptyKeycard: qsTr("Empty Keycard")
|
|
|
|
readonly property string kcStateMaxPairingSlotsReached: qsTr("Max Pairing Slots Reached")
|
|
|
|
readonly property string kcStateMaxPINRetriesReached: qsTr("Max PIN Retries Reached")
|
|
|
|
readonly property string kcStateMaxPUKRetriesReached: qsTr("Max PUK Retries Reached")
|
|
|
|
readonly property string kcStateKeycardWithMnemonicOnly: qsTr("Keycard With Mnemonic Only")
|
|
|
|
readonly property string kcStateKeycardWithMnemonicAndMedatada: qsTr("Keycard With Mnemonic & Metadata")
|
|
|
|
readonly property string kcStateCustomKeycard: qsTr("Custom Keycard")
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
text: root.title
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
id: selectKeycardsStateButton
|
|
|
|
|
|
|
|
text: {
|
|
|
|
switch (root.selectedState) {
|
|
|
|
case MockedKeycardStateSelector.State.NotStatusKeycard:
|
|
|
|
return d.kcStateNotStatusKeycard
|
|
|
|
case MockedKeycardStateSelector.State.EmptyKeycard:
|
|
|
|
return d.kcStateEmptyKeycard
|
|
|
|
case MockedKeycardStateSelector.State.MaxPairingSlotsReached:
|
|
|
|
return d.kcStateMaxPairingSlotsReached
|
|
|
|
case MockedKeycardStateSelector.State.MaxPINRetriesReached:
|
|
|
|
return d.kcStateMaxPINRetriesReached
|
|
|
|
case MockedKeycardStateSelector.State.MaxPUKRetriesReached:
|
|
|
|
return d.kcStateMaxPUKRetriesReached
|
|
|
|
case MockedKeycardStateSelector.State.KeycardWithMnemonicOnly:
|
|
|
|
return d.kcStateKeycardWithMnemonicOnly
|
|
|
|
case MockedKeycardStateSelector.State.KeycardWithMnemonicAndMedatada:
|
|
|
|
return d.kcStateKeycardWithMnemonicAndMedatada
|
|
|
|
case MockedKeycardStateSelector.State.CustomKeycard:
|
|
|
|
return d.kcStateCustomKeycard
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
icon.name: "chevron-down"
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
if (initialKeycardState.opened) {
|
|
|
|
initialKeycardState.close()
|
|
|
|
} else {
|
|
|
|
initialKeycardState.popup(selectKeycardsStateButton.x, selectKeycardsStateButton.y + selectKeycardsStateButton.height + 8)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenu {
|
|
|
|
id: initialKeycardState
|
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
|
|
|
|
|
|
|
|
StatusAction {
|
|
|
|
text: d.kcStateNotStatusKeycard
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "notStatusKeycardAction"
|
2023-09-22 10:38:44 +00:00
|
|
|
onTriggered: {
|
|
|
|
root.selectedState = MockedKeycardStateSelector.State.NotStatusKeycard
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusAction {
|
|
|
|
text: d.kcStateEmptyKeycard
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "emptyKeycardAction"
|
2023-09-22 10:38:44 +00:00
|
|
|
onTriggered: {
|
|
|
|
root.selectedState = MockedKeycardStateSelector.State.EmptyKeycard
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusAction {
|
|
|
|
text: d.kcStateMaxPairingSlotsReached
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "maxPairingSlotsReachedAction"
|
2023-09-22 10:38:44 +00:00
|
|
|
onTriggered: {
|
|
|
|
root.selectedState = MockedKeycardStateSelector.State.MaxPairingSlotsReached
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusAction {
|
|
|
|
text: d.kcStateMaxPINRetriesReached
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "maxPINRetriesReachedAction"
|
2023-09-22 10:38:44 +00:00
|
|
|
onTriggered: {
|
|
|
|
root.selectedState = MockedKeycardStateSelector.State.MaxPINRetriesReached
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusAction {
|
|
|
|
text: d.kcStateMaxPUKRetriesReached
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "maxPUKRetriesReachedAction"
|
2023-09-22 10:38:44 +00:00
|
|
|
onTriggered: {
|
|
|
|
root.selectedState = MockedKeycardStateSelector.State.MaxPUKRetriesReached
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusAction {
|
|
|
|
text: d.kcStateKeycardWithMnemonicOnly
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "keycardWithMnemonicOnlyAction"
|
2023-09-22 10:38:44 +00:00
|
|
|
onTriggered: {
|
|
|
|
root.selectedState = MockedKeycardStateSelector.State.KeycardWithMnemonicOnly
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusAction {
|
|
|
|
text: d.kcStateKeycardWithMnemonicAndMedatada
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "keycardWithMnemonicAndMedatadaAction"
|
2023-09-22 10:38:44 +00:00
|
|
|
onTriggered: {
|
|
|
|
root.selectedState = MockedKeycardStateSelector.State.KeycardWithMnemonicAndMedatada
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusAction {
|
|
|
|
text: d.kcStateCustomKeycard
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "customKeycardAction"
|
2023-09-22 10:38:44 +00:00
|
|
|
onTriggered: {
|
|
|
|
root.selectedState = MockedKeycardStateSelector.State.CustomKeycard
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|