Commit abe955a5 authored by Gus Grubba's avatar Gus Grubba

Expose toolbar to plugin (replaceable)

Restore QGC to its normal UI layout (buttons on toolbar)
parent 75dcc988
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<file alias="FactSystemTest.qml">src/FactSystem/FactSystemTest.qml</file> <file alias="FactSystemTest.qml">src/FactSystem/FactSystemTest.qml</file>
</qresource> </qresource>
<qresource prefix="/toolbar"> <qresource prefix="/toolbar">
<file alias="MainToolBar.qml">src/ui/toolbar/MainToolBar.qml</file>
<file alias="ArmedIndicator.qml">src/ui/toolbar/ArmedIndicator.qml</file> <file alias="ArmedIndicator.qml">src/ui/toolbar/ArmedIndicator.qml</file>
<file alias="BatteryIndicator.qml">src/ui/toolbar/BatteryIndicator.qml</file> <file alias="BatteryIndicator.qml">src/ui/toolbar/BatteryIndicator.qml</file>
<file alias="GPSIndicator.qml">src/ui/toolbar/GPSIndicator.qml</file> <file alias="GPSIndicator.qml">src/ui/toolbar/GPSIndicator.qml</file>
...@@ -48,7 +49,7 @@ ...@@ -48,7 +49,7 @@
<file alias="LinkSettings.qml">src/ui/preferences/LinkSettings.qml</file> <file alias="LinkSettings.qml">src/ui/preferences/LinkSettings.qml</file>
<file alias="LogDownloadPage.qml">src/AnalyzeView/LogDownloadPage.qml</file> <file alias="LogDownloadPage.qml">src/AnalyzeView/LogDownloadPage.qml</file>
<file alias="LogReplaySettings.qml">src/ui/preferences/LogReplaySettings.qml</file> <file alias="LogReplaySettings.qml">src/ui/preferences/LogReplaySettings.qml</file>
<file alias="MainQmlWindow.qml">src/ui/MainQmlWindow.qml</file> <file alias="MainRootWindow.qml">src/ui/MainRootWindow.qml</file>
<file alias="MavlinkConsolePage.qml">src/AnalyzeView/MavlinkConsolePage.qml</file> <file alias="MavlinkConsolePage.qml">src/AnalyzeView/MavlinkConsolePage.qml</file>
<file alias="MavlinkSettings.qml">src/ui/preferences/MavlinkSettings.qml</file> <file alias="MavlinkSettings.qml">src/ui/preferences/MavlinkSettings.qml</file>
<file alias="MissionSettingsEditor.qml">src/PlanView/MissionSettingsEditor.qml</file> <file alias="MissionSettingsEditor.qml">src/PlanView/MissionSettingsEditor.qml</file>
...@@ -76,8 +77,6 @@ ...@@ -76,8 +77,6 @@
<file alias="QGroundControl/Controls/GeoFenceMapVisuals.qml">src/PlanView/GeoFenceMapVisuals.qml</file> <file alias="QGroundControl/Controls/GeoFenceMapVisuals.qml">src/PlanView/GeoFenceMapVisuals.qml</file>
<file alias="QGroundControl/Controls/IndicatorButton.qml">src/QmlControls/IndicatorButton.qml</file> <file alias="QGroundControl/Controls/IndicatorButton.qml">src/QmlControls/IndicatorButton.qml</file>
<file alias="QGroundControl/Controls/JoystickThumbPad.qml">src/QmlControls/JoystickThumbPad.qml</file> <file alias="QGroundControl/Controls/JoystickThumbPad.qml">src/QmlControls/JoystickThumbPad.qml</file>
<file alias="QGroundControl/Controls/MainToolBar.qml">src/ui/toolbar/MainToolBar.qml</file>
<file alias="QGroundControl/Controls/MainToolBarIndicators.qml">src/ui/toolbar/MainToolBarIndicators.qml</file>
<file alias="QGroundControl/Controls/MissionCommandDialog.qml">src/QmlControls/MissionCommandDialog.qml</file> <file alias="QGroundControl/Controls/MissionCommandDialog.qml">src/QmlControls/MissionCommandDialog.qml</file>
<file alias="QGroundControl/Controls/MissionItemEditor.qml">src/PlanView/MissionItemEditor.qml</file> <file alias="QGroundControl/Controls/MissionItemEditor.qml">src/PlanView/MissionItemEditor.qml</file>
<file alias="QGroundControl/Controls/MissionItemIndexLabel.qml">src/QmlControls/MissionItemIndexLabel.qml</file> <file alias="QGroundControl/Controls/MissionItemIndexLabel.qml">src/QmlControls/MissionItemIndexLabel.qml</file>
......
...@@ -33,10 +33,10 @@ FactPanelController::FactPanelController() ...@@ -33,10 +33,10 @@ FactPanelController::FactPanelController()
void FactPanelController::_notifyPanelMissingParameter(const QString& missingParam) void FactPanelController::_notifyPanelMissingParameter(const QString& missingParam)
{ {
if (qgcApp()->mainQmlWindow()) { if (qgcApp()->mainRootWindow()) {
QVariant returnedValue; QVariant returnedValue;
QMetaObject::invokeMethod( QMetaObject::invokeMethod(
qgcApp()->mainQmlWindow(), qgcApp()->mainRootWindow(),
"showMissingParameterOverlay", "showMissingParameterOverlay",
Q_RETURN_ARG(QVariant, returnedValue), Q_RETURN_ARG(QVariant, returnedValue),
Q_ARG(QVariant, missingParam)); Q_ARG(QVariant, missingParam));
...@@ -45,10 +45,10 @@ void FactPanelController::_notifyPanelMissingParameter(const QString& missingPar ...@@ -45,10 +45,10 @@ void FactPanelController::_notifyPanelMissingParameter(const QString& missingPar
void FactPanelController::_notifyPanelErrorMsg(const QString& errorMsg) void FactPanelController::_notifyPanelErrorMsg(const QString& errorMsg)
{ {
if(qgcApp()->mainQmlWindow()) { if(qgcApp()->mainRootWindow()) {
QVariant returnedValue; QVariant returnedValue;
QMetaObject::invokeMethod( QMetaObject::invokeMethod(
qgcApp()->mainQmlWindow(), qgcApp()->mainRootWindow(),
"showFactError", "showFactError",
Q_RETURN_ARG(QVariant, returnedValue), Q_RETURN_ARG(QVariant, returnedValue),
Q_ARG(QVariant, errorMsg)); Q_ARG(QVariant, errorMsg));
...@@ -67,7 +67,7 @@ void FactPanelController::_reportMissingParameter(int componentId, const QString ...@@ -67,7 +67,7 @@ void FactPanelController::_reportMissingParameter(int componentId, const QString
// will not have access to _factPanel yet. Just record list of missing facts // will not have access to _factPanel yet. Just record list of missing facts
// in that case instead of notify. Once _factPanel is available they will be // in that case instead of notify. Once _factPanel is available they will be
// send out for real. // send out for real.
if (qgcApp()->mainQmlWindow()) { if (qgcApp()->mainRootWindow()) {
_notifyPanelMissingParameter(missingParam); _notifyPanelMissingParameter(missingParam);
} else { } else {
_delayedMissingParams += missingParam; _delayedMissingParams += missingParam;
......
...@@ -570,8 +570,8 @@ Item { ...@@ -570,8 +570,8 @@ Item {
z: _mapAndVideo.z + 4 z: _mapAndVideo.z + 4
title: qsTr("Fly") title: qsTr("Fly")
maxHeight: (_flightVideo.visible ? _flightVideo.y : parent.height) - toolStrip.y maxHeight: (_flightVideo.visible ? _flightVideo.y : parent.height) - toolStrip.y
buttonVisible: [true, _useChecklist, _guidedController.showTakeoff || !_guidedController.showLand, _guidedController.showLand && !_guidedController.showTakeoff, true, true, true ] buttonVisible: [_useChecklist, _guidedController.showTakeoff || !_guidedController.showLand, _guidedController.showLand && !_guidedController.showTakeoff, true, true, true ]
buttonEnabled: [true, _useChecklist && activeVehicle, _guidedController.showTakeoff, _guidedController.showLand, _guidedController.showRTL, _guidedController.showPause, _anyActionAvailable ] buttonEnabled: [_useChecklist && activeVehicle, _guidedController.showTakeoff, _guidedController.showLand, _guidedController.showRTL, _guidedController.showPause, _anyActionAvailable ]
property bool _anyActionAvailable: _guidedController.showStartMission || _guidedController.showResumeMission || _guidedController.showChangeAlt || _guidedController.showLandAbort property bool _anyActionAvailable: _guidedController.showStartMission || _guidedController.showResumeMission || _guidedController.showChangeAlt || _guidedController.showLandAbort
property var _actionModel: [ property var _actionModel: [
...@@ -608,10 +608,6 @@ Item { ...@@ -608,10 +608,6 @@ Item {
] ]
model: [ model: [
{
name: "Plan",
iconSource: "/qmlimages/Plan.svg",
},
{ {
name: "Checklist", name: "Checklist",
iconSource: "/qmlimages/check.svg", iconSource: "/qmlimages/check.svg",
...@@ -646,9 +642,6 @@ Item { ...@@ -646,9 +642,6 @@ Item {
onClicked: { onClicked: {
guidedActionsController.closeAll() guidedActionsController.closeAll()
if(index === 0) {
mainWindow.showPlanView()
} else {
var action = model[index].action var action = model[index].action
if (action === -1) { if (action === -1) {
guidedActionList.model = _actionModel guidedActionList.model = _actionModel
...@@ -657,8 +650,6 @@ Item { ...@@ -657,8 +650,6 @@ Item {
_guidedController.confirmAction(action) _guidedController.confirmAction(action)
} }
} }
}
} }
GuidedActionsController { GuidedActionsController {
...@@ -689,7 +680,6 @@ Item { ...@@ -689,7 +680,6 @@ Item {
/// Close all dialogs /// Close all dialogs
function closeAll() { function closeAll() {
mainWindow.enableToolbar()
rootLoader.sourceComponent = null rootLoader.sourceComponent = null
guidedActionConfirm.visible = false guidedActionConfirm.visible = false
guidedActionList.visible = false guidedActionList.visible = false
......
...@@ -23,12 +23,12 @@ Rectangle { ...@@ -23,12 +23,12 @@ Rectangle {
property real missionMaxTelemetry: _controllerValid ? _planMasterController.missionController.missionMaxTelemetry : NaN property real missionMaxTelemetry: _controllerValid ? _planMasterController.missionController.missionMaxTelemetry : NaN
property bool missionDirty: _controllerValid ? _planMasterController.missionController.dirty : false property bool missionDirty: _controllerValid ? _planMasterController.missionController.dirty : false
property bool _controllerValid: _planMasterController !== undefined property bool _controllerValid: _planMasterController !== undefined && _planMasterController !== null
property bool _controllerOffline: _controllerValid ? _planMasterController.offline : true property bool _controllerOffline: _controllerValid ? _planMasterController.offline : true
property var _controllerDirty: _controllerValid ? _planMasterController.dirty : false property var _controllerDirty: _controllerValid ? _planMasterController.dirty : false
property var _controllerSyncInProgress: _controllerValid ? _planMasterController.syncInProgress : false property var _controllerSyncInProgress: _controllerValid ? _planMasterController.syncInProgress : false
property bool _statusValid: _currentMissionItem !== undefined property bool _statusValid: _currentMissionItem !== undefined && _currentMissionItem !== null
property bool _missionValid: missionItems !== undefined property bool _missionValid: missionItems !== undefined
property real _dataFontSize: ScreenTools.defaultFontPointSize property real _dataFontSize: ScreenTools.defaultFontPointSize
...@@ -77,6 +77,28 @@ Rectangle { ...@@ -77,6 +77,28 @@ Rectangle {
anchors.fill: parent anchors.fill: parent
} }
//-- The reason for this Row to be here is so the Logo (Home) button is in the same
// location as the one in the main toolbar.
Row {
id: logoRow
anchors.bottomMargin: 1
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
QGCToolBarButton {
id: settingsButton
anchors.top: parent.top
anchors.bottom: parent.bottom
icon.source: "/qmlimages/PaperPlane.svg"
logo: true
checked: false
onClicked: {
checked = false
mainWindow.showFlyView()
}
}
}
// Progress bar // Progress bar
on_ControllerProgressPctChanged: { on_ControllerProgressPctChanged: {
......
...@@ -551,20 +551,16 @@ Item { ...@@ -551,20 +551,16 @@ Item {
color: qgcPal.window color: qgcPal.window
title: qsTr("Plan") title: qsTr("Plan")
z: QGroundControl.zOrderWidgets z: QGroundControl.zOrderWidgets
showAlternateIcon: [ false, _planMasterController.dirty, false, false, false, false, false, false ] showAlternateIcon: [ _planMasterController.dirty, false, false, false, false, false, false ]
rotateImage: [ false, _planMasterController.syncInProgress, false, false, false, false, false, false ] rotateImage: [ _planMasterController.syncInProgress, false, false, false, false, false, false ]
animateImage: [ false, _planMasterController.dirty, false, false, false, false, false, false ] animateImage: [ _planMasterController.dirty, false, false, false, false, false, false ]
buttonEnabled: [ true, !_planMasterController.syncInProgress, true, true, true, true, true, true ] buttonEnabled: [ !_planMasterController.syncInProgress, true, true, true, true, true, true ]
buttonVisible: [ true, true, true, _waypointsOnlyMode, true, true, _showZoom, _showZoom ] buttonVisible: [ true, true, _waypointsOnlyMode, true, true, _showZoom, _showZoom ]
maxHeight: mapScale.y - toolStrip.y maxHeight: mapScale.y - toolStrip.y
property bool _showZoom: !ScreenTools.isMobile property bool _showZoom: !ScreenTools.isMobile
model: [ model: [
{
name: qsTr("Fly"),
iconSource: "/qmlimages/PaperPlane.svg",
},
{ {
name: qsTr("File"), name: qsTr("File"),
iconSource: "/qmlimages/MapSync.svg", iconSource: "/qmlimages/MapSync.svg",
...@@ -603,26 +599,23 @@ Item { ...@@ -603,26 +599,23 @@ Item {
onClicked: { onClicked: {
switch (index) { switch (index) {
case 0: case 1:
mainWindow.showFlyView()
break;
case 2:
_addWaypointOnClick = checked _addWaypointOnClick = checked
_addROIOnClick = false _addROIOnClick = false
break break
case 3: case 2:
_addROIOnClick = checked _addROIOnClick = checked
_addWaypointOnClick = false _addWaypointOnClick = false
break break
case 4: case 3:
if (_singleComplexItem) { if (_singleComplexItem) {
addComplexItem(_missionController.complexMissionItemNames[0]) addComplexItem(_missionController.complexMissionItemNames[0])
} }
break break
case 6: case 5:
editorMap.zoomLevel += 0.5 editorMap.zoomLevel += 0.5
break break
case 7: case 6:
editorMap.zoomLevel -= 0.5 editorMap.zoomLevel -= 0.5
break break
} }
......
...@@ -654,12 +654,12 @@ void QGCApplication::showMessage(const QString& message) ...@@ -654,12 +654,12 @@ void QGCApplication::showMessage(const QString& message)
} }
} }
QQuickItem* QGCApplication::mainQmlWindow() QQuickItem* QGCApplication::mainRootWindow()
{ {
if(_mainQmlWindow) { if(_mainRootWindow) {
_mainQmlWindow = reinterpret_cast<QQuickItem*>(_rootQmlObject()); _mainRootWindow = reinterpret_cast<QQuickItem*>(_rootQmlObject());
} }
return _mainQmlWindow; return _mainRootWindow;
} }
void QGCApplication::showSetupView() void QGCApplication::showSetupView()
......
...@@ -96,7 +96,7 @@ public: ...@@ -96,7 +96,7 @@ public:
static QString cachedAirframeMetaDataFile(void); static QString cachedAirframeMetaDataFile(void);
void setLanguage(); void setLanguage();
QQuickItem* mainQmlWindow(); QQuickItem* mainRootWindow();
public slots: public slots:
/// You can connect to this slot to show an information message box from a different thread. /// You can connect to this slot to show an information message box from a different thread.
...@@ -180,7 +180,7 @@ private: ...@@ -180,7 +180,7 @@ private:
QGCFileDownload* _currentVersionDownload = nullptr; QGCFileDownload* _currentVersionDownload = nullptr;
GPSRTKFactGroup* _gpsRtkFactGroup = nullptr; GPSRTKFactGroup* _gpsRtkFactGroup = nullptr;
QGCToolbox* _toolbox = nullptr; QGCToolbox* _toolbox = nullptr;
QQuickItem* _mainQmlWindow = nullptr; QQuickItem* _mainRootWindow = nullptr;
bool _bluetoothAvailable = false; bool _bluetoothAvailable = false;
QTranslator _QGCTranslator; QTranslator _QGCTranslator;
......
...@@ -104,7 +104,7 @@ public: ...@@ -104,7 +104,7 @@ public:
DEFINE_QGC_COLOR(alertText, setAlertText) DEFINE_QGC_COLOR(alertText, setAlertText)
DEFINE_QGC_COLOR(missionItemEditor, setMissionItemEditor) DEFINE_QGC_COLOR(missionItemEditor, setMissionItemEditor)
QGCPalette(QObject* parent = NULL); QGCPalette(QObject* parent = nullptr);
~QGCPalette(); ~QGCPalette();
bool colorGroupEnabled (void) const { return _colorGroupEnabled; } bool colorGroupEnabled (void) const { return _colorGroupEnabled; }
......
...@@ -20,11 +20,13 @@ Button { ...@@ -20,11 +20,13 @@ Button {
height: ScreenTools.defaultFontPixelHeight * 3 height: ScreenTools.defaultFontPixelHeight * 3
autoExclusive: true autoExclusive: true
property bool logo: false
QGCPalette { id: qgcPal } QGCPalette { id: qgcPal }
background: Rectangle { background: Rectangle {
anchors.fill: parent anchors.fill: parent
color: checked ? qgcPal.buttonHighlight : qgcPal.button color: logo ? qgcPal.brandingPurple : (checked ? qgcPal.buttonHighlight : Qt.rgba(0,0,0,0))
} }
contentItem: Row { contentItem: Row {
...@@ -38,12 +40,13 @@ Button { ...@@ -38,12 +40,13 @@ Button {
width: height width: height
sourceSize.height: parent.height sourceSize.height: parent.height
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
color: button.checked ? qgcPal.buttonHighlightText : qgcPal.buttonText color: logo ? "white" : (button.checked ? qgcPal.buttonHighlightText : qgcPal.buttonText)
source: button.icon.source source: button.icon.source
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
Label { Label {
id: _label id: _label
visible: text !== ""
text: button.text text: button.text
color: button.checked ? qgcPal.buttonHighlightText : qgcPal.buttonText color: button.checked ? qgcPal.buttonHighlightText : qgcPal.buttonText
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
......
...@@ -20,7 +20,6 @@ GeoFenceMapVisuals 1.0 GeoFenceMapVisuals.qml ...@@ -20,7 +20,6 @@ GeoFenceMapVisuals 1.0 GeoFenceMapVisuals.qml
HackFileDialog 1.0 HackFileDialog.qml HackFileDialog 1.0 HackFileDialog.qml
IndicatorButton 1.0 IndicatorButton.qml IndicatorButton 1.0 IndicatorButton.qml
JoystickThumbPad 1.0 JoystickThumbPad.qml JoystickThumbPad 1.0 JoystickThumbPad.qml
MainToolBar 1.0 MainToolBar.qml
MissionCommandDialog 1.0 MissionCommandDialog.qml MissionCommandDialog 1.0 MissionCommandDialog.qml
MissionItemEditor 1.0 MissionItemEditor.qml MissionItemEditor 1.0 MissionItemEditor.qml
MissionItemIndexLabel 1.0 MissionItemIndexLabel.qml MissionItemIndexLabel 1.0 MissionItemIndexLabel.qml
......
...@@ -230,7 +230,6 @@ Item { ...@@ -230,7 +230,6 @@ Item {
onAcceptedForLoad: { onAcceptedForLoad: {
if(!QGroundControl.mapEngineManager.importSets(file)) { if(!QGroundControl.mapEngineManager.importSets(file)) {
showList(); showList();
mainWindow.enableToolbar()
} }
close() close()
} }
...@@ -1143,7 +1142,6 @@ Item { ...@@ -1143,7 +1142,6 @@ Item {
visible: !QGroundControl.mapEngineManager.exporting visible: !QGroundControl.mapEngineManager.exporting
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
onClicked: { onClicked: {
mainWindow.enableToolbar()
rootLoader.sourceComponent = null rootLoader.sourceComponent = null
} }
} }
...@@ -1227,7 +1225,6 @@ Item { ...@@ -1227,7 +1225,6 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
onClicked: { onClicked: {
showList(); showList();
mainWindow.enableToolbar()
rootLoader.sourceComponent = null rootLoader.sourceComponent = null
} }
} }
...@@ -1250,7 +1247,6 @@ Item { ...@@ -1250,7 +1247,6 @@ Item {
width: _bigButtonSize * 1.25 width: _bigButtonSize * 1.25
onClicked: { onClicked: {
showList(); showList();
mainWindow.enableToolbar()
rootLoader.sourceComponent = null rootLoader.sourceComponent = null
} }
} }
......
...@@ -300,7 +300,7 @@ QQmlApplicationEngine* QGCCorePlugin::createRootWindow(QObject *parent) ...@@ -300,7 +300,7 @@ QQmlApplicationEngine* QGCCorePlugin::createRootWindow(QObject *parent)
pEngine->addImportPath("qrc:/qml"); pEngine->addImportPath("qrc:/qml");
pEngine->rootContext()->setContextProperty("joystickManager", qgcApp()->toolbox()->joystickManager()); pEngine->rootContext()->setContextProperty("joystickManager", qgcApp()->toolbox()->joystickManager());
pEngine->rootContext()->setContextProperty("debugMessageModel", AppMessages::getModel()); pEngine->rootContext()->setContextProperty("debugMessageModel", AppMessages::getModel());
pEngine->load(QUrl(QStringLiteral("qrc:/qml/MainQmlWindow.qml"))); pEngine->load(QUrl(QStringLiteral("qrc:/qml/MainRootWindow.qml")));
return pEngine; return pEngine;
} }
......
...@@ -31,9 +31,27 @@ QGCOptions::instrumentWidget() ...@@ -31,9 +31,27 @@ QGCOptions::instrumentWidget()
} }
QUrl QUrl
QGCOptions::mainToolbarIndicatorsUrl() const QGCOptions::mainToolbarUrl() const
{ {
return QUrl(QStringLiteral("qrc:/toolbar/MainToolBarIndicators.qml")); return QUrl(QStringLiteral("qrc:/toolbar/MainToolBar.qml"));
}
QUrl
QGCOptions::planToolbarUrl() const
{
return QUrl(QStringLiteral("qrc:/qml/PlanToolBar.qml"));
}
QColor
QGCOptions::toolbarBackgroundLight() const
{
return QColor(255,255,255,204);
}
QColor
QGCOptions::toolbarBackgroundDark() const
{
return QColor(0,0,0,192);
} }
QUrl QUrl
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QUrl> #include <QUrl>
#include <QColor>
/// @file /// @file
/// @brief Core Plugin Interface for QGroundControl - Application Options /// @brief Core Plugin Interface for QGroundControl - Application Options
...@@ -29,7 +30,12 @@ public: ...@@ -29,7 +30,12 @@ public:
Q_PROPERTY(bool enablePlanViewSelector READ enablePlanViewSelector CONSTANT) Q_PROPERTY(bool enablePlanViewSelector READ enablePlanViewSelector CONSTANT)
Q_PROPERTY(CustomInstrumentWidget* instrumentWidget READ instrumentWidget CONSTANT) Q_PROPERTY(CustomInstrumentWidget* instrumentWidget READ instrumentWidget CONSTANT)
Q_PROPERTY(QUrl flyViewOverlay READ flyViewOverlay CONSTANT) Q_PROPERTY(QUrl flyViewOverlay READ flyViewOverlay CONSTANT)
Q_PROPERTY(QUrl mainToolbarIndicatorsUrl READ mainToolbarIndicatorsUrl CONSTANT)
Q_PROPERTY(QUrl mainToolbarUrl READ mainToolbarUrl CONSTANT)
Q_PROPERTY(QUrl planToolbarUrl READ planToolbarUrl CONSTANT)
Q_PROPERTY(QColor toolbarBackgroundLight READ toolbarBackgroundLight CONSTANT)
Q_PROPERTY(QColor toolbarBackgroundDark READ toolbarBackgroundDark CONSTANT)
Q_PROPERTY(QUrl planToolbarIndicatorsUrl READ planToolbarIndicatorsUrl CONSTANT) Q_PROPERTY(QUrl planToolbarIndicatorsUrl READ planToolbarIndicatorsUrl CONSTANT)
Q_PROPERTY(bool showSensorCalibrationCompass READ showSensorCalibrationCompass NOTIFY showSensorCalibrationCompassChanged) Q_PROPERTY(bool showSensorCalibrationCompass READ showSensorCalibrationCompass NOTIFY showSensorCalibrationCompassChanged)
Q_PROPERTY(bool showSensorCalibrationGyro READ showSensorCalibrationGyro NOTIFY showSensorCalibrationGyroChanged) Q_PROPERTY(bool showSensorCalibrationGyro READ showSensorCalibrationGyro NOTIFY showSensorCalibrationGyroChanged)
...@@ -79,8 +85,11 @@ public: ...@@ -79,8 +85,11 @@ public:
/// Allows access to the full fly view window /// Allows access to the full fly view window
virtual QUrl flyViewOverlay () const { return QUrl(); } virtual QUrl flyViewOverlay () const { return QUrl(); }
/// Allows replacing the toolbar container /// Allows replacing the toolbar
virtual QUrl mainToolbarIndicatorsUrl () const; virtual QUrl mainToolbarUrl () const;
virtual QUrl planToolbarUrl () const;
virtual QColor toolbarBackgroundLight () const;
virtual QColor toolbarBackgroundDark () const;
/// Allows replacing the Plan View toolbar container /// Allows replacing the Plan View toolbar container
virtual QUrl planToolbarIndicatorsUrl () const; virtual QUrl planToolbarIndicatorsUrl () const;
/// By returning false you can hide the following sensor calibration pages /// By returning false you can hide the following sensor calibration pages
...@@ -157,7 +166,7 @@ public: ...@@ -157,7 +166,7 @@ public:
POS_BOTTOM_LEFT POS_BOTTOM_LEFT
}; };
Q_ENUM(Pos) Q_ENUM(Pos)
CustomInstrumentWidget(QObject* parent = NULL); CustomInstrumentWidget(QObject* parent = nullptr);
Q_PROPERTY(QUrl source READ source CONSTANT) Q_PROPERTY(QUrl source READ source CONSTANT)
Q_PROPERTY(Pos widgetPosition READ widgetPosition NOTIFY widgetPositionChanged) Q_PROPERTY(Pos widgetPosition READ widgetPosition NOTIFY widgetPositionChanged)
virtual QUrl source () { return QUrl(); } virtual QUrl source () { return QUrl(); }
......
...@@ -24,12 +24,12 @@ import QGroundControl.FlightMap 1.0 ...@@ -24,12 +24,12 @@ import QGroundControl.FlightMap 1.0
ApplicationWindow { ApplicationWindow {
id: mainWindow id: mainWindow
width: 1280 width: 1280
height: 1024 height: 720
visible: true visible: true
readonly property real _topBottomMargins: ScreenTools.defaultFontPixelHeight * 0.5 readonly property real _topBottomMargins: ScreenTools.defaultFontPixelHeight * 0.5
readonly property string _mainToolbarIndicators: QGroundControl.corePlugin.options.mainToolbarIndicatorsUrl readonly property string _mainToolbar: QGroundControl.corePlugin.options.mainToolbarUrl
readonly property string _planToolbarIndicators: QGroundControl.corePlugin.options.planToolbarIndicatorsUrl readonly property string _planToolbar: QGroundControl.corePlugin.options.planToolbarUrl
readonly property string _settingsViewSource: "AppSettings.qml" readonly property string _settingsViewSource: "AppSettings.qml"
readonly property string _setupViewSource: "SetupView.qml" readonly property string _setupViewSource: "SetupView.qml"
readonly property string _planViewSource: "PlanView.qml" readonly property string _planViewSource: "PlanView.qml"
...@@ -64,28 +64,18 @@ ApplicationWindow { ...@@ -64,28 +64,18 @@ ApplicationWindow {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//-- Global Scope Functions //-- Global Scope Functions
function disableToolbar() {
drawer.enabled = false
}
function enableToolbar() {
drawer.enabled = true
}
function viewSwitch(isPlanView) { function viewSwitch(isPlanView) {
enableToolbar()
drawer.close()
if(isPlanView) { if(isPlanView) {
rootBackground.visible = false rootBackground.visible = false
planViewLoader.visible = true planViewLoader.visible = true
if(toolbarIndicators.source !== _planToolbarIndicators) { if(toolbar.source !== _planToolbar) {
toolbarIndicators.source = _planToolbarIndicators toolbar.source = _planToolbar
} }
} else { } else {
rootBackground.visible = true rootBackground.visible = true
planViewLoader.visible = false planViewLoader.visible = false
if(toolbarIndicators.source !== _mainToolbarIndicators) { if(toolbar.source !== _mainToolbar) {
toolbarIndicators.source = _mainToolbarIndicators toolbar.source = _mainToolbar
} }
} }
} }
...@@ -93,9 +83,6 @@ ApplicationWindow { ...@@ -93,9 +83,6 @@ ApplicationWindow {
function showFlyView() { function showFlyView() {
viewSwitch(false) viewSwitch(false)
mainContentWindow.source = "" mainContentWindow.source = ""
if(toolbarIndicators.source !== _mainToolbarIndicators) {
toolbarIndicators.source = _mainToolbarIndicators
}
} }
function showPlanView() { function showPlanView() {
...@@ -297,169 +284,17 @@ ApplicationWindow { ...@@ -297,169 +284,17 @@ ApplicationWindow {
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//-- Global Indicator Bar //-- Toolbar
header: ToolBar { header: ToolBar {
height: ScreenTools.toolbarHeight height: ScreenTools.toolbarHeight
visible: !QGroundControl.videoManager.fullScreen visible: !QGroundControl.videoManager.fullScreen
background: Rectangle { background: Rectangle {
color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(1,1,1,0.8) : Qt.rgba(0,0,0,0.75) color: qgcPal.globalTheme === QGCPalette.Light ? QGroundControl.corePlugin.options.toolbarBackgroundLight : QGroundControl.corePlugin.options.toolbarBackgroundDark
}
RowLayout {
anchors.fill: parent
spacing: 0
Rectangle {
height: parent.height
width: height
color: qgcPal.brandingPurple
QGCColoredImage {
anchors.centerIn: parent
height: ScreenTools.defaultFontPixelHeight * 2
width: height
sourceSize.height: parent.height
fillMode: Image.PreserveAspectFit
source: "/res/QGCLogoWhite"
color: "white"
}
MouseArea {
anchors.fill: parent
onClicked:{
if(drawer.visible) {
drawer.close()
} else {
drawer.open()
}
}
}
} }
Loader { Loader {
id: toolbarIndicators id: toolbar
height: parent.height
source: _mainToolbarIndicators
Layout.fillWidth: true
}
}
}
//-------------------------------------------------------------------------
// Small parameter download progress bar
Rectangle {
x: 0
y: header.height
height: ScreenTools.toolbarHeight * 0.05
width: activeVehicle ? activeVehicle.parameterManager.loadProgress * mainWindow.width : 0
color: qgcPal.colorGreen
visible: !largeProgressBar.visible
}
//-------------------------------------------------------------------------
// Large parameter download progress bar
Rectangle {
id: largeProgressBar
x: 0
y: header.height
height: ScreenTools.toolbarHeight
width: mainWindow.width
color: qgcPal.window
visible: _showLargeProgress
property bool _initialDownloadComplete: activeVehicle ? activeVehicle.parameterManager.parametersReady : true
property bool _userHide: false
property bool _showLargeProgress: !_initialDownloadComplete && !_userHide && qgcPal.globalTheme === QGCPalette.Light
Connections {
target: QGroundControl.multiVehicleManager
onActiveVehicleChanged: largeProgressBar._userHide = false
}
Rectangle {
anchors.top: parent.top
anchors.bottom: parent.bottom
width: activeVehicle ? activeVehicle.parameterManager.loadProgress * mainWindow.width : 0
color: qgcPal.colorGreen
}
QGCLabel {
anchors.centerIn: parent
text: qsTr("Downloading Parameters")
font.pointSize: ScreenTools.largeFontPointSize
}
QGCLabel {
anchors.margins: _margin
anchors.right: parent.right
anchors.bottom: parent.bottom
text: qsTr("Click anywhere to hide")
property real _margin: ScreenTools.defaultFontPixelWidth * 0.5
}
MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: largeProgressBar._userHide = true source: _mainToolbar
}
}
//-------------------------------------------------------------------------
//-- Navigation Drawer (Left to Right, on command or using touch gestures)
Drawer {
id: drawer
y: header.height
width: navButtonWidth
height: mainWindow.height - header.height
background: Rectangle {
color: qgcPal.globalTheme === QGCPalette.Light ? "white" : "black"
}
ButtonGroup {
buttons: buttons.children
}
ColumnLayout {
id: buttons
anchors.top: parent.top
anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.5
anchors.left: parent.left
anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelHeight * 0.5
QGCToolBarButton {
text: "Fly"
icon.source: "/qmlimages/PaperPlane.svg"
Layout.fillWidth: true
onClicked: {
checked = true
showFlyView()
}
}
QGCToolBarButton {
text: "Plan"
icon.source: "/qmlimages/Plan.svg"
Layout.fillWidth: true
onClicked: {
checked = true
showPlanView()
}
}
QGCToolBarButton {
text: "Analyze"
icon.source: "/qmlimages/Analyze.svg"
Layout.fillWidth: true
onClicked: {
checked = true
showAnalyzeView()
}
}
QGCToolBarButton {
text: "Vehicle Setup"
icon.source: "/qmlimages/Gears.svg"
Layout.fillWidth: true
onClicked: {
checked = true
showSetupView()
}
}
QGCToolBarButton {
text: "Settings"
icon.source: "/qmlimages/Gears.svg"
Layout.fillWidth: true
onClicked: {
checked = true
showSettingsView()
}
}
} }
} }
...@@ -472,7 +307,7 @@ ApplicationWindow { ...@@ -472,7 +307,7 @@ ApplicationWindow {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//-- Loader helper for any child, no matter how deep can display an element //-- Loader helper for any child, no matter how deep can display an element
// in the middle of the main window. // on top of the main window.
Loader { Loader {
id: rootLoader id: rootLoader
anchors.centerIn: parent anchors.centerIn: parent
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1024</width>
<height>600</height>
</rect>
</property>
<property name="baseSize">
<size>
<width>1100</width>
<height>800</height>
</size>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="windowTitle">
<string>MGMainWindow</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QWidget" name="centralWidget"/>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1024</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="separator"/>
<addaction name="actionStatusBar"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
<widget class="QMenu" name="menuWidgets">
<property name="title">
<string>Widgets</string>
</property>
</widget>
<addaction name="menuFile"/>
<addaction name="menuWidgets"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionExit">
<property name="text">
<string>Exit</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action>
<action name="actionAdd_Link">
<property name="text">
<string>Manage Communication Links</string>
</property>
</action>
<action name="actionAdvanced_Mode">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Advanced Mode</string>
</property>
</action>
<action name="actionStatusBar">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Replay Flight Data</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections>
<connection>
<sender>actionExit</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>299</x>
<y>199</y>
</hint>
</hints>
</connection>
</connections>
</ui>
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import QGroundControl 1.0
import QGroundControl.Controls 1.0
/// Native QML top level window
Item {
function showSetupView() {
mainWindowInner.item.showSetupView()
}
function attemptWindowClose() {
if(!mainWindowInner.item) {
controller.reallyClose()
} else {
mainWindowInner.item.attemptWindowClose()
}
}
function showMessage(message) {
if(mainWindowInner.item) {
mainWindowInner.item.showMessage(message)
} else {
console.log(message)
}
}
Loader {
id: mainWindowInner
anchors.fill: parent
source: "MainWindowInner.qml"
Connections {
target: mainWindowInner.item
onReallyClose: controller.reallyClose()
}
}
}
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import QtPositioning 5.3
import QGroundControl 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.FlightDisplay 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.MultiVehicleManager 1.0
/// Inner common QML for mainWindow
Item {
id: mainWindow
signal reallyClose
QGCPalette { id: qgcPal; colorGroupEnabled: true }
property var currentPopUp: null
property real currentCenterX: 0
property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property string formatedMessage: activeVehicle ? activeVehicle.formatedMessage : ""
property var _viewList: [ settingsViewLoader, setupViewLoader, planViewLoader, flightView, analyzeViewLoader ]
readonly property string _settingsViewSource: "AppSettings.qml"
readonly property string _setupViewSource: "SetupView.qml"
readonly property string _planViewSource: "PlanView.qml"
readonly property string _analyzeViewSource: !ScreenTools.isMobile ? "AnalyzeView.qml" : "MavlinkConsolePage.qml"
onHeightChanged: {
//-- We only deal with the available height if within the Fly or Plan view
if(!setupViewLoader.visible) {
ScreenTools.availableHeight = parent.height - toolBar.height
}
}
function disableToolbar() {
toolbarBlocker.enabled = true
}
function enableToolbar() {
toolbarBlocker.enabled = false
}
function hideAllViews() {
for (var i=0; i<_viewList.length; i++) {
_viewList[i].visible = false
}
planToolBar.visible = false
}
function showSettingsView() {
mainWindow.enableToolbar()
rootLoader.sourceComponent = null
if(currentPopUp) {
currentPopUp.close()
}
//-- In settings view, the full height is available. Set to 0 so it is ignored.
ScreenTools.availableHeight = 0
hideAllViews()
if (settingsViewLoader.source != _settingsViewSource) {
settingsViewLoader.source = _settingsViewSource
}
settingsViewLoader.visible = true
toolBar.checkSettingsButton()
}
function showSetupView() {
mainWindow.enableToolbar()
rootLoader.sourceComponent = null
if(currentPopUp) {
currentPopUp.close()
}
//-- In setup view, the full height is available. Set to 0 so it is ignored.
ScreenTools.availableHeight = 0
hideAllViews()
if (setupViewLoader.source != _setupViewSource) {
setupViewLoader.source = _setupViewSource
}
setupViewLoader.visible = true
toolBar.checkSetupButton()
}
function showPlanView() {
mainWindow.enableToolbar()
rootLoader.sourceComponent = null
if(currentPopUp) {
currentPopUp.close()
}
if (planViewLoader.source != _planViewSource) {
planViewLoader.source = _planViewSource
}
ScreenTools.availableHeight = parent.height - toolBar.height
hideAllViews()
planViewLoader.visible = true
planToolBar.visible = true
}
function showFlyView() {
mainWindow.enableToolbar()
rootLoader.sourceComponent = null
if(currentPopUp) {
currentPopUp.close()
}
ScreenTools.availableHeight = parent.height - toolBar.height
hideAllViews()
flightView.visible = true
toolBar.checkFlyButton()
}
function showAnalyzeView() {
mainWindow.enableToolbar()
rootLoader.sourceComponent = null
if(currentPopUp) {
currentPopUp.close()
}
ScreenTools.availableHeight = 0
if (analyzeViewLoader.source != _analyzeViewSource) {
analyzeViewLoader.source = _analyzeViewSource
}
hideAllViews()
analyzeViewLoader.visible = true
toolBar.checkAnalyzeButton()
}
/// Start the process of closing QGroundControl. Prompts the user are needed.
function attemptWindowClose() {
unsavedMissionCloseDialog.check()
}
function finishCloseProcess() {
QGroundControl.linkManager.shutdown()
// The above shutdown causes a flurry of activity as the vehicle components are removed. This in turn
// causes the Windows Version of Qt to crash if you allow the close event to be accepted. In order to prevent
// the crash, we ignore the close event and setup a delayed timer to close the window after things settle down.
if(ScreenTools.isWindows) {
delayedWindowCloseTimer.start()
} else {
mainWindow.reallyClose()
}
}
MessageDialog {
id: unsavedMissionCloseDialog
title: qsTr("%1 close").arg(QGroundControl.appName)
text: qsTr("You have a mission edit in progress which has not been saved/sent. If you close you will lose changes. Are you sure you want to close?")
standardButtons: StandardButton.Yes | StandardButton.No
modality: Qt.ApplicationModal
visible: false
onYes: activeConnectionsCloseDialog.check()
function check() {
if (planViewLoader.item && planViewLoader.item.dirty) {
unsavedMissionCloseDialog.open()
} else {
activeConnectionsCloseDialog.check()
}
}
}
MessageDialog {
id: activeConnectionsCloseDialog
title: qsTr("%1 close").arg(QGroundControl.appName)
text: qsTr("There are still active connections to vehicles. Are you sure you want to exit?")
standardButtons: StandardButton.Yes | StandardButton.Cancel
modality: Qt.ApplicationModal
visible: false
onYes: finishCloseProcess()
function check() {
if (QGroundControl.multiVehicleManager.activeVehicle) {
activeConnectionsCloseDialog.open()
} else {
finishCloseProcess()
}
}
}
Timer {
id: delayedWindowCloseTimer
interval: 1500
running: false
repeat: false
onTriggered: {
mainWindow.reallyClose()
}
}
property var messageQueue: []
function showMessage(message) {
if(criticalMmessageArea.visible || QGroundControl.videoManager.fullScreen) {
messageQueue.push(message)
} else {
criticalMessageText.text = message
criticalMmessageArea.visible = true
}
}
function formatMessage(message) {
message = message.replace(new RegExp("<#E>", "g"), "color: " + qgcPal.warningText + "; font: " + (ScreenTools.defaultFontPointSize.toFixed(0) - 1) + "pt monospace;");
message = message.replace(new RegExp("<#I>", "g"), "color: " + qgcPal.warningText + "; font: " + (ScreenTools.defaultFontPointSize.toFixed(0) - 1) + "pt monospace;");
message = message.replace(new RegExp("<#N>", "g"), "color: " + qgcPal.text + "; font: " + (ScreenTools.defaultFontPointSize.toFixed(0) - 1) + "pt monospace;");
return message;
}
onFormatedMessageChanged: {
if(messageArea.visible) {
messageText.append(formatMessage(formatedMessage))
//-- Hack to scroll down
messageFlick.flick(0,-500)
}
}
function showMessageArea() {
mainWindow.enableToolbar()
rootLoader.sourceComponent = null
var currentlyVisible = messageArea.visible
if(currentPopUp) {
currentPopUp.close()
}
if(!currentlyVisible) {
if(QGroundControl.multiVehicleManager.activeVehicleAvailable) {
messageText.text = formatMessage(activeVehicle.formatedMessages)
//-- Hack to scroll to last message
for (var i = 0; i < activeVehicle.messageCount; i++)
messageFlick.flick(0,-5000)
activeVehicle.resetMessages()
} else {
messageText.text = qsTr("No Messages")
}
currentPopUp = messageArea
messageArea.visible = true
}
}
function showPopUp(dropItem, centerX) {
mainWindow.enableToolbar()
rootLoader.sourceComponent = null
var oldIndicator = indicatorDropdown.sourceComponent
if(currentPopUp) {
currentPopUp.close()
}
if(oldIndicator !== dropItem) {
//console.log(oldIndicator)
//console.log(dropItem)
indicatorDropdown.centerX = centerX
indicatorDropdown.sourceComponent = dropItem
indicatorDropdown.visible = true
currentPopUp = indicatorDropdown
}
}
//-- Main UI
MainToolBar {
id: toolBar
height: ScreenTools.toolbarHeight
visible: !QGroundControl.videoManager.fullScreen
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
opacity: planToolBar.visible ? 0 : 1
z: QGroundControl.zOrderTopMost
Component.onCompleted: ScreenTools.availableHeight = parent.height - toolBar.height
onShowSettingsView: mainWindow.showSettingsView()
onShowSetupView: mainWindow.showSetupView()
onShowPlanView: mainWindow.showPlanView()
onShowFlyView: mainWindow.showFlyView()
onShowAnalyzeView: mainWindow.showAnalyzeView()
onArmVehicle: flightView.guidedController.confirmAction(flightView.guidedController.actionArm)
onDisarmVehicle: {
if (flightView.guidedController.showEmergenyStop) {
flightView.guidedController.confirmAction(flightView.guidedController.actionEmergencyStop)
} else {
flightView.guidedController.confirmAction(flightView.guidedController.actionDisarm)
}
}
onVtolTransitionToFwdFlight: flightView.guidedController.confirmAction(flightView.guidedController.actionVtolTransitionToFwdFlight)
onVtolTransitionToMRFlight: flightView.guidedController.confirmAction(flightView.guidedController.actionVtolTransitionToMRFlight)
//-- Entire tool bar area disable on cammand
DeadMouseArea {
id: toolbarBlocker
enabled: false
anchors.fill: parent
}
}
PlanToolBar {
id: planToolBar
height: ScreenTools.toolbarHeight
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
z: toolBar.z + 1
onShowFlyView: {
planToolBar.visible = false
mainWindow.showFlyView()
}
}
Loader {
id: settingsViewLoader
anchors.left: parent.left
anchors.right: parent.right
anchors.top: toolBar.bottom
anchors.bottom: parent.bottom
visible: false
/*
onVisibleChanged: {
if (!visible) {
// Free up the memory for this when not shown. No need to persist.
source = ""
}
}*/
}
Loader {
id: setupViewLoader
anchors.left: parent.left
anchors.right: parent.right
anchors.top: toolBar.bottom
anchors.bottom: parent.bottom
visible: false
property var planToolBar: planToolBar
}
Loader {
id: planViewLoader
anchors.fill: parent
visible: false
property var toolbar: planToolBar
}
FlightDisplayView {
id: flightView
anchors.fill: parent
visible: true
//-------------------------------------------------------------------------
//-- Loader helper for any child, no matter how deep can display an element
// on top of the video window.
Loader {
id: rootVideoLoader
anchors.centerIn: parent
}
}
Loader {
id: analyzeViewLoader
anchors.left: parent.left
anchors.right: parent.right
anchors.top: toolBar.bottom
anchors.bottom: parent.bottom
visible: false
}
//-------------------------------------------------------------------------
//-- Dismiss Pop Up Messages
MouseArea {
visible: currentPopUp != null
enabled: currentPopUp != null
anchors.fill: parent
onClicked: {
currentPopUp.close()
}
}
//-------------------------------------------------------------------------
//-- Indicator Drop Down Info
Loader {
id: indicatorDropdown
visible: false
property real centerX: 0
function close() {
sourceComponent = null
mainWindow.currentPopUp = null
}
}
//-------------------------------------------------------------------------
//-- System Message Area
Rectangle {
id: messageArea
width: mainWindow.width * 0.5
height: mainWindow.height * 0.5
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: toolBar.height + ScreenTools.defaultFontPixelHeight
radius: ScreenTools.defaultFontPixelHeight * 0.5
color: qgcPal.window
border.color: qgcPal.text
visible: false
function close() {
currentPopUp = null
messageText.text = ""
messageArea.visible = false
}
MouseArea {
// This MouseArea prevents the Map below it from getting Mouse events. Without this
// things like mousewheel will scroll the Flickable and then scroll the map as well.
anchors.fill: parent
preventStealing: true
onWheel: wheel.accepted = true
}
QGCFlickable {
id: messageFlick
anchors.margins: ScreenTools.defaultFontPixelHeight
anchors.fill: parent
contentHeight: messageText.height
contentWidth: messageText.width
pixelAligned: true
clip: true
TextEdit {
id: messageText
readOnly: true
textFormat: TextEdit.RichText
color: qgcPal.text
}
}
//-- Dismiss System Message
QGCColoredImage {
anchors.margins: ScreenTools.defaultFontPixelHeight * 0.5
anchors.top: parent.top
anchors.right: parent.right
width: ScreenTools.isMobile ? ScreenTools.defaultFontPixelHeight * 1.5 : ScreenTools.defaultFontPixelHeight
height: width
sourceSize.height: width
source: "/res/XDelete.svg"
fillMode: Image.PreserveAspectFit
mipmap: true
smooth: true
color: qgcPal.text
MouseArea {
anchors.fill: parent
anchors.margins: ScreenTools.isMobile ? -ScreenTools.defaultFontPixelHeight : 0
onClicked: {
messageArea.close()
}
}
}
//-- Clear Messages
QGCColoredImage {
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.margins: ScreenTools.defaultFontPixelHeight * 0.5
height: ScreenTools.isMobile ? ScreenTools.defaultFontPixelHeight * 1.5 : ScreenTools.defaultFontPixelHeight
width: height
sourceSize.height: height
source: "/res/TrashDelete.svg"
fillMode: Image.PreserveAspectFit
mipmap: true
smooth: true
color: qgcPal.text
MouseArea {
anchors.fill: parent
onClicked: {
if(QGroundControl.multiVehicleManager.activeVehicleAvailable) {
activeVehicle.clearMessages();
messageArea.close()
}
}
}
}
}
//-------------------------------------------------------------------------
//-- Critical Message Area
Rectangle {
id: criticalMmessageArea
width: mainWindow.width * 0.55
height: Math.min(criticalMessageText.height + _textMargins * 2, ScreenTools.defaultFontPixelHeight * 6)
color: qgcPal.alertBackground
visible: false
radius: ScreenTools.defaultFontPixelHeight * 0.5
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: toolBar.height + ScreenTools.defaultFontPixelHeight / 2
border.color: qgcPal.alertBorder
border.width: 2
readonly property real _textMargins: ScreenTools.defaultFontPixelHeight
function close() {
//-- Are there messages in the waiting queue?
if(mainWindow.messageQueue.length) {
criticalMessageText.text = ""
//-- Show all messages in queue
for (var i = 0; i < mainWindow.messageQueue.length; i++) {
var text = mainWindow.messageQueue[i]
criticalMessageText.append(text)
}
//-- Clear it
mainWindow.messageQueue = []
} else {
criticalMessageText.text = ""
criticalMmessageArea.visible = false
}
}
MouseArea {
// This MouseArea prevents the Map below it from getting Mouse events. Without this
// things like mousewheel will scroll the Flickable and then scroll the map as well.
anchors.fill: parent
preventStealing: true
onWheel: wheel.accepted = true
}
Flickable {
id: criticalMessageFlick
anchors.margins: parent._textMargins
anchors.fill: parent
contentHeight: criticalMessageText.height
contentWidth: criticalMessageText.width
boundsBehavior: Flickable.StopAtBounds
pixelAligned: true
clip: true
TextEdit {
id: criticalMessageText
width: criticalMmessageArea.width - criticalClose.width - (ScreenTools.defaultFontPixelHeight * 2)
anchors.left: parent.left
readOnly: true
textFormat: TextEdit.RichText
font.pointSize: ScreenTools.defaultFontPointSize
font.family: ScreenTools.demiboldFontFamily
wrapMode: TextEdit.WordWrap
color: qgcPal.alertText
}
}
//-- Dismiss Critical Message
QGCColoredImage {
id: criticalClose
anchors.margins: ScreenTools.defaultFontPixelHeight * 0.5
anchors.top: parent.top
anchors.right: parent.right
width: ScreenTools.isMobile ? ScreenTools.defaultFontPixelHeight * 1.5 : ScreenTools.defaultFontPixelHeight
height: width
sourceSize.height: width
source: "/res/XDelete.svg"
fillMode: Image.PreserveAspectFit
color: qgcPal.alertText
MouseArea {
anchors.fill: parent
anchors.margins: ScreenTools.isMobile ? -ScreenTools.defaultFontPixelHeight : 0
onClicked: {
criticalMmessageArea.close()
}
}
}
//-- More text below indicator
QGCColoredImage {
anchors.margins: ScreenTools.defaultFontPixelHeight * 0.5
anchors.bottom: parent.bottom
anchors.right: parent.right
width: ScreenTools.isMobile ? ScreenTools.defaultFontPixelHeight * 1.5 : ScreenTools.defaultFontPixelHeight
height: width
sourceSize.height: width
source: "/res/ArrowDown.svg"
fillMode: Image.PreserveAspectFit
visible: criticalMessageText.lineCount > 5
color: qgcPal.alertText
MouseArea {
anchors.fill: parent
onClicked: {
criticalMessageFlick.flick(0,-500)
}
}
}
}
//-------------------------------------------------------------------------
//-- Loader helper for any child, no matter how deep can display an element
// in the middle of the main window.
Loader {
id: rootLoader
anchors.centerIn: parent
}
}
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
* *
****************************************************************************/ ****************************************************************************/
import QtQuick 2.3 import QtQuick 2.11
import QtQuick.Layouts 1.2 import QtQuick.Controls 2.4
import QtQuick.Controls 1.2 import QtQuick.Layouts 1.11
import QGroundControl 1.0 import QGroundControl 1.0
import QGroundControl.Controls 1.0 import QGroundControl.Controls 1.0
...@@ -18,55 +18,14 @@ import QGroundControl.MultiVehicleManager 1.0 ...@@ -18,55 +18,14 @@ import QGroundControl.MultiVehicleManager 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
import QGroundControl.Controllers 1.0 import QGroundControl.Controllers 1.0
Rectangle { Item {
id: toolBar id: toolBar
color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(1,1,1,0.8) : Qt.rgba(0,0,0,0.75)
visible: !QGroundControl.videoManager.fullScreen
QGCPalette { id: qgcPal; colorGroupEnabled: true }
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
signal showSettingsView
signal showSetupView
signal showPlanView
signal showFlyView
signal showAnalyzeView
signal armVehicle
signal disarmVehicle
signal vtolTransitionToFwdFlight
signal vtolTransitionToMRFlight
function checkSettingsButton() {
settingsButton.checked = true
}
function checkSetupButton() {
setupButton.checked = true
}
function checkPlanButton() {
planButton.checked = true
}
function checkFlyButton() {
flyButton.checked = true
}
function checkAnalyzeButton() {
analyzeButton.checked = true
}
Component.onCompleted: { Component.onCompleted: {
//-- TODO: Get this from the actual state //-- TODO: Get this from the actual state
flyButton.checked = true flyButton.checked = true
} }
// Prevent all clicks from going through to lower layers
DeadMouseArea {
anchors.fill: parent
}
/// Bottom single pixel divider /// Bottom single pixel divider
Rectangle { Rectangle {
anchors.left: parent.left anchors.left: parent.left
...@@ -83,6 +42,10 @@ Rectangle { ...@@ -83,6 +42,10 @@ Rectangle {
anchors.fill: parent anchors.fill: parent
spacing: ScreenTools.defaultFontPixelWidth * 2 spacing: ScreenTools.defaultFontPixelWidth * 2
ButtonGroup {
buttons: viewRow.children
}
//--------------------------------------------- //---------------------------------------------
// Toolbar Row // Toolbar Row
Row { Row {
...@@ -90,54 +53,62 @@ Rectangle { ...@@ -90,54 +53,62 @@ Rectangle {
Layout.fillHeight: true Layout.fillHeight: true
spacing: ScreenTools.defaultFontPixelWidth / 2 spacing: ScreenTools.defaultFontPixelWidth / 2
ExclusiveGroup { id: mainActionGroup }
QGCToolBarButton { QGCToolBarButton {
id: settingsButton id: settingsButton
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
exclusiveGroup: mainActionGroup icon.source: "/res/QGCLogoWhite"
source: "/res/QGCLogoWhite"
logo: true logo: true
onClicked: toolBar.showSettingsView()
visible: !QGroundControl.corePlugin.options.combineSettingsAndSetup visible: !QGroundControl.corePlugin.options.combineSettingsAndSetup
onClicked: {
checked = true
mainWindow.showSettingsView()
}
} }
QGCToolBarButton { QGCToolBarButton {
id: setupButton id: setupButton
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
exclusiveGroup: mainActionGroup icon.source: "/qmlimages/Gears.svg"
source: "/qmlimages/Gears.svg" onClicked: {
onClicked: toolBar.showSetupView() checked = true
mainWindow.showSetupView()
}
} }
QGCToolBarButton { QGCToolBarButton {
id: planButton id: planButton
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
exclusiveGroup: mainActionGroup icon.source: "/qmlimages/Plan.svg"
source: "/qmlimages/Plan.svg" onClicked: {
onClicked: toolBar.showPlanView() checked = true
mainWindow.showPlanView()
}
} }
QGCToolBarButton { QGCToolBarButton {
id: flyButton id: flyButton
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
exclusiveGroup: mainActionGroup icon.source: "/qmlimages/PaperPlane.svg"
source: "/qmlimages/PaperPlane.svg" onClicked: {
onClicked: toolBar.showFlyView() checked = true
mainWindow.showFlyView()
}
} }
QGCToolBarButton { QGCToolBarButton {
id: analyzeButton id: analyzeButton
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
exclusiveGroup: mainActionGroup icon.source: "/qmlimages/Analyze.svg"
source: "/qmlimages/Analyze.svg"
visible: QGroundControl.corePlugin.showAdvancedUI visible: QGroundControl.corePlugin.showAdvancedUI
onClicked: toolBar.showAnalyzeView() onClicked: {
checked = true
mainWindow.showAnalyzeView()
}
} }
Rectangle { Rectangle {
...@@ -146,67 +117,15 @@ Rectangle { ...@@ -146,67 +117,15 @@ Rectangle {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
width: 1 width: 1
color: qgcPal.text color: qgcPal.text
visible: _activeVehicle visible: activeVehicle
}
}
//-------------------------------------------------------------------------
//-- Vehicle Selector
QGCButton {
id: vehicleSelectorButton
width: ScreenTools.defaultFontPixelHeight * 8
text: "Vehicle " + (_activeVehicle ? _activeVehicle.id : "None")
visible: QGroundControl.multiVehicleManager.vehicles.count > 1
Layout.alignment: Qt.AlignVCenter
menu: vehicleMenu
Menu {
id: vehicleMenu
} }
Component {
id: vehicleMenuItemComponent
MenuItem {
onTriggered: QGroundControl.multiVehicleManager.activeVehicle = vehicle
property int vehicleId: Number(text.split(" ")[1])
property var vehicle: QGroundControl.multiVehicleManager.getVehicleById(vehicleId)
} }
}
property var vehicleMenuItems: []
function updateVehicleMenu() { Loader {
var i; id: toolbarIndicators
// Remove old menu items height: parent.height
for (i = 0; i < vehicleMenuItems.length; i++) { source: "/toolbar/MainToolBarIndicators.qml"
vehicleMenu.removeItem(vehicleMenuItems[i])
}
vehicleMenuItems.length = 0
// Add new items
for (i = 0; i < QGroundControl.multiVehicleManager.vehicles.count; i++) {
var vehicle = QGroundControl.multiVehicleManager.vehicles.get(i)
var menuItem = vehicleMenuItemComponent.createObject(null, { "text": "Vehicle " + vehicle.id })
vehicleMenuItems.push(menuItem)
vehicleMenu.insertItem(i, menuItem)
}
}
Component.onCompleted: updateVehicleMenu()
Connections {
target: QGroundControl.multiVehicleManager.vehicles
onCountChanged: vehicleSelectorButton.updateVehicleMenu()
}
}
MainToolBarIndicators {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true
Layout.margins: ScreenTools.defaultFontPixelHeight * 0.66
} }
} }
...@@ -214,7 +133,7 @@ Rectangle { ...@@ -214,7 +133,7 @@ Rectangle {
Rectangle { Rectangle {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
height: toolBar.height * 0.05 height: toolBar.height * 0.05
width: _activeVehicle ? _activeVehicle.parameterManager.loadProgress * parent.width : 0 width: activeVehicle ? activeVehicle.parameterManager.loadProgress * parent.width : 0
color: qgcPal.colorGreen color: qgcPal.colorGreen
visible: !largeProgressBar.visible visible: !largeProgressBar.visible
} }
...@@ -229,7 +148,7 @@ Rectangle { ...@@ -229,7 +148,7 @@ Rectangle {
color: qgcPal.window color: qgcPal.window
visible: _showLargeProgress visible: _showLargeProgress
property bool _initialDownloadComplete: _activeVehicle ? _activeVehicle.parameterManager.parametersReady : true property bool _initialDownloadComplete: activeVehicle ? activeVehicle.parameterManager.parametersReady : true
property bool _userHide: false property bool _userHide: false
property bool _showLargeProgress: !_initialDownloadComplete && !_userHide && qgcPal.globalTheme === QGCPalette.Light property bool _showLargeProgress: !_initialDownloadComplete && !_userHide && qgcPal.globalTheme === QGCPalette.Light
...@@ -241,7 +160,7 @@ Rectangle { ...@@ -241,7 +160,7 @@ Rectangle {
Rectangle { Rectangle {
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
width: _activeVehicle ? _activeVehicle.parameterManager.loadProgress * parent.width : 0 width: activeVehicle ? activeVehicle.parameterManager.loadProgress * parent.width : 0
color: qgcPal.colorGreen color: qgcPal.colorGreen
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment