diff --git a/src/QmlControls/QGroundControl.Controls.qmldir b/src/QmlControls/QGroundControl.Controls.qmldir index a04b37ba7efe013425c99d90376bf71bf2314b70..5334f916da04b82e6514e2094703854a5290f2f3 100644 --- a/src/QmlControls/QGroundControl.Controls.qmldir +++ b/src/QmlControls/QGroundControl.Controls.qmldir @@ -9,6 +9,7 @@ FactSliderPanel 1.0 FactSliderPanel.qml IndicatorButton 1.0 IndicatorButton.qml JoystickThumbPad 1.0 JoystickThumbPad.qml MainToolBar 1.0 MainToolBar.qml +MainToolBarIndicators 1.0 MainToolBarIndicators.qml MissionCommandDialog 1.0 MissionCommandDialog.qml MissionItemEditor 1.0 MissionItemEditor.qml MissionItemIndexLabel 1.0 MissionItemIndexLabel.qml diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml index 2d5670039a8e0c02cfe4f97b8a3aa03e061cfb7f..574b32320941cc7025a4ba537a69d898bb2d5e71 100644 --- a/src/ui/toolbar/MainToolBar.qml +++ b/src/ui/toolbar/MainToolBar.qml @@ -7,17 +7,9 @@ * ****************************************************************************/ - -/** - * @file - * @brief QGC Main Tool Bar - * @author Gus Grubba - */ - -import QtQuick 2.5 -import QtQuick.Layouts 1.2 -import QtQuick.Controls 1.2 -import QtQuick.Controls.Styles 1.2 +import QtQuick 2.5 +import QtQuick.Layouts 1.2 +import QtQuick.Controls 1.2 import QGroundControl 1.0 import QGroundControl.Controls 1.0 @@ -316,123 +308,136 @@ Rectangle { visible: qgcPal.globalTheme == QGCPalette.Light } - //--------------------------------------------- - // Toolbar Row - Row { - id: viewRow - height: mainWindow.tbCellHeight - spacing: mainWindow.tbSpacing - anchors.left: parent.left + RowLayout { anchors.bottomMargin: 1 - anchors.top: parent.top - anchors.bottom: parent.bottom - - ExclusiveGroup { id: mainActionGroup } - - QGCToolBarButton { - id: settingsButton - width: mainWindow.tbButtonWidth - anchors.top: parent.top - anchors.bottom: parent.bottom - exclusiveGroup: mainActionGroup - source: "/res/QGCLogoWhite" - logo: true - onClicked: toolBar.showSettingsView() - visible: !QGroundControl.corePlugin.options.combineSettingsAndSetup - } + anchors.rightMargin: ScreenTools.defaultFontPixelWidth / 2 + anchors.fill: parent + spacing: mainWindow.tbSpacing * 2 + + //--------------------------------------------- + // Toolbar Row + Row { + id: viewRow + height: mainWindow.tbCellHeight + spacing: mainWindow.tbSpacing + anchors.top: parent.top + anchors.bottom: parent.bottom + + ExclusiveGroup { id: mainActionGroup } + + QGCToolBarButton { + id: settingsButton + width: mainWindow.tbButtonWidth + anchors.top: parent.top + anchors.bottom: parent.bottom + exclusiveGroup: mainActionGroup + source: "/res/QGCLogoWhite" + logo: true + onClicked: toolBar.showSettingsView() + visible: !QGroundControl.corePlugin.options.combineSettingsAndSetup + } - QGCToolBarButton { - id: setupButton - width: mainWindow.tbButtonWidth - anchors.top: parent.top - anchors.bottom: parent.bottom - exclusiveGroup: mainActionGroup - source: "/qmlimages/Gears.svg" - onClicked: toolBar.showSetupView() - } + QGCToolBarButton { + id: setupButton + width: mainWindow.tbButtonWidth + anchors.top: parent.top + anchors.bottom: parent.bottom + exclusiveGroup: mainActionGroup + source: "/qmlimages/Gears.svg" + onClicked: toolBar.showSetupView() + } - QGCToolBarButton { - id: planButton - width: mainWindow.tbButtonWidth - anchors.top: parent.top - anchors.bottom: parent.bottom - exclusiveGroup: mainActionGroup - source: "/qmlimages/Plan.svg" - onClicked: toolBar.showPlanView() - } + QGCToolBarButton { + id: planButton + width: mainWindow.tbButtonWidth + anchors.top: parent.top + anchors.bottom: parent.bottom + exclusiveGroup: mainActionGroup + source: "/qmlimages/Plan.svg" + onClicked: toolBar.showPlanView() + } - QGCToolBarButton { - id: flyButton - width: mainWindow.tbButtonWidth - anchors.top: parent.top - anchors.bottom: parent.bottom - exclusiveGroup: mainActionGroup - source: "/qmlimages/PaperPlane.svg" - onClicked: toolBar.showFlyView() - } + QGCToolBarButton { + id: flyButton + width: mainWindow.tbButtonWidth + anchors.top: parent.top + anchors.bottom: parent.bottom + exclusiveGroup: mainActionGroup + source: "/qmlimages/PaperPlane.svg" + onClicked: toolBar.showFlyView() + } - 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() + 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() + } } - } - Item { - id: vehicleIndicators - height: mainWindow.tbCellHeight - anchors.leftMargin: mainWindow.tbSpacing * 2 - anchors.left: viewRow.right - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter + //------------------------------------------------------------------------- + //-- Vehicle Selector + QGCButton { + id: vehicleSelectorButton + width: ScreenTools.defaultFontPixelHeight * 8 + text: "Vehicle " + (activeVehicle ? activeVehicle.id : "None") + visible: QGroundControl.multiVehicleManager.vehicles.count > 1 + anchors.verticalCenter: parent.verticalCenter - property bool vehicleConnectionLost: activeVehicle ? activeVehicle.connectionLost : false + menu: vehicleMenu - Loader { - id: indicatorLoader - source: activeVehicle && !parent.vehicleConnectionLost ? "MainToolBarIndicators.qml" : "" - anchors.left: parent.left - anchors.verticalCenter: parent.verticalCenter - } + Menu { + id: vehicleMenu + } - QGCLabel { - id: connectionLost - text: qsTr("COMMUNICATION LOST") - 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 - } + Component { + id: vehicleMenuItemComponent - 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() - } + MenuItem { + checkable: true + onTriggered: QGroundControl.multiVehicleManager.activeVehicle = vehicle + + property int vehicleId: Number(text.split(" ")[1]) + property var vehicle: QGroundControl.multiVehicleManager.getVehicleById(vehicleId) + } + } + + property var vehicleMenuItems: [] - Image { - anchors.rightMargin: ScreenTools.defaultFontPixelWidth / 2 - anchors.right: parent.right - anchors.top: parent.top - anchors.bottom: parent.bottom - visible: x > indicatorLoader.x + indicatorLoader.width && !disconnectButton.visible && source != "" - fillMode: Image.PreserveAspectFit - source: activeVehicle ? activeVehicle.brandImage : "" + function updateVehicleMenu() { + // Remove old menu items + for (var i = 0; i < vehicleMenuItems.length; i++) { + vehicleMenu.removeItem(vehicleMenuItems[i]) + } + vehicleMenuItems.length = 0 + + // Add new items + for (var i=0; i= 0) { - return activeVehicle.battery.voltage.valueString + activeVehicle.battery.voltage.units + if (_activeVehicle.battery.voltage.value >= 0) { + return _activeVehicle.battery.voltage.valueString + _activeVehicle.battery.voltage.units } return 'N/A'; } - //------------------------------------------------------------------------- function getBatteryPercentageText() { - if(activeVehicle) { - if(activeVehicle.battery.percentRemaining.value > 98.9) { + if(_activeVehicle) { + if(_activeVehicle.battery.percentRemaining.value > 98.9) { return "100%" } - if(activeVehicle.battery.percentRemaining.value > 0.1) { - return activeVehicle.battery.percentRemaining.valueString + activeVehicle.battery.percentRemaining.units + if(_activeVehicle.battery.percentRemaining.value > 0.1) { + return _activeVehicle.battery.percentRemaining.valueString + _activeVehicle.battery.percentRemaining.units } - if(activeVehicle.battery.voltage.value >= 0) { - return activeVehicle.battery.voltage.valueString + activeVehicle.battery.voltage.units + if(_activeVehicle.battery.voltage.value >= 0) { + return _activeVehicle.battery.voltage.valueString + _activeVehicle.battery.voltage.units } } return "N/A" } - //------------------------------------------------------------------------- - //-- Message Indicator - Item { - id: messages - width: mainWindow.tbCellHeight - height: mainWindow.tbCellHeight - visible: activeVehicle && activeVehicle.messageCount - anchors.verticalCenter: parent.verticalCenter - Item { - id: criticalMessage - anchors.fill: parent - visible: activeVehicle && activeVehicle.messageCount > 0 && isMessageImportant - Image { - source: "/qmlimages/Yield.svg" - height: mainWindow.tbCellHeight * 0.75 - sourceSize.height: height - fillMode: Image.PreserveAspectFit - cache: false - visible: isMessageImportant - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - } - } - Item { - anchors.fill: parent - visible: !criticalMessage.visible - QGCColoredImage { - id: messageIcon - source: "/qmlimages/Megaphone.svg" - height: mainWindow.tbCellHeight * 0.5 - width: height - sourceSize.height: height - fillMode: Image.PreserveAspectFit - color: getMessageColor() - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - } - } - MouseArea { - anchors.fill: parent - onClicked: { - mainWindow.showMessageArea() - } - } - } + Row { + id: indicatorRow + anchors.top: parent.top + anchors.bottom: parent.bottom + spacing: ScreenTools.defaultFontPixelWidth * 1.5 + visible: !_communicationLost - //------------------------------------------------------------------------- - //-- GPS Indicator - Item { - id: satelitte - width: (gpsValuesColumn.x + gpsValuesColumn.width) * 1.1 - height: mainWindow.tbCellHeight - - QGCColoredImage { - id: gpsIcon - source: "/qmlimages/Gps.svg" - fillMode: Image.PreserveAspectFit - width: mainWindow.tbCellHeight * 0.65 - height: mainWindow.tbCellHeight * 0.5 - sourceSize.height: height - opacity: (activeVehicle && activeVehicle.gps.count.value >= 0) ? 1 : 0.5 - color: qgcPal.buttonText - anchors.verticalCenter: parent.verticalCenter - } + QGCPalette { id: qgcPal } - Column { - id: gpsValuesColumn + //------------------------------------------------------------------------- + //-- Message Indicator + Item { + id: messages + width: mainWindow.tbCellHeight + height: mainWindow.tbCellHeight + visible: _activeVehicle && _activeVehicle.messageCount anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2 - anchors.left: gpsIcon.right - - QGCLabel { - anchors.horizontalCenter: hdopValue.horizontalCenter - visible: activeVehicle && !isNaN(activeVehicle.gps.hdop.value) - color: qgcPal.buttonText - text: activeVehicle ? activeVehicle.gps.count.valueString : "" + Item { + id: criticalMessage + anchors.fill: parent + visible: _activeVehicle && _activeVehicle.messageCount > 0 && isMessageImportant + Image { + source: "/qmlimages/Yield.svg" + height: mainWindow.tbCellHeight * 0.75 + sourceSize.height: height + fillMode: Image.PreserveAspectFit + cache: false + visible: isMessageImportant + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + } } - - QGCLabel { - id: hdopValue - visible: activeVehicle && !isNaN(activeVehicle.gps.hdop.value) - color: qgcPal.buttonText - text: activeVehicle ? activeVehicle.gps.hdop.value.toFixed(1) : "" + Item { + anchors.fill: parent + visible: !criticalMessage.visible + QGCColoredImage { + id: messageIcon + source: "/qmlimages/Megaphone.svg" + height: mainWindow.tbCellHeight * 0.5 + width: height + sourceSize.height: height + fillMode: Image.PreserveAspectFit + color: getMessageColor() + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + } } - } // Column - - MouseArea { - anchors.fill: parent - onClicked: { - var centerX = mapToItem(toolBar, x, y).x + (width / 2) - mainWindow.showPopUp(gpsInfo, centerX) + MouseArea { + anchors.fill: parent + onClicked: { + mainWindow.showMessageArea() + } } } - } - //------------------------------------------------------------------------- - //-- RC RSSI - Item { - id: rcRssi - width: rssiRow.width * 1.1 - height: mainWindow.tbCellHeight - visible: activeVehicle ? activeVehicle.supportsRadio : true - Row { - id: rssiRow - height: parent.height - spacing: ScreenTools.defaultFontPixelWidth + //------------------------------------------------------------------------- + //-- GPS Indicator + Item { + id: satelitte + width: (gpsValuesColumn.x + gpsValuesColumn.width) * 1.1 + height: mainWindow.tbCellHeight + QGCColoredImage { + id: gpsIcon + source: "/qmlimages/Gps.svg" + fillMode: Image.PreserveAspectFit width: mainWindow.tbCellHeight * 0.65 - height: width + height: mainWindow.tbCellHeight * 0.5 sourceSize.height: height - source: "/qmlimages/RC.svg" - fillMode: Image.PreserveAspectFit - opacity: activeVehicle ? (((activeVehicle.rcRSSI < 0) || (activeVehicle.rcRSSI > 100)) ? 0.5 : 1) : 0.5 + opacity: (_activeVehicle && _activeVehicle.gps.count.value >= 0) ? 1 : 0.5 color: qgcPal.buttonText anchors.verticalCenter: parent.verticalCenter } - SignalStrength { - size: mainWindow.tbCellHeight * 0.5 - percent: activeVehicle ? ((activeVehicle.rcRSSI > 100) ? 0 : activeVehicle.rcRSSI) : 0 + + Column { + id: gpsValuesColumn anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2 + anchors.left: gpsIcon.right + + QGCLabel { + anchors.horizontalCenter: hdopValue.horizontalCenter + visible: _activeVehicle && !isNaN(_activeVehicle.gps.hdop.value) + color: qgcPal.buttonText + text: _activeVehicle ? _activeVehicle.gps.count.valueString : "" + } + + QGCLabel { + id: hdopValue + visible: _activeVehicle && !isNaN(_activeVehicle.gps.hdop.value) + color: qgcPal.buttonText + text: _activeVehicle ? _activeVehicle.gps.hdop.value.toFixed(1) : "" + } + } // Column + + MouseArea { + anchors.fill: parent + onClicked: { + var centerX = mapToItem(toolBar, x, y).x + (width / 2) + mainWindow.showPopUp(gpsInfo, centerX) + } } } - MouseArea { - anchors.fill: parent - onClicked: { - var centerX = mapToItem(toolBar, x, y).x + (width / 2) - mainWindow.showPopUp(rcRSSIInfo, centerX) - } - } - } - //------------------------------------------------------------------------- - //-- Telemetry RSSI - Item { - id: telemRssi - width: telemIcon.width - height: mainWindow.tbCellHeight - visible: _controller.telemetryLRSSI < 0 - QGCColoredImage { - id: telemIcon - height: parent.height * 0.5 - sourceSize.height: height - width: height * 1.5 - source: "/qmlimages/TelemRSSI.svg" - fillMode: Image.PreserveAspectFit - color: qgcPal.buttonText - anchors.verticalCenter: parent.verticalCenter - } - MouseArea { - anchors.fill: parent - onClicked: { - var centerX = mapToItem(toolBar, x, y).x + (width / 2) - mainWindow.showPopUp(telemRSSIInfo, centerX) + //------------------------------------------------------------------------- + //-- RC RSSI + Item { + id: rcRssi + width: rssiRow.width * 1.1 + height: mainWindow.tbCellHeight + visible: _activeVehicle ? _activeVehicle.supportsRadio : true + Row { + id: rssiRow + height: parent.height + spacing: ScreenTools.defaultFontPixelWidth + QGCColoredImage { + width: mainWindow.tbCellHeight * 0.65 + height: width + sourceSize.height: height + source: "/qmlimages/RC.svg" + fillMode: Image.PreserveAspectFit + opacity: _activeVehicle ? (((_activeVehicle.rcRSSI < 0) || (_activeVehicle.rcRSSI > 100)) ? 0.5 : 1) : 0.5 + color: qgcPal.buttonText + anchors.verticalCenter: parent.verticalCenter + } + SignalStrength { + size: mainWindow.tbCellHeight * 0.5 + percent: _activeVehicle ? ((_activeVehicle.rcRSSI > 100) ? 0 : _activeVehicle.rcRSSI) : 0 + anchors.verticalCenter: parent.verticalCenter + } + } + MouseArea { + anchors.fill: parent + onClicked: { + var centerX = mapToItem(toolBar, x, y).x + (width / 2) + mainWindow.showPopUp(rcRSSIInfo, centerX) + } } } - } - //------------------------------------------------------------------------- - //-- Battery Indicator - Item { - id: batteryStatus - width: battRow.width * 1.1 - height: mainWindow.tbCellHeight - opacity: (activeVehicle && activeVehicle.battery.voltage.value >= 0) ? 1 : 0.5 - Row { - id: battRow - height: mainWindow.tbCellHeight - anchors.horizontalCenter: parent.horizontalCenter + //------------------------------------------------------------------------- + //-- Telemetry RSSI + Item { + id: telemRssi + width: telemIcon.width + height: mainWindow.tbCellHeight + visible: _controller.telemetryLRSSI < 0 QGCColoredImage { - height: mainWindow.tbCellHeight * 0.65 - width: height - sourceSize.width: width - source: "/qmlimages/Battery.svg" + id: telemIcon + height: parent.height * 0.5 + sourceSize.height: height + width: height * 1.5 + source: "/qmlimages/TelemRSSI.svg" fillMode: Image.PreserveAspectFit - color: qgcPal.text - anchors.verticalCenter: parent.verticalCenter - } - QGCLabel { - text: getBatteryPercentageText() - font.pointSize: ScreenTools.mediumFontPointSize - color: getBatteryColor() + color: qgcPal.buttonText anchors.verticalCenter: parent.verticalCenter } - } - MouseArea { - anchors.fill: parent - onClicked: { - if (activeVehicle) { + MouseArea { + anchors.fill: parent + onClicked: { var centerX = mapToItem(toolBar, x, y).x + (width / 2) - mainWindow.showPopUp(batteryInfo, centerX) + mainWindow.showPopUp(telemRSSIInfo, centerX) } } } - } - //------------------------------------------------------------------------- - //-- Vehicle Selector - QGCButton { - id: vehicleSelectorButton - width: ScreenTools.defaultFontPixelHeight * 8 - text: "Vehicle " + (activeVehicle ? activeVehicle.id : "None") - visible: QGroundControl.multiVehicleManager.vehicles.count > 1 - anchors.verticalCenter: parent.verticalCenter - - menu: vehicleMenu - - Menu { - id: vehicleMenu - } - - Component { - id: vehicleMenuItemComponent - - MenuItem { - checkable: true - onTriggered: QGroundControl.multiVehicleManager.activeVehicle = vehicle - - property int vehicleId: Number(text.split(" ")[1]) - property var vehicle: QGroundControl.multiVehicleManager.getVehicleById(vehicleId) + //------------------------------------------------------------------------- + //-- Battery Indicator + Item { + id: batteryStatus + width: battRow.width * 1.1 + height: mainWindow.tbCellHeight + opacity: (_activeVehicle && _activeVehicle.battery.voltage.value >= 0) ? 1 : 0.5 + Row { + id: battRow + height: mainWindow.tbCellHeight + anchors.horizontalCenter: parent.horizontalCenter + QGCColoredImage { + height: mainWindow.tbCellHeight * 0.65 + width: height + sourceSize.width: width + source: "/qmlimages/Battery.svg" + fillMode: Image.PreserveAspectFit + color: qgcPal.text + anchors.verticalCenter: parent.verticalCenter + } + QGCLabel { + text: getBatteryPercentageText() + font.pointSize: ScreenTools.mediumFontPointSize + color: getBatteryColor() + anchors.verticalCenter: parent.verticalCenter + } } - } - - property var vehicleMenuItems: [] - function updateVehicleMenu() { - // Remove old menu items - for (var i = 0; i < vehicleMenuItems.length; i++) { - vehicleMenu.removeItem(vehicleMenuItems[i]) - } - vehicleMenuItems.length = 0 - - // Add new items - for (var i=0; i indicatorRow.width && !_communicationLost + fillMode: Image.PreserveAspectFit + source: _activeVehicle ? _activeVehicle.brandImage : "" } -} + Row { + anchors.fill: parent + layoutDirection: Qt.RightToLeft + spacing: ScreenTools.defaultFontPixelWidth + visible: _communicationLost + + QGCButton { + id: disconnectButton + anchors.verticalCenter: parent.verticalCenter + text: qsTr("Disconnect") + primary: true + onClicked: _activeVehicle.disconnectInactiveVehicle() + } + QGCLabel { + id: connectionLost + anchors.verticalCenter: parent.verticalCenter + text: qsTr("COMMUNICATION LOST") + font.pointSize: ScreenTools.largeFontPointSize + font.family: ScreenTools.demiboldFontFamily + color: colorRed + } + } // Row - Communication lost +} // Item