Commit c2ccfda0 authored by Gus Grubba's avatar Gus Grubba

Allow plugin control of map scale visibility

parent b413f7f9
...@@ -476,7 +476,7 @@ FlightMap { ...@@ -476,7 +476,7 @@ FlightMap {
anchors.topMargin: ScreenTools.defaultFontPixelHeight * (0.33) + state === "bottomMode" ? 0 : ScreenTools.toolbarHeight anchors.topMargin: ScreenTools.defaultFontPixelHeight * (0.33) + state === "bottomMode" ? 0 : ScreenTools.toolbarHeight
anchors.bottomMargin: ScreenTools.defaultFontPixelHeight * (0.33) anchors.bottomMargin: ScreenTools.defaultFontPixelHeight * (0.33)
mapControl: flightMap mapControl: flightMap
visible: !ScreenTools.isTinyScreen visible: !ScreenTools.isTinyScreen && QGroundControl.corePlugin.options.enableMapScale
state: "bottomMode" state: "bottomMode"
states: [ states: [
State { State {
......
...@@ -110,70 +110,69 @@ Item { ...@@ -110,70 +110,69 @@ Item {
} }
function calculateScale() { function calculateScale() {
var scaleLinePixelLength = 100 if(mapControl) {
var leftCoord = mapControl.toCoordinate(Qt.point(0, scale.y), false /* clipToViewPort */) var scaleLinePixelLength = 100
var rightCoord = mapControl.toCoordinate(Qt.point(scaleLinePixelLength, scale.y), false /* clipToViewPort */) var leftCoord = mapControl.toCoordinate(Qt.point(0, scale.y), false /* clipToViewPort */)
var scaleLineMeters = Math.round(leftCoord.distanceTo(rightCoord)) var rightCoord = mapControl.toCoordinate(Qt.point(scaleLinePixelLength, scale.y), false /* clipToViewPort */)
var scaleLineMeters = Math.round(leftCoord.distanceTo(rightCoord))
if (QGroundControl.settingsManager.unitsSettings.distanceUnits.value === UnitsSettings.DistanceUnitsFeet) { if (QGroundControl.settingsManager.unitsSettings.distanceUnits.value === UnitsSettings.DistanceUnitsFeet) {
calculateFeetRatio(scaleLineMeters, scaleLinePixelLength) calculateFeetRatio(scaleLineMeters, scaleLinePixelLength)
} else { } else {
calculateMetersRatio(scaleLineMeters, scaleLinePixelLength) calculateMetersRatio(scaleLineMeters, scaleLinePixelLength)
}
} }
} }
Connections { Connections {
target: mapControl target: mapControl
onWidthChanged: scaleTimer.restart()
onWidthChanged: scaleTimer.restart() onHeightChanged: scaleTimer.restart()
onHeightChanged: scaleTimer.restart()
onZoomLevelChanged: scaleTimer.restart() onZoomLevelChanged: scaleTimer.restart()
} }
Timer { Timer {
id: scaleTimer id: scaleTimer
interval: 100 interval: 100
running: false running: false
repeat: false repeat: false
onTriggered: calculateScale()
onTriggered: calculateScale()
} }
QGCMapLabel { QGCMapLabel {
id: scaleText id: scaleText
map: mapControl map: mapControl
font.family: ScreenTools.demiboldFontFamily font.family: ScreenTools.demiboldFontFamily
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
horizontalAlignment: Text.AlignRight horizontalAlignment:Text.AlignRight
text: "0 m" text: "0 m"
} }
Rectangle { Rectangle {
id: leftEnd id: leftEnd
anchors.top: scaleText.bottom anchors.top: scaleText.bottom
anchors.left: parent.left anchors.left: parent.left
width: 2 width: 2
height: ScreenTools.defaultFontPixelHeight height: ScreenTools.defaultFontPixelHeight
color: _color color: _color
} }
Rectangle { Rectangle {
id: centerLine id: centerLine
anchors.bottomMargin: 2 anchors.bottomMargin: 2
anchors.bottom: leftEnd.bottom anchors.bottom: leftEnd.bottom
anchors.left: leftEnd.right anchors.left: leftEnd.right
height: 2 height: 2
color: _color color: _color
} }
Rectangle { Rectangle {
id: rightEnd id: rightEnd
anchors.top: leftEnd.top anchors.top: leftEnd.top
anchors.left: centerLine.right anchors.left: centerLine.right
width: 2 width: 2
height: ScreenTools.defaultFontPixelHeight height: ScreenTools.defaultFontPixelHeight
color: _color color: _color
} }
Component.onCompleted: { Component.onCompleted: {
......
...@@ -63,6 +63,7 @@ public: ...@@ -63,6 +63,7 @@ public:
Q_PROPERTY(bool checkFirmwareVersion READ checkFirmwareVersion CONSTANT) Q_PROPERTY(bool checkFirmwareVersion READ checkFirmwareVersion CONSTANT)
Q_PROPERTY(bool showMavlinkLogOptions READ showMavlinkLogOptions CONSTANT) Q_PROPERTY(bool showMavlinkLogOptions READ showMavlinkLogOptions CONSTANT)
Q_PROPERTY(bool enableMultiVehicleList READ enableMultiVehicleList CONSTANT) Q_PROPERTY(bool enableMultiVehicleList READ enableMultiVehicleList CONSTANT)
Q_PROPERTY(bool enableMapScale READ enableMapScale CONSTANT)
/// Should QGC hide its settings menu and colapse it into one single menu (Settings and Vehicle Setup)? /// Should QGC hide its settings menu and colapse it into one single menu (Settings and Vehicle Setup)?
/// @return true if QGC should consolidate both menus into one. /// @return true if QGC should consolidate both menus into one.
...@@ -114,7 +115,8 @@ public: ...@@ -114,7 +115,8 @@ public:
virtual bool disableVehicleConnection () const { return false; } ///< true: vehicle connection is disabled virtual bool disableVehicleConnection () const { return false; } ///< true: vehicle connection is disabled
virtual bool checkFirmwareVersion () const { return true; } virtual bool checkFirmwareVersion () const { return true; }
virtual bool showMavlinkLogOptions () const { return true; } virtual bool showMavlinkLogOptions () const { return true; }
virtual bool enableMultiVehicleList () const { return true; } virtual bool enableMultiVehicleList () const { return true; }
virtual bool enableMapScale () const { return true; }
#if defined(__mobile__) #if defined(__mobile__)
virtual bool useMobileFileDialog () const { return true;} virtual bool useMobileFileDialog () const { return true;}
......
...@@ -228,6 +228,7 @@ int main(int argc, char *argv[]) ...@@ -228,6 +228,7 @@ int main(int argc, char *argv[])
#endif #endif
#endif // QT_DEBUG #endif // QT_DEBUG
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QGCApplication* app = new QGCApplication(argc, argv, runUnitTests); QGCApplication* app = new QGCApplication(argc, argv, runUnitTests);
Q_CHECK_PTR(app); Q_CHECK_PTR(app);
......
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