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: MockedKeycardReaderStateSelector.State.NoReader
|
|
|
|
|
|
|
|
enum State {
|
|
|
|
NoReader,
|
|
|
|
NoKeycard,
|
|
|
|
KeycardInserted
|
|
|
|
}
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property string readerStateReaderUnplugged: qsTr("Reader Unplugged")
|
|
|
|
readonly property string readerStateKeycardNotInserted: qsTr("Keycard Not Inserted")
|
|
|
|
readonly property string readerStateKeycardInserted: qsTr("Keycard Inserted")
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
text: root.title
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
id: selectReaderStateButton
|
|
|
|
|
|
|
|
text: {
|
|
|
|
switch (root.selectedState) {
|
|
|
|
case MockedKeycardReaderStateSelector.State.NoReader:
|
|
|
|
return d.readerStateReaderUnplugged
|
|
|
|
case MockedKeycardReaderStateSelector.State.NoKeycard:
|
|
|
|
return d.readerStateKeycardNotInserted
|
|
|
|
case MockedKeycardReaderStateSelector.State.KeycardInserted:
|
|
|
|
return d.readerStateKeycardInserted
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
icon.name: "chevron-down"
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
if (initialReaderState.opened) {
|
|
|
|
initialReaderState.close()
|
|
|
|
} else {
|
|
|
|
initialReaderState.popup(selectReaderStateButton.x, selectReaderStateButton.y + selectReaderStateButton.height + 8)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenu {
|
|
|
|
id: initialReaderState
|
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
|
|
|
|
|
|
|
|
StatusAction {
|
|
|
|
text: d.readerStateReaderUnplugged
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "readerStateReaderUnpluggedAction"
|
2023-09-22 10:38:44 +00:00
|
|
|
onTriggered: {
|
|
|
|
root.selectedState = MockedKeycardReaderStateSelector.State.NoReader
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusAction {
|
|
|
|
text: d.readerStateKeycardNotInserted
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "readerStateKeycardNotInsertedAction"
|
2023-09-22 10:38:44 +00:00
|
|
|
onTriggered: {
|
|
|
|
root.selectedState = MockedKeycardReaderStateSelector.State.NoKeycard
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusAction {
|
|
|
|
text: d.readerStateKeycardInserted
|
2023-10-30 16:57:24 +00:00
|
|
|
objectName: "readerStateKeycardInsertedAction"
|
2023-09-22 10:38:44 +00:00
|
|
|
onTriggered: {
|
|
|
|
root.selectedState = MockedKeycardReaderStateSelector.State.KeycardInserted
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|