Commit 6d636fd3 authored by Gus Grubba's avatar Gus Grubba

Flight Widget

Allow plugins to define a left placement for its custom flight widget.
When placed on the left, the action tool strip is placed on the right side.
parent ffe6813b
...@@ -93,6 +93,20 @@ QGCView { ...@@ -93,6 +93,20 @@ QGCView {
QGroundControl.saveBoolGlobalSetting(_PIPVisibleKey, state) QGroundControl.saveBoolGlobalSetting(_PIPVisibleKey, state)
} }
function isInstrumentRight() {
if(QGroundControl.corePlugin.options.instrumentWidget) {
if(QGroundControl.corePlugin.options.instrumentWidget.source.toString().length) {
switch(QGroundControl.corePlugin.options.instrumentWidget.widgetPosition) {
case CustomInstrumentWidget.POS_TOP_LEFT:
case CustomInstrumentWidget.POS_BOTTOM_LEFT:
case CustomInstrumentWidget.POS_CENTER_LEFT:
return false;
}
}
}
return true;
}
PlanMasterController { PlanMasterController {
id: masterController id: masterController
Component.onCompleted: start(false /* editMode */) Component.onCompleted: start(false /* editMode */)
...@@ -446,8 +460,10 @@ QGCView { ...@@ -446,8 +460,10 @@ QGCView {
ToolStrip { ToolStrip {
visible: (_activeVehicle ? _activeVehicle.guidedModeSupported : true) && !QGroundControl.videoManager.fullScreen visible: (_activeVehicle ? _activeVehicle.guidedModeSupported : true) && !QGroundControl.videoManager.fullScreen
id: toolStrip id: toolStrip
anchors.leftMargin: ScreenTools.defaultFontPixelWidth anchors.leftMargin: isInstrumentRight() ? ScreenTools.defaultFontPixelWidth : undefined
anchors.left: _panel.left anchors.left: isInstrumentRight() ? _panel.left : undefined
anchors.rightMargin:isInstrumentRight() ? undefined : ScreenTools.defaultFontPixelWidth
anchors.right: isInstrumentRight() ? undefined : _panel.right
anchors.topMargin: ScreenTools.toolbarHeight + (_margins * 2) anchors.topMargin: ScreenTools.toolbarHeight + (_margins * 2)
anchors.top: _panel.top anchors.top: _panel.top
z: _panel.z + 4 z: _panel.z + 4
......
...@@ -52,15 +52,24 @@ Item { ...@@ -52,15 +52,24 @@ Item {
if(QGroundControl.corePlugin.options.instrumentWidget.source.toString().length) { if(QGroundControl.corePlugin.options.instrumentWidget.source.toString().length) {
instrumentsLoader.source = QGroundControl.corePlugin.options.instrumentWidget.source instrumentsLoader.source = QGroundControl.corePlugin.options.instrumentWidget.source
switch(QGroundControl.corePlugin.options.instrumentWidget.widgetPosition) { switch(QGroundControl.corePlugin.options.instrumentWidget.widgetPosition) {
case CustomInstrumentWidget.POS_TOP_LEFT:
instrumentsLoader.state = "topLeftMode"
break;
case CustomInstrumentWidget.POS_BOTTOM_LEFT:
instrumentsLoader.state = "bottomLeftMode"
break;
case CustomInstrumentWidget.POS_CENTER_LEFT:
instrumentsLoader.state = "centerLeftMode"
break;
case CustomInstrumentWidget.POS_TOP_RIGHT: case CustomInstrumentWidget.POS_TOP_RIGHT:
instrumentsLoader.state = "topMode" instrumentsLoader.state = "topRightMode"
break; break;
case CustomInstrumentWidget.POS_BOTTOM_RIGHT: case CustomInstrumentWidget.POS_BOTTOM_RIGHT:
instrumentsLoader.state = "bottomMode" instrumentsLoader.state = "bottomRightMode"
break; break;
case CustomInstrumentWidget.POS_CENTER_RIGHT: case CustomInstrumentWidget.POS_CENTER_RIGHT:
default: default:
instrumentsLoader.state = "centerMode" instrumentsLoader.state = "centerRightMode"
break; break;
} }
} else { } else {
...@@ -69,10 +78,9 @@ Item { ...@@ -69,10 +78,9 @@ Item {
var useAlternateInstruments = true//QGroundControl.settingsManager.appSettings.virtualJoystick.value || ScreenTools.isTinyScreen var useAlternateInstruments = true//QGroundControl.settingsManager.appSettings.virtualJoystick.value || ScreenTools.isTinyScreen
if(useAlternateInstruments) { if(useAlternateInstruments) {
instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidgetAlternate.qml" instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidgetAlternate.qml"
instrumentsLoader.state = "topMode"
} else { } else {
instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidget.qml" instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidget.qml"
instrumentsLoader.state = QGroundControl.settingsManager.appSettings.showLargeCompass.value === 1 ? "centerMode" : "topMode" instrumentsLoader.state = QGroundControl.settingsManager.appSettings.showLargeCompass.value === 1 ? "centerRightMode" : "topRightMode"
} }
} }
} else { } else {
...@@ -141,30 +149,69 @@ Item { ...@@ -141,30 +149,69 @@ Item {
property real maxHeight:parent.height - (anchors.margins * 2) property real maxHeight:parent.height - (anchors.margins * 2)
states: [ states: [
State { State {
name: "topMode" name: "topRightMode"
AnchorChanges {
target: instrumentsLoader
anchors.verticalCenter: undefined
anchors.bottom: undefined
anchors.top: _root ? _root.top : undefined
anchors.right: _root ? _root.right : undefined
anchors.left: undefined
}
},
State {
name: "centerRightMode"
AnchorChanges {
target: instrumentsLoader
anchors.top: undefined
anchors.bottom: undefined
anchors.verticalCenter: _root ? _root.verticalCenter : undefined
anchors.right: _root ? _root.right : undefined
anchors.left: undefined
}
},
State {
name: "bottomRightMode"
AnchorChanges {
target: instrumentsLoader
anchors.top: undefined
anchors.verticalCenter: undefined
anchors.bottom: _root ? _root.bottom : undefined
anchors.right: _root ? _root.right : undefined
anchors.left: undefined
}
},
State {
name: "topLeftMode"
AnchorChanges { AnchorChanges {
target: instrumentsLoader target: instrumentsLoader
anchors.verticalCenter: undefined anchors.verticalCenter: undefined
anchors.bottom: undefined anchors.bottom: undefined
anchors.top: _root ? _root.top : undefined anchors.top: _root ? _root.top : undefined
anchors.right: undefined
anchors.left: _root ? _root.left : undefined
} }
}, },
State { State {
name: "centerMode" name: "centerLeftMode"
AnchorChanges { AnchorChanges {
target: instrumentsLoader target: instrumentsLoader
anchors.top: undefined anchors.top: undefined
anchors.bottom: undefined anchors.bottom: undefined
anchors.verticalCenter: _root ? _root.verticalCenter : undefined anchors.verticalCenter: _root ? _root.verticalCenter : undefined
anchors.right: undefined
anchors.left: _root ? _root.left : undefined
} }
}, },
State { State {
name: "bottomMode" name: "bottomLeftMode"
AnchorChanges { AnchorChanges {
target: instrumentsLoader target: instrumentsLoader
anchors.top: undefined anchors.top: undefined
anchors.verticalCenter: undefined anchors.verticalCenter: undefined
anchors.bottom: _root ? _root.bottom : undefined anchors.bottom: _root ? _root.bottom : undefined
anchors.right: undefined
anchors.left: _root ? _root.left : undefined
} }
} }
] ]
......
...@@ -123,16 +123,19 @@ class CustomInstrumentWidget : public QObject ...@@ -123,16 +123,19 @@ class CustomInstrumentWidget : public QObject
public: public:
//-- Widget Position //-- Widget Position
enum Pos { enum Pos {
POS_TOP_RIGHT = 0, POS_TOP_RIGHT,
POS_CENTER_RIGHT = 1, POS_CENTER_RIGHT,
POS_BOTTOM_RIGHT = 2, POS_BOTTOM_RIGHT,
POS_TOP_LEFT,
POS_CENTER_LEFT,
POS_BOTTOM_LEFT
}; };
Q_ENUMS(Pos) Q_ENUMS(Pos)
CustomInstrumentWidget(QObject* parent = NULL); CustomInstrumentWidget(QObject* parent = NULL);
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(); }
virtual Pos widgetPosition () { return POS_CENTER_RIGHT; } virtual Pos widgetPosition () { return POS_TOP_RIGHT; }
signals: signals:
void widgetPositionChanged (); void widgetPositionChanged ();
}; };
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