diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro
index ffbc0bf66f6fee9b832c12bee1cef512fe25492b..d3be1b28f5cad4e7ec48c35e8f4f67659dde9cbb 100644
--- a/qgroundcontrol.pro
+++ b/qgroundcontrol.pro
@@ -497,7 +497,7 @@ HEADERS += \
src/ui/QGCUDPLinkConfiguration.h \
src/uas/UASMessageHandler.h \
src/ui/toolbar/MainToolBar.h \
- src/QmlControls/MousePosition.h
+ src/QmlControls/ScreenTools.h
SOURCES += \
src/main.cc \
@@ -639,7 +639,7 @@ SOURCES += \
src/ui/QGCUDPLinkConfiguration.cc \
src/uas/UASMessageHandler.cc \
src/ui/toolbar/MainToolBar.cc \
- src/QmlControls/MousePosition.cc
+ src/QmlControls/ScreenTools.cc
#
# Unit Test specific configuration goes here
@@ -742,6 +742,7 @@ HEADERS+= \
src/AutoPilotPlugins/PX4/SensorsComponent.h \
src/AutoPilotPlugins/PX4/SensorsComponentController.h \
src/AutoPilotPlugins/PX4/SafetyComponent.h \
+ src/AutoPilotPlugins/PX4/PowerComponent.h \
src/AutoPilotPlugins/PX4/PX4ParameterFacts.h \
SOURCES += \
@@ -764,6 +765,7 @@ SOURCES += \
src/AutoPilotPlugins/PX4/SensorsComponent.cc \
src/AutoPilotPlugins/PX4/SensorsComponentController.cc \
src/AutoPilotPlugins/PX4/SafetyComponent.cc \
+ src/AutoPilotPlugins/PX4/PowerComponent.cc \
src/AutoPilotPlugins/PX4/PX4ParameterFacts.cc \
# Fact System code
diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index 16459b2f42d82337cf273530d5f93621be5920bc..48ec2158367e718c3538cca3259981160dffa658 100644
--- a/qgroundcontrol.qrc
+++ b/qgroundcontrol.qrc
@@ -247,13 +247,11 @@
src/test.qml
src/QmlControls/QmlTest.qml
-
src/FactSystem/FactControls/qmldir
src/FactSystem/FactControls/FactLabel.qml
src/FactSystem/FactControls/FactTextField.qml
src/FactSystem/FactControls/FactCheckBox.qml
src/FactSystem/FactControls/FactComboBox.qml
-
src/QmlControls/qmldir
src/QmlControls/QGCButton.qml
src/QmlControls/QGCRadioButton.qml
@@ -263,31 +261,27 @@
src/QmlControls/QGCComboBox.qml
src/QmlControls/QGCColoredImage.qml
src/QmlControls/QGCToolBarButton.qml
-
src/QmlControls/SubMenuButton.qml
src/QmlControls/IndicatorButton.qml
src/QmlControls/VehicleRotationCal.qml
-
src/QmlControls/arrow-down.png
-
files/images/px4/airframes/octo_x.png
files/images/px4/boards/px4fmu_2.x.png
src/VehicleSetup/SetupViewButtons.qml
src/VehicleSetup/VehicleSummary.qml
src/VehicleSetup/FirmwareUpgrade.qml
-
src/AutoPilotPlugins/PX4/SafetyComponent.qml
+ src/AutoPilotPlugins/PX4/PowerComponent.qml
src/AutoPilotPlugins/PX4/SensorsComponent.qml
src/AutoPilotPlugins/PX4/FlightModesComponent.qml
-
src/AutoPilotPlugins/PX4/SafetyComponentSummary.qml
+ src/AutoPilotPlugins/PX4/PowerComponentSummary.qml
src/AutoPilotPlugins/PX4/SensorsComponentSummary.qml
src/AutoPilotPlugins/PX4/SensorsComponentSummaryFixedWing.qml
src/AutoPilotPlugins/PX4/RadioComponentSummary.qml
src/AutoPilotPlugins/PX4/FlightModesComponentSummary.qml
src/AutoPilotPlugins/PX4/AirframeComponentSummary.qml
-
- src/AutoPilotPlugins/PX4/Images/SafetyComponentTree.png
+ src/AutoPilotPlugins/PX4/Images/SafetyComponentTree.svg
src/AutoPilotPlugins/PX4/Images/SafetyComponentHome.png
src/AutoPilotPlugins/PX4/Images/SafetyComponentArrowDown.png
src/AutoPilotPlugins/PX4/Images/SafetyComponentPlane.png
@@ -297,16 +291,21 @@
src/AutoPilotPlugins/PX4/Images/VehicleRight.png
src/AutoPilotPlugins/PX4/Images/VehicleNoseDown.png
src/AutoPilotPlugins/PX4/Images/VehicleTailDown.png
-
files/Setup/cogwheels.png
src/AutoPilotPlugins/PX4/Images/SensorsComponentIcon.png
src/AutoPilotPlugins/PX4/Images/RadioComponentIcon.png
src/AutoPilotPlugins/PX4/Images/FlightModesComponentIcon.png
src/AutoPilotPlugins/PX4/Images/AirframeComponentIcon.png
src/AutoPilotPlugins/PX4/Images/SafetyComponentIcon.png
+ src/AutoPilotPlugins/PX4/Images/PowerComponentIcon.png
src/VehicleSetup/FirmwareUpgradeIcon.png
src/VehicleSetup/VehicleSummaryIcon.png
-
+ src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_01cell.svg
+ src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_02cell.svg
+ src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_03cell.svg
+ src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_04cell.svg
+ src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_05cell.svg
+ src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_06cell.svg
src/ui/toolbar/MainToolBar.qml
diff --git a/src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_01cell.svg b/src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_01cell.svg
new file mode 100644
index 0000000000000000000000000000000000000000..c026fe3f82a0d6843f3a425f7aace1ad0f24345b
--- /dev/null
+++ b/src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_01cell.svg
@@ -0,0 +1,21 @@
+
+
+
diff --git a/src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_02cell.svg b/src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_02cell.svg
new file mode 100644
index 0000000000000000000000000000000000000000..cd2b371cf9909ccfc60d190316464f7b366f7ace
--- /dev/null
+++ b/src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_02cell.svg
@@ -0,0 +1,22 @@
+
+
+
diff --git a/src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_03cell.svg b/src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_03cell.svg
new file mode 100644
index 0000000000000000000000000000000000000000..54859ffa16a9908275142041ece91f6fc3ce1f11
--- /dev/null
+++ b/src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_03cell.svg
@@ -0,0 +1,23 @@
+
+
+
diff --git a/src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_04cell.svg b/src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_04cell.svg
new file mode 100644
index 0000000000000000000000000000000000000000..2d0dda8ec05742853bab5253ab387ad02ac46007
--- /dev/null
+++ b/src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_04cell.svg
@@ -0,0 +1,24 @@
+
+
+
diff --git a/src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_05cell.svg b/src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_05cell.svg
new file mode 100644
index 0000000000000000000000000000000000000000..150bc0b897dcc6b11c97ebb55cfdc7f065a6af93
--- /dev/null
+++ b/src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_05cell.svg
@@ -0,0 +1,25 @@
+
+
+
diff --git a/src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_06cell.svg b/src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_06cell.svg
new file mode 100644
index 0000000000000000000000000000000000000000..1d8d9f26f6d57ecffc80cde65c87d9a3fa279136
--- /dev/null
+++ b/src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_06cell.svg
@@ -0,0 +1,26 @@
+
+
+
diff --git a/src/AutoPilotPlugins/PX4/Images/PowerComponentIcon.png b/src/AutoPilotPlugins/PX4/Images/PowerComponentIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..cba13b67525fa2e315ea53d7ac3e0eb3474cb834
Binary files /dev/null and b/src/AutoPilotPlugins/PX4/Images/PowerComponentIcon.png differ
diff --git a/src/AutoPilotPlugins/PX4/Images/SafetyComponentTree.png b/src/AutoPilotPlugins/PX4/Images/SafetyComponentTree.png
deleted file mode 100644
index 9c618a3060326f456f2cb2ac7aee2cdb466e1025..0000000000000000000000000000000000000000
Binary files a/src/AutoPilotPlugins/PX4/Images/SafetyComponentTree.png and /dev/null differ
diff --git a/src/AutoPilotPlugins/PX4/Images/SafetyComponentTree.svg b/src/AutoPilotPlugins/PX4/Images/SafetyComponentTree.svg
new file mode 100644
index 0000000000000000000000000000000000000000..2b9645a77667f8399f68fe47fe043787526e7b39
--- /dev/null
+++ b/src/AutoPilotPlugins/PX4/Images/SafetyComponentTree.svg
@@ -0,0 +1,19 @@
+
+
+
diff --git a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc
index e9e553efe25e97edaf7450477ee8923dc85786a7..0bf534915dbb4323f2ba628810e98bb78bbdde52 100644
--- a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc
+++ b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc
@@ -70,6 +70,7 @@ PX4AutoPilotPlugin::PX4AutoPilotPlugin(UASInterface* uas, QObject* parent) :
_flightModesComponent(NULL),
_sensorsComponent(NULL),
_safetyComponent(NULL),
+ _powerComponent(NULL),
_incorrectParameterVersion(false)
{
Q_ASSERT(uas);
@@ -214,6 +215,10 @@ const QVariantList& PX4AutoPilotPlugin::components(void)
Q_CHECK_PTR(_sensorsComponent);
_components.append(QVariant::fromValue((VehicleComponent*)_sensorsComponent));
+ _powerComponent = new PowerComponent(_uas, this);
+ Q_CHECK_PTR(_powerComponent);
+ _components.append(QVariant::fromValue((VehicleComponent*)_powerComponent));
+
_safetyComponent = new SafetyComponent(_uas, this);
Q_CHECK_PTR(_safetyComponent);
_components.append(QVariant::fromValue((VehicleComponent*)_safetyComponent));
diff --git a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h
index 92e1499c033d6e8f18606bf9e1c2f90ea1cc521c..47c6ee5927cadcbd7cfa50234c3564b7773341c5 100644
--- a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h
+++ b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h
@@ -33,6 +33,7 @@
#include "FlightModesComponent.h"
#include "SensorsComponent.h"
#include "SafetyComponent.h"
+#include "PowerComponent.h"
#include
@@ -64,7 +65,8 @@ public:
FlightModesComponent* flightModesComponent(void) { return _flightModesComponent; }
SensorsComponent* sensorsComponent(void) { return _sensorsComponent; }
SafetyComponent* safetyComponent(void) { return _safetyComponent; }
-
+ PowerComponent* powerComponent(void) { return _powerComponent; }
+
private slots:
void _checkForIncorrectParameterVersion(void);
@@ -76,6 +78,7 @@ private:
FlightModesComponent* _flightModesComponent;
SensorsComponent* _sensorsComponent;
SafetyComponent* _safetyComponent;
+ PowerComponent* _powerComponent;
bool _incorrectParameterVersion; ///< true: parameter version incorrect, setup not allowed
};
diff --git a/src/AutoPilotPlugins/PX4/ParameterFactMetaData.xml b/src/AutoPilotPlugins/PX4/ParameterFactMetaData.xml
index bde8da849f57ed7ade9be84fc6dd7d161e76737b..8b7ea4f3db585edc8a4d16b812fafca7cf2c682d 100644
--- a/src/AutoPilotPlugins/PX4/ParameterFactMetaData.xml
+++ b/src/AutoPilotPlugins/PX4/ParameterFactMetaData.xml
@@ -5,22 +5,26 @@
Empty cell voltage
Defines the voltage where a single cell of the battery is considered empty.
3.4
+ V
Full cell voltage
Defines the voltage where a single cell of the battery is considered full.
4.2
+ V
Voltage drop per cell on 100% load
This implicitely defines the internal resistance
to maximum current ratio and assumes linearity.
0.07
+ V
Number of cells
Defines the number of cells the attached battery consists of.
3
+ S
Battery capacity
diff --git a/src/AutoPilotPlugins/PX4/PowerComponent.cc b/src/AutoPilotPlugins/PX4/PowerComponent.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5a3ff31f173892e51f9835a106a3c6d1dac26ca1
--- /dev/null
+++ b/src/AutoPilotPlugins/PX4/PowerComponent.cc
@@ -0,0 +1,118 @@
+/*=====================================================================
+
+ QGroundControl Open Source Ground Control Station
+
+ (c) 2009 - 2015 QGROUNDCONTROL PROJECT
+
+ This file is part of the QGROUNDCONTROL project
+
+ QGROUNDCONTROL is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ QGROUNDCONTROL is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QGROUNDCONTROL. If not, see .
+
+ ======================================================================*/
+
+/// @file
+/// @author Gus Grubba
+
+#include "PowerComponent.h"
+#include "PX4RCCalibration.h"
+#include "QGCQmlWidgetHolder.h"
+#include "PX4AutoPilotPlugin.h"
+
+PowerComponent::PowerComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
+ PX4Component(uas, autopilot, parent),
+ _name(tr("Power"))
+{
+}
+
+QString PowerComponent::name(void) const
+{
+ return _name;
+}
+
+QString PowerComponent::description(void) const
+{
+ return tr("The Power Component is used to setup battery parameters as well as advanced settings for propellers and magnetometer.");
+}
+
+QString PowerComponent::iconResource(void) const
+{
+ return "PowerComponentIcon.png";
+}
+
+bool PowerComponent::requiresSetup(void) const
+{
+ return true;
+}
+
+bool PowerComponent::setupComplete(void) const
+{
+ QVariant cvalue, evalue, nvalue;
+ if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "BAT_V_CHARGED", cvalue)) {
+ if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "BAT_V_EMPTY", evalue)) {
+ if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "BAT_N_CELLS", nvalue)) {
+ return (cvalue.toFloat() > 0.1f) && (evalue.toFloat() > 0.1f) && (nvalue.toInt() > 0);
+ }
+ }
+ }
+ Q_ASSERT(false);
+ return false;
+}
+
+QString PowerComponent::setupStateDescription(void) const
+{
+ const char* stateDescription;
+
+ if (requiresSetup()) {
+ stateDescription = "Requires setup";
+ } else {
+ stateDescription = "Setup complete";
+ }
+ return QString(stateDescription);
+}
+
+QStringList PowerComponent::setupCompleteChangedTriggerList(void) const
+{
+ return QStringList();
+}
+
+QStringList PowerComponent::paramFilterList(void) const
+{
+ QStringList list;
+
+ return list;
+}
+
+QWidget* PowerComponent::setupWidget(void) const
+{
+ QGCQmlWidgetHolder* holder = new QGCQmlWidgetHolder();
+ Q_CHECK_PTR(holder);
+ holder->setAutoPilot(_autopilot);
+ holder->setSource(QUrl::fromUserInput("qrc:/qml/PowerComponent.qml"));
+ return holder;
+}
+
+QUrl PowerComponent::summaryQmlSource(void) const
+{
+ return QUrl::fromUserInput("qrc:/qml/PowerComponentSummary.qml");
+}
+
+QString PowerComponent::prerequisiteSetup(void) const
+{
+ PX4AutoPilotPlugin* plugin = dynamic_cast(_autopilot);
+ Q_ASSERT(plugin);
+ if (!plugin->airframeComponent()->setupComplete()) {
+ return plugin->airframeComponent()->name();
+ }
+ return QString();
+}
diff --git a/src/AutoPilotPlugins/PX4/PowerComponent.h b/src/AutoPilotPlugins/PX4/PowerComponent.h
new file mode 100644
index 0000000000000000000000000000000000000000..a89ef9a4acd611d827f65817cccec95dad74b595
--- /dev/null
+++ b/src/AutoPilotPlugins/PX4/PowerComponent.h
@@ -0,0 +1,60 @@
+/*=====================================================================
+
+ QGroundControl Open Source Ground Control Station
+
+ (c) 2009 - 2015 QGROUNDCONTROL PROJECT
+
+ This file is part of the QGROUNDCONTROL project
+
+ QGROUNDCONTROL is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ QGROUNDCONTROL is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QGROUNDCONTROL. If not, see .
+
+ ======================================================================*/
+
+#ifndef PowerComponent_H
+#define PowerComponent_H
+
+#include "PX4Component.h"
+
+/// @file
+/// @brief Battery, propeller and magnetometer settings
+/// @author Gus Grubba
+
+class PowerComponent : public PX4Component
+{
+ Q_OBJECT
+
+public:
+ PowerComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
+
+ // Virtuals from PX4Component
+ virtual QStringList setupCompleteChangedTriggerList(void) const;
+
+ // Virtuals from VehicleComponent
+ virtual QString name (void) const;
+ virtual QString description (void) const;
+ virtual QString iconResource (void) const;
+ virtual bool requiresSetup (void) const;
+ virtual bool setupComplete (void) const;
+ virtual QString setupStateDescription (void) const;
+ virtual QWidget* setupWidget (void) const;
+ virtual QStringList paramFilterList (void) const;
+ virtual QUrl summaryQmlSource (void) const;
+ virtual QString prerequisiteSetup (void) const;
+
+private:
+ const QString _name;
+ QVariantList _summaryItems;
+};
+
+#endif
diff --git a/src/AutoPilotPlugins/PX4/PowerComponent.qml b/src/AutoPilotPlugins/PX4/PowerComponent.qml
new file mode 100644
index 0000000000000000000000000000000000000000..0fc64b10882fe9ce7ace07aa839b77a359c82b98
--- /dev/null
+++ b/src/AutoPilotPlugins/PX4/PowerComponent.qml
@@ -0,0 +1,278 @@
+/*=====================================================================
+
+ QGroundControl Open Source Ground Control Station
+
+ (c) 2009 - 2015 QGROUNDCONTROL PROJECT
+
+ This file is part of the QGROUNDCONTROL project
+
+ QGROUNDCONTROL is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ QGROUNDCONTROL is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QGROUNDCONTROL. If not, see .
+
+ ======================================================================*/
+
+/// @file
+/// @brief Battery, propeller and magnetometer settings
+/// @author Gus Grubba
+
+import QtQuick 2.2
+import QtQuick.Controls 1.2
+import QtQuick.Controls.Styles 1.2
+
+import QGroundControl.FactSystem 1.0
+import QGroundControl.FactControls 1.0
+import QGroundControl.Palette 1.0
+import QGroundControl.Controls 1.0
+import QGroundControl.ScreenTools 1.0
+
+Rectangle {
+ QGCPalette { id: palette; colorGroupEnabled: true }
+
+ id: powerSettings
+ width: 600
+ height: 600
+ color: palette.window
+
+ property int firstColumnWidth: 220
+ property int textEditWidth: 60
+ property ScreenTools screenTools: ScreenTools { }
+
+ property Fact battNumCells: Fact { name: "BAT_N_CELLS" }
+ property Fact battHighVolt: Fact { name: "BAT_V_CHARGED" }
+ property Fact battLowVolt: Fact { name: "BAT_V_EMPTY" }
+
+ property alias battHigh: battHighRow
+ property alias battLow: battLowRow
+
+ function getBatteryImage()
+ {
+ switch(battNumCells.value) {
+ case 1: return "/qml/PowerComponentBattery_01cell.svg";
+ case 2: return "/qml/PowerComponentBattery_02cell.svg"
+ case 3: return "/qml/PowerComponentBattery_03cell.svg"
+ case 4: return "/qml/PowerComponentBattery_04cell.svg"
+ case 5: return "/qml/PowerComponentBattery_05cell.svg"
+ case 6: return "/qml/PowerComponentBattery_06cell.svg"
+ default: return "/qml/PowerComponentBattery_01cell.svg";
+ }
+ }
+
+ function drawArrowhead(ctx, x, y, radians)
+ {
+ ctx.save();
+ ctx.beginPath();
+ ctx.translate(x,y);
+ ctx.rotate(radians);
+ ctx.moveTo(0,0);
+ ctx.lineTo(5,10);
+ ctx.lineTo(-5,10);
+ ctx.closePath();
+ ctx.restore();
+ ctx.fill();
+ }
+
+ function drawLineWithArrow(ctx, x1, y1, x2, y2)
+ {
+ ctx.beginPath();
+ ctx.moveTo(x1, y1);
+ ctx.lineTo(x2, y2);
+ ctx.stroke();
+ var rd = Math.atan((y2 - y1) / (x2 - x1));
+ rd += ((x2 > x1) ? 90 : -90) * Math.PI/180;
+ drawArrowhead(ctx, x2, y2, rd);
+ }
+
+ Column {
+ anchors.fill: parent
+ spacing: 10
+
+ QGCLabel {
+ text: "POWER CONFIG"
+ font.pointSize: 20 * screenTools.dpiFactor;
+ }
+
+ QGCLabel {
+ text: "Battery"
+ color: palette.text
+ font.pointSize: 20 * screenTools.dpiFactor;
+ }
+
+ Rectangle {
+ width: parent.width
+ height: 160
+ color: palette.windowShade
+
+ Column {
+ id: batteryColumn
+ spacing: 10
+ anchors.verticalCenter: parent.verticalCenter
+ x: (parent.x + 20)
+
+ Row {
+ spacing: 10
+ Column {
+ id: voltageCol
+ spacing: 10
+ Row {
+ spacing: 10
+ QGCLabel { text: "Number of Cells (in Series)"; width: firstColumnWidth; anchors.baseline: cellsField.baseline}
+ FactTextField {
+ id: cellsField
+ width: textEditWidth
+ fact: Fact { name: "BAT_N_CELLS" }
+ showUnits: true
+ }
+ }
+ Row {
+ id: battHighRow
+ spacing: 10
+ QGCLabel { text: "Full Voltage (per cell)"; width: firstColumnWidth; anchors.baseline: battHighField.baseline}
+ FactTextField {
+ id: battHighField
+ width: textEditWidth
+ fact: Fact { name: "BAT_V_CHARGED" }
+ showUnits: true
+ }
+ }
+ Row {
+ id: battLowRow
+ spacing: 10
+ QGCLabel { text: "Empty Voltage (per cell)"; width: firstColumnWidth; anchors.baseline: battLowField.baseline}
+ FactTextField {
+ id: battLowField
+ width: textEditWidth
+ fact: Fact { name: "BAT_V_EMPTY" }
+ showUnits: true
+ }
+ }
+ Row {
+ spacing: 10
+ visible: showAdvanced.checked
+ QGCLabel { text: "Voltage Drop on Full Load (per cell)"; width: firstColumnWidth; anchors.baseline: battDropField.baseline}
+ FactTextField {
+ id: battDropField
+ width: textEditWidth
+ fact: Fact { name: "BAT_V_LOAD_DROP" }
+ showUnits: true
+ }
+ }
+ }
+ Canvas {
+ id: arrows
+ height: voltageCol.height
+ width: 40
+ antialiasing: true
+ Connections {
+ target: screenTools
+ onRepaintRequestedChanged: {
+ arrows.requestPaint();
+ }
+ }
+ onPaint: {
+ var y0 = voltageCol.mapFromItem(battHigh, 0, battHigh.height / 2).y;
+ var y1 = voltageCol.mapFromItem(battLow, 0, battLow.height / 2).y;
+ var context = getContext("2d");
+ context.reset();
+ context.strokeStyle = palette.button;
+ context.fillStyle = palette.button;
+ drawLineWithArrow(context, 0, y0, width, height * 0.25);
+ drawLineWithArrow(context, 0, y1, width, height * 0.85);
+ }
+ }
+ QGCColoredImage {
+ height: voltageCol.height
+ width: voltageCol.height * 0.75
+ source: getBatteryImage();
+ fillMode: Image.PreserveAspectFit
+ smooth: true
+ color: palette.button
+ cache: false
+ }
+ Item { width: 20; height: 1; }
+ Column {
+ spacing: 10
+ anchors.verticalCenter: parent.verticalCenter
+ Row {
+ spacing: 10
+ QGCLabel {
+ text: "Battery Max:"
+ color: palette.text
+ width: 80
+ font.pointSize: 12 * screenTools.dpiFactor;
+ }
+ QGCLabel {
+ text: (battNumCells.value * battHighVolt.value).toFixed(1) + ' V'
+ color: palette.text
+ font.pointSize: 12 * screenTools.dpiFactor;
+ }
+ }
+ Row {
+ spacing: 10
+ QGCLabel {
+ text: "Battery Min:"
+ color: palette.text
+ width: 80
+ font.pointSize: 12 * screenTools.dpiFactor;
+ }
+ QGCLabel {
+ text: (battNumCells.value * battLowVolt.value).toFixed(1) + ' V'
+ color: palette.text
+ font.pointSize: 12 * screenTools.dpiFactor;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ Row {
+ width: parent.width
+ spacing: 30
+ visible: showAdvanced.checked
+ Column {
+ spacing: 10
+ width: (parent.width / 2) - 5
+ QGCLabel {
+ text: "Propeller Function"
+ color: palette.text
+ font.pointSize: 20 * screenTools.dpiFactor;
+ }
+ Rectangle {
+ width: parent.width
+ height: 160
+ color: palette.windowShade
+ }
+ }
+ Column {
+ spacing: 10
+ width: (parent.width / 2) - 5
+ QGCLabel {
+ text: "Magnetometer Distortion"
+ color: palette.text
+ font.pointSize: 20 * screenTools.dpiFactor;
+ }
+ Rectangle {
+ width: parent.width
+ height: 160
+ color: palette.windowShade
+ }
+
+ }
+ }
+ //-- Advanced Settings
+ QGCCheckBox {
+ id: showAdvanced
+ text: "Show Advanced Settings"
+ }
+ }
+}
diff --git a/src/AutoPilotPlugins/PX4/PowerComponentSummary.qml b/src/AutoPilotPlugins/PX4/PowerComponentSummary.qml
new file mode 100644
index 0000000000000000000000000000000000000000..f2cc77661621bf3927ad04aa3b8c70dac000d573
--- /dev/null
+++ b/src/AutoPilotPlugins/PX4/PowerComponentSummary.qml
@@ -0,0 +1,80 @@
+/*=====================================================================
+
+ QGroundControl Open Source Ground Control Station
+
+ (c) 2009 - 2015 QGROUNDCONTROL PROJECT
+
+ This file is part of the QGROUNDCONTROL project
+
+ QGROUNDCONTROL is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ QGROUNDCONTROL is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QGROUNDCONTROL. If not, see .
+
+ ======================================================================*/
+
+/// @file
+/// @brief Battery, propeller and magnetometer summary
+/// @author Gus Grubba
+
+import QtQuick 2.2
+import QtQuick.Controls 1.2
+import QtQuick.Controls.Styles 1.2
+
+import QGroundControl.FactSystem 1.0
+import QGroundControl.FactControls 1.0
+import QGroundControl.Controls 1.0
+
+Column {
+ anchors.fill: parent
+ anchors.margins: 8
+
+ Row {
+ width: parent.width
+ QGCLabel { id: battFull; text: "Battery Full:" }
+ FactLabel {
+ fact: Fact { name: "BAT_V_CHARGED" }
+ horizontalAlignment: Text.AlignRight;
+ width: parent.width - battFull.contentWidth;
+ }
+ }
+
+ Row {
+ width: parent.width
+ QGCLabel { id: battEmpty; text: "Battery Empty:" }
+ FactLabel {
+ fact: Fact { name: "BAT_V_EMPTY" }
+ horizontalAlignment: Text.AlignRight;
+ width: parent.width - battEmpty.contentWidth;
+ }
+ }
+
+ Row {
+ width: parent.width
+ QGCLabel { id: battCells; text: "Number of Cells:" }
+ FactLabel {
+ fact: Fact { name: "BAT_N_CELLS" }
+ horizontalAlignment: Text.AlignRight;
+ width: parent.width - battCells.contentWidth;
+ }
+ }
+
+ Row {
+ width: parent.width
+ QGCLabel { id: battDrop; text: "Voltage Drop:" }
+ FactLabel {
+ fact: Fact { name: "BAT_V_LOAD_DROP" }
+ horizontalAlignment: Text.AlignRight;
+ width: parent.width - battDrop.contentWidth;
+ }
+ }
+
+}
diff --git a/src/AutoPilotPlugins/PX4/SafetyComponent.qml b/src/AutoPilotPlugins/PX4/SafetyComponent.qml
index 42ca8cc0ecbfa9ca85e7cf0eb6db265a78083226..3721300f7d7aef7e9500f079283749e26fe11eed 100644
--- a/src/AutoPilotPlugins/PX4/SafetyComponent.qml
+++ b/src/AutoPilotPlugins/PX4/SafetyComponent.qml
@@ -201,7 +201,7 @@ Rectangle {
y: parent.height - height - 20
width: 80
height: parent.height / 2
- source: "/qml/SafetyComponentTree.png"
+ source: "/qml/SafetyComponentTree.svg"
fillMode: Image.Stretch
smooth: true
color: palette.windowShadeDark
@@ -212,8 +212,8 @@ Rectangle {
y: parent.height - height
width: 100
height: parent.height * .75
- source: "/qml/SafetyComponentTree.png"
- fillMode: Image.Stretch
+ source: "/qml/SafetyComponentTree.svg"
+ fillMode: Image.PreserveAspectFit
smooth: true
color: palette.button
}
diff --git a/src/FactSystem/Fact.cc b/src/FactSystem/Fact.cc
index 860fd1c5ee72f38390e93b833522ae4b08d9d675..bed0ddf213786edb2c83b656b22770a117c8944b 100644
--- a/src/FactSystem/Fact.cc
+++ b/src/FactSystem/Fact.cc
@@ -39,7 +39,27 @@ Fact::Fact(QString name, FactMetaData::ValueType_t type, QObject* parent) :
void Fact::setValue(const QVariant& value)
{
- _value = value;
+ switch (type()) {
+ case FactMetaData::valueTypeInt8:
+ case FactMetaData::valueTypeInt16:
+ case FactMetaData::valueTypeInt32:
+ _value.setValue(QVariant(value.toInt()));
+ break;
+
+ case FactMetaData::valueTypeUint8:
+ case FactMetaData::valueTypeUint16:
+ case FactMetaData::valueTypeUint32:
+ _value.setValue(value.toUInt());
+ break;
+
+ case FactMetaData::valueTypeFloat:
+ _value.setValue(value.toFloat());
+ break;
+
+ case FactMetaData::valueTypeDouble:
+ _value.setValue(value.toDouble());
+ break;
+ }
emit valueChanged(_value);
emit _containerValueChanged(_value);
}
diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc
index 631649ba496558b333130b48a36b258fc83bff74..df3d9e272f359697c90750d6e8ecf32dd80109eb 100644
--- a/src/QGCApplication.cc
+++ b/src/QGCApplication.cc
@@ -59,7 +59,7 @@
#include "QGCTemporaryFile.h"
#include "QGCFileDialog.h"
#include "QGCPalette.h"
-#include "MousePosition.h"
+#include "ScreenTools.h"
#ifdef QGC_RTLAB_ENABLED
#include "OpalLink.h"
@@ -252,7 +252,7 @@ void QGCApplication::_initCommon(void)
// Register our Qml objects
qmlRegisterType("QGroundControl.Palette", 1, 0, "QGCPalette");
- qmlRegisterType("QGroundControl.MousePosition", 1, 0, "MousePosition");
+ qmlRegisterType("QGroundControl.ScreenTools", 1, 0, "ScreenTools");
}
bool QGCApplication::_initForNormalAppBoot(void)
diff --git a/src/QmlControls/MousePosition.cc b/src/QmlControls/MousePosition.cc
deleted file mode 100644
index 594f313e1068a0c7d01655728154c044906664f8..0000000000000000000000000000000000000000
--- a/src/QmlControls/MousePosition.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-/*=====================================================================
-
- QGroundControl Open Source Ground Control Station
-
- (c) 2009, 2015 QGROUNDCONTROL PROJECT
-
- This file is part of the QGROUNDCONTROL project
-
- QGROUNDCONTROL is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- QGROUNDCONTROL is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with QGROUNDCONTROL. If not, see .
-
- ======================================================================*/
-
-/// @file
-/// @author Don Gagne
-
-#include "MousePosition.h"
-
-MousePosition::MousePosition(void)
-{
-
-}
diff --git a/src/QmlControls/QGCButton.qml b/src/QmlControls/QGCButton.qml
index a3d31b2670236c2b44baa9fb7347caf2acfb2aea..19a76ffe31eedfa7a1b5c14ef4488228502ab687 100644
--- a/src/QmlControls/QGCButton.qml
+++ b/src/QmlControls/QGCButton.qml
@@ -4,7 +4,7 @@ import QtQuick.Controls.Styles 1.2
import QtQuick.Controls.Private 1.0
import QGroundControl.Palette 1.0
-import QGroundControl.MousePosition 1.0
+import QGroundControl.ScreenTools 1.0
Button {
// primary: true - this is the primary button for this group of buttons
@@ -23,17 +23,17 @@ Button {
property int __lastGlobalMouseX: 0
property int __lastGlobalMouseY: 0
- property MousePosition __globalMousePosition: MousePosition { }
+ property ScreenTools __screenTools: ScreenTools { }
Connections {
target: __behavior
onMouseXChanged: {
- __lastGlobalMouseX = __globalMousePosition.mouseX
- __lastGlobalMouseY = __globalMousePosition.mouseY
+ __lastGlobalMouseX = __screenTools.mouseX
+ __lastGlobalMouseY = __screenTools.mouseY
}
onMouseYChanged: {
- __lastGlobalMouseX = __globalMousePosition.mouseX
- __lastGlobalMouseY = __globalMousePosition.mouseY
+ __lastGlobalMouseX = __screenTools.mouseX
+ __lastGlobalMouseY = __screenTools.mouseY
}
onEntered: { __forceHoverOff; false; hoverTimer.start() }
onExited: { __forceHoverOff; false; hoverTimer.stop() }
@@ -45,7 +45,7 @@ Button {
repeat: true
onTriggered: {
- if (__lastGlobalMouseX != __globalMousePosition.mouseX || __lastGlobalMouseY != __globalMousePosition.mouseY) {
+ if (__lastGlobalMouseX != __screenTools.mouseX || __lastGlobalMouseY != __screenTools.mouseY) {
__forceHoverOff = true
} else {
__forceHoverOff = false
diff --git a/src/QmlControls/QGCColoredImage.qml b/src/QmlControls/QGCColoredImage.qml
index 72e4ee77580ddd6aab3504edf31e2b5e4e179b44..c6d7a43277804d04ea29669eb82379c28ea828e7 100644
--- a/src/QmlControls/QGCColoredImage.qml
+++ b/src/QmlControls/QGCColoredImage.qml
@@ -1,4 +1,4 @@
-import QtQuick 2.2
+import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtGraphicalEffects 1.0
@@ -17,6 +17,7 @@ Item {
property alias paintedWidth: image.paintedWidth
property alias progress: image.progress
property alias smooth: image.smooth
+ property alias mipmap: image.mipmap
property alias source: image.source
property alias sourceSize: image.sourceSize
property alias status: image.status
@@ -28,6 +29,7 @@ Item {
Image {
id: image
smooth: true
+ mipmap: true
visible: false
anchors.fill: parent
}
@@ -37,4 +39,4 @@ Item {
source: image
color: parent.color
}
-}
\ No newline at end of file
+}
diff --git a/src/QmlControls/ScreenTools.cc b/src/QmlControls/ScreenTools.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5501a0d4afda9082bc0610cb9a8ace0dfaa5c1d1
--- /dev/null
+++ b/src/QmlControls/ScreenTools.cc
@@ -0,0 +1,48 @@
+/*=====================================================================
+
+ QGroundControl Open Source Ground Control Station
+
+ (c) 2009, 2015 QGROUNDCONTROL PROJECT
+
+ This file is part of the QGROUNDCONTROL project
+
+ QGROUNDCONTROL is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ QGROUNDCONTROL is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QGROUNDCONTROL. If not, see .
+
+ ======================================================================*/
+
+/// @file
+/// @author Gus Grubba
+
+#include "ScreenTools.h"
+#include "MainWindow.h"
+
+ScreenTools::ScreenTools()
+ : _dotsPerInch(96.0)
+ , _dpiFactor( 72.0 / 96.0)
+{
+ // Get screen DPI to manage font sizes on different platforms
+ QScreen *srn = QGuiApplication::screens().at(0); // TODO: Find current monitor as opposed to picking first one
+ if(srn && srn->logicalDotsPerInch() > 50.0) {
+ _dotsPerInch = (double)srn->logicalDotsPerInch(); // Font point sizes are based on Mac 72dpi
+ _dpiFactor = 72.0 / _dotsPerInch;
+ } else {
+ qWarning() << "System not reporting logical DPI, which is used to compute the appropriate font size. The default being used is 96dpi. If the text within buttons and UI elements are too big or too small, that's the reason.";
+ }
+ connect(MainWindow::instance(), &MainWindow::repaintCanvas, this, &ScreenTools::_updateCanvas);
+}
+
+void ScreenTools::_updateCanvas()
+{
+ emit repaintRequestedChanged();
+}
diff --git a/src/QmlControls/MousePosition.h b/src/QmlControls/ScreenTools.h
similarity index 50%
rename from src/QmlControls/MousePosition.h
rename to src/QmlControls/ScreenTools.h
index 64c7a3a4f5e72dee6a22b6d17f7349bddc278e50..839a8776014b445bda8e8a99ad654730b4b3a2b8 100644
--- a/src/QmlControls/MousePosition.h
+++ b/src/QmlControls/ScreenTools.h
@@ -1,50 +1,64 @@
/*=====================================================================
-
+
QGroundControl Open Source Ground Control Station
-
+
(c) 2009, 2015 QGROUNDCONTROL PROJECT
-
+
This file is part of the QGROUNDCONTROL project
-
+
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
-
+
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see .
-
+
======================================================================*/
/// @file
-/// @author Don Gagne
+/// @author Gus Grubba
-#ifndef MOUSEPOSITION_H
-#define MOUSEPOSITION_H
+#ifndef SCREENTOOLS_H
+#define SCREENTOOLS_H
#include
#include
-/// This Qml control is used to return global mouse positions. It is needed to fix
-/// a problem with hover state of buttons not being updated correctly if the mouse
-/// moves out of a QQuickWidget control.
-class MousePosition : public QObject
+/// This Qml control is used to return screen parameters
+class ScreenTools : public QObject
{
Q_OBJECT
-
public:
- MousePosition(void);
-
- Q_PROPERTY(int mouseX READ mouseX)
- Q_PROPERTY(int mouseY READ mouseY)
-
- int mouseX(void) { return QCursor::pos().x(); }
- int mouseY(void) { return QCursor::pos().y(); }
+ ScreenTools();
+
+ Q_PROPERTY(double screenDPI READ screenDPI CONSTANT)
+ Q_PROPERTY(double dpiFactor READ dpiFactor CONSTANT)
+ Q_PROPERTY(int mouseX READ mouseX)
+ Q_PROPERTY(int mouseY READ mouseY)
+ Q_PROPERTY(bool repaintRequested READ repaintRequested NOTIFY repaintRequestedChanged)
+
+ double screenDPI () { return _dotsPerInch; }
+ double dpiFactor () { return _dpiFactor; }
+ int mouseX () { return QCursor::pos().x(); }
+ int mouseY () { return QCursor::pos().y(); }
+ bool repaintRequested () { return true; }
+
+signals:
+ void repaintRequestedChanged();
+
+private slots:
+ void _updateCanvas();
+
+private:
+ double _dotsPerInch;
+ double _dpiFactor;
+
};
#endif
diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc
index 74f62565ba82221aa156b254d3eee091f3d2a75d..497ce927a4ac3b95b16a13caed87c16e87ca8b09 100644
--- a/src/ui/MainWindow.cc
+++ b/src/ui/MainWindow.cc
@@ -947,7 +947,7 @@ void MainWindow::connectCommonActions()
connect(_ui.actionSimulate, SIGNAL(triggered(bool)), this, SLOT(simulateLink(bool)));
// Update Tool Bar
- _mainToolBar->setCurrentView((MainToolBar::ViewType_t)_currentView);
+ _mainToolBar->setCurrentView(_currentView);
}
void MainWindow::_openUrl(const QString& url, const QString& errorMessage)
@@ -1173,6 +1173,10 @@ void MainWindow::_loadCurrentViewState(void)
// HIL dock widget are dynamic and don't take part in the saved window state, so this
// need to happen after we restore state
_showHILConfigurationWidgets();
+
+ // There is a bug in Qt where a Canvas element inside a QQuickWidget does not
+ // receive update requests. Here we emit a signal for them to get repainted.
+ emit repaintCanvas();
}
void MainWindow::_hideAllHilDockWidgets(void)
@@ -1371,22 +1375,3 @@ void MainWindow::_showQmlTestWidget(void)
new QmlTestWidget();
}
#endif
-
-// There is a bug in Qt where a Canvas element inside a QQuickWidget does not
-// receive update requests. We hook into this event and notify the tool bar
-// to update its canvas elements. If other QQuickWidgets start using Canvas
-// and this bug is not fixed, this should be turned into a signal emited by
-// MainWindow and the various QQuickWidgets that need it should connect to it.
-bool MainWindow::event(QEvent* e)
-{
- bool result = true;
- switch (e->type()) {
- case QEvent::Paint:
- result = QMainWindow::event(e);
- _mainToolBar->updateCanvas();
- return result;
- default:
- break;
- }
- return QMainWindow::event(e);
-}
diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h
index 7ba54971c71a0a3e267b98a1ea84e965ccea5eeb..b02fcd087645c165d0d78ef7225c462803b67f8c 100644
--- a/src/ui/MainWindow.h
+++ b/src/ui/MainWindow.h
@@ -205,6 +205,8 @@ signals:
void initStatusChanged(const QString& message, int alignment, const QColor &color);
/** Emitted when any value changes from any source */
void valueChanged(const int uasId, const QString& name, const QString& unit, const QVariant& value, const quint64 msec);
+ /** Emitted when any the Canvas elements within QML wudgets need updating */
+ void repaintCanvas();
#ifdef QGC_MOUSE_ENABLED_LINUX
/** @brief Forward X11Event to catch 3DMouse inputs */
@@ -219,8 +221,6 @@ public:
protected:
- bool event(QEvent *);
-
typedef enum _VIEW_SECTIONS
{
VIEW_ENGINEER, // Engineering/Analyze view mode. Used for analyzing data and modifying onboard parameters
diff --git a/src/ui/toolbar/MainToolBar.cc b/src/ui/toolbar/MainToolBar.cc
index 1a708e4e4e7e31e5143ae211586c4168cd74d37d..50f66d8a06798f54487d58804fed2898dfaa6af0 100644
--- a/src/ui/toolbar/MainToolBar.cc
+++ b/src/ui/toolbar/MainToolBar.cc
@@ -30,8 +30,8 @@ This file is part of the QGROUNDCONTROL project
#include
#include
-#include "MainWindow.h"
#include "MainToolBar.h"
+#include "MainWindow.h"
#include "UASMessageHandler.h"
#include "UASMessageView.h"
@@ -55,7 +55,6 @@ MainToolBar::MainToolBar(QWidget* parent)
, _currentNormalCount(0)
, _currentMessageType(MessageNone)
, _satelliteCount(-1)
- , _dotsPerInch(96.0) // Default to Windows as it's more likely not to report below
, _satelliteLock(0)
, _showGPS(true)
, _showMav(true)
@@ -73,13 +72,6 @@ MainToolBar::MainToolBar(QWidget* parent)
if(pl) {
pl->setContentsMargins(0,0,0,0);
}
- // Get screen DPI to manage font sizes on different platforms
- QScreen *srn = QGuiApplication::screens().at(0); // TODO: Find current monitor as opposed to picking first one
- if(srn && srn->logicalDotsPerInch() > 50.0) {
- _dotsPerInch = (qreal)srn->logicalDotsPerInch(); // Font point sizes are based on Mac 72dpi
- } else {
- qWarning() << "System not reporting logical DPI, which is used to compute the appropriate font size. The default being used is 96dpi. If the text within buttons and UI elements are too big or too small, that's the reason.";
- }
// Tool Bar Preferences
QSettings settings;
@@ -138,25 +130,25 @@ void MainToolBar::viewStateChanged(const QString &key, bool value)
void MainToolBar::onSetupView()
{
- setCurrentView(ViewSetup);
+ setCurrentView(MainWindow::VIEW_SETUP);
MainWindow::instance()->loadSetupView();
}
void MainToolBar::onPlanView()
{
- setCurrentView(ViewPlan);
+ setCurrentView(MainWindow::VIEW_MISSION);
MainWindow::instance()->loadOperatorView();
}
void MainToolBar::onFlyView()
{
- setCurrentView(ViewFly);
+ setCurrentView(MainWindow::VIEW_FLIGHT);
MainWindow::instance()->loadPilotView();
}
void MainToolBar::onAnalyzeView()
{
- setCurrentView(ViewAnalyze);
+ setCurrentView(MainWindow::VIEW_ENGINEER);
MainWindow::instance()->loadEngineerView();
}
@@ -655,8 +647,3 @@ void MainToolBar::_setSatLoc(UASInterface*, int fix)
emit satelliteLockChanged(_satelliteLock);
}
}
-
-void MainToolBar::updateCanvas()
-{
- emit repaintRequestedChanged();
-}
diff --git a/src/ui/toolbar/MainToolBar.h b/src/ui/toolbar/MainToolBar.h
index f903127e8bb15bf93f053619a5c5f73af6703896..0a7ff584debf01996588298ba10499643b1d3b07 100644
--- a/src/ui/toolbar/MainToolBar.h
+++ b/src/ui/toolbar/MainToolBar.h
@@ -92,13 +92,11 @@ public:
Q_PROPERTY(QStringList connectedList READ connectedList NOTIFY connectedListChanged)
Q_PROPERTY(bool mavPresent READ mavPresent NOTIFY mavPresentChanged)
Q_PROPERTY(QString currentState READ currentState NOTIFY currentStateChanged)
- Q_PROPERTY(double dotsPerInch READ dotsPerInch NOTIFY dotsPerInchChanged)
Q_PROPERTY(int satelliteLock READ satelliteLock NOTIFY satelliteLockChanged)
Q_PROPERTY(bool showGPS READ showGPS NOTIFY showGPSChanged)
Q_PROPERTY(bool showMav READ showMav NOTIFY showMavChanged)
Q_PROPERTY(bool showMessages READ showMessages NOTIFY showMessagesChanged)
Q_PROPERTY(bool showBattery READ showBattery NOTIFY showBatteryChanged)
- Q_PROPERTY(bool repaintRequested READ repaintRequested NOTIFY repaintRequestedChanged)
int connectionCount () { return _connectionCount; }
double batteryVoltage () { return _batteryVoltage; }
@@ -117,17 +115,14 @@ public:
QStringList connectedList () { return _connectedList; }
bool mavPresent () { return _mav != NULL; }
QString currentState () { return _currentState; }
- double dotsPerInch () { return _dotsPerInch; }
int satelliteLock () { return _satelliteLock; }
bool showGPS () { return _showGPS; }
bool showMav () { return _showMav; }
bool showMessages () { return _showMessages; }
bool showBattery () { return _showBattery; }
- bool repaintRequested () { return true; }
void setCurrentView (int currentView);
void viewStateChanged (const QString& key, bool value);
- void updateCanvas ();
signals:
void connectionCountChanged (int count);
@@ -147,13 +142,11 @@ signals:
void connectedListChanged (QStringList connectedList);
void mavPresentChanged (bool present);
void currentStateChanged (QString state);
- void dotsPerInchChanged ();
void satelliteLockChanged (int lock);
void showGPSChanged (bool value);
void showMavChanged (bool value);
void showMessagesChanged (bool value);
void showBatteryChanged (bool value);
- void repaintRequestedChanged ();
private slots:
void _setActiveUAS (UASInterface* active);
@@ -205,7 +198,6 @@ private:
MessageType_t _currentMessageType;
int _satelliteCount;
QStringList _connectedList;
- qreal _dotsPerInch;
int _satelliteLock;
bool _showGPS;
bool _showMav;
diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml
index c044fbc170996e72cc9d1f76bf9ec09a99a5755b..5f39ea290190f1ae4776c0b373718ae3c97a536f 100644
--- a/src/ui/toolbar/MainToolBar.qml
+++ b/src/ui/toolbar/MainToolBar.qml
@@ -35,14 +35,16 @@ import QGroundControl.Controls 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.MainToolBar 1.0
+import QGroundControl.ScreenTools 1.0
Rectangle {
property var qgcPal: QGCPalette { id: palette; colorGroupEnabled: true }
+ property ScreenTools screenTools: ScreenTools { }
+
property int cellSpacerSize: 4
property int cellHeight: 30
property int cellRadius: 3
- property double dpiFactor: (72.0 / mainToolBar.dotsPerInch);
property var colorBlue: "#1a6eaa"
property var colorGreen: "#079527"
@@ -133,13 +135,12 @@ Rectangle {
height: cellHeight
spacing: -12
anchors.verticalCenter: parent.verticalCenter
-
Connections {
- target: mainToolBar
+ target: screenTools
onRepaintRequestedChanged: {
- setupButton.repaintChevron = true;
- planButton.repaintChevron = true;
- flyButton.repaintChevron = true;
+ setupButton.repaintChevron = true;
+ planButton.repaintChevron = true;
+ flyButton.repaintChevron = true;
analyzeButton.repaintChevron = true;
}
}
@@ -240,7 +241,7 @@ Rectangle {
Text {
id: messageText
text: (mainToolBar.messageCount > 0) ? mainToolBar.messageCount : ''
- font.pointSize: 14 * dpiFactor
+ font.pointSize: 14 * screenTools.dpiFactor
font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
@@ -328,7 +329,7 @@ Rectangle {
Text {
id: satelitteText
text: (mainToolBar.satelliteCount > 0) ? mainToolBar.satelliteCount : ''
- font.pointSize: 14 * dpiFactor
+ font.pointSize: 14 * screenTools.dpiFactor
font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
@@ -363,7 +364,7 @@ Rectangle {
Text {
id: batteryText
text: mainToolBar.batteryVoltage.toFixed(1) + ' V';
- font.pointSize: 14 * dpiFactor
+ font.pointSize: 14 * screenTools.dpiFactor
font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
@@ -391,7 +392,7 @@ Rectangle {
Text {
id: armedStatusText
text: (mainToolBar.systemArmed) ? qsTr("ARMED") : qsTr("DISARMED")
- font.pointSize: 12 * dpiFactor
+ font.pointSize: 12 * screenTools.dpiFactor
font.weight: Font.DemiBold
anchors.centerIn: parent
color: (mainToolBar.systemArmed) ? colorOrangeText : colorGreenText
@@ -410,7 +411,7 @@ Rectangle {
Text {
id: stateStatusText
text: mainToolBar.currentState
- font.pointSize: 12 * dpiFactor
+ font.pointSize: 12 * screenTools.dpiFactor
font.weight: Font.DemiBold
anchors.centerIn: parent
color: (mainToolBar.currentState === "STANDBY") ? colorGreenText : colorRedText
@@ -431,7 +432,7 @@ Rectangle {
Text {
id: modeStatusText
text: mainToolBar.currentMode
- font.pointSize: 12 * dpiFactor
+ font.pointSize: 12 * screenTools.dpiFactor
font.weight: Font.DemiBold
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
@@ -452,7 +453,7 @@ Rectangle {
Text {
id: connectionStatusText
text: qsTr("CONNECTION LOST")
- font.pointSize: 14 * dpiFactor
+ font.pointSize: 14 * screenTools.dpiFactor
font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter