author | sl |
Tue, 03 Jun 2014 18:35:43 +0200 | |
changeset 31 | e68f1542d9d3 |
parent 9 | 52372bbbc0f8 |
permissions | -rw-r--r-- |
sl@8 | 1 |
import QtQuick 2.0 |
sl@8 | 2 |
import QtQuick.Controls 1.2 |
sl@8 | 3 |
import QtQuick.Layouts 1.1 |
sl@8 | 4 |
|
sl@8 | 5 |
|
sl@8 | 6 |
|
sl@8 | 7 |
StatusBar { |
sl@8 | 8 |
|
sl@8 | 9 |
Component.onCompleted: { |
sl@9 | 10 |
display.closed.connect(onDisplayClosed); |
sl@9 | 11 |
display.opened.connect(onDisplayOpened); |
sl@8 | 12 |
display.openError.connect(updateDisplayStatusError); |
sl@9 | 13 |
display.powerStatus.connect(updatePowerStatus); |
sl@9 | 14 |
display.deviceId.connect(updateDeviceId); |
sl@9 | 15 |
display.firmwareVersion.connect(updateFirmwareVersion); |
sl@8 | 16 |
} |
sl@8 | 17 |
|
sl@11 | 18 |
//We need to disconnect our signals to avoid receiving stray events |
sl@11 | 19 |
Component.onDestruction: { |
sl@11 | 20 |
display.closed.disconnect(onDisplayClosed); |
sl@11 | 21 |
display.opened.disconnect(onDisplayOpened); |
sl@11 | 22 |
display.openError.disconnect(updateDisplayStatusError); |
sl@11 | 23 |
display.powerStatus.disconnect(updatePowerStatus); |
sl@11 | 24 |
display.deviceId.disconnect(updateDeviceId); |
sl@11 | 25 |
display.firmwareVersion.disconnect(updateFirmwareVersion); |
sl@11 | 26 |
} |
sl@11 | 27 |
|
sl@9 | 28 |
function updatePowerStatus(powerOn) |
sl@9 | 29 |
{ |
sl@9 | 30 |
if (powerOn) |
sl@9 | 31 |
{ |
sl@9 | 32 |
labelDisplayPowerStatus.text=qsTr("Power: ON"); |
sl@9 | 33 |
} |
sl@9 | 34 |
else |
sl@9 | 35 |
{ |
sl@9 | 36 |
labelDisplayPowerStatus.text=qsTr("Power: OFF"); |
sl@9 | 37 |
} |
sl@9 | 38 |
} |
sl@9 | 39 |
|
sl@9 | 40 |
function updateDeviceId(deviceId) |
sl@9 | 41 |
{ |
sl@9 | 42 |
labelDisplayDeviceId.text = deviceId; |
sl@9 | 43 |
display.requestFirmwareVersion(); |
sl@9 | 44 |
} |
sl@9 | 45 |
|
sl@9 | 46 |
function updateFirmwareVersion(version) |
sl@9 | 47 |
{ |
sl@9 | 48 |
labelDisplayFirmwareVersion.text = "Firmware v" + version; |
sl@9 | 49 |
display.requestPowerStatus(); |
sl@9 | 50 |
} |
sl@9 | 51 |
|
sl@9 | 52 |
function onDisplayOpened() |
sl@9 | 53 |
{ |
sl@9 | 54 |
updateDisplayStatus(); |
sl@9 | 55 |
// |
sl@9 | 56 |
display.requestDeviceId(); |
sl@9 | 57 |
} |
sl@9 | 58 |
|
sl@9 | 59 |
function onDisplayClosed() |
sl@9 | 60 |
{ |
sl@9 | 61 |
updateDisplayStatus(); |
sl@9 | 62 |
labelDisplayDeviceId.text=""; |
sl@9 | 63 |
labelDisplayFirmwareVersion.text=""; |
sl@9 | 64 |
labelDisplayPowerStatus.text=""; |
sl@9 | 65 |
} |
sl@9 | 66 |
|
sl@9 | 67 |
|
sl@8 | 68 |
function updateDisplayStatusError() |
sl@8 | 69 |
{ |
sl@8 | 70 |
updateDisplayStatus(); |
sl@8 | 71 |
labelDisplayStatus.text=qsTr("Connection error"); |
sl@8 | 72 |
} |
sl@8 | 73 |
|
sl@8 | 74 |
function updateDisplayStatus() |
sl@8 | 75 |
{ |
sl@8 | 76 |
if (display.isOpen) |
sl@8 | 77 |
{ |
sl@8 | 78 |
labelDisplayStatus.text=qsTr("Connected"); |
sl@8 | 79 |
} |
sl@8 | 80 |
else |
sl@8 | 81 |
{ |
sl@8 | 82 |
labelDisplayStatus.text=qsTr("Disconnected"); |
sl@8 | 83 |
} |
sl@8 | 84 |
|
sl@8 | 85 |
labelDisplayVendor.text=display.vendor; |
sl@8 | 86 |
labelDisplayProduct.text=display.product; |
sl@8 | 87 |
labelDisplaySerialNumber.text=display.serialNumber; |
sl@8 | 88 |
} |
sl@8 | 89 |
|
sl@8 | 90 |
|
sl@8 | 91 |
RowLayout { |
sl@8 | 92 |
Label { |
sl@8 | 93 |
id: labelDisplayStatus |
sl@8 | 94 |
text: qsTr("Disconnected") |
sl@8 | 95 |
} |
sl@8 | 96 |
|
sl@8 | 97 |
Label { |
sl@8 | 98 |
id: labelDisplayVendor |
sl@8 | 99 |
text: qsTr("") |
sl@8 | 100 |
} |
sl@8 | 101 |
|
sl@8 | 102 |
Label { |
sl@8 | 103 |
id: labelDisplayProduct |
sl@8 | 104 |
text: qsTr("") |
sl@8 | 105 |
} |
sl@8 | 106 |
|
sl@8 | 107 |
Label { |
sl@8 | 108 |
id: labelDisplaySerialNumber |
sl@8 | 109 |
visible: false //We don't want to display that. GP1212A01A does not even provide a proper string. |
sl@8 | 110 |
text: qsTr("") |
sl@8 | 111 |
} |
sl@9 | 112 |
|
sl@9 | 113 |
Label { |
sl@9 | 114 |
id: labelDisplayDeviceId |
sl@9 | 115 |
text: qsTr("") |
sl@9 | 116 |
} |
sl@9 | 117 |
|
sl@9 | 118 |
Label { |
sl@9 | 119 |
id: labelDisplayFirmwareVersion |
sl@9 | 120 |
text: qsTr("") |
sl@9 | 121 |
} |
sl@9 | 122 |
|
sl@9 | 123 |
Label { |
sl@9 | 124 |
id: labelDisplayPowerStatus |
sl@9 | 125 |
text: qsTr("") |
sl@9 | 126 |
} |
sl@9 | 127 |
|
sl@8 | 128 |
} |
sl@8 | 129 |
} |