Commit 240b37fe authored by Gus Grubba's avatar Gus Grubba

Allow FirmwarePlugin to provide vehicle icons.

parent cdde6b74
...@@ -302,3 +302,21 @@ QString FirmwarePlugin::takeControlFlightMode(void) ...@@ -302,3 +302,21 @@ QString FirmwarePlugin::takeControlFlightMode(void)
{ {
return QString(); return QString();
} }
QString FirmwarePlugin::vehicleImageOpaque(const Vehicle* vehicle) const
{
Q_UNUSED(vehicle);
return QStringLiteral("/qmlimages/vehicleArrowOpaque.svg");
}
QString FirmwarePlugin::vehicleImageOutline(const Vehicle* vehicle) const
{
Q_UNUSED(vehicle);
return QStringLiteral("/qmlimages/vehicleArrowOutline.svg");
}
QString FirmwarePlugin::vehicleImageCompass(const Vehicle* vehicle) const
{
Q_UNUSED(vehicle);
return QStringLiteral("/qmlimages/compassInstrumentArrow.svg");
}
...@@ -242,6 +242,15 @@ public: ...@@ -242,6 +242,15 @@ public:
/// Return the resource file which contains the brand image for the vehicle. /// Return the resource file which contains the brand image for the vehicle.
virtual QString brandImage(const Vehicle* vehicle) const { Q_UNUSED(vehicle) return QString(); } virtual QString brandImage(const Vehicle* vehicle) const { Q_UNUSED(vehicle) return QString(); }
/// Return the resource file which contains the vehicle icon used in the flight view when the view is dark (Satellite for instance)
virtual QString vehicleImageOpaque(const Vehicle* vehicle) const;
/// Return the resource file which contains the vehicle icon used in the flight view when the view is light (Map for instance)
virtual QString vehicleImageOutline(const Vehicle* vehicle) const;
/// Return the resource file which contains the vehicle icon used in the compass
virtual QString vehicleImageCompass(const Vehicle* vehicle) const;
// FIXME: Hack workaround for non pluginize FollowMe support // FIXME: Hack workaround for non pluginize FollowMe support
static const char* px4FollowMeFlightMode; static const char* px4FollowMeFlightMode;
}; };
......
...@@ -81,7 +81,6 @@ Item { ...@@ -81,7 +81,6 @@ Item {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
visible: !_useAlternateInstruments visible: !_useAlternateInstruments
size: getGadgetWidth() size: getGadgetWidth()
active: _activeVehicle != null
heading: _heading heading: _heading
rollAngle: _roll rollAngle: _roll
pitchAngle: _pitch pitchAngle: _pitch
...@@ -100,7 +99,6 @@ Item { ...@@ -100,7 +99,6 @@ Item {
anchors.right: altitudeSlider.visible ? altitudeSlider.left : parent.right anchors.right: altitudeSlider.visible ? altitudeSlider.left : parent.right
visible: _useAlternateInstruments visible: _useAlternateInstruments
width: ScreenTools.isTinyScreen ? getGadgetWidth() * 1.5 : getGadgetWidth() width: ScreenTools.isTinyScreen ? getGadgetWidth() * 1.5 : getGadgetWidth()
active: _activeVehicle != null
heading: _heading heading: _heading
rollAngle: _roll rollAngle: _roll
pitchAngle: _pitch pitchAngle: _pitch
......
...@@ -52,8 +52,8 @@ QGCListView { ...@@ -52,8 +52,8 @@ QGCListView {
QGCCompassWidget { QGCCompassWidget {
size: _widgetHeight size: _widgetHeight
active: true
heading: _vehicle.heading.rawValue heading: _vehicle.heading.rawValue
vehicle: _vehicle
} }
QGCAttitudeWidget { QGCAttitudeWidget {
......
...@@ -30,7 +30,7 @@ MapQuickItem { ...@@ -30,7 +30,7 @@ MapQuickItem {
sourceItem: Image { sourceItem: Image {
id: vehicleIcon id: vehicleIcon
source: isSatellite ? "/qmlimages/vehicleArrowOpaque.svg" : "/qmlimages/vehicleArrowOutline.svg" source: isSatellite ? vehicle.vehicleImageOpaque : vehicle.vehicleImageOutline
mipmap: true mipmap: true
width: size width: size
sourceSize.width: size sourceSize.width: size
......
...@@ -17,15 +17,16 @@ ...@@ -17,15 +17,16 @@
import QtQuick 2.4 import QtQuick 2.4
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import QGroundControl.Controls 1.0 import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
import QGroundControl.Vehicle 1.0
Item { Item {
id: root id: root
property bool active: false ///< true: actively connected to data provider, false: show inactive control
property real heading: 0
property real size: _defaultSize property real size: _defaultSize
property real heading: 0
property var vehicle: null
property real _defaultSize: ScreenTools.defaultFontPixelHeight * (10) property real _defaultSize: ScreenTools.defaultFontPixelHeight * (10)
property real _sizeRatio: ScreenTools.isTinyScreen ? (size / _defaultSize) * 0.5 : size / _defaultSize property real _sizeRatio: ScreenTools.isTinyScreen ? (size / _defaultSize) * 0.5 : size / _defaultSize
...@@ -48,7 +49,7 @@ Item { ...@@ -48,7 +49,7 @@ Item {
Image { Image {
id: pointer id: pointer
source: "/qmlimages/compassInstrumentArrow.svg" source: vehicle ? vehicle.vehicleImageCompass : ""
mipmap: true mipmap: true
width: size * 0.75 width: size * 0.75
sourceSize.width: width sourceSize.width: width
...@@ -78,8 +79,8 @@ Item { ...@@ -78,8 +79,8 @@ Item {
color: Qt.rgba(0,0,0,0.65) color: Qt.rgba(0,0,0,0.65)
QGCLabel { QGCLabel {
text: active ? heading.toFixed(0) : qsTr("OFF") text: vehicle ? heading.toFixed(0) : qsTr("OFF")
font.family: active ? ScreenTools.demiboldFontFamily : ScreenTools.normalFontFamily font.family: vehicle ? ScreenTools.demiboldFontFamily : ScreenTools.normalFontFamily
font.pointSize: _fontSize < 8 ? 8 : _fontSize; font.pointSize: _fontSize < 8 ? 8 : _fontSize;
color: "white" color: "white"
anchors.centerIn: parent anchors.centerIn: parent
......
...@@ -150,8 +150,8 @@ Item { ...@@ -150,8 +150,8 @@ Item {
QGCCompassWidget { QGCCompassWidget {
id: compass id: compass
size: parent.width * 0.95 size: parent.width * 0.95
active: instrumentPanel.active
visible: _showCompass visible: _showCompass
vehicle: _activeVehicle
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
} }
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
import QtQuick 2.4 import QtQuick 2.4
import QGroundControl 1.0
import QGroundControl.Controls 1.0 import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
import QGroundControl.FactSystem 1.0 import QGroundControl.FactSystem 1.0
...@@ -68,7 +69,7 @@ Rectangle { ...@@ -68,7 +69,7 @@ Rectangle {
anchors.leftMargin: _spacing anchors.leftMargin: _spacing
anchors.left: attitude.right anchors.left: attitude.right
size: _innerRadius * 2 size: _innerRadius * 2
active: root.active vehicle: QGroundControl.multiVehicleManager.activeVehicle
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
......
...@@ -2203,6 +2203,30 @@ QString Vehicle::takeControlFlightMode(void) const ...@@ -2203,6 +2203,30 @@ QString Vehicle::takeControlFlightMode(void) const
return _firmwarePlugin->takeControlFlightMode(); return _firmwarePlugin->takeControlFlightMode();
} }
QString Vehicle::vehicleImageOpaque() const
{
if(_firmwarePlugin)
return _firmwarePlugin->vehicleImageOpaque(this);
else
return QString();
}
QString Vehicle::vehicleImageOutline() const
{
if(_firmwarePlugin)
return _firmwarePlugin->vehicleImageOutline(this);
else
return QString();
}
QString Vehicle::vehicleImageCompass() const
{
if(_firmwarePlugin)
return _firmwarePlugin->vehicleImageCompass(this);
else
return QString();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
......
...@@ -264,6 +264,9 @@ public: ...@@ -264,6 +264,9 @@ public:
Q_PROPERTY(QString takeControlFlightMode READ takeControlFlightMode CONSTANT) Q_PROPERTY(QString takeControlFlightMode READ takeControlFlightMode CONSTANT)
Q_PROPERTY(QString firmwareTypeString READ firmwareTypeString NOTIFY firmwareTypeChanged) Q_PROPERTY(QString firmwareTypeString READ firmwareTypeString NOTIFY firmwareTypeChanged)
Q_PROPERTY(QString vehicleTypeString READ vehicleTypeString NOTIFY vehicleTypeChanged) Q_PROPERTY(QString vehicleTypeString READ vehicleTypeString NOTIFY vehicleTypeChanged)
Q_PROPERTY(QString vehicleImageOpaque READ vehicleImageOpaque CONSTANT)
Q_PROPERTY(QString vehicleImageOutline READ vehicleImageOutline CONSTANT)
Q_PROPERTY(QString vehicleImageCompass READ vehicleImageCompass CONSTANT)
/// true: Vehicle is flying, false: Vehicle is on ground /// true: Vehicle is flying, false: Vehicle is on ground
Q_PROPERTY(bool flying READ flying WRITE setFlying NOTIFY flyingChanged) Q_PROPERTY(bool flying READ flying WRITE setFlying NOTIFY flyingChanged)
...@@ -582,6 +585,10 @@ public: ...@@ -582,6 +585,10 @@ public:
/// and destroyed when the vehicle goes away. /// and destroyed when the vehicle goes away.
void setFirmwarePluginInstanceData(QObject* firmwarePluginInstanceData); void setFirmwarePluginInstanceData(QObject* firmwarePluginInstanceData);
QString vehicleImageOpaque () const;
QString vehicleImageOutline () const;
QString vehicleImageCompass () const;
public slots: public slots:
void setLatitude(double latitude); void setLatitude(double latitude);
void setLongitude(double longitude); void setLongitude(double longitude);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment