From 63c76487e792e735a7122a567e3bb688862d1022 Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Thu, 24 May 2018 09:20:58 -0700 Subject: [PATCH] Control renaming * QGCCheckListItem -> PreFlightCheckButton * CheckList -> PreFlightCheckList --- qgroundcontrol.qrc | 4 +- src/FlightDisplay/CheckList.qml | 228 ------------------------- src/FlightDisplay/FlightDisplayView.qml | 8 +- src/FlightDisplay/PreFlightCheckList.qml | 228 +++++++++++++++++++++++++ src/FlightDisplay/qmldir | 2 +- src/QmlControls/PreFlightCheckButton.qml | 117 +++++++++++++ src/QmlControls/QGCCheckListItem.qml | 117 ------------- src/QmlControls/QGroundControl.Controls.qmldir | 2 +- 8 files changed, 353 insertions(+), 353 deletions(-) delete mode 100644 src/FlightDisplay/CheckList.qml create mode 100644 src/FlightDisplay/PreFlightCheckList.qml create mode 100644 src/QmlControls/PreFlightCheckButton.qml delete mode 100644 src/QmlControls/QGCCheckListItem.qml diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 2c13d66..8dfabfe 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -88,8 +88,8 @@ src/QmlControls/ParameterEditorDialog.qml src/QmlControls/PIDTuning.qml src/PlanView/PlanToolBar.qml + src/QmlControls/PreFlightCheckButton.qml src/QmlControls/QGCButton.qml - src/QmlControls/QGCCheckListItem.qml src/QmlControls/QGCCheckBox.qml src/QmlControls/QGCColoredImage.qml src/QmlControls/QGCComboBox.qml @@ -152,6 +152,7 @@ src/FlightDisplay/GuidedActionsController.qml src/FlightDisplay/GuidedAltitudeSlider.qml src/FlightDisplay/MultiVehicleList.qml + src/FlightDisplay/PreFlightCheckList.qml src/FlightDisplay/qmldir src/FlightMap/MapItems/CameraTriggerIndicator.qml src/FlightMap/Widgets/CenterMapDropButton.qml @@ -195,7 +196,6 @@ src/FlightMap/Widgets/VibrationPageWidget.qml src/FlightMap/Widgets/VideoPageWidget.qml src/FlightDisplay/VirtualJoystick.qml - src/FlightDisplay/CheckList.qml src/MissionManager/CameraCalc.FactMetaData.json diff --git a/src/FlightDisplay/CheckList.qml b/src/FlightDisplay/CheckList.qml deleted file mode 100644 index daddfb6..0000000 --- a/src/FlightDisplay/CheckList.qml +++ /dev/null @@ -1,228 +0,0 @@ -/**************************************************************************** - * - * (c) 2009-2016 QGROUNDCONTROL PROJECT - * - * QGroundControl is licensed according to the terms in the file - * COPYING.md in the root of the source code directory. - * - ****************************************************************************/ - -import QtQuick 2.3 -import QtQml.Models 2.1 - -import QGroundControl 1.0 -import QGroundControl.FlightDisplay 1.0 -import QGroundControl.ScreenTools 1.0 -import QGroundControl.Controls 1.0 -import QGroundControl.Palette 1.0 -import QGroundControl.Vehicle 1.0 - -// This class stores the data and functions of the check list but NOT the GUI (which is handled somewhere else). -Item { - // Properties - property int unhealthySensors: _activeVehicle ? _activeVehicle.sensorsUnhealthyBits : 0 - property bool gpsLock: _activeVehicle ? _activeVehicle.gps.lock.rawValue>=3 : 0 - property var batPercentRemaining: _activeVehicle ? _activeVehicle.battery.percentRemaining.value : 0 - property bool audioMuted: QGroundControl.settingsManager.appSettings.audioMuted.rawValue - property ObjectModel checkListItems: _checkListItems - property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle - property int _checkState: _activeVehicle ? (_activeVehicle.armed ? 1 + (buttonActuators.state + buttonMotors.state + buttonMission.state + buttonSoundOutput.state) / 4 / 4 : 0) : 0 ; // Shows progress of checks inside the checklist - unlocks next check steps in groups - - // Connections - onBatPercentRemainingChanged: buttonBattery.updateItem(); - onGpsLockChanged: buttonSensors.updateItem(); - onAudioMutedChanged: buttonSoundOutput.updateItem(); - onUnhealthySensorsChanged: updateVehicleDependentItems(); - - Connections { - target: QGroundControl.multiVehicleManager - onActiveVehicleChanged: onActiveVehicleChanged(); - } - Component.onCompleted: { - if(QGroundControl.multiVehicleManager.vehicles.count > 0) { - onActiveVehicleChanged(); - } - } - - // Functions - function updateVehicleDependentItems() { - buttonSensors.updateItem(); - buttonBattery.updateItem(); - buttonRC.updateItem(); - buttonEstimator.updateItem(); - } - function onActiveVehicleChanged() { - buttonSoundOutput.updateItem(); // Just updated here for initialization once we connect to a vehicle - updateVehicleDependentItems(); - } - function resetNrClicks() { - buttonHardware.resetNrClicks(); - buttonBattery.resetNrClicks(); - buttonRC.resetNrClicks(); - buttonActuators.resetNrClicks(); - buttonMotors.resetNrClicks(); - buttonMission.resetNrClicks(); - buttonSoundOutput.resetNrClicks(); - buttonPayload.resetNrClicks(); - buttonWeather.resetNrClicks(); - buttonFlightAreaFree.resetNrClicks(); - } - - // Check list item data - ObjectModel { - id: _checkListItems - - // Standard check list items (group 0) - Available from the start - QGCCheckListItem { - id: buttonHardware - name: "Hardware" - defaulttext: "Props mounted? Wings secured? Tail secured?" - } - QGCCheckListItem { - id: buttonBattery - name: "Battery" - pendingtext: "Healthy & charged > 40%. Battery connector firmly plugged?" - function updateItem() { - if (!_activeVehicle) { - state = statePassed - } else { - if (unhealthySensors & Vehicle.SysStatusSensorBattery) { - failuretext = qsTr("Not healthy. Check console.") - state = stateMajorIssue - } else if (batPercentRemaining < 40.0) { - failuretext = qsTr("Low (below 40%). Please recharge.") - state = stateMajorIssue - } else { - state = _nrClicked > 0 ? statePassed : statePending - } - } - } - } - QGCCheckListItem { - id: buttonSensors - name: "Sensors" - function updateItem() { - if (!_activeVehicle) { - state = statePassed - } else { - if(!(unhealthySensors & Vehicle.SysStatusSensor3dMag) && - !(unhealthySensors & Vehicle.SysStatusSensor3dAccel) && - !(unhealthySensors & Vehicle.SysStatusSensor3dGyro) && - !(unhealthySensors & Vehicle.SysStatusSensorAbsolutePressure) && - !(unhealthySensors & Vehicle.SysStatusSensorDifferentialPressure) && - !(unhealthySensors & Vehicle.SysStatusSensorGPS)) { - if (!gpsLock) { - pendingtext = qsTr("Pending. Waiting for GPS lock.") - state = statePending - } else { - state = statePassed - } - } else { - if(unhealthySensors & Vehicle.SysStatusSensor3dMag) failuretext="Failure. Magnetometer issues. Check console."; - else if(unhealthySensors & Vehicle.SysStatusSensor3dAccel) failuretext="Failure. Accelerometer issues. Check console."; - else if(unhealthySensors & Vehicle.SysStatusSensor3dGyro) failuretext="Failure. Gyroscope issues. Check console."; - else if(unhealthySensors & Vehicle.SysStatusSensorAbsolutePressure) failuretext="Failure. Barometer issues. Check console."; - else if(unhealthySensors & Vehicle.SysStatusSensorDifferentialPressure) failuretext="Failure. Airspeed sensor issues. Check console."; - else if(unhealthySensors & Vehicle.SysStatusSensorGPS) failuretext="Failure. No valid or low quality GPS signal. Check console."; - state = stateMajorIssue - } - } - } - } - QGCCheckListItem { - id: buttonRC - name: "Radio Control" - pendingtext: "Receiving signal. Perform range test & confirm." - failuretext: "No signal or invalid autopilot-RC config. Check RC and console." - function updateItem() { - if (!_activeVehicle) { - state = statePassed - } else { - if (unhealthySensors & Vehicle.SysStatusSensorRCReceiver) { - state = stateMajorIssue - } else { - state = _nrClicked > 0 ? statePassed : statePending - } - } - } - } - QGCCheckListItem { - id: buttonEstimator - name: "Global position estimate" - function updateItem() { - if (!_activeVehicle) { - state = statePassed - } else { - if (unhealthySensors & Vehicle.SysStatusSensorAHRS) { - state = stateMajorIssue - } else { - state = statePassed - } - } - } - } - - // Check list item group 1 - Require arming - QGCLabel {text:qsTr("Please arm the vehicle here.") ; opacity: 0.2+0.8*(QGroundControl.multiVehicleManager.vehicles.count > 0) ; anchors.horizontalCenter:buttonHardware.horizontalCenter ; anchors.topMargin:40 ; anchors.bottomMargin:40;} - QGCCheckListItem { - id: buttonActuators - name: "Actuators" - group: 1 - defaulttext: "Move all control surfaces. Did they work properly?" - } - QGCCheckListItem { - id: buttonMotors - name: "Motors" - group: 1 - defaulttext: "Propellers free? Then throttle up gently. Working properly?" - } - QGCCheckListItem { - id: buttonMission - name: "Mission" - group: 1 - defaulttext: "Please confirm mission is valid (waypoints valid, no terrain collision)." - } - QGCCheckListItem { - id: buttonSoundOutput - name: "Sound output" - group: 1 - pendingtext: "QGC audio output enabled. System audio output enabled, too?" - failuretext: "Failure, QGC audio output is disabled. Please enable it under application settings->general to hear audio warnings!" - function updateItem() { - if (!_activeVehicle) { - state = statePassed - } else { - if (audioMuted) { - state = stateMajorIssue - _nrClicked = 0 - } else { - state = _nrClicked > 0 ? statePassed : statePending - } - } - } - } - - // Check list item group 2 - Final checks before launch - QGCLabel {text:qsTr("Last preparations before launch") ; opacity : 0.2+0.8*(_checkState >= 2); anchors.horizontalCenter:buttonHardware.horizontalCenter} - QGCCheckListItem { - id: buttonPayload - name: "Payload" - group: 2 - defaulttext: "Configured and started?" - pendingtext: "Payload lid closed?" - } - QGCCheckListItem { - id: buttonWeather - name: "Wind & weather" - group: 2 - defaulttext: "OK for your platform?" - pendingtext: "Launching into the wind?" - } - QGCCheckListItem { - id: buttonFlightAreaFree - name: "Flight area" - group: 2 - defaulttext: "Launch area and path free of obstacles/people?" - } - } // Object Model -} diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index 770636d..dd1d029 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -113,8 +113,8 @@ QGCView { Component.onCompleted: start(true /* flyView */) } - CheckList { - id: checklist + PreFlightCheckList { + id: preFlightCheckList } Connections { @@ -729,7 +729,7 @@ QGCView { opacity : 0.2+0.8*(QGroundControl.multiVehicleManager.vehicles.count > 0) tooltip: "Reset the checklist (e.g. after a vehicle reboot)" - onClicked: checklist.resetNrClicks() + onClicked: preFlightCheckList.resetNrClicks() Image { source:"/qmlimages/MapSyncBlack.svg" ; anchors.fill: parent } } @@ -739,7 +739,7 @@ QGCView { // All check list items Repeater { - model: checklist.checkListItems + model: preFlightCheckList.checkListItems } } // Column } //Rectangle diff --git a/src/FlightDisplay/PreFlightCheckList.qml b/src/FlightDisplay/PreFlightCheckList.qml new file mode 100644 index 0000000..de04b34 --- /dev/null +++ b/src/FlightDisplay/PreFlightCheckList.qml @@ -0,0 +1,228 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +import QtQuick 2.3 +import QtQml.Models 2.1 + +import QGroundControl 1.0 +import QGroundControl.FlightDisplay 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.Vehicle 1.0 + +// This class stores the data and functions of the check list but NOT the GUI (which is handled somewhere else). +Item { + // Properties + property int unhealthySensors: _activeVehicle ? _activeVehicle.sensorsUnhealthyBits : 0 + property bool gpsLock: _activeVehicle ? _activeVehicle.gps.lock.rawValue>=3 : 0 + property var batPercentRemaining: _activeVehicle ? _activeVehicle.battery.percentRemaining.value : 0 + property bool audioMuted: QGroundControl.settingsManager.appSettings.audioMuted.rawValue + property ObjectModel checkListItems: _checkListItems + property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle + property int _checkState: _activeVehicle ? (_activeVehicle.armed ? 1 + (buttonActuators.state + buttonMotors.state + buttonMission.state + buttonSoundOutput.state) / 4 / 4 : 0) : 0 ; // Shows progress of checks inside the checklist - unlocks next check steps in groups + + // Connections + onBatPercentRemainingChanged: buttonBattery.updateItem(); + onGpsLockChanged: buttonSensors.updateItem(); + onAudioMutedChanged: buttonSoundOutput.updateItem(); + onUnhealthySensorsChanged: updateVehicleDependentItems(); + + Connections { + target: QGroundControl.multiVehicleManager + onActiveVehicleChanged: onActiveVehicleChanged(); + } + Component.onCompleted: { + if(QGroundControl.multiVehicleManager.vehicles.count > 0) { + onActiveVehicleChanged(); + } + } + + // Functions + function updateVehicleDependentItems() { + buttonSensors.updateItem(); + buttonBattery.updateItem(); + buttonRC.updateItem(); + buttonEstimator.updateItem(); + } + function onActiveVehicleChanged() { + buttonSoundOutput.updateItem(); // Just updated here for initialization once we connect to a vehicle + updateVehicleDependentItems(); + } + function resetNrClicks() { + buttonHardware.resetNrClicks(); + buttonBattery.resetNrClicks(); + buttonRC.resetNrClicks(); + buttonActuators.resetNrClicks(); + buttonMotors.resetNrClicks(); + buttonMission.resetNrClicks(); + buttonSoundOutput.resetNrClicks(); + buttonPayload.resetNrClicks(); + buttonWeather.resetNrClicks(); + buttonFlightAreaFree.resetNrClicks(); + } + + // Check list item data + ObjectModel { + id: _checkListItems + + // Standard check list items (group 0) - Available from the start + PreFlightCheckButton { + id: buttonHardware + name: "Hardware" + defaulttext: "Props mounted? Wings secured? Tail secured?" + } + PreFlightCheckButton { + id: buttonBattery + name: "Battery" + pendingtext: "Healthy & charged > 40%. Battery connector firmly plugged?" + function updateItem() { + if (!_activeVehicle) { + state = statePassed + } else { + if (unhealthySensors & Vehicle.SysStatusSensorBattery) { + failuretext = qsTr("Not healthy. Check console.") + state = stateMajorIssue + } else if (batPercentRemaining < 40.0) { + failuretext = qsTr("Low (below 40%). Please recharge.") + state = stateMajorIssue + } else { + state = _nrClicked > 0 ? statePassed : statePending + } + } + } + } + PreFlightCheckButton { + id: buttonSensors + name: "Sensors" + function updateItem() { + if (!_activeVehicle) { + state = statePassed + } else { + if(!(unhealthySensors & Vehicle.SysStatusSensor3dMag) && + !(unhealthySensors & Vehicle.SysStatusSensor3dAccel) && + !(unhealthySensors & Vehicle.SysStatusSensor3dGyro) && + !(unhealthySensors & Vehicle.SysStatusSensorAbsolutePressure) && + !(unhealthySensors & Vehicle.SysStatusSensorDifferentialPressure) && + !(unhealthySensors & Vehicle.SysStatusSensorGPS)) { + if (!gpsLock) { + pendingtext = qsTr("Pending. Waiting for GPS lock.") + state = statePending + } else { + state = statePassed + } + } else { + if(unhealthySensors & Vehicle.SysStatusSensor3dMag) failuretext="Failure. Magnetometer issues. Check console."; + else if(unhealthySensors & Vehicle.SysStatusSensor3dAccel) failuretext="Failure. Accelerometer issues. Check console."; + else if(unhealthySensors & Vehicle.SysStatusSensor3dGyro) failuretext="Failure. Gyroscope issues. Check console."; + else if(unhealthySensors & Vehicle.SysStatusSensorAbsolutePressure) failuretext="Failure. Barometer issues. Check console."; + else if(unhealthySensors & Vehicle.SysStatusSensorDifferentialPressure) failuretext="Failure. Airspeed sensor issues. Check console."; + else if(unhealthySensors & Vehicle.SysStatusSensorGPS) failuretext="Failure. No valid or low quality GPS signal. Check console."; + state = stateMajorIssue + } + } + } + } + PreFlightCheckButton { + id: buttonRC + name: "Radio Control" + pendingtext: "Receiving signal. Perform range test & confirm." + failuretext: "No signal or invalid autopilot-RC config. Check RC and console." + function updateItem() { + if (!_activeVehicle) { + state = statePassed + } else { + if (unhealthySensors & Vehicle.SysStatusSensorRCReceiver) { + state = stateMajorIssue + } else { + state = _nrClicked > 0 ? statePassed : statePending + } + } + } + } + PreFlightCheckButton { + id: buttonEstimator + name: "Global position estimate" + function updateItem() { + if (!_activeVehicle) { + state = statePassed + } else { + if (unhealthySensors & Vehicle.SysStatusSensorAHRS) { + state = stateMajorIssue + } else { + state = statePassed + } + } + } + } + + // Check list item group 1 - Require arming + QGCLabel {text:qsTr("Please arm the vehicle here.") ; opacity: 0.2+0.8*(QGroundControl.multiVehicleManager.vehicles.count > 0) ; anchors.horizontalCenter:buttonHardware.horizontalCenter ; anchors.topMargin:40 ; anchors.bottomMargin:40;} + PreFlightCheckButton { + id: buttonActuators + name: "Actuators" + group: 1 + defaulttext: "Move all control surfaces. Did they work properly?" + } + PreFlightCheckButton { + id: buttonMotors + name: "Motors" + group: 1 + defaulttext: "Propellers free? Then throttle up gently. Working properly?" + } + PreFlightCheckButton { + id: buttonMission + name: "Mission" + group: 1 + defaulttext: "Please confirm mission is valid (waypoints valid, no terrain collision)." + } + PreFlightCheckButton { + id: buttonSoundOutput + name: "Sound output" + group: 1 + pendingtext: "QGC audio output enabled. System audio output enabled, too?" + failuretext: "Failure, QGC audio output is disabled. Please enable it under application settings->general to hear audio warnings!" + function updateItem() { + if (!_activeVehicle) { + state = statePassed + } else { + if (audioMuted) { + state = stateMajorIssue + _nrClicked = 0 + } else { + state = _nrClicked > 0 ? statePassed : statePending + } + } + } + } + + // Check list item group 2 - Final checks before launch + QGCLabel {text:qsTr("Last preparations before launch") ; opacity : 0.2+0.8*(_checkState >= 2); anchors.horizontalCenter:buttonHardware.horizontalCenter} + PreFlightCheckButton { + id: buttonPayload + name: "Payload" + group: 2 + defaulttext: "Configured and started?" + pendingtext: "Payload lid closed?" + } + PreFlightCheckButton { + id: buttonWeather + name: "Wind & weather" + group: 2 + defaulttext: "OK for your platform?" + pendingtext: "Launching into the wind?" + } + PreFlightCheckButton { + id: buttonFlightAreaFree + name: "Flight area" + group: 2 + defaulttext: "Launch area and path free of obstacles/people?" + } + } // Object Model +} diff --git a/src/FlightDisplay/qmldir b/src/FlightDisplay/qmldir index bc327b9..816bd8d 100644 --- a/src/FlightDisplay/qmldir +++ b/src/FlightDisplay/qmldir @@ -9,5 +9,5 @@ GuidedActionsController 1.0 GuidedActionsController.qml GuidedActionList 1.0 GuidedActionList.qml GuidedAltitudeSlider 1.0 GuidedAltitudeSlider.qml MultiVehicleList 1.0 MultiVehicleList.qml -CheckList 1.0 CheckList.qml +PreFlightCheckList 1.0 PreFlightCheckList.qml diff --git a/src/QmlControls/PreFlightCheckButton.qml b/src/QmlControls/PreFlightCheckButton.qml new file mode 100644 index 0000000..e9c4e26 --- /dev/null +++ b/src/QmlControls/PreFlightCheckButton.qml @@ -0,0 +1,117 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.4 + +import QGroundControl 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.ScreenTools 1.0 + +QGCButton { + property string name: "" + property int group: 0 + property string defaulttext: qsTr("Not checked yet") + property string pendingtext: "" + property string failuretext: qsTr("Failure. Check console.") + property int state: stateNotChecked + + readonly property int stateNotChecked: 0 + readonly property int statePending: 1 + readonly property int stateMinorIssue: 2 + readonly property int stateMajorIssue: 3 + readonly property int statePassed: 4 + + property var _color: qgcPal.button + property int _nrClicked: 0 + property string _text: name + ": " + defaulttext + property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle + + enabled: (!_activeVehicle || _activeVehicle.connectionLost) ? false : preFlightCheckList._checkState >= group + opacity: (!_activeVehicle || _activeVehicle.connectionLost) ? 0.4 : 0.2 + (0.8 * (preFlightCheckList._checkState >= group)) + width: 40 * ScreenTools.defaultFontPixelWidth + + style: ButtonStyle { + background: Rectangle {color:_color; border.color: qgcPal.button; radius:3} + label: Label { + text: _text + wrapMode: Text.WordWrap + horizontalAlignment: Text.AlignHCenter + color: state > 0 ? qgcPal.mapWidgetBorderLight : qgcPal.buttonText + } + } + + onPendingtextChanged: { if (state === statePending) { getTextFromState(); getColorFromState(); } } + onFailuretextChanged: { if (state === stateMajorIssue) { getTextFromState(); getColorFromState(); } } + onStateChanged: { getTextFromState(); getColorFromState(); } + onClicked: { + if (state <= statePending) { + _nrClicked = _nrClicked + 1 //Only allow click-counter to increase when not failed yet + } + updateItem() + } + + function updateItem() { + // This is the default updateFunction. It assumes the item is a MANUAL check list item, i.e. one that + // only requires user clicks (one click if pendingtext="", two clicks otherwise) for completion. + + if (_nrClicked === 0) { + state = stateNotChecked + } else if (_nrClicked === 1) { + if (pendingtext.length === 0) { + state = statePassed + } else { + state = statePending + } + } else { + state = statePassed + } + + getTextFromState(); + getColorFromState(); + } + + function getTextFromState() { + if (state === stateNotChecked) { + _text = qsTr(name) + ": " + qsTr(defaulttext) + } else if (state === statePending) { + _text = ""+qsTr(name)+"" +": " + pendingtext + } else if (state === stateMinorIssue) { + _text = ""+qsTr(name)+"" +": " + qsTr("Minor problem") + } else if (state === stateMajorIssue) { + _text = ""+qsTr(name)+"" +": " + failuretext + } else if (state === statePassed) { + _text = ""+qsTr(name)+"" +": " + qsTr("OK") + } else { + console.warn("Internal Error: invalid state", state) + } + } + + function getColorFromState() { + if (state === stateNotChecked) { + _color = qgcPal.button + } else if (state === statePending) { + _color = Qt.rgba(0.9,0.47,0.2,1) + } else if (state === stateMinorIssue) { + _color = Qt.rgba(1.0,0.6,0.2,1) + } else if (state === stateMajorIssue) { + _color = Qt.rgba(0.92,0.22,0.22,1) + } else if (state === statePassed ) { + _color = Qt.rgba(0.27,0.67,0.42,1) + } else { + console.warn("Internal Error: invalid state", state) + } + } + + function resetNrClicks() { + _nrClicked=0; + updateItem(); + } +} diff --git a/src/QmlControls/QGCCheckListItem.qml b/src/QmlControls/QGCCheckListItem.qml deleted file mode 100644 index 371e0b4..0000000 --- a/src/QmlControls/QGCCheckListItem.qml +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** - * - * (c) 2009-2016 QGROUNDCONTROL PROJECT - * - * QGroundControl is licensed according to the terms in the file - * COPYING.md in the root of the source code directory. - * - ****************************************************************************/ - -import QtQuick 2.3 -import QtQuick.Controls 1.2 -import QtQuick.Controls.Styles 1.4 - -import QGroundControl 1.0 -import QGroundControl.Palette 1.0 -import QGroundControl.ScreenTools 1.0 - -QGCButton { - property string name: "" - property int group: 0 - property string defaulttext: qsTr("Not checked yet") - property string pendingtext: "" - property string failuretext: qsTr("Failure. Check console.") - property int state: stateNotChecked - - readonly property int stateNotChecked: 0 - readonly property int statePending: 1 - readonly property int stateMinorIssue: 2 - readonly property int stateMajorIssue: 3 - readonly property int statePassed: 4 - - property var _color: qgcPal.button - property int _nrClicked: 0 - property string _text: name + ": " + defaulttext - property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle - - enabled: (!_activeVehicle || _activeVehicle.connectionLost) ? false : checklist._checkState >= group - opacity: (!_activeVehicle || _activeVehicle.connectionLost) ? 0.4 : 0.2 + (0.8 * (checklist._checkState >= group)) - width: 40 * ScreenTools.defaultFontPixelWidth - - style: ButtonStyle { - background: Rectangle {color:_color; border.color: qgcPal.button; radius:3} - label: Label { - text: _text - wrapMode: Text.WordWrap - horizontalAlignment: Text.AlignHCenter - color: state > 0 ? qgcPal.mapWidgetBorderLight : qgcPal.buttonText - } - } - - onPendingtextChanged: { if (state === statePending) { getTextFromState(); getColorFromState(); } } - onFailuretextChanged: { if (state === stateMajorIssue) { getTextFromState(); getColorFromState(); } } - onStateChanged: { getTextFromState(); getColorFromState(); } - onClicked: { - if (state <= statePending) { - _nrClicked = _nrClicked + 1 //Only allow click-counter to increase when not failed yet - } - updateItem() - } - - function updateItem() { - // This is the default updateFunction. It assumes the item is a MANUAL check list item, i.e. one that - // only requires user clicks (one click if pendingtext="", two clicks otherwise) for completion. - - if (_nrClicked === 0) { - state = stateNotChecked - } else if (_nrClicked === 1) { - if (pendingtext.length === 0) { - state = statePassed - } else { - state = statePending - } - } else { - state = statePassed - } - - getTextFromState(); - getColorFromState(); - } - - function getTextFromState() { - if (state === stateNotChecked) { - _text = qsTr(name) + ": " + qsTr(defaulttext) - } else if (state === statePending) { - _text = ""+qsTr(name)+"" +": " + pendingtext - } else if (state === stateMinorIssue) { - _text = ""+qsTr(name)+"" +": " + qsTr("Minor problem") - } else if (state === stateMajorIssue) { - _text = ""+qsTr(name)+"" +": " + failuretext - } else if (state === statePassed) { - _text = ""+qsTr(name)+"" +": " + qsTr("OK") - } else { - console.warn("Internal Error: invalid state", state) - } - } - - function getColorFromState() { - if (state === stateNotChecked) { - _color = qgcPal.button - } else if (state === statePending) { - _color = Qt.rgba(0.9,0.47,0.2,1) - } else if (state === stateMinorIssue) { - _color = Qt.rgba(1.0,0.6,0.2,1) - } else if (state === stateMajorIssue) { - _color = Qt.rgba(0.92,0.22,0.22,1) - } else if (state === statePassed ) { - _color = Qt.rgba(0.27,0.67,0.42,1) - } else { - console.warn("Internal Error: invalid state", state) - } - } - - function resetNrClicks() { - _nrClicked=0; - updateItem(); - } -} diff --git a/src/QmlControls/QGroundControl.Controls.qmldir b/src/QmlControls/QGroundControl.Controls.qmldir index 9277f3f..25a3344 100644 --- a/src/QmlControls/QGroundControl.Controls.qmldir +++ b/src/QmlControls/QGroundControl.Controls.qmldir @@ -34,8 +34,8 @@ ParameterEditor 1.0 ParameterEditor.qml ParameterEditorDialog 1.0 ParameterEditorDialog.qml PIDTuning 1.0 PIDTuning.qml PlanToolBar 1.0 PlanToolBar.qml +PreFlightCheckButton 1.0 PreFlightCheckButton.qml QGCButton 1.0 QGCButton.qml -QGCCheckListItem 1.0 QGCCheckListItem.qml QGCCheckBox 1.0 QGCCheckBox.qml QGCColoredImage 1.0 QGCColoredImage.qml QGCComboBox 1.0 QGCComboBox.qml