diff --git a/src/AutoPilotPlugins/PX4/ParameterFactMetaData.xml b/src/AutoPilotPlugins/PX4/ParameterFactMetaData.xml
index 9a27ed5a4d2ebbc79b4d7ed3bba599a6513719a0..8b7ea4f3db585edc8a4d16b812fafca7cf2c682d 100644
--- a/src/AutoPilotPlugins/PX4/ParameterFactMetaData.xml
+++ b/src/AutoPilotPlugins/PX4/ParameterFactMetaData.xml
@@ -24,6 +24,7 @@
Number of cells
Defines the number of cells the attached battery consists of.
3
+ S
Battery capacity
diff --git a/src/AutoPilotPlugins/PX4/PowerComponent.qml b/src/AutoPilotPlugins/PX4/PowerComponent.qml
index 1ebed13d752e129add8ac7cf877edca4ea813ec5..0fc64b10882fe9ce7ace07aa839b77a359c82b98 100644
--- a/src/AutoPilotPlugins/PX4/PowerComponent.qml
+++ b/src/AutoPilotPlugins/PX4/PowerComponent.qml
@@ -38,13 +38,14 @@ 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 ScreenTools screenTools: ScreenTools { }
property Fact battNumCells: Fact { name: "BAT_N_CELLS" }
property Fact battHighVolt: Fact { name: "BAT_V_CHARGED" }
@@ -97,13 +98,13 @@ Rectangle {
QGCLabel {
text: "POWER CONFIG"
- font.pointSize: 20 * __screenTools.dpiFactor;
+ font.pointSize: 20 * screenTools.dpiFactor;
}
QGCLabel {
text: "Battery"
color: palette.text
- font.pointSize: 20 * __screenTools.dpiFactor;
+ font.pointSize: 20 * screenTools.dpiFactor;
}
Rectangle {
@@ -124,7 +125,7 @@ Rectangle {
spacing: 10
Row {
spacing: 10
- QGCLabel { text: "Number of Cells"; width: firstColumnWidth; anchors.baseline: cellsField.baseline}
+ QGCLabel { text: "Number of Cells (in Series)"; width: firstColumnWidth; anchors.baseline: cellsField.baseline}
FactTextField {
id: cellsField
width: textEditWidth
@@ -171,6 +172,12 @@ Rectangle {
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;
@@ -201,12 +208,12 @@ Rectangle {
text: "Battery Max:"
color: palette.text
width: 80
- font.pointSize: 12 * __screenTools.dpiFactor;
+ font.pointSize: 12 * screenTools.dpiFactor;
}
QGCLabel {
text: (battNumCells.value * battHighVolt.value).toFixed(1) + ' V'
color: palette.text
- font.pointSize: 12 * __screenTools.dpiFactor;
+ font.pointSize: 12 * screenTools.dpiFactor;
}
}
Row {
@@ -215,12 +222,12 @@ Rectangle {
text: "Battery Min:"
color: palette.text
width: 80
- font.pointSize: 12 * __screenTools.dpiFactor;
+ font.pointSize: 12 * screenTools.dpiFactor;
}
QGCLabel {
text: (battNumCells.value * battLowVolt.value).toFixed(1) + ' V'
color: palette.text
- font.pointSize: 12 * __screenTools.dpiFactor;
+ font.pointSize: 12 * screenTools.dpiFactor;
}
}
}
@@ -238,7 +245,7 @@ Rectangle {
QGCLabel {
text: "Propeller Function"
color: palette.text
- font.pointSize: 20 * __screenTools.dpiFactor;
+ font.pointSize: 20 * screenTools.dpiFactor;
}
Rectangle {
width: parent.width
@@ -252,7 +259,7 @@ Rectangle {
QGCLabel {
text: "Magnetometer Distortion"
color: palette.text
- font.pointSize: 20 * __screenTools.dpiFactor;
+ font.pointSize: 20 * screenTools.dpiFactor;
}
Rectangle {
width: parent.width
diff --git a/src/QmlControls/ScreenTools.cc b/src/QmlControls/ScreenTools.cc
index 345819b596d54c39f6605cd002ae5039e348433f..5501a0d4afda9082bc0610cb9a8ace0dfaa5c1d1 100644
--- a/src/QmlControls/ScreenTools.cc
+++ b/src/QmlControls/ScreenTools.cc
@@ -39,5 +39,10 @@ ScreenTools::ScreenTools()
} 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/ScreenTools.h b/src/QmlControls/ScreenTools.h
index fbec19d782fff31093a7d1636565f2a4b102ed14..839a8776014b445bda8e8a99ad654730b4b3a2b8 100644
--- a/src/QmlControls/ScreenTools.h
+++ b/src/QmlControls/ScreenTools.h
@@ -37,16 +37,23 @@ class ScreenTools : public QObject
public:
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)
-
- double screenDPI(void) { return _dotsPerInch; }
- double dpiFactor(void) { return _dpiFactor; }
-
- int mouseX(void) { return QCursor::pos().x(); }
- int mouseY(void) { return QCursor::pos().y(); }
+ 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;
diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc
index 5576a1de4246cf9e2bbc0fd514a49ac1b458047e..b51420350e16562d42c385c7adce80a680028070 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)
@@ -1372,22 +1376,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 e8f88fd2c1c79e99469329c131bbe3f57d46fb8b..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"
@@ -130,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();
}
@@ -647,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 3f8d5415a504de0a0524ff6a56d0b0150cb0a28e..0a7ff584debf01996588298ba10499643b1d3b07 100644
--- a/src/ui/toolbar/MainToolBar.h
+++ b/src/ui/toolbar/MainToolBar.h
@@ -97,7 +97,6 @@ public:
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; }
@@ -121,11 +120,9 @@ public:
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);
@@ -150,7 +147,6 @@ signals:
void showMavChanged (bool value);
void showMessagesChanged (bool value);
void showBatteryChanged (bool value);
- void repaintRequestedChanged ();
private slots:
void _setActiveUAS (UASInterface* active);
diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml
index acf1f0b439a88c3bdf713d84048e395fb836c4d5..5f39ea290190f1ae4776c0b373718ae3c97a536f 100644
--- a/src/ui/toolbar/MainToolBar.qml
+++ b/src/ui/toolbar/MainToolBar.qml
@@ -40,7 +40,8 @@ import QGroundControl.ScreenTools 1.0
Rectangle {
property var qgcPal: QGCPalette { id: palette; colorGroupEnabled: true }
- property ScreenTools __screenTools: ScreenTools { }
+ property ScreenTools screenTools: ScreenTools { }
+
property int cellSpacerSize: 4
property int cellHeight: 30
property int cellRadius: 3
@@ -134,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;
}
}
@@ -241,7 +241,7 @@ Rectangle {
Text {
id: messageText
text: (mainToolBar.messageCount > 0) ? mainToolBar.messageCount : ''
- font.pointSize: 14 * __screenTools.dpiFactor
+ font.pointSize: 14 * screenTools.dpiFactor
font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
@@ -329,7 +329,7 @@ Rectangle {
Text {
id: satelitteText
text: (mainToolBar.satelliteCount > 0) ? mainToolBar.satelliteCount : ''
- font.pointSize: 14 * __screenTools.dpiFactor
+ font.pointSize: 14 * screenTools.dpiFactor
font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
@@ -364,7 +364,7 @@ Rectangle {
Text {
id: batteryText
text: mainToolBar.batteryVoltage.toFixed(1) + ' V';
- font.pointSize: 14 * __screenTools.dpiFactor
+ font.pointSize: 14 * screenTools.dpiFactor
font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
@@ -392,7 +392,7 @@ Rectangle {
Text {
id: armedStatusText
text: (mainToolBar.systemArmed) ? qsTr("ARMED") : qsTr("DISARMED")
- font.pointSize: 12 * __screenTools.dpiFactor
+ font.pointSize: 12 * screenTools.dpiFactor
font.weight: Font.DemiBold
anchors.centerIn: parent
color: (mainToolBar.systemArmed) ? colorOrangeText : colorGreenText
@@ -411,7 +411,7 @@ Rectangle {
Text {
id: stateStatusText
text: mainToolBar.currentState
- font.pointSize: 12 * __screenTools.dpiFactor
+ font.pointSize: 12 * screenTools.dpiFactor
font.weight: Font.DemiBold
anchors.centerIn: parent
color: (mainToolBar.currentState === "STANDBY") ? colorGreenText : colorRedText
@@ -432,7 +432,7 @@ Rectangle {
Text {
id: modeStatusText
text: mainToolBar.currentMode
- font.pointSize: 12 * __screenTools.dpiFactor
+ font.pointSize: 12 * screenTools.dpiFactor
font.weight: Font.DemiBold
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
@@ -453,7 +453,7 @@ Rectangle {
Text {
id: connectionStatusText
text: qsTr("CONNECTION LOST")
- font.pointSize: 14 * __screenTools.dpiFactor
+ font.pointSize: 14 * screenTools.dpiFactor
font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter