From e3d7e12953c05bbf21be9a3300a5963b50a6d7f6 Mon Sep 17 00:00:00 2001
From: dogmaphobic <mavlink@grubba.com>
Date: Wed, 4 Mar 2015 12:44:46 -0500
Subject: [PATCH] Chevron buttons in Main Tool Bar

---
 qgroundcontrol.qrc                   |  13 +-
 src/QmlControls/QGCToolBarButton.qml |  58 ++++
 src/QmlControls/qmldir               |   1 +
 src/ui/MainWindow.cc                 |  18 ++
 src/ui/MainWindow.h                  |   2 +
 src/ui/toolbar/MainToolBar.cc        |   5 +
 src/ui/toolbar/MainToolBar.h         |   4 +
 src/ui/toolbar/MainToolBar.qml       | 535 ++++++++++++++++++-----------------
 8 files changed, 367 insertions(+), 269 deletions(-)
 create mode 100644 src/QmlControls/QGCToolBarButton.qml

diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index 45b585b..a75fe66 100644
--- a/qgroundcontrol.qrc
+++ b/qgroundcontrol.qrc
@@ -247,13 +247,11 @@
     <qresource prefix="/qml">
         <file alias="test.qml">src/test.qml</file>
         <file alias="QmlTest.qml">src/QmlControls/QmlTest.qml</file>
-
         <file alias="QGroundControl/FactControls/qmldir">src/FactSystem/FactControls/qmldir</file>
         <file alias="QGroundControl/FactControls/FactLabel.qml">src/FactSystem/FactControls/FactLabel.qml</file>
         <file alias="QGroundControl/FactControls/FactTextField.qml">src/FactSystem/FactControls/FactTextField.qml</file>
         <file alias="QGroundControl/FactControls/FactCheckBox.qml">src/FactSystem/FactControls/FactCheckBox.qml</file>
         <file alias="QGroundControl/FactControls/FactComboBox.qml">src/FactSystem/FactControls/FactComboBox.qml</file>
-
         <file alias="QGroundControl/Controls/qmldir">src/QmlControls/qmldir</file>
         <file alias="QGroundControl/Controls/SubMenuButton.qml">src/QmlControls/SubMenuButton.qml</file>
         <file alias="QGroundControl/Controls/IndicatorButton.qml">src/QmlControls/IndicatorButton.qml</file>
@@ -265,26 +263,21 @@
         <file alias="QGroundControl/Controls/QGCTextField.qml">src/QmlControls/QGCTextField.qml</file>
         <file alias="QGroundControl/Controls/QGCComboBox.qml">src/QmlControls/QGCComboBox.qml</file>
         <file alias="QGroundControl/Controls/QGCColoredImage.qml">src/QmlControls/QGCColoredImage.qml</file>
-
         <file alias="QGroundControl/Controls/arrow-down.png">src/QmlControls/arrow-down.png</file>
-
+        <file alias="QGroundControl/Controls/QGCToolBarButton.qml">src/QmlControls/QGCToolBarButton.qml</file>
         <file alias="octo_x.png">files/images/px4/airframes/octo_x.png</file>
         <file alias="px4fmu_2.x.png">files/images/px4/boards/px4fmu_2.x.png</file>
-
         <file alias="SetupViewButtons.qml">src/VehicleSetup/SetupViewButtons.qml</file>
         <file alias="VehicleSummary.qml">src/VehicleSetup/VehicleSummary.qml</file>
         <file alias="FirmwareUpgrade.qml">src/VehicleSetup/FirmwareUpgrade.qml</file>
-
         <file alias="SafetyComponent.qml">src/AutoPilotPlugins/PX4/SafetyComponent.qml</file>
         <file alias="SensorsComponent.qml">src/AutoPilotPlugins/PX4/SensorsComponent.qml</file>
-
         <file alias="SafetyComponentSummary.qml">src/AutoPilotPlugins/PX4/SafetyComponentSummary.qml</file>
         <file alias="SensorsComponentSummary.qml">src/AutoPilotPlugins/PX4/SensorsComponentSummary.qml</file>
         <file alias="SensorsComponentSummaryFixedWing.qml">src/AutoPilotPlugins/PX4/SensorsComponentSummaryFixedWing.qml</file>
         <file alias="RadioComponentSummary.qml">src/AutoPilotPlugins/PX4/RadioComponentSummary.qml</file>
         <file alias="FlightModesComponentSummary.qml">src/AutoPilotPlugins/PX4/FlightModesComponentSummary.qml</file>
         <file alias="AirframeComponentSummary.qml">src/AutoPilotPlugins/PX4/AirframeComponentSummary.qml</file>
-
         <file alias="SafetyComponentTree.png">src/AutoPilotPlugins/PX4/Images/SafetyComponentTree.png</file>
         <file alias="SafetyComponentHome.png">src/AutoPilotPlugins/PX4/Images/SafetyComponentHome.png</file>
         <file alias="SafetyComponentArrowDown.png">src/AutoPilotPlugins/PX4/Images/SafetyComponentArrowDown.png</file>
@@ -295,7 +288,6 @@
         <file alias="VehicleRight.png">src/AutoPilotPlugins/PX4/Images/VehicleRight.png</file>
         <file alias="VehicleNoseDown.png">src/AutoPilotPlugins/PX4/Images/VehicleNoseDown.png</file>
         <file alias="VehicleTailDown.png">src/AutoPilotPlugins/PX4/Images/VehicleTailDown.png</file>
-
         <file alias="QGroundControl/Controls/subMenuButtonImage.png">files/Setup/cogwheels.png</file>
         <file alias="QGroundControl/Controls/SensorsComponentIcon.png">src/AutoPilotPlugins/PX4/Images/SensorsComponentIcon.png</file>
         <file alias="QGroundControl/Controls/RadioComponentIcon.png">src/AutoPilotPlugins/PX4/Images/RadioComponentIcon.png</file>
@@ -304,8 +296,7 @@
         <file alias="QGroundControl/Controls/SafetyComponentIcon.png">src/AutoPilotPlugins/PX4/Images/SafetyComponentIcon.png</file>
         <file alias="QGroundControl/Controls/FirmwareUpgradeIcon.png">src/VehicleSetup/FirmwareUpgradeIcon.png</file>
         <file alias="QGroundControl/Controls/VehicleSummaryIcon.png">src/VehicleSetup/VehicleSummaryIcon.png</file>
-
-		<file alias="MainToolBar.qml">src/ui/toolbar/MainToolBar.qml</file>
+        <file alias="MainToolBar.qml">src/ui/toolbar/MainToolBar.qml</file>
     </qresource>
     <qresource prefix="/AutoPilotPlugins/PX4">
         <file alias="ParameterFactMetaData.xml">src/AutoPilotPlugins/PX4/ParameterFactMetaData.xml</file>
diff --git a/src/QmlControls/QGCToolBarButton.qml b/src/QmlControls/QGCToolBarButton.qml
new file mode 100644
index 0000000..dbe7044
--- /dev/null
+++ b/src/QmlControls/QGCToolBarButton.qml
@@ -0,0 +1,58 @@
+import QtQuick 2.2
+import QtQuick.Controls 1.2
+import QtQuick.Controls.Styles 1.2
+import QtQuick.Controls.Private 1.0
+
+import QGroundControl.Palette 1.0
+
+Button {
+    id: button
+    property bool repaintChevron: false
+    property var  __qgcPal: QGCPalette { colorGroupEnabled: enabled }
+    style: ButtonStyle {
+        background: Item {
+            anchors.margins: 3
+            Canvas {
+                id: chevron
+                anchors.fill: parent
+                antialiasing: true
+                Connections {
+                    target: button
+                    onHoveredChanged: chevron.requestPaint()
+                    onPressedChanged: chevron.requestPaint()
+                    onCheckedChanged: chevron.requestPaint()
+                    onRepaintChevronChanged: {
+                        if(repaintChevron) {
+                            chevron.requestPaint()
+                            repaintChevron = false;
+                        }
+                    }
+                }
+                onPaint: {
+                    var vMiddle = height / 2;
+                    var context = getContext("2d");
+                    context.reset();
+                    context.beginPath();
+                    context.lineWidth = 6;
+                    context.beginPath();
+                    context.moveTo(0, 0);
+                    context.lineTo(width - 12 - 3, 0);
+                    context.lineTo(width - 3, vMiddle);
+                    context.lineTo(width - 12 - 3, height);
+                    context.lineTo(0, height);
+                    context.closePath();
+                    context.strokeStyle = __qgcPal.windowShade
+                    context.fillStyle = (button.hovered && !button.pressed) ? __qgcPal.buttonHighlight : (button.checked ? __qgcPal.buttonHighlight : __qgcPal.button);
+                    context.stroke();
+                    context.fill();
+                }
+            }
+        }
+        label: Label {
+            text: button.text
+            horizontalAlignment: Text.AlignHCenter
+            verticalAlignment: Text.AlignVCenter
+            color: (button.hovered && !button.pressed) ? __qgcPal.buttonHighlightText : (button.checked ? __qgcPal.primaryButtonText : __qgcPal.buttonText)
+        }
+    }
+}
diff --git a/src/QmlControls/qmldir b/src/QmlControls/qmldir
index cc96afb..ea2f99d 100644
--- a/src/QmlControls/qmldir
+++ b/src/QmlControls/qmldir
@@ -7,6 +7,7 @@ QGCCheckBox 1.0 QGCCheckBox.qml
 QGCTextField 1.0 QGCTextField.qml
 QGCComboBox 1.0 QGCComboBox.qml
 QGCColoredImage 1.0 QGCColoredImage.qml
+QGCToolBarButton 1.0 QGCToolBarButton.qml
 
 SubMenuButton 1.0 SubMenuButton.qml
 IndicatorButton 1.0 IndicatorButton.qml
diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc
index d86f53a..5576a1d 100644
--- a/src/ui/MainWindow.cc
+++ b/src/ui/MainWindow.cc
@@ -1373,3 +1373,21 @@ void MainWindow::_showQmlTestWidget(void)
 }
 #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 788e6db..7ba5497 100644
--- a/src/ui/MainWindow.h
+++ b/src/ui/MainWindow.h
@@ -219,6 +219,8 @@ 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 fad4da2..1a708e4 100644
--- a/src/ui/toolbar/MainToolBar.cc
+++ b/src/ui/toolbar/MainToolBar.cc
@@ -655,3 +655,8 @@ 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 4984918..f903127 100644
--- a/src/ui/toolbar/MainToolBar.h
+++ b/src/ui/toolbar/MainToolBar.h
@@ -98,6 +98,7 @@ 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; }
@@ -122,9 +123,11 @@ 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,6 +153,7 @@ 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 c577c33..20fa6ee 100644
--- a/src/ui/toolbar/MainToolBar.qml
+++ b/src/ui/toolbar/MainToolBar.qml
@@ -40,8 +40,8 @@ Rectangle {
 
     property var qgcPal: QGCPalette { id: palette; colorGroupEnabled: true }
     property int cellSpacerSize: 4
-    property int cellHeight: 30
-    property int cellRadius: 3
+    property int cellHeight:     30
+    property int cellRadius:     3
     property double dpiFactor: (72.0 / mainToolBar.dotsPerInch);
 
     property var colorBlue:       "#1a6eaa"
@@ -117,325 +117,344 @@ Rectangle {
     }
 
     Row {
-        id: row1
-        height: cellHeight
-        anchors.left: parent.left
-        spacing:      cellSpacerSize
+        id:                     row1
+        height:                 cellHeight
+        anchors.left:           parent.left
+        spacing:                4
         anchors.verticalCenter: parent.verticalCenter
-        anchors.leftMargin: 10
-
-        ExclusiveGroup { id: mainActionGroup }
+        anchors.leftMargin:     10
 
-        QGCButton {
-            id: setupButton
-            width: 90
-            height: cellHeight
-            exclusiveGroup: mainActionGroup
-            text: qsTr("1. Setup")
+        Row {
+            id:                     row11
+            height:                 cellHeight
+            spacing:                -12
             anchors.verticalCenter: parent.verticalCenter
-            checked: (mainToolBar.currentView === MainToolBar.ViewSetup)
-            onClicked: {
-                mainToolBar.onSetupView();
+
+            Connections {
+                target: mainToolBar
+                onRepaintRequestedChanged: {
+                    setupButton.repaintChevron = true;
+                    planButton.repaintChevron = true;
+                    flyButton.repaintChevron = true;
+                    analyzeButton.repaintChevron = true;
+                }
             }
-        }
 
-        QGCButton {
-            id: planButton
-            width: 90
-            height: cellHeight
-            exclusiveGroup: mainActionGroup
-            text: qsTr("2. Plan")
-            anchors.verticalCenter: parent.verticalCenter
-            checked: (mainToolBar.currentView === MainToolBar.ViewPlan)
-            onClicked: {
-                mainToolBar.onPlanView();
+            ExclusiveGroup { id: mainActionGroup }
+
+            QGCToolBarButton {
+                id: setupButton
+                width: 100
+                height: cellHeight
+                exclusiveGroup: mainActionGroup
+                text: qsTr("1. Setup")
+                anchors.verticalCenter: parent.verticalCenter
+                checked: (mainToolBar.currentView === MainToolBar.ViewSetup)
+                onClicked: {
+                    mainToolBar.onSetupView();
+                }
+                z: 1000
             }
-        }
 
-        QGCButton {
-            id: flyButton
-            width: 90
-            height: cellHeight
-            exclusiveGroup: mainActionGroup
-            text: qsTr("3. Fly")
-            anchors.verticalCenter: parent.verticalCenter
-            checked: (mainToolBar.currentView === MainToolBar.ViewFly)
-            onClicked: {
-                mainToolBar.onFlyView();
+            QGCToolBarButton {
+                id: planButton
+                width: 100
+                height: cellHeight
+                exclusiveGroup: mainActionGroup
+                text: qsTr("2. Plan")
+                anchors.verticalCenter: parent.verticalCenter
+                checked: (mainToolBar.currentView === MainToolBar.ViewPlan)
+                onClicked: {
+                    mainToolBar.onPlanView();
+                }
+                z: 900
             }
-        }
 
-        QGCButton {
-            id: analyzeButton
-            width: 90
-            height: cellHeight
-            exclusiveGroup: mainActionGroup
-            text: qsTr("4. Analyze")
-            anchors.verticalCenter: parent.verticalCenter
-            checked: (mainToolBar.currentView === MainToolBar.ViewAnalyze)
-            onClicked: {
-                mainToolBar.onAnalyzeView();
+            QGCToolBarButton {
+                id: flyButton
+                width: 100
+                height: cellHeight
+                exclusiveGroup: mainActionGroup
+                text: qsTr("3. Fly")
+                anchors.verticalCenter: parent.verticalCenter
+                checked: (mainToolBar.currentView === MainToolBar.ViewFly)
+                onClicked: {
+                    mainToolBar.onFlyView();
+                }
+                z: 800
+            }
+
+            QGCToolBarButton {
+                id: analyzeButton
+                width: 100
+                height: cellHeight
+                exclusiveGroup: mainActionGroup
+                text: qsTr("4. Analyze")
+                anchors.verticalCenter: parent.verticalCenter
+                checked: (mainToolBar.currentView === MainToolBar.ViewAnalyze)
+                onClicked: {
+                    mainToolBar.onAnalyzeView();
+                }
+                z: 700
             }
-        }
 
-        Rectangle {
-            width: 4
-            height: cellHeight
-            color: "#00000000"
-            border.color: "#00000000"
-            border.width: 0
         }
 
-        Rectangle {
-            id: messages
-            width: (mainToolBar.newMessageCount > 99) ? 70 : 60
-            height: cellHeight
-            visible: (mainToolBar.connectionCount > 0) && (mainToolBar.showMessages)
+        Row {
+            id:                     row12
+            height:                 cellHeight
+            spacing:                cellSpacerSize
             anchors.verticalCenter: parent.verticalCenter
-            color:  getMessageColor()
-            radius: cellRadius
-            border.color: "#00000000"
-            border.width: 0
-            property bool showTriangle: false
-
-            Image {
-                id: messageIcon
-                source: getMessageIcon();
-                height: 16
-                fillMode: Image.PreserveAspectFit
-                anchors.verticalCenter: parent.verticalCenter
-                anchors.left: parent.left
-                anchors.leftMargin: 10
-            }
 
             Rectangle {
-                id: messageTextRect
+                id: messages
+                width: (mainToolBar.messageCount > 99) ? 70 : 60
+                height: cellHeight
+                visible: (mainToolBar.connectionCount > 0) && (mainToolBar.showMessages)
                 anchors.verticalCenter: parent.verticalCenter
-                anchors.right: parent.right
-                width: messages.width - messageIcon.width
-                Text {
-                    id: messageText
-                    text: (mainToolBar.newMessageCount > 0) ? mainToolBar.newMessageCount : ''
-                    font.pointSize: 14 * dpiFactor
-                    font.weight: Font.DemiBold
+                color:  getMessageColor()
+                radius: cellRadius
+                border.color: "#00000000"
+                border.width: 0
+                property bool showTriangle: false
+
+                Image {
+                    id: messageIcon
+                    source: getMessageIcon();
+                    height: 16
+                    fillMode: Image.PreserveAspectFit
                     anchors.verticalCenter: parent.verticalCenter
-                    anchors.horizontalCenter: parent.horizontalCenter
-                    horizontalAlignment: Text.AlignHCenter
-                    color: colorWhite
+                    anchors.left: parent.left
+                    anchors.leftMargin: 10
                 }
-            }
 
-            Image {
-                id: dropDown
-                source: "QGroundControl/Controls/arrow-down.png"
-                visible: (messages.showTriangle) && (mainToolBar.messageCount > 0)
-                anchors.bottom: parent.bottom
-                anchors.right: parent.right
-                anchors.bottomMargin: 3
-                anchors.rightMargin: 3
-            }
+                Rectangle {
+                    id: messageTextRect
+                    anchors.verticalCenter: parent.verticalCenter
+                    anchors.right: parent.right
+                    width: messages.width - messageIcon.width
+                    Text {
+                        id: messageText
+                        text: (mainToolBar.messageCount > 0) ? mainToolBar.messageCount : ''
+                        font.pointSize: 14 * dpiFactor
+                        font.weight: Font.DemiBold
+                        anchors.verticalCenter: parent.verticalCenter
+                        anchors.horizontalCenter: parent.horizontalCenter
+                        horizontalAlignment: Text.AlignHCenter
+                        color: colorWhite
+                    }
+                }
 
-            Timer {
-                id: mouseOffTimer
-                interval: 2000;
-                running: false;
-                repeat: false
-                onTriggered: {
-                    messages.showTriangle = false;
+                Image {
+                    id: dropDown
+                    source: "QGroundControl/Controls/arrow-down.png"
+                    visible: (messages.showTriangle) && (mainToolBar.messageCount > 0)
+                    anchors.bottom: parent.bottom
+                    anchors.right: parent.right
+                    anchors.bottomMargin: 3
+                    anchors.rightMargin: 3
                 }
-            }
 
-            MouseArea {
-                anchors.fill: parent
-                hoverEnabled: true
-                onEntered: {
-                    messages.showTriangle = true;
-                    mouseOffTimer.start();
+                Timer {
+                    id: mouseOffTimer
+                    interval: 2000;
+                    running: false;
+                    repeat: false
+                    onTriggered: {
+                        messages.showTriangle = false;
+                    }
                 }
-                onClicked: {
-                    if(mainToolBar.messageCount > 0) {
+
+                MouseArea {
+                    anchors.fill: parent
+                    hoverEnabled: true
+                    onEntered: {
+                        messages.showTriangle = true;
+                        mouseOffTimer.start();
+                    }
+                    onClicked: {
                         var p = mapToItem(toolBarHolder, mouseX, mouseY);
                         mainToolBar.onEnterMessageArea(p.x, p.y);
                     }
                 }
-            }
-
-        }
 
-        Rectangle {
-            id: mavIcon
-            width: cellHeight
-            height: cellHeight
-            visible: showMavStatus() &&  (mainToolBar.showMav)
-            anchors.verticalCenter: parent.verticalCenter
-            color: colorBlue
-            radius: cellRadius
-            border.color: "#00000000"
-            border.width: 0
-            Image {
-                source: mainToolBar.systemPixmap
-                height: cellHeight * 0.75
-                fillMode: Image.PreserveAspectFit
-                anchors.verticalCenter: parent.verticalCenter
-                anchors.horizontalCenter: parent.horizontalCenter
             }
-        }
 
-        Rectangle {
-            id: satelitte
-            width: 60
-            height: cellHeight
-            visible: showMavStatus()  && (mainToolBar.showGPS)
-            anchors.verticalCenter: parent.verticalCenter
-            color:  getSatelliteColor();
-            radius: cellRadius
-            border.color: "#00000000"
-            border.width: 0
-
-            Image {
-                source: "qrc:/files/images/status/gps.svg";
-                height: 24
-                fillMode: Image.PreserveAspectFit
+            Rectangle {
+                id: mavIcon
+                width: cellHeight
+                height: cellHeight
+                visible: showMavStatus() &&  (mainToolBar.showMav)
                 anchors.verticalCenter: parent.verticalCenter
-                anchors.left: parent.left
-                anchors.leftMargin: 10
-                mipmap: true
-                smooth: true
+                color: colorBlue
+                radius: cellRadius
+                border.color: "#00000000"
+                border.width: 0
+                Image {
+                    source: mainToolBar.systemPixmap
+                    height: cellHeight * 0.75
+                    fillMode: Image.PreserveAspectFit
+                    anchors.verticalCenter: parent.verticalCenter
+                    anchors.horizontalCenter: parent.horizontalCenter
+                }
             }
 
-            Text {
-                id: satelitteText
-                text: (mainToolBar.satelliteCount > 0) ? mainToolBar.satelliteCount : ''
-                font.pointSize: 14 * dpiFactor
-                font.weight: Font.DemiBold
+            Rectangle {
+                id: satelitte
+                width: 60
+                height: cellHeight
+                visible: showMavStatus() && (mainToolBar.showGPS)
                 anchors.verticalCenter: parent.verticalCenter
-                anchors.right: parent.right
-                anchors.rightMargin: 10
-                horizontalAlignment: Text.AlignRight
-                color: colorWhite
+                color:  getSatelliteColor();
+                radius: cellRadius
+                border.color: "#00000000"
+                border.width: 0
+
+                Image {
+                    source: "qrc:/files/images/status/gps.svg";
+                    height: 24
+                    fillMode: Image.PreserveAspectFit
+                    anchors.verticalCenter: parent.verticalCenter
+                    anchors.left: parent.left
+                    anchors.leftMargin: 10
+                    mipmap: true
+                    smooth: true
+                }
+
+                Text {
+                    id: satelitteText
+                    text: (mainToolBar.satelliteCount > 0) ? mainToolBar.satelliteCount : ''
+                    font.pointSize: 14 * dpiFactor
+                    font.weight: Font.DemiBold
+                    anchors.verticalCenter: parent.verticalCenter
+                    anchors.right: parent.right
+                    anchors.rightMargin: 10
+                    horizontalAlignment: Text.AlignRight
+                    color: colorWhite
+                }
             }
-        }
 
-        Rectangle {
-            id: battery
-            width: 80
-            height: cellHeight
-            visible: showMavStatus() && (mainToolBar.showBattery)
-            anchors.verticalCenter: parent.verticalCenter
-            color:  (mainToolBar.batteryPercent > 40.0 || mainToolBar.batteryPercent < 0.01) ? colorGreen : colorRed
-            radius: cellRadius
-            border.color: "#00000000"
-            border.width: 0
-
-            Image {
-                source: getBatteryIcon();
-                height: 20
-                fillMode: Image.PreserveAspectFit
+            Rectangle {
+                id: battery
+                width: 80
+                height: cellHeight
+                visible: showMavStatus() && (mainToolBar.showBattery)
                 anchors.verticalCenter: parent.verticalCenter
-                anchors.left: parent.left
-                anchors.leftMargin: 6
-                mipmap: true
-                smooth: true
+                color:  (mainToolBar.batteryPercent > 40.0 || mainToolBar.batteryPercent < 0.01) ? colorBlue : colorRed
+                radius: cellRadius
+                border.color: "#00000000"
+                border.width: 0
+
+                Image {
+                    source: getBatteryIcon();
+                    height: 20
+                    fillMode: Image.PreserveAspectFit
+                    anchors.verticalCenter: parent.verticalCenter
+                    anchors.left: parent.left
+                    anchors.leftMargin: 6
+                    mipmap: true
+                    smooth: true
+                }
+
+                Text {
+                    id: batteryText
+                    text: mainToolBar.batteryVoltage.toFixed(1) + ' V';
+                    font.pointSize: 14 * dpiFactor
+                    font.weight: Font.DemiBold
+                    anchors.verticalCenter: parent.verticalCenter
+                    anchors.right: parent.right
+                    anchors.rightMargin: 8
+                    horizontalAlignment: Text.AlignRight
+                    color: colorWhite
+                }
             }
 
-            Text {
-                id: batteryText
-                text: mainToolBar.batteryVoltage.toFixed(1) + ' V';
-                font.pointSize: 14 * dpiFactor
-                font.weight: Font.DemiBold
+            Column {
+                visible: showMavStatus()
+                height:  cellHeight * 0.85
+                width:   80
                 anchors.verticalCenter: parent.verticalCenter
-                anchors.right: parent.right
-                anchors.rightMargin: 8
-                horizontalAlignment: Text.AlignRight
-                color: colorWhite
-            }
-        }
 
-        Column {
-            visible: showMavStatus()
-            height:  cellHeight * 0.85
-            width:   80
-            anchors.verticalCenter: parent.verticalCenter
+                Rectangle {
+                    id: armedStatus
+                    width: parent.width
+                    height: parent.height / 2
+                    anchors.horizontalCenter: parent.horizontalCenter
+                    color: "#00000000"
+                    border.color: "#00000000"
+                    border.width: 0
+
+                    Text {
+                        id: armedStatusText
+                        text: (mainToolBar.systemArmed) ? qsTr("ARMED") :  qsTr("DISARMED")
+                        font.pointSize: 12 * dpiFactor
+                        font.weight: Font.DemiBold
+                        anchors.centerIn: parent
+                        color: (mainToolBar.systemArmed) ? colorRed : colorGreen
+                    }
+                }
+
+                Rectangle {
+                    id: stateStatus
+                    width: parent.width
+                    height: parent.height / 2
+                    anchors.horizontalCenter: parent.horizontalCenter
+                    color: "#00000000"
+                    border.color: "#00000000"
+                    border.width: 0
+
+                    Text {
+                        id: stateStatusText
+                        text: mainToolBar.currentState
+                        font.pointSize: 12 * dpiFactor
+                        font.weight: Font.DemiBold
+                        anchors.centerIn: parent
+                        color: (mainToolBar.currentState === "STANDBY") ? colorGreen : colorRed
+                    }
+                }
+
+            }
 
             Rectangle {
-                id: armedStatus
-                width: parent.width
-                height: parent.height / 2
-                anchors.horizontalCenter: parent.horizontalCenter
+                id: modeStatus
+                width: 90
+                height: cellHeight
+                visible: showMavStatus()
                 color: "#00000000"
                 border.color: "#00000000"
                 border.width: 0
 
                 Text {
-                    id: armedStatusText
-                    text: (mainToolBar.systemArmed) ? qsTr("ARMED") :  qsTr("DISARMED")
+                    id: modeStatusText
+                    text: mainToolBar.currentMode
                     font.pointSize: 12 * dpiFactor
                     font.weight: Font.DemiBold
-                    anchors.centerIn: parent
-                    color: (mainToolBar.systemArmed) ? colorRed : colorGreenText
+                    anchors.horizontalCenter: parent.horizontalCenter
+                    anchors.verticalCenter: parent.verticalCenter
+                    color: qgcPal.text
                 }
             }
 
             Rectangle {
-                id: stateStatus
-                width: parent.width
-                height: parent.height / 2
-                anchors.horizontalCenter: parent.horizontalCenter
+                id: connectionStatus
+                width: 160
+                height: cellHeight
+                visible: (mainToolBar.connectionCount > 0 && mainToolBar.mavPresent && mainToolBar.heartbeatTimeout != 0)
+                anchors.verticalCenter: parent.verticalCenter
                 color: "#00000000"
                 border.color: "#00000000"
                 border.width: 0
 
                 Text {
-                    id: stateStatusText
-                    text: mainToolBar.currentState
-                    font.pointSize: 12 * dpiFactor
+                    id: connectionStatusText
+                    text: qsTr("CONNECTION LOST")
+                    font.pointSize: 14 * dpiFactor
                     font.weight: Font.DemiBold
-                    anchors.centerIn: parent
-                    color: (mainToolBar.currentState === "STANDBY") ? colorGreenText : colorRed
+                    anchors.verticalCenter: parent.verticalCenter
+                    anchors.horizontalCenter: parent.horizontalCenter
+                    color: colorRed
                 }
             }
-
-        }
-
-        Rectangle {
-            id: modeStatus
-            width: 90
-            height: cellHeight
-            visible: showMavStatus()
-            color: "#00000000"
-            border.color: "#00000000"
-            border.width: 0
-
-            Text {
-                id: modeStatusText
-                text: mainToolBar.currentMode
-                font.pointSize: 12 * dpiFactor
-                font.weight: Font.DemiBold
-                anchors.horizontalCenter: parent.horizontalCenter
-                anchors.verticalCenter: parent.verticalCenter
-                color: qgcPal.text
-            }
-        }
-
-        Rectangle {
-            id: connectionStatus
-            width: 160
-            height: cellHeight
-            visible: (mainToolBar.connectionCount > 0 && mainToolBar.mavPresent && mainToolBar.heartbeatTimeout != 0)
-            anchors.verticalCenter: parent.verticalCenter
-            color: "#00000000"
-            border.color: "#00000000"
-            border.width: 0
-
-            Text {
-                id: connectionStatusText
-                text: qsTr("CONNECTION LOST")
-                font.pointSize: 14 * dpiFactor
-                font.weight: Font.DemiBold
-                anchors.verticalCenter: parent.verticalCenter
-                anchors.horizontalCenter: parent.horizontalCenter
-                color: colorRed
-            }
         }
     }