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 @@
<file alias="FactSystemTest.qml">src/FactSystem/FactSystemTest.qml</file>
</qresource>
<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="BatteryIndicator.qml">src/ui/toolbar/BatteryIndicator.qml</file>
<file alias="GPSIndicator.qml">src/ui/toolbar/GPSIndicator.qml</file>
......@@ -48,7 +49,7 @@
<file alias="LinkSettings.qml">src/ui/preferences/LinkSettings.qml</file>
<file alias="LogDownloadPage.qml">src/AnalyzeView/LogDownloadPage.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="MavlinkSettings.qml">src/ui/preferences/MavlinkSettings.qml</file>
<file alias="MissionSettingsEditor.qml">src/PlanView/MissionSettingsEditor.qml</file>
......@@ -76,8 +77,6 @@
<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/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/MissionItemEditor.qml">src/PlanView/MissionItemEditor.qml</file>
<file alias="QGroundControl/Controls/MissionItemIndexLabel.qml">src/QmlControls/MissionItemIndexLabel.qml</file>
......
......@@ -33,10 +33,10 @@ FactPanelController::FactPanelController()
void FactPanelController::_notifyPanelMissingParameter(const QString& missingParam)
{
if (qgcApp()->mainQmlWindow()) {
if (qgcApp()->mainRootWindow()) {
QVariant returnedValue;
QMetaObject::invokeMethod(
qgcApp()->mainQmlWindow(),
qgcApp()->mainRootWindow(),
"showMissingParameterOverlay",
Q_RETURN_ARG(QVariant, returnedValue),
Q_ARG(QVariant, missingParam));
......@@ -45,10 +45,10 @@ void FactPanelController::_notifyPanelMissingParameter(const QString& missingPar
void FactPanelController::_notifyPanelErrorMsg(const QString& errorMsg)
{
if(qgcApp()->mainQmlWindow()) {
if(qgcApp()->mainRootWindow()) {
QVariant returnedValue;
QMetaObject::invokeMethod(
qgcApp()->mainQmlWindow(),
qgcApp()->mainRootWindow(),
"showFactError",
Q_RETURN_ARG(QVariant, returnedValue),
Q_ARG(QVariant, errorMsg));
......@@ -67,7 +67,7 @@ void FactPanelController::_reportMissingParameter(int componentId, const QString
// 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
// send out for real.
if (qgcApp()->mainQmlWindow()) {
if (qgcApp()->mainRootWindow()) {
_notifyPanelMissingParameter(missingParam);
} else {
_delayedMissingParams += missingParam;
......
......@@ -570,8 +570,8 @@ Item {
z: _mapAndVideo.z + 4
title: qsTr("Fly")
maxHeight: (_flightVideo.visible ? _flightVideo.y : parent.height) - toolStrip.y
buttonVisible: [true, _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 ]
buttonVisible: [_useChecklist, _guidedController.showTakeoff || !_guidedController.showLand, _guidedController.showLand && !_guidedController.showTakeoff, true, true, true ]
buttonEnabled: [_useChecklist && activeVehicle, _guidedController.showTakeoff, _guidedController.showLand, _guidedController.showRTL, _guidedController.showPause, _anyActionAvailable ]
property bool _anyActionAvailable: _guidedController.showStartMission || _guidedController.showResumeMission || _guidedController.showChangeAlt || _guidedController.showLandAbort
property var _actionModel: [
......@@ -609,12 +609,8 @@ Item {
model: [
{
name: "Plan",
iconSource: "/qmlimages/Plan.svg",
},
{
name: "Checklist",
iconSource: "/qmlimages/check.svg",
name: "Checklist",
iconSource: "/qmlimages/check.svg",
dropPanelComponent: checklistDropPanel
},
{
......@@ -646,18 +642,13 @@ Item {
onClicked: {
guidedActionsController.closeAll()
if(index === 0) {
mainWindow.showPlanView()
var action = model[index].action
if (action === -1) {
guidedActionList.model = _actionModel
guidedActionList.visible = true
} else {
var action = model[index].action
if (action === -1) {
guidedActionList.model = _actionModel
guidedActionList.visible = true
} else {
_guidedController.confirmAction(action)
}
_guidedController.confirmAction(action)
}
}
}
......@@ -689,7 +680,6 @@ Item {
/// Close all dialogs
function closeAll() {
mainWindow.enableToolbar()
rootLoader.sourceComponent = null
guidedActionConfirm.visible = false
guidedActionList.visible = false
......
......@@ -23,12 +23,12 @@ Rectangle {
property real missionMaxTelemetry: _controllerValid ? _planMasterController.missionController.missionMaxTelemetry : NaN
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 var _controllerDirty: _controllerValid ? _planMasterController.dirty : 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 real _dataFontSize: ScreenTools.defaultFontPointSize
......@@ -77,6 +77,28 @@ Rectangle {
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
on_ControllerProgressPctChanged: {
......
......@@ -551,20 +551,16 @@ Item {
color: qgcPal.window
title: qsTr("Plan")
z: QGroundControl.zOrderWidgets
showAlternateIcon: [ false, _planMasterController.dirty, false, false, false, false, false, false ]
rotateImage: [ false, _planMasterController.syncInProgress, false, false, false, false, false, false ]
animateImage: [ false, _planMasterController.dirty, false, false, false, false, false, false ]
buttonEnabled: [ true, !_planMasterController.syncInProgress, true, true, true, true, true, true ]
buttonVisible: [ true, true, true, _waypointsOnlyMode, true, true, _showZoom, _showZoom ]
showAlternateIcon: [ _planMasterController.dirty, false, false, false, false, false, false ]
rotateImage: [ _planMasterController.syncInProgress, false, false, false, false, false, false ]
animateImage: [ _planMasterController.dirty, false, false, false, false, false, false ]
buttonEnabled: [ !_planMasterController.syncInProgress, true, true, true, true, true, true ]
buttonVisible: [ true, true, _waypointsOnlyMode, true, true, _showZoom, _showZoom ]
maxHeight: mapScale.y - toolStrip.y
property bool _showZoom: !ScreenTools.isMobile
model: [
{
name: qsTr("Fly"),
iconSource: "/qmlimages/PaperPlane.svg",
},
{
name: qsTr("File"),
iconSource: "/qmlimages/MapSync.svg",
......@@ -603,26 +599,23 @@ Item {
onClicked: {
switch (index) {
case 0:
mainWindow.showFlyView()
break;
case 2:
case 1:
_addWaypointOnClick = checked
_addROIOnClick = false
break
case 3:
case 2:
_addROIOnClick = checked
_addWaypointOnClick = false
break
case 4:
case 3:
if (_singleComplexItem) {
addComplexItem(_missionController.complexMissionItemNames[0])
}
break
case 6:
case 5:
editorMap.zoomLevel += 0.5
break
case 7:
case 6:
editorMap.zoomLevel -= 0.5
break
}
......
......@@ -654,12 +654,12 @@ void QGCApplication::showMessage(const QString& message)
}
}
QQuickItem* QGCApplication::mainQmlWindow()
QQuickItem* QGCApplication::mainRootWindow()
{
if(_mainQmlWindow) {
_mainQmlWindow = reinterpret_cast<QQuickItem*>(_rootQmlObject());
if(_mainRootWindow) {
_mainRootWindow = reinterpret_cast<QQuickItem*>(_rootQmlObject());
}
return _mainQmlWindow;
return _mainRootWindow;
}
void QGCApplication::showSetupView()
......
......@@ -96,7 +96,7 @@ public:
static QString cachedAirframeMetaDataFile(void);
void setLanguage();
QQuickItem* mainQmlWindow();
QQuickItem* mainRootWindow();
public slots:
/// You can connect to this slot to show an information message box from a different thread.
......@@ -180,7 +180,7 @@ private:
QGCFileDownload* _currentVersionDownload = nullptr;
GPSRTKFactGroup* _gpsRtkFactGroup = nullptr;
QGCToolbox* _toolbox = nullptr;
QQuickItem* _mainQmlWindow = nullptr;
QQuickItem* _mainRootWindow = nullptr;
bool _bluetoothAvailable = false;
QTranslator _QGCTranslator;
......
......@@ -104,24 +104,24 @@ public:
DEFINE_QGC_COLOR(alertText, setAlertText)
DEFINE_QGC_COLOR(missionItemEditor, setMissionItemEditor)
QGCPalette(QObject* parent = NULL);
QGCPalette(QObject* parent = nullptr);
~QGCPalette();
bool colorGroupEnabled (void) const { return _colorGroupEnabled; }
void setColorGroupEnabled (bool enabled);
static Theme globalTheme (void) { return _theme; }
static void setGlobalTheme (Theme newTheme);
signals:
void paletteChanged ();
private:
static void _buildMap (void);
static void _signalPaletteChangeToAll (void);
void _signalPaletteChanged (void);
void _themeChanged (void);
static Theme _theme; ///< There is a single theme for all palettes
bool _colorGroupEnabled; ///< Currently selected ColorGroup. true: enabled, false: disabled
......
......@@ -20,11 +20,13 @@ Button {
height: ScreenTools.defaultFontPixelHeight * 3
autoExclusive: true
property bool logo: false
QGCPalette { id: qgcPal }
background: Rectangle {
anchors.fill: parent
color: checked ? qgcPal.buttonHighlight : qgcPal.button
color: logo ? qgcPal.brandingPurple : (checked ? qgcPal.buttonHighlight : Qt.rgba(0,0,0,0))
}
contentItem: Row {
......@@ -38,12 +40,13 @@ Button {
width: height
sourceSize.height: parent.height
fillMode: Image.PreserveAspectFit
color: button.checked ? qgcPal.buttonHighlightText : qgcPal.buttonText
color: logo ? "white" : (button.checked ? qgcPal.buttonHighlightText : qgcPal.buttonText)
source: button.icon.source
anchors.verticalCenter: parent.verticalCenter
}
Label {
id: _label
visible: text !== ""
text: button.text
color: button.checked ? qgcPal.buttonHighlightText : qgcPal.buttonText
anchors.verticalCenter: parent.verticalCenter
......
......@@ -20,7 +20,6 @@ GeoFenceMapVisuals 1.0 GeoFenceMapVisuals.qml
HackFileDialog 1.0 HackFileDialog.qml
IndicatorButton 1.0 IndicatorButton.qml
JoystickThumbPad 1.0 JoystickThumbPad.qml
MainToolBar 1.0 MainToolBar.qml
MissionCommandDialog 1.0 MissionCommandDialog.qml
MissionItemEditor 1.0 MissionItemEditor.qml
MissionItemIndexLabel 1.0 MissionItemIndexLabel.qml
......
......@@ -230,7 +230,6 @@ Item {
onAcceptedForLoad: {
if(!QGroundControl.mapEngineManager.importSets(file)) {
showList();
mainWindow.enableToolbar()
}
close()
}
......@@ -1143,7 +1142,6 @@ Item {
visible: !QGroundControl.mapEngineManager.exporting
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
mainWindow.enableToolbar()
rootLoader.sourceComponent = null
}
}
......@@ -1227,7 +1225,6 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
showList();
mainWindow.enableToolbar()
rootLoader.sourceComponent = null
}
}
......@@ -1250,7 +1247,6 @@ Item {
width: _bigButtonSize * 1.25
onClicked: {
showList();
mainWindow.enableToolbar()
rootLoader.sourceComponent = null
}
}
......
......@@ -300,7 +300,7 @@ QQmlApplicationEngine* QGCCorePlugin::createRootWindow(QObject *parent)
pEngine->addImportPath("qrc:/qml");
pEngine->rootContext()->setContextProperty("joystickManager", qgcApp()->toolbox()->joystickManager());
pEngine->rootContext()->setContextProperty("debugMessageModel", AppMessages::getModel());
pEngine->load(QUrl(QStringLiteral("qrc:/qml/MainQmlWindow.qml")));
pEngine->load(QUrl(QStringLiteral("qrc:/qml/MainRootWindow.qml")));
return pEngine;
}
......
......@@ -31,9 +31,27 @@ QGCOptions::instrumentWidget()
}
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
......
......@@ -12,6 +12,7 @@
#include <QObject>
#include <QString>
#include <QUrl>
#include <QColor>
/// @file
/// @brief Core Plugin Interface for QGroundControl - Application Options
......@@ -29,7 +30,12 @@ public:
Q_PROPERTY(bool enablePlanViewSelector READ enablePlanViewSelector CONSTANT)
Q_PROPERTY(CustomInstrumentWidget* instrumentWidget READ instrumentWidget 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(bool showSensorCalibrationCompass READ showSensorCalibrationCompass NOTIFY showSensorCalibrationCompassChanged)
Q_PROPERTY(bool showSensorCalibrationGyro READ showSensorCalibrationGyro NOTIFY showSensorCalibrationGyroChanged)
......@@ -79,8 +85,11 @@ public:
/// Allows access to the full fly view window
virtual QUrl flyViewOverlay () const { return QUrl(); }
/// Allows replacing the toolbar container
virtual QUrl mainToolbarIndicatorsUrl () const;
/// Allows replacing the toolbar
virtual QUrl mainToolbarUrl () const;
virtual QUrl planToolbarUrl () const;
virtual QColor toolbarBackgroundLight () const;
virtual QColor toolbarBackgroundDark () const;
/// Allows replacing the Plan View toolbar container
virtual QUrl planToolbarIndicatorsUrl () const;
/// By returning false you can hide the following sensor calibration pages
......@@ -157,7 +166,7 @@ public:
POS_BOTTOM_LEFT
};
Q_ENUM(Pos)
CustomInstrumentWidget(QObject* parent = NULL);
CustomInstrumentWidget(QObject* parent = nullptr);
Q_PROPERTY(QUrl source READ source CONSTANT)
Q_PROPERTY(Pos widgetPosition READ widgetPosition NOTIFY widgetPositionChanged)
virtual QUrl source () { return QUrl(); }
......
......@@ -24,12 +24,12 @@ import QGroundControl.FlightMap 1.0
ApplicationWindow {
id: mainWindow
width: 1280
height: 1024
height: 720
visible: true
readonly property real _topBottomMargins: ScreenTools.defaultFontPixelHeight * 0.5
readonly property string _mainToolbarIndicators: QGroundControl.corePlugin.options.mainToolbarIndicatorsUrl
readonly property string _planToolbarIndicators: QGroundControl.corePlugin.options.planToolbarIndicatorsUrl
readonly property string _mainToolbar: QGroundControl.corePlugin.options.mainToolbarUrl
readonly property string _planToolbar: QGroundControl.corePlugin.options.planToolbarUrl
readonly property string _settingsViewSource: "AppSettings.qml"
readonly property string _setupViewSource: "SetupView.qml"
readonly property string _planViewSource: "PlanView.qml"
......@@ -64,28 +64,18 @@ ApplicationWindow {
//-------------------------------------------------------------------------
//-- Global Scope Functions
function disableToolbar() {
drawer.enabled = false
}
function enableToolbar() {
drawer.enabled = true
}
function viewSwitch(isPlanView) {
enableToolbar()
drawer.close()
if(isPlanView) {
rootBackground.visible = false
planViewLoader.visible = true
if(toolbarIndicators.source !== _planToolbarIndicators) {
toolbarIndicators.source = _planToolbarIndicators
if(toolbar.source !== _planToolbar) {
toolbar.source = _planToolbar
}
} else {
rootBackground.visible = true
planViewLoader.visible = false
if(toolbarIndicators.source !== _mainToolbarIndicators) {
toolbarIndicators.source = _mainToolbarIndicators
if(toolbar.source !== _mainToolbar) {
toolbar.source = _mainToolbar
}
}
}
......@@ -93,9 +83,6 @@ ApplicationWindow {
function showFlyView() {
viewSwitch(false)
mainContentWindow.source = ""
if(toolbarIndicators.source !== _mainToolbarIndicators) {
toolbarIndicators.source = _mainToolbarIndicators
}
}
function showPlanView() {
......@@ -297,169 +284,17 @@ ApplicationWindow {
}
//-------------------------------------------------------------------------
//-- Global Indicator Bar
//-- Toolbar
header: ToolBar {
height: ScreenTools.toolbarHeight
visible: !QGroundControl.videoManager.fullScreen
background: Rectangle {
color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(1,1,1,0.8) : Qt.rgba(0,0,0,0.75)
}
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 {
id: toolbarIndicators
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
color: qgcPal.globalTheme === QGCPalette.Light ? QGroundControl.corePlugin.options.toolbarBackgroundLight : QGroundControl.corePlugin.options.toolbarBackgroundDark
}
MouseArea {
Loader {
id: toolbar
anchors.fill: parent
onClicked: largeProgressBar._userHide = true
}
}
//-------------------------------------------------------------------------
//-- 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()
}
}
source: _mainToolbar
}
}
......@@ -472,7 +307,7 @@ ApplicationWindow {
//-------------------------------------------------------------------------
//-- 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 {
id: rootLoader
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()
}
}
}
This diff is collapsed.
......@@ -7,9 +7,9 @@
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Layouts 1.2
import QtQuick.Controls 1.2
import QtQuick 2.11
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.11
import QGroundControl 1.0
import QGroundControl.Controls 1.0
......@@ -18,55 +18,14 @@ import QGroundControl.MultiVehicleManager 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controllers 1.0
Rectangle {
Item {
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: {
//-- TODO: Get this from the actual state
flyButton.checked = true
}
// Prevent all clicks from going through to lower layers
DeadMouseArea {
anchors.fill: parent
}
/// Bottom single pixel divider
Rectangle {
anchors.left: parent.left
......@@ -83,6 +42,10 @@ Rectangle {
anchors.fill: parent
spacing: ScreenTools.defaultFontPixelWidth * 2
ButtonGroup {
buttons: viewRow.children
}
//---------------------------------------------
// Toolbar Row
Row {
......@@ -90,54 +53,62 @@ Rectangle {
Layout.fillHeight: true
spacing: ScreenTools.defaultFontPixelWidth / 2
ExclusiveGroup { id: mainActionGroup }
QGCToolBarButton {
id: settingsButton
anchors.top: parent.top
anchors.bottom: parent.bottom
exclusiveGroup: mainActionGroup
source: "/res/QGCLogoWhite"
icon.source: "/res/QGCLogoWhite"
logo: true
onClicked: toolBar.showSettingsView()
visible: !QGroundControl.corePlugin.options.combineSettingsAndSetup
onClicked: {
checked = true
mainWindow.showSettingsView()
}
}
QGCToolBarButton {
id: setupButton
anchors.top: parent.top
anchors.bottom: parent.bottom
exclusiveGroup: mainActionGroup
source: "/qmlimages/Gears.svg"
onClicked: toolBar.showSetupView()
icon.source: "/qmlimages/Gears.svg"
onClicked: {
checked = true
mainWindow.showSetupView()
}
}
QGCToolBarButton {
id: planButton
anchors.top: parent.top
anchors.bottom: parent.bottom
exclusiveGroup: mainActionGroup
source: "/qmlimages/Plan.svg"
onClicked: toolBar.showPlanView()
icon.source: "/qmlimages/Plan.svg"
onClicked: {
checked = true
mainWindow.showPlanView()
}
}
QGCToolBarButton {
id: flyButton
anchors.top: parent.top
anchors.bottom: parent.bottom
exclusiveGroup: mainActionGroup
source: "/qmlimages/PaperPlane.svg"
onClicked: toolBar.showFlyView()
icon.source: "/qmlimages/PaperPlane.svg"
onClicked: {
checked = true
mainWindow.showFlyView()
}
}
QGCToolBarButton {
id: analyzeButton
anchors.top: parent.top
anchors.bottom: parent.bottom
exclusiveGroup: mainActionGroup
source: "/qmlimages/Analyze.svg"
icon.source: "/qmlimages/Analyze.svg"
visible: QGroundControl.corePlugin.showAdvancedUI
onClicked: toolBar.showAnalyzeView()
onClicked: {
checked = true
mainWindow.showAnalyzeView()
}
}
Rectangle {
......@@ -146,67 +117,15 @@ Rectangle {
anchors.bottom: parent.bottom
width: 1
color: qgcPal.text
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() {
var i;
// Remove old menu items
for (i = 0; i < vehicleMenuItems.length; i++) {
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()
visible: activeVehicle
}
}
MainToolBarIndicators {
Loader {
id: toolbarIndicators
height: parent.height
source: "/toolbar/MainToolBarIndicators.qml"
Layout.fillWidth: true
Layout.fillHeight: true
Layout.margins: ScreenTools.defaultFontPixelHeight * 0.66
}
}
......@@ -214,7 +133,7 @@ Rectangle {
Rectangle {
anchors.bottom: parent.bottom
height: toolBar.height * 0.05
width: _activeVehicle ? _activeVehicle.parameterManager.loadProgress * parent.width : 0
width: activeVehicle ? activeVehicle.parameterManager.loadProgress * parent.width : 0
color: qgcPal.colorGreen
visible: !largeProgressBar.visible
}
......@@ -229,7 +148,7 @@ Rectangle {
color: qgcPal.window
visible: _showLargeProgress
property bool _initialDownloadComplete: _activeVehicle ? _activeVehicle.parameterManager.parametersReady : true
property bool _initialDownloadComplete: activeVehicle ? activeVehicle.parameterManager.parametersReady : true
property bool _userHide: false
property bool _showLargeProgress: !_initialDownloadComplete && !_userHide && qgcPal.globalTheme === QGCPalette.Light
......@@ -241,7 +160,7 @@ Rectangle {
Rectangle {
anchors.top: parent.top
anchors.bottom: parent.bottom
width: _activeVehicle ? _activeVehicle.parameterManager.loadProgress * parent.width : 0
width: activeVehicle ? activeVehicle.parameterManager.loadProgress * parent.width : 0
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