地面站终端 App
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

447 lines
17 KiB

/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
/**
* @file
* @brief QGC Main Tool Bar
* @author Gus Grubba <mavlink@grubba.com>
*/
10 years ago
import QtQuick 2.5
import QtQuick.Layouts 1.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QGroundControl 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.MultiVehicleManager 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controllers 1.0
Rectangle {
id: toolBar
color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(1,1,1,0.8) : Qt.rgba(0,0,0,0.75)
QGCPalette { id: qgcPal; colorGroupEnabled: true }
property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
10 years ago
property var mainWindow: null
10 years ago
property bool isMessageImportant: activeVehicle ? !activeVehicle.messageTypeNormal && !activeVehicle.messageTypeNone : false
property bool isBackgroundDark: true
property bool opaqueBackground: false
10 years ago
readonly property var colorGreen: "#05f068"
readonly property var colorOrange: "#f0ab06"
readonly property var colorRed: "#fc4638"
readonly property var colorGrey: "#7f7f7f"
readonly property var colorBlue: "#636efe"
readonly property var colorWhite: "#ffffff"
9 years ago
signal showSettingsView
signal showSetupView
signal showPlanView
signal showFlyView
signal showAnalyzeView
MainToolBarController { id: _controller }
function checkSettingsButton() {
settingsButton.checked = true
}
function checkSetupButton() {
setupButton.checked = true
}
function checkPlanButton() {
planButton.checked = true
}
function checkFlyButton() {
flyButton.checked = true
}
9 years ago
function checkAnalyzeButton() {
analyzeButton.checked = true
}
function getBatteryColor() {
if(activeVehicle) {
if(activeVehicle.battery.percentRemaining.value > 75) {
return qgcPal.text
}
if(activeVehicle.battery.percentRemaining.value > 50) {
return colorOrange
}
if(activeVehicle.battery.percentRemaining.value > 0.1) {
return colorRed
}
}
return colorGrey
}
10 years ago
function getRSSIColor(value) {
if(value >= 0)
return colorGrey;
if(value > -60)
return colorGreen;
if(value > -90)
return colorOrange;
return colorRed;
}
10 years ago
Component.onCompleted: {
//-- TODO: Get this from the actual state
flyButton.checked = true
}
//---------------------------------------------
// GPS Info
Component {
id: gpsInfo
Rectangle {
width: gpsCol.width + ScreenTools.defaultFontPixelWidth * 3
height: gpsCol.height + ScreenTools.defaultFontPixelHeight * 2
radius: ScreenTools.defaultFontPixelHeight * 0.5
color: qgcPal.window
Column {
id: gpsCol
spacing: ScreenTools.defaultFontPixelHeight * 0.5
width: Math.max(gpsGrid.width, gpsLabel.width)
anchors.margins: ScreenTools.defaultFontPixelHeight
anchors.centerIn: parent
QGCLabel {
id: gpsLabel
text: (activeVehicle && activeVehicle.gps.count.value >= 0) ? qsTr("GPS Status") : qsTr("GPS Data Unavailable")
font.family: ScreenTools.demiboldFontFamily
anchors.horizontalCenter: parent.horizontalCenter
}
GridLayout {
id: gpsGrid
visible: (activeVehicle && activeVehicle.gps.count.value >= 0)
anchors.margins: ScreenTools.defaultFontPixelHeight
columnSpacing: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
columns: 2
QGCLabel { text: qsTr("GPS Count:") }
QGCLabel { text: activeVehicle ? activeVehicle.gps.count.valueString : qsTr("N/A", "No data to display") }
QGCLabel { text: qsTr("GPS Lock:") }
QGCLabel { text: activeVehicle ? activeVehicle.gps.lock.enumStringValue : qsTr("N/A", "No data to display") }
QGCLabel { text: qsTr("HDOP:") }
QGCLabel { text: activeVehicle ? activeVehicle.gps.hdop.valueString : qsTr("--.--", "No data to display") }
QGCLabel { text: qsTr("VDOP:") }
QGCLabel { text: activeVehicle ? activeVehicle.gps.vdop.valueString : qsTr("--.--", "No data to display") }
QGCLabel { text: qsTr("Course Over Ground:") }
QGCLabel { text: activeVehicle ? activeVehicle.gps.courseOverGround.valueString : qsTr("--.--", "No data to display") }
}
}
Component.onCompleted: {
var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height)
x = pos.x
y = pos.y + ScreenTools.defaultFontPixelHeight
}
}
}
//---------------------------------------------
// Battery Info
Component {
id: batteryInfo
Rectangle {
width: battCol.width + ScreenTools.defaultFontPixelWidth * 3
height: battCol.height + ScreenTools.defaultFontPixelHeight * 2
radius: ScreenTools.defaultFontPixelHeight * 0.5
color: qgcPal.window
Column {
id: battCol
spacing: ScreenTools.defaultFontPixelHeight * 0.5
width: Math.max(battGrid.width, battLabel.width)
anchors.margins: ScreenTools.defaultFontPixelHeight
anchors.centerIn: parent
QGCLabel {
id: battLabel
text: qsTr("Battery Status")
font.family: ScreenTools.demiboldFontFamily
anchors.horizontalCenter: parent.horizontalCenter
}
GridLayout {
id: battGrid
anchors.margins: ScreenTools.defaultFontPixelHeight
columnSpacing: ScreenTools.defaultFontPixelWidth
columns: 2
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel { text: qsTr("Voltage:") }
QGCLabel { text: (activeVehicle && activeVehicle.battery.voltage.value != -1) ? (activeVehicle.battery.voltage.valueString + " " + activeVehicle.battery.voltage.units) : "N/A" }
QGCLabel { text: qsTr("Accumulated Consumption:") }
QGCLabel { text: (activeVehicle && activeVehicle.battery.mahConsumed.value != -1) ? (activeVehicle.battery.mahConsumed.valueString + " " + activeVehicle.battery.mahConsumed.units) : "N/A" }
}
}
Component.onCompleted: {
var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height)
x = pos.x
y = pos.y + ScreenTools.defaultFontPixelHeight
}
}
}
//---------------------------------------------
// RC RSSI Info
Component {
id: rcRSSIInfo
Rectangle {
width: rcrssiCol.width + ScreenTools.defaultFontPixelWidth * 3
height: rcrssiCol.height + ScreenTools.defaultFontPixelHeight * 2
radius: ScreenTools.defaultFontPixelHeight * 0.5
color: qgcPal.window
Column {
id: rcrssiCol
spacing: ScreenTools.defaultFontPixelHeight * 0.5
width: Math.max(rcrssiGrid.width, rssiLabel.width)
anchors.margins: ScreenTools.defaultFontPixelHeight
anchors.centerIn: parent
QGCLabel {
id: rssiLabel
9 years ago
text: activeVehicle ? (activeVehicle.rcRSSI != 255 ? qsTr("RC RSSI Status") : qsTr("RC RSSI Data Unavailable")) : qsTr("N/A", "No data available")
font.family: ScreenTools.demiboldFontFamily
anchors.horizontalCenter: parent.horizontalCenter
}
GridLayout {
id: rcrssiGrid
visible: activeVehicle && activeVehicle.rcRSSI != 255
anchors.margins: ScreenTools.defaultFontPixelHeight
columnSpacing: ScreenTools.defaultFontPixelWidth
columns: 2
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel { text: qsTr("RSSI:") }
QGCLabel { text: activeVehicle ? (activeVehicle.rcRSSI + "%") : 0 }
}
}
Component.onCompleted: {
var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height)
x = pos.x
y = pos.y + ScreenTools.defaultFontPixelHeight
}
}
}
//---------------------------------------------
10 years ago
// Telemetry RSSI Info
Component {
id: telemRSSIInfo
10 years ago
Rectangle {
width: telemCol.width + ScreenTools.defaultFontPixelWidth * 3
height: telemCol.height + ScreenTools.defaultFontPixelHeight * 2
radius: ScreenTools.defaultFontPixelHeight * 0.5
color: qgcPal.window
10 years ago
Column {
id: telemCol
spacing: ScreenTools.defaultFontPixelHeight * 0.5
width: Math.max(telemGrid.width, telemLabel.width)
anchors.margins: ScreenTools.defaultFontPixelHeight
anchors.centerIn: parent
10 years ago
QGCLabel {
id: telemLabel
text: qsTr("Telemetry RSSI Status")
font.family: ScreenTools.demiboldFontFamily
10 years ago
anchors.horizontalCenter: parent.horizontalCenter
}
10 years ago
GridLayout {
id: telemGrid
anchors.margins: ScreenTools.defaultFontPixelHeight
columnSpacing: ScreenTools.defaultFontPixelWidth
columns: 2
10 years ago
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel { text: qsTr("Local RSSI:") }
QGCLabel { text: _controller.telemetryLRSSI + " dBm" }
QGCLabel { text: qsTr("Remote RSSI:") }
QGCLabel { text: _controller.telemetryRRSSI + " dBm" }
QGCLabel { text: qsTr("RX Errors:") }
QGCLabel { text: _controller.telemetryRXErrors }
QGCLabel { text: qsTr("Errors Fixed:") }
QGCLabel { text: _controller.telemetryFixed }
QGCLabel { text: qsTr("TX Buffer:") }
QGCLabel { text: _controller.telemetryTXBuffer }
QGCLabel { text: qsTr("Local Noise:") }
QGCLabel { text: _controller.telemetryLNoise }
QGCLabel { text: qsTr("Remote Noise:") }
QGCLabel { text: _controller.telemetryRNoise }
10 years ago
}
}
10 years ago
Component.onCompleted: {
var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height)
x = pos.x
y = pos.y + ScreenTools.defaultFontPixelHeight
}
}
}
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
height: 1
color: "black"
visible: qgcPal.globalTheme == QGCPalette.Light
}
//---------------------------------------------
// Toolbar Row
10 years ago
Row {
id: viewRow
height: mainWindow.tbCellHeight
spacing: mainWindow.tbSpacing
anchors.left: parent.left
anchors.bottomMargin: 1
anchors.top: parent.top
anchors.bottom: parent.bottom
10 years ago
ExclusiveGroup { id: mainActionGroup }
QGCToolBarButton {
9 years ago
id: settingsButton
width: mainWindow.tbButtonWidth
anchors.top: parent.top
anchors.bottom: parent.bottom
exclusiveGroup: mainActionGroup
source: "/res/QGCLogoWhite"
logo: true
onClicked: toolBar.showSettingsView()
}
QGCToolBarButton {
10 years ago
id: setupButton
width: mainWindow.tbButtonWidth
anchors.top: parent.top
anchors.bottom: parent.bottom
10 years ago
exclusiveGroup: mainActionGroup
source: "/qmlimages/Gears.svg"
onClicked: toolBar.showSetupView()
10 years ago
}
10 years ago
QGCToolBarButton {
id: planButton
width: mainWindow.tbButtonWidth
anchors.top: parent.top
anchors.bottom: parent.bottom
10 years ago
exclusiveGroup: mainActionGroup
source: "/qmlimages/Plan.svg"
onClicked: toolBar.showPlanView()
10 years ago
}
10 years ago
QGCToolBarButton {
id: flyButton
width: mainWindow.tbButtonWidth
anchors.top: parent.top
anchors.bottom: parent.bottom
10 years ago
exclusiveGroup: mainActionGroup
source: "/qmlimages/PaperPlane.svg"
onClicked: toolBar.showFlyView()
}
9 years ago
QGCToolBarButton {
id: analyzeButton
width: mainWindow.tbButtonWidth
anchors.top: parent.top
anchors.bottom: parent.bottom
exclusiveGroup: mainActionGroup
source: "/qmlimages/Analyze.svg"
visible: !ScreenTools.isMobile
onClicked: toolBar.showAnalyzeView()
}
10 years ago
}
10 years ago
Item {
id: vehicleIndicators
height: mainWindow.tbCellHeight
anchors.leftMargin: mainWindow.tbSpacing * 2
anchors.left: viewRow.right
anchors.right: parent.right
10 years ago
anchors.verticalCenter: parent.verticalCenter
property bool vehicleConnectionLost: activeVehicle ? activeVehicle.connectionLost : false
10 years ago
Loader {
source: activeVehicle && !parent.vehicleConnectionLost ? "MainToolBarIndicators.qml" : ""
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
}
QGCLabel {
id: connectionLost
text: qsTr("COMMUNICATION LOST")
9 years ago
font.pointSize: ScreenTools.largeFontPointSize
font.family: ScreenTools.demiboldFontFamily
color: colorRed
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.right: disconnectButton.left
anchors.verticalCenter: parent.verticalCenter
visible: parent.vehicleConnectionLost
}
QGCButton {
id: disconnectButton
anchors.rightMargin: mainWindow.tbSpacing * 2
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
text: qsTr("Disconnect")
visible: parent.vehicleConnectionLost
primary: true
onClicked: activeVehicle.disconnectInactiveVehicle()
}
Image {
anchors.rightMargin: ScreenTools.defaultFontPixelWidth / 2
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
visible: parent.x < x && !disconnectButton.visible && source != ""
fillMode: Image.PreserveAspectFit
source: activeVehicle ? activeVehicle.brandImage : ""
}
10 years ago
}
// Progress bar
Rectangle {
id: progressBar
10 years ago
anchors.bottom: parent.bottom
height: toolBar.height * 0.05
width: parent.width * _controller.progressBarValue
10 years ago
color: colorGreen
}
}