diff --git a/qgcresources.qrc b/qgcresources.qrc index ab45927ff935a07ce0046e67ef6211f677c9e1cc..1adcca7a6f3c8f61ad2f9c6182230a324745696b 100644 --- a/qgcresources.qrc +++ b/qgcresources.qrc @@ -154,6 +154,7 @@ src/ui/toolbar/Images/TelemRSSI.svg src/ui/toolbar/Images/Yield.svg src/ui/toolbar/Images/CameraIcon.svg + src/ui/toolbar/Images/Joystick.png src/MissionManager/CogWheel.svg src/AutoPilotPlugins/Common/Images/StationMode.svg src/AutoPilotPlugins/Common/Images/APMode.svg diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 643946656b2e6bb763e1e10bb77422e5fb956015..13452d1fcfda0673ee71be55a57e547f44c34a2d 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -10,6 +10,7 @@ src/ui/toolbar/ModeIndicator.qml src/ui/toolbar/RCRSSIIndicator.qml src/ui/toolbar/TelemetryRSSIIndicator.qml + src/ui/toolbar/JoystickIndicator.qml src/AutoPilotPlugins/PX4/AirframeComponent.qml diff --git a/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc b/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc index d71b7aebf7897b020c61306a01ce9f059c268c24..78ca8d4ee4b70a33c4cb67bf5d7ecc4fe4aa4f3e 100644 --- a/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc +++ b/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc @@ -117,6 +117,7 @@ const QVariantList& ArduSubFirmwarePlugin::toolBarIndicators(const Vehicle* vehi _toolBarIndicators.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/MessageIndicator.qml"))); _toolBarIndicators.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/BatteryIndicator.qml"))); _toolBarIndicators.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/ModeIndicator.qml"))); + _toolBarIndicators.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/JoystickIndicator.qml"))); } return _toolBarIndicators; } diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index d68d6db7c416cea2583832e663a5cd573afebb5f..db85687c5071a05b4da2b11850b7956a8e2ea6b0 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -1409,7 +1409,7 @@ void Vehicle::_loadSettings(void) // Joystick enabled is a global setting so first make sure there are any joysticks connected if (qgcApp()->toolbox()->joystickManager()->joysticks().count()) { - _joystickEnabled = settings.value(_joystickEnabledSettingsKey, false).toBool(); + setJoystickEnabled(settings.value(_joystickEnabledSettingsKey, false).toBool()); } } diff --git a/src/ui/toolbar/Images/Joystick.png b/src/ui/toolbar/Images/Joystick.png new file mode 100644 index 0000000000000000000000000000000000000000..bbaa8350d08ac3172e5dca97689c8b3dcf4fc5df Binary files /dev/null and b/src/ui/toolbar/Images/Joystick.png differ diff --git a/src/ui/toolbar/JoystickIndicator.qml b/src/ui/toolbar/JoystickIndicator.qml new file mode 100644 index 0000000000000000000000000000000000000000..ecfa8d95dfcbf61f58f840595238efa0a56cf2fc --- /dev/null +++ b/src/ui/toolbar/JoystickIndicator.qml @@ -0,0 +1,102 @@ +/**************************************************************************** + * + * (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.5 +import QtQuick.Controls 1.2 +import QtQuick.Layouts 1.2 + +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.MultiVehicleManager 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Palette 1.0 + +// Joystick Indicator +Item { + width: joystickRow.width * 1.1 + anchors.top: parent.top + anchors.bottom: parent.bottom + visible: activeVehicle ? activeVehicle.sub : false + + + Component { + id: joystickInfo + + Rectangle { + width: joystickCol.width + ScreenTools.defaultFontPixelWidth * 3 + height: joystickCol.height + ScreenTools.defaultFontPixelHeight * 2 + radius: ScreenTools.defaultFontPixelHeight * 0.5 + color: qgcPal.window + border.color: qgcPal.text + + Column { + id: joystickCol + spacing: ScreenTools.defaultFontPixelHeight * 0.5 + width: Math.max(joystickGrid.width, joystickLabel.width) + anchors.margins: ScreenTools.defaultFontPixelHeight + anchors.centerIn: parent + + QGCLabel { + id: joystickLabel + text: qsTr("Joystick Status") + font.family: ScreenTools.demiboldFontFamily + anchors.horizontalCenter: parent.horizontalCenter + } + + GridLayout { + id: joystickGrid + anchors.margins: ScreenTools.defaultFontPixelHeight + columnSpacing: ScreenTools.defaultFontPixelWidth + columns: 2 + anchors.horizontalCenter: parent.horizontalCenter + + QGCLabel { text: qsTr("Connected:") } + QGCLabel { + text: joystickManager.activeJoystick ? "Yes" : "No" + color: joystickManager.activeJoystick ? qgcPal.buttonText : "red" + } + QGCLabel { text: qsTr("Enabled:") } + QGCLabel { + text: activeVehicle && activeVehicle.joystickEnabled ? "Yes" : "No" + color: activeVehicle && activeVehicle.joystickEnabled ? qgcPal.buttonText : "red" + } + } + } + + Component.onCompleted: { + var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height) + x = pos.x + y = pos.y + ScreenTools.defaultFontPixelHeight + } + } + } + + Row { + id: joystickRow + anchors.top: parent.top + anchors.bottom: parent.bottom + spacing: ScreenTools.defaultFontPixelWidth + + QGCColoredImage { + width: height + anchors.top: parent.top + anchors.bottom: parent.bottom + sourceSize.height: height + source: "/qmlimages/Joystick.png" + fillMode: Image.PreserveAspectFit + color: activeVehicle && activeVehicle.joystickEnabled && joystickManager.activeJoystick ? qgcPal.buttonText : "red" + } + } + + MouseArea { + anchors.fill: parent + onClicked: mainWindow.showPopUp(joystickInfo, mapToItem(toolBar, x, y).x + (width / 2)) + } +} diff --git a/src/ui/toolbar/RCRSSIIndicator.qml b/src/ui/toolbar/RCRSSIIndicator.qml index 0ec602c3f4f1993e447deb25c2e7b1149207c691..baf04b172e0d9009237c76614c81b09aa67ac795 100644 --- a/src/ui/toolbar/RCRSSIIndicator.qml +++ b/src/ui/toolbar/RCRSSIIndicator.qml @@ -19,7 +19,7 @@ import QGroundControl.ScreenTools 1.0 import QGroundControl.Palette 1.0 //------------------------------------------------------------------------- -//-- GPS Indicator +//-- RC RSSI Indicator Item { width: rssiRow.width * 1.1 anchors.top: parent.top