Commit 75dc8e5b authored by Gus Grubba's avatar Gus Grubba

Update Airmap controls to QtQuick 2.4 and bring it in sync with the new QGC UI core.

Better handle the dirty state of Airmap's flightplan
parent 5c400033
......@@ -139,9 +139,11 @@ AirMapFlightPlanManager::setFlightStartTime(QDateTime start)
{
if(start < QDateTime::currentDateTime()) {
start = QDateTime::currentDateTime().addSecs(1);
setDirty(true);
}
if(_flightStartTime != start) {
_flightStartTime = start;
setDirty(true);
emit flightStartTimeChanged();
}
qCDebug(AirMapManagerLog) << "Set time start time" << _flightStartTime;
......@@ -152,6 +154,7 @@ void
AirMapFlightPlanManager::setFlightStartsNow(bool now)
{
_flightStartsNow = now;
setDirty(true);
emit flightStartsNowChanged();
}
......@@ -159,12 +162,15 @@ AirMapFlightPlanManager::setFlightStartsNow(bool now)
void
AirMapFlightPlanManager::setFlightDuration(int seconds)
{
if(_flightDuration != seconds || _flightDuration < 30) {
_flightDuration = seconds;
if(_flightDuration < 30) {
_flightDuration = 30;
}
setDirty(true);
emit flightDurationChanged();
qCDebug(AirMapManagerLog) << "Set time duration" << _flightDuration;
}
}
//-----------------------------------------------------------------------------
......@@ -261,6 +267,7 @@ AirMapFlightPlanManager::updateFlightPlan()
}
_flightPermitStatus = AirspaceFlightPlanProvider::PermitPending;
emit flightPermitStatusChanged();
setDirty(false);
_updateFlightPlan(true);
}
......
......@@ -7,6 +7,7 @@
*
****************************************************************************/
#include "AirspaceFlightPlanProvider.h"
#include "AirMapRulesetsManager.h"
#include "AirMapManager.h"
#include "QGCApplication.h"
......@@ -136,6 +137,7 @@ AirMapRuleFeature::setValue(const QVariant val)
settings.setValue(name(), _value);
settings.endGroup();
emit valueChanged();
qgcApp()->toolbox()->airspaceManager()->flightPlan()->setDirty(true);
}
//-----------------------------------------------------------------------------
......
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick 2.11
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.11
import QtQuick.Dialogs 1.3
import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.2
import QtQml 2.2
import QtGraphicalEffects 1.0
......@@ -21,7 +21,7 @@ Item {
height: _colapsed ? colapsedRect.height : expandedRect.height
property bool showColapse: true
property bool planView: true
property bool planView: false
property color _airspaceColor: _validAdvisories ? getAispaceColor(QGroundControl.airspaceManager.advisories.airspaceColor) : _colorGray
property bool _validRules: QGroundControl.airspaceManager.connected && QGroundControl.airspaceManager.ruleSets.valid
......@@ -29,7 +29,6 @@ Item {
property color _textColor: qgcPal.text
property bool _colapsed: !QGroundControl.airspaceManager.airspaceVisible || !QGroundControl.airspaceManager.connected
property int _flightPermit: QGroundControl.airspaceManager.flightPlan.flightPermitStatus
property bool _dirty: false
readonly property real _radius: ScreenTools.defaultFontPixelWidth * 0.5
readonly property color _colorOrange: "#d75e0d"
......@@ -42,6 +41,8 @@ Item {
readonly property color _colorWhite: "#ffffff"
readonly property color _colorRed: "#aa1200"
readonly property color _colorGreen: "#125f00"
readonly property real _baseHeight: ScreenTools.defaultFontPixelHeight * 22
readonly property real _baseWidth: ScreenTools.defaultFontPixelWidth * 40
QGCPalette {
id: qgcPal
......@@ -309,8 +310,7 @@ Item {
MouseArea {
anchors.fill: parent
onClicked: {
rootLoader.sourceComponent = ruleSelector
mainWindow.disableToolbar()
ruleSelector.open()
}
}
}
......@@ -377,8 +377,7 @@ Item {
visible: _flightPermit !== AirspaceFlightPlanProvider.PermitNone
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
rootLoader.sourceComponent = planView ? flightDetails : flightBrief
mainWindow.disableToolbar()
planView ? flightDetails.open() : flightBrief.open()
}
}
QGCLabel {
......@@ -391,45 +390,34 @@ Item {
}
//---------------------------------------------------------------
//-- Rule Selector
Component {
Popup {
id: ruleSelector
Rectangle {
width: mainWindow.width
height: mainWindow.height
color: Qt.rgba(0,0,0,0.1)
MouseArea {
anchors.fill: parent
onWheel: { wheel.accepted = true; }
onClicked: {
mainWindow.enableToolbar()
rootLoader.sourceComponent = null
}
width: rulesCol.width + ScreenTools.defaultFontPixelWidth
height: rulesCol.height + ScreenTools.defaultFontPixelHeight
modal: true
focus: true
parent: Overlay.overlay
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
property var _popupTarget: null
property var _arrowTarget: null
onVisibleChanged: {
if(visible) {
_popupTarget = mainWindow.contentItem.mapFromItem(_root, 0, 0)
_arrowTarget = mainWindow.contentItem.mapFromItem(pencilIcon, 0, 0)
}
Rectangle {
id: ruleSelectorShadow
anchors.fill: ruleSelectorRect
radius: ruleSelectorRect.radius
color: qgcPal.window
visible: false
}
DropShadow {
anchors.fill: ruleSelectorShadow
visible: ruleSelectorRect.visible
horizontalOffset: 4
verticalOffset: 4
radius: 32.0
samples: 65
color: Qt.rgba(0,0,0,0.75)
source: ruleSelectorShadow
}
Rectangle {
id: ruleSelectorRect
x: 0
y: 0
x: _popupTarget ? _popupTarget.x - width - (ScreenTools.defaultFontPixelWidth * 5) : 0
y: _popupTarget ? _popupTarget.y + mainWindow.header.height : 0
background: Rectangle {
anchors.fill: parent
color: qgcPal.window
width: rulesCol.width + ScreenTools.defaultFontPixelWidth
height: rulesCol.height + ScreenTools.defaultFontPixelHeight
radius: ScreenTools.defaultFontPixelWidth
}
Column {
id: rulesCol
spacing: ScreenTools.defaultFontPixelHeight * 0.5
......@@ -464,7 +452,6 @@ Item {
width: 1
height: 1
}
ExclusiveGroup { id: rulesGroup }
QGCLabel {
text: qsTr("PICK ONE REGULATION")
font.pointSize: ScreenTools.smallFontPointSize
......@@ -475,7 +462,7 @@ Item {
delegate: RuleSelector {
visible: object.selectionType === AirspaceRuleSet.Pickone
rule: object
exclusiveGroup: rulesGroup
autoExclusive: true
anchors.right: parent.right
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.left: parent.left
......@@ -516,7 +503,7 @@ Item {
delegate: RuleSelector {
visible: object.selectionType === AirspaceRuleSet.Required
rule: object
required: true
enabled: false
anchors.right: parent.right
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.left: parent.left
......@@ -526,91 +513,37 @@ Item {
}
}
}
}
//-- Arrow
QGCColoredImage {
id: arrowIconShadow
anchors.fill: arrowIcon
sourceSize.height: height
source: "qrc:/airmap/right-arrow.svg"
color: qgcPal.window
visible: false
}
DropShadow {
anchors.fill: arrowIconShadow
visible: ruleSelectorRect.visible && qgcPal.globalTheme === QGCPalette.Dark
horizontalOffset: 4
verticalOffset: 4
radius: 32.0
samples: 65
color: Qt.rgba(0,0,0,0.75)
source: arrowIconShadow
}
QGCColoredImage {
id: arrowIcon
width: height
height: ScreenTools.defaultFontPixelHeight * 2
sourceSize.height: height
source: "qrc:/airmap/right-arrow.svg"
color: ruleSelectorRect.color
anchors.left: ruleSelectorRect.right
anchors.top: ruleSelectorRect.top
anchors.topMargin: (ScreenTools.defaultFontPixelHeight * 4) - (height * 0.5) + (pencilIcon.height * 0.5)
}
Component.onCompleted: {
mainWindow.disableToolbar()
var target = mainWindow.mapFromItem(pencilIcon, 0, 0)
ruleSelectorRect.x = target.x - ruleSelectorRect.width - (ScreenTools.defaultFontPixelWidth * 7)
ruleSelectorRect.y = target.y - (ScreenTools.defaultFontPixelHeight * 4)
}
color: qgcPal.window
anchors.left: parent.right
y: ruleSelector._arrowTarget ? (ruleSelector._arrowTarget.y - height) : 0
}
}
//---------------------------------------------------------------
//-- Flight Details
Component {
Popup {
id: flightDetails
Rectangle {
id: flightDetailsRoot
width: mainWindow.width
height: mainWindow.height
color: Qt.rgba(0,0,0,0.1)
property real baseHeight: ScreenTools.defaultFontPixelHeight * 22
property real baseWidth: ScreenTools.defaultFontPixelWidth * 40
Component.onCompleted: {
_dirty = false
mainWindow.disableToolbar()
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onWheel: { wheel.accepted = true; }
onPressed: { mouse.accepted = true; }
onReleased: { mouse.accepted = true; }
}
Rectangle {
id: flightDetailsShadow
anchors.fill: flightDetailsRect
radius: flightDetailsRect.radius
color: qgcPal.window
visible: false
}
DropShadow {
anchors.fill: flightDetailsShadow
visible: flightDetailsRect.visible
horizontalOffset: 4
verticalOffset: 4
radius: 32.0
samples: 65
color: Qt.rgba(0,0,0,0.75)
source: flightDetailsShadow
}
Rectangle {
id: flightDetailsRect
color: qgcPal.window
width: flDetailsRow.width + (ScreenTools.defaultFontPixelWidth * 4)
height: flDetailsRow.height + (ScreenTools.defaultFontPixelHeight * 2)
modal: true
focus: true
parent: Overlay.overlay
x: Math.round((mainWindow.width - width) * 0.5)
y: Math.round((mainWindow.height - height) * 0.5)
closePolicy: Popup.NoAutoClose
background: Rectangle {
anchors.fill: parent
color: qgcPal.window
radius: ScreenTools.defaultFontPixelWidth
anchors.centerIn: parent
}
Row {
id: flDetailsRow
spacing: ScreenTools.defaultFontPixelWidth
......@@ -618,8 +551,9 @@ Item {
//---------------------------------------------------------
//-- Flight Details
FlightDetails {
baseHeight: flightDetailsRoot.baseHeight
baseWidth: flightDetailsRoot.baseWidth
id: _flightDetails
baseHeight: _baseHeight
baseWidth: _baseWidth
}
//---------------------------------------------------------
//-- Divider
......@@ -633,68 +567,37 @@ Item {
//---------------------------------------------------------
//-- Flight Brief
FlightBrief {
baseHeight: flightDetailsRoot.baseHeight
baseWidth: flightDetailsRoot.baseWidth
}
}
baseHeight: _baseHeight
baseWidth: _baseWidth
onClosed: flightDetails.close()
}
}
}
//---------------------------------------------------------------
//-- Flight Brief
Component {
Popup {
id: flightBrief
Rectangle {
id: flightBriefRoot
width: mainWindow.width
height: mainWindow.height
color: Qt.rgba(0,0,0,0.1)
property real baseHeight: ScreenTools.defaultFontPixelHeight * 22
property real baseWidth: ScreenTools.defaultFontPixelWidth * 40
Component.onCompleted: {
_dirty = false
mainWindow.disableToolbar()
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onWheel: { wheel.accepted = true; }
onPressed: { mouse.accepted = true; }
onReleased: { mouse.accepted = true; }
}
Rectangle {
id: flightBriefShadow
anchors.fill: flightBriefRect
radius: flightBriefRect.radius
color: qgcPal.window
visible: false
}
DropShadow {
anchors.fill: flightBriefShadow
visible: flightBriefRect.visible
horizontalOffset: 4
verticalOffset: 4
radius: 32.0
samples: 65
color: Qt.rgba(0,0,0,0.75)
source: flightBriefShadow
}
Rectangle {
id: flightBriefRect
color: qgcPal.window
width: flightBriedItem.width + (ScreenTools.defaultFontPixelWidth * 4)
height: flightBriedItem.height + (ScreenTools.defaultFontPixelHeight * 2)
modal: true
focus: true
parent: Overlay.overlay
x: Math.round((mainWindow.width - width) * 0.5)
y: Math.round((mainWindow.height - height) * 0.5)
closePolicy: Popup.NoAutoClose
background: Rectangle {
anchors.fill: parent
color: qgcPal.window
radius: ScreenTools.defaultFontPixelWidth
anchors.centerIn: parent
}
//---------------------------------------------------------
//-- Flight Brief
FlightBrief {
id: flightBriedItem
baseHeight: flightBriefRoot.baseHeight
baseWidth: flightBriefRoot.baseWidth
baseHeight: _baseHeight
baseWidth: _baseWidth
onClosed: flightBrief.close()
anchors.centerIn: parent
}
}
}
}
}
......@@ -18,6 +18,7 @@ Item {
implicitWidth: briefRootCol.width
property real baseHeight: ScreenTools.defaultFontPixelHeight * 22
property real baseWidth: ScreenTools.defaultFontPixelWidth * 40
signal closed()
Column {
id: briefRootCol
spacing: ScreenTools.defaultFontPixelHeight * 0.25
......@@ -198,11 +199,10 @@ Item {
backRadius: 4
heightFactor: 0.3333
showBorder: true
enabled: _flightPermit !== AirspaceFlightPlanProvider.PermitNone && _dirty
enabled: _flightPermit !== AirspaceFlightPlanProvider.PermitNone && QGroundControl.airspaceManager.flightPlan.dirty
visible: planView
width: ScreenTools.defaultFontPixelWidth * 12
onClicked: {
_dirty = false
QGroundControl.airspaceManager.flightPlan.updateFlightPlan()
}
}
......@@ -216,8 +216,7 @@ Item {
visible: planView
onClicked: {
QGroundControl.airspaceManager.flightPlan.submitFlightPlan()
mainWindow.enableToolbar()
rootLoader.sourceComponent = null
_root.closed()
}
}
QGCButton {
......@@ -227,8 +226,7 @@ Item {
showBorder: true
width: ScreenTools.defaultFontPixelWidth * 12
onClicked: {
mainWindow.enableToolbar()
rootLoader.sourceComponent = null
_root.closed()
}
}
}
......
......@@ -71,7 +71,6 @@ Item {
text: qsTr("Now")
checked: QGroundControl.airspaceManager.flightPlan.flightStartsNow
onClicked: {
_dirty = true
QGroundControl.airspaceManager.flightPlan.flightStartsNow = !QGroundControl.airspaceManager.flightPlan.flightStartsNow
}
}
......@@ -89,7 +88,6 @@ Item {
enabled: !QGroundControl.airspaceManager.flightPlan.flightStartsNow
iconSource: "qrc:/airmap/expand.svg"
onClicked: {
_dirty = true
datePicker.visible = true
}
}
......@@ -112,7 +110,6 @@ Item {
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
onValueChanged: {
_dirty = true
var today = QGroundControl.airspaceManager.flightPlan.flightStartTime
today.setHours(Math.floor(timeSlider.value * 0.25))
today.setMinutes((timeSlider.value * 15) % 60)
......
......@@ -29,32 +29,36 @@ Rectangle {
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
QGCLabel {
text: feature.description
text: feature ? feature.description : ""
anchors.right: parent.right
anchors.left: parent.left
wrapMode: Text.WordWrap
visible: feature.type !== AirspaceRuleFeature.Boolean
visible: feature ? (feature.type !== AirspaceRuleFeature.Boolean) : false
}
QGCTextField {
text: feature.value ? feature.value : ""
visible: feature.type !== AirspaceRuleFeature.Boolean
text: feature ? (feature.value ? feature.value : "") : ""
visible: feature ? (feature.type !== AirspaceRuleFeature.Boolean) : false
showUnits: true
unitsLabel: {
if(feature) {
if(feature.unit == AirspaceRuleFeature.Kilogram)
return "kg";
if(feature.unit == AirspaceRuleFeature.Meters)
return "m";
if(feature.unit == AirspaceRuleFeature.MetersPerSecond)
return "m/s";
}
return ""
}
anchors.right: parent.right
anchors.left: parent.left
inputMethodHints: feature.type === AirspaceRuleFeature.Float ? Qt.ImhFormattedNumbersOnly :Qt.ImhNone
inputMethodHints: feature ? (feature.type === AirspaceRuleFeature.Float ? Qt.ImhFormattedNumbersOnly : Qt.ImhNone) : Qt.ImhNone
onAccepted: {
if(feature)
feature.value = parseFloat(text)
}
onEditingFinished: {
if(feature)
feature.value = parseFloat(text)
}
}
......@@ -62,20 +66,20 @@ Rectangle {
height: Math.max(checkBox.height, label.height)
anchors.right: parent.right
anchors.left: parent.left
visible: feature.type === AirspaceRuleFeature.Boolean
visible: feature ? (feature.type === AirspaceRuleFeature.Boolean) : false
QGCCheckBox {
id: checkBox
text: ""
onClicked: feature.value = checked
onClicked: { if(feature) {feature.value = checked} }
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
Component.onCompleted: {
checked = feature.value === 2 ? false : feature.value
checked = feature ? (feature.value === 2 ? false : feature.value) : false
}
}
QGCLabel {
id: label
text: feature.description
text: feature ? feature.description : ""
anchors.right: parent.right
anchors.left: checkBox.right
anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 0.5
......
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.2
import QtQml 2.2
import QtQuick 2.11
import QtQuick.Controls 2.4
import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
......@@ -11,35 +8,26 @@ import QGroundControl.Palette 1.0
import QGroundControl.Airmap 1.0
import QGroundControl.SettingsManager 1.0
Rectangle {
Button {
id: _root
autoExclusive: false
height: ScreenTools.defaultFontPixelHeight
background: Rectangle {
anchors.fill: parent
color: _selected ? qgcPal.windowShade : qgcPal.window
}
property var rule: null
property bool checked: false
property bool required: false
property bool _selected: {
if (exclusiveGroup) {
if (autoExclusive) {
return checked
} else {
return rule ? rule.selected : false
}
}
property ExclusiveGroup exclusiveGroup: null
onExclusiveGroupChanged: {
if (exclusiveGroup) {
checked = rule.selected
exclusiveGroup.bindCheckable(_root)
}
}
onCheckedChanged: {
rule.selected = checked
}
QGCPalette {
id: qgcPal
colorGroupEnabled: enabled
}
Row {
contentItem: Row {
id: ruleRow
spacing: ScreenTools.defaultFontPixelWidth
anchors.right: parent.right
......@@ -52,20 +40,16 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter
}
QGCLabel {
text: rule.name === "" ? rule.shortName : rule.name
text: rule ? (rule.name === "" ? rule.shortName : rule.name) : ""
font.pointSize: ScreenTools.smallFontPointSize
anchors.verticalCenter: parent.verticalCenter
}
}
MouseArea {
anchors.fill: parent
enabled: !required
onClicked: {
if (exclusiveGroup) {
if (autoExclusive) {
checked = true
} else {
rule.selected = !rule.selected
}
}
}
}
......@@ -20,6 +20,7 @@
#include <QObject>
#include <QDateTime>
#include <QAbstractListModel>
#include <QDebug>
class PlanMasterController;
class AirspaceFlightInfo;
......@@ -164,6 +165,7 @@ public:
///< Flight Management
Q_PROPERTY(AirspaceFlightModel* flightList READ flightList NOTIFY flightListChanged)
Q_PROPERTY(bool loadingFlightList READ loadingFlightList NOTIFY loadingFlightListChanged)
Q_PROPERTY(bool dirty READ dirty WRITE setDirty NOTIFY dirtyChanged)
//-- TODO: This will submit the current flight plan in memory.
Q_INVOKABLE virtual void submitFlightPlan () = 0;
......@@ -189,11 +191,13 @@ public:
virtual QmlObjectListModel* authorizations () = 0; ///< List of AirspaceFlightAuthorization
virtual AirspaceFlightModel*flightList () = 0; ///< List of AirspaceFlightInfo
virtual bool loadingFlightList () = 0;
virtual bool dirty () { return _dirty; }
virtual void setFlightStartTime (QDateTime start) = 0;
virtual void setFlightDuration (int seconds) = 0;
virtual void setFlightStartsNow (bool now) = 0;
virtual void startFlightPlanning (PlanMasterController* planController) = 0;
virtual void setDirty (bool dirt) { if(_dirty != dirt) { _dirty = dirt; emit dirtyChanged(); qDebug() << "Dirty" << _dirty; }}
signals:
void flightPermitStatusChanged ();
......@@ -205,4 +209,8 @@ signals:
void rulesChanged ();
void flightListChanged ();
void loadingFlightListChanged ();
void dirtyChanged ();
protected:
bool _dirty = false;
};
......@@ -735,7 +735,7 @@ Item {
width: airspaceRow.width + (ScreenTools.defaultFontPixelWidth * 3)
height: airspaceRow.height * 1.25
color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(1,1,1,0.95) : Qt.rgba(0,0,0,0.75)
visible: QGroundControl.airmapSupported && _mainIsMap && flightPermit && flightPermit !== AirspaceFlightPlanProvider.PermitNone && !messageArea.visible && !criticalMmessageArea.visible
visible: QGroundControl.airmapSupported && _mainIsMap && flightPermit && flightPermit !== AirspaceFlightPlanProvider.PermitNone
radius: 3
border.width: 1
border.color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(0,0,0,0.35) : Qt.rgba(1,1,1,0.35)
......
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