diff --git a/src/Airmap/AirMapFlightPlanManager.cc b/src/Airmap/AirMapFlightPlanManager.cc index 72462b2967a71d98470a95b957932c9c28cb7c67..ff763255baa82408755f84739f458e8896d362b7 100644 --- a/src/Airmap/AirMapFlightPlanManager.cc +++ b/src/Airmap/AirMapFlightPlanManager.cc @@ -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) { - _flightDuration = seconds; - if(_flightDuration < 30) { - _flightDuration = 30; + if(_flightDuration != seconds || _flightDuration < 30) { + _flightDuration = seconds; + if(_flightDuration < 30) { + _flightDuration = 30; + } + setDirty(true); + emit flightDurationChanged(); + qCDebug(AirMapManagerLog) << "Set time duration" << _flightDuration; } - emit flightDurationChanged(); - qCDebug(AirMapManagerLog) << "Set time duration" << _flightDuration; } //----------------------------------------------------------------------------- @@ -261,6 +267,7 @@ AirMapFlightPlanManager::updateFlightPlan() } _flightPermitStatus = AirspaceFlightPlanProvider::PermitPending; emit flightPermitStatusChanged(); + setDirty(false); _updateFlightPlan(true); } diff --git a/src/Airmap/AirMapRulesetsManager.cc b/src/Airmap/AirMapRulesetsManager.cc index 99d75c0b23d293eba8ddf59ef99d91135440b808..6a5d9255fb476fbf3db54a7f3af4f3433b21649f 100644 --- a/src/Airmap/AirMapRulesetsManager.cc +++ b/src/Airmap/AirMapRulesetsManager.cc @@ -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); } //----------------------------------------------------------------------------- diff --git a/src/Airmap/AirspaceControl.qml b/src/Airmap/AirspaceControl.qml index ae77edbfdcda3a685b1a0286b543b2ba6057284b..b43ce85a83fd55952dd7f0ff9ca0c8d1a866bdf9 100644 --- a/src/Airmap/AirspaceControl.qml +++ b/src/Airmap/AirspaceControl.qml @@ -1,8 +1,8 @@ -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,310 +390,214 @@ Item { } //--------------------------------------------------------------- //-- Rule Selector - Component { - 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 - } + Popup { + id: ruleSelector + 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) } + } + + 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 + radius: ScreenTools.defaultFontPixelWidth + } + + Column { + id: rulesCol + spacing: ScreenTools.defaultFontPixelHeight * 0.5 + anchors.centerIn: parent + //-- Regulations 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 + color: qgcPal.windowShade + height: rulesTitle.height + ScreenTools.defaultFontPixelHeight + width: parent.width * 0.95 + radius: _radius + anchors.horizontalCenter: parent.horizontalCenter + QGCLabel { + id: rulesTitle + text: qsTr("Airspace Regulation Options") + anchors.centerIn: parent + } } - Rectangle { - id: ruleSelectorRect - x: 0 - y: 0 - color: qgcPal.window - width: rulesCol.width + ScreenTools.defaultFontPixelWidth - height: rulesCol.height + ScreenTools.defaultFontPixelHeight - radius: ScreenTools.defaultFontPixelWidth + Flickable { + clip: true + width: ScreenTools.defaultFontPixelWidth * 30 + height: ScreenTools.defaultFontPixelHeight * 14 + contentHeight: rulesetCol.height + flickableDirection: Flickable.VerticalFlick Column { - id: rulesCol - spacing: ScreenTools.defaultFontPixelHeight * 0.5 - anchors.centerIn: parent - //-- Regulations - Rectangle { - color: qgcPal.windowShade - height: rulesTitle.height + ScreenTools.defaultFontPixelHeight - width: parent.width * 0.95 - radius: _radius - anchors.horizontalCenter: parent.horizontalCenter - QGCLabel { - id: rulesTitle - text: qsTr("Airspace Regulation Options") - anchors.centerIn: parent + id: rulesetCol + spacing: ScreenTools.defaultFontPixelHeight * 0.25 + anchors.right: parent.right + anchors.left: parent.left + anchors.rightMargin: ScreenTools.defaultFontPixelWidth * 2 + anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2 + Item { + width: 1 + height: 1 + } + QGCLabel { + text: qsTr("PICK ONE REGULATION") + font.pointSize: ScreenTools.smallFontPointSize + anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2 + } + Repeater { + model: _validRules ? QGroundControl.airspaceManager.ruleSets.ruleSets : [] + delegate: RuleSelector { + visible: object.selectionType === AirspaceRuleSet.Pickone + rule: object + autoExclusive: true + anchors.right: parent.right + anchors.rightMargin: ScreenTools.defaultFontPixelWidth + anchors.left: parent.left + anchors.leftMargin: ScreenTools.defaultFontPixelWidth } } - Flickable { - clip: true - width: ScreenTools.defaultFontPixelWidth * 30 - height: ScreenTools.defaultFontPixelHeight * 14 - contentHeight: rulesetCol.height - flickableDirection: Flickable.VerticalFlick - Column { - id: rulesetCol - spacing: ScreenTools.defaultFontPixelHeight * 0.25 - anchors.right: parent.right - anchors.left: parent.left - anchors.rightMargin: ScreenTools.defaultFontPixelWidth * 2 - anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2 - Item { - width: 1 - height: 1 - } - ExclusiveGroup { id: rulesGroup } - QGCLabel { - text: qsTr("PICK ONE REGULATION") - font.pointSize: ScreenTools.smallFontPointSize - anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2 - } - Repeater { - model: _validRules ? QGroundControl.airspaceManager.ruleSets.ruleSets : [] - delegate: RuleSelector { - visible: object.selectionType === AirspaceRuleSet.Pickone - rule: object - exclusiveGroup: rulesGroup - anchors.right: parent.right - anchors.rightMargin: ScreenTools.defaultFontPixelWidth - anchors.left: parent.left - anchors.leftMargin: ScreenTools.defaultFontPixelWidth - } - } - Item { - width: 1 - height: 1 - } - QGCLabel { - text: qsTr("OPTIONAL") - font.pointSize: ScreenTools.smallFontPointSize - anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2 - } - Repeater { - model: _validRules ? QGroundControl.airspaceManager.ruleSets.ruleSets : [] - delegate: RuleSelector { - visible: object.selectionType === AirspaceRuleSet.Optional - rule: object - anchors.right: parent.right - anchors.rightMargin: ScreenTools.defaultFontPixelWidth - anchors.left: parent.left - anchors.leftMargin: ScreenTools.defaultFontPixelWidth - } - } - Item { - width: 1 - height: 1 - } - QGCLabel { - text: qsTr("REQUIRED") - font.pointSize: ScreenTools.smallFontPointSize - anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2 - } - Repeater { - model: _validRules ? QGroundControl.airspaceManager.ruleSets.ruleSets : [] - delegate: RuleSelector { - visible: object.selectionType === AirspaceRuleSet.Required - rule: object - required: true - anchors.right: parent.right - anchors.rightMargin: ScreenTools.defaultFontPixelWidth - anchors.left: parent.left - anchors.leftMargin: ScreenTools.defaultFontPixelWidth - } - } + Item { + width: 1 + height: 1 + } + QGCLabel { + text: qsTr("OPTIONAL") + font.pointSize: ScreenTools.smallFontPointSize + anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2 + } + Repeater { + model: _validRules ? QGroundControl.airspaceManager.ruleSets.ruleSets : [] + delegate: RuleSelector { + visible: object.selectionType === AirspaceRuleSet.Optional + rule: object + anchors.right: parent.right + anchors.rightMargin: ScreenTools.defaultFontPixelWidth + anchors.left: parent.left + anchors.leftMargin: ScreenTools.defaultFontPixelWidth + } + } + Item { + width: 1 + height: 1 + } + QGCLabel { + text: qsTr("REQUIRED") + font.pointSize: ScreenTools.smallFontPointSize + anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2 + } + Repeater { + model: _validRules ? QGroundControl.airspaceManager.ruleSets.ruleSets : [] + delegate: RuleSelector { + visible: object.selectionType === AirspaceRuleSet.Required + rule: object + enabled: false + anchors.right: parent.right + anchors.rightMargin: ScreenTools.defaultFontPixelWidth + anchors.left: parent.left + anchors.leftMargin: ScreenTools.defaultFontPixelWidth } } } } - //-- 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) - } + } + + //-- Arrow + QGCColoredImage { + id: arrowIcon + width: height + height: ScreenTools.defaultFontPixelHeight * 2 + sourceSize.height: height + source: "qrc:/airmap/right-arrow.svg" + color: qgcPal.window + anchors.left: parent.right + y: ruleSelector._arrowTarget ? (ruleSelector._arrowTarget.y - height) : 0 } } + //--------------------------------------------------------------- //-- Flight Details - Component { - 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; } + Popup { + id: flightDetails + 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 + } + Row { + id: flDetailsRow + spacing: ScreenTools.defaultFontPixelWidth + anchors.centerIn: parent + //--------------------------------------------------------- + //-- Flight Details + FlightDetails { + id: _flightDetails + baseHeight: _baseHeight + baseWidth: _baseWidth } + //--------------------------------------------------------- + //-- Divider 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 + color: qgcPal.text + width: 1 + height: parent.height + opacity: 0.25 + anchors.verticalCenter: parent.verticalCenter } - Rectangle { - id: flightDetailsRect - color: qgcPal.window - width: flDetailsRow.width + (ScreenTools.defaultFontPixelWidth * 4) - height: flDetailsRow.height + (ScreenTools.defaultFontPixelHeight * 2) - radius: ScreenTools.defaultFontPixelWidth - anchors.centerIn: parent - Row { - id: flDetailsRow - spacing: ScreenTools.defaultFontPixelWidth - anchors.centerIn: parent - //--------------------------------------------------------- - //-- Flight Details - FlightDetails { - baseHeight: flightDetailsRoot.baseHeight - baseWidth: flightDetailsRoot.baseWidth - } - //--------------------------------------------------------- - //-- Divider - Rectangle { - color: qgcPal.text - width: 1 - height: parent.height - opacity: 0.25 - anchors.verticalCenter: parent.verticalCenter - } - //--------------------------------------------------------- - //-- Flight Brief - FlightBrief { - baseHeight: flightDetailsRoot.baseHeight - baseWidth: flightDetailsRoot.baseWidth - } - } + //--------------------------------------------------------- + //-- Flight Brief + FlightBrief { + baseHeight: _baseHeight + baseWidth: _baseWidth + onClosed: flightDetails.close() } } } //--------------------------------------------------------------- //-- Flight Brief - Component { - 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) - radius: ScreenTools.defaultFontPixelWidth - anchors.centerIn: parent - //--------------------------------------------------------- - //-- Flight Brief - FlightBrief { - id: flightBriedItem - baseHeight: flightBriefRoot.baseHeight - baseWidth: flightBriefRoot.baseWidth - anchors.centerIn: parent - } - } + Popup { + id: flightBrief + 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 + } + //--------------------------------------------------------- + //-- Flight Brief + FlightBrief { + id: flightBriedItem + baseHeight: _baseHeight + baseWidth: _baseWidth + onClosed: flightBrief.close() + anchors.centerIn: parent } } } diff --git a/src/Airmap/FlightBrief.qml b/src/Airmap/FlightBrief.qml index 75f7ef13eb01ce780c2e64a93fd677209bcf1305..061c2dbdf3cf60dc4c6ef43c1f45120e80089aaf 100644 --- a/src/Airmap/FlightBrief.qml +++ b/src/Airmap/FlightBrief.qml @@ -16,8 +16,9 @@ Item { id: _root implicitHeight: briefRootCol.height implicitWidth: briefRootCol.width - property real baseHeight: ScreenTools.defaultFontPixelHeight * 22 - property real baseWidth: ScreenTools.defaultFontPixelWidth * 40 + 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() } } } diff --git a/src/Airmap/FlightDetails.qml b/src/Airmap/FlightDetails.qml index aecacf34206d161c013b0040dc74603da97f8799..61a9003fb504744385ea965987c89bae654f79bc 100644 --- a/src/Airmap/FlightDetails.qml +++ b/src/Airmap/FlightDetails.qml @@ -17,8 +17,8 @@ Item { id: _root implicitHeight: detailCol.height implicitWidth: detailCol.width - property real baseHeight: ScreenTools.defaultFontPixelHeight * 22 - property real baseWidth: ScreenTools.defaultFontPixelWidth * 40 + property real baseHeight: ScreenTools.defaultFontPixelHeight * 22 + property real baseWidth: ScreenTools.defaultFontPixelWidth * 40 Column { id: detailCol spacing: ScreenTools.defaultFontPixelHeight * 0.25 @@ -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) diff --git a/src/Airmap/FlightFeature.qml b/src/Airmap/FlightFeature.qml index d7b9d38d6b6f5d0ed6281a5be4eb690e65d0713e..2f70ce7ea2dc0ff0e35b466bc321694b9c1ff8b1 100644 --- a/src/Airmap/FlightFeature.qml +++ b/src/Airmap/FlightFeature.qml @@ -29,53 +29,57 @@ 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.unit == AirspaceRuleFeature.Kilogram) - return "kg"; - if(feature.unit == AirspaceRuleFeature.Meters) - return "m"; - if(feature.unit == AirspaceRuleFeature.MetersPerSecond) - return "m/s"; + 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: { - feature.value = parseFloat(text) + if(feature) + feature.value = parseFloat(text) } onEditingFinished: { - feature.value = parseFloat(text) + if(feature) + feature.value = parseFloat(text) } } Item { 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 diff --git a/src/Airmap/RuleSelector.qml b/src/Airmap/RuleSelector.qml index 951ba203683325f37a422211ee5f486dc3b6bb76..dd88b337c31fc59c5769cc9f25d10669f16bdd23 100644 --- a/src/Airmap/RuleSelector.qml +++ b/src/Airmap/RuleSelector.qml @@ -1,8 +1,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 - color: _selected ? qgcPal.windowShade : qgcPal.window + 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) { - checked = true - } else { - rule.selected = !rule.selected - } + onClicked: { + if (autoExclusive) { + checked = true + } else { + rule.selected = !rule.selected } } } diff --git a/src/AirspaceManagement/AirspaceFlightPlanProvider.h b/src/AirspaceManagement/AirspaceFlightPlanProvider.h index bd741648eac86389757066d696b0ba9214b25ae4..1e6de3adfc60e18730688a2c9a4c7afe42c85f61 100644 --- a/src/AirspaceManagement/AirspaceFlightPlanProvider.h +++ b/src/AirspaceManagement/AirspaceFlightPlanProvider.h @@ -20,6 +20,7 @@ #include #include #include +#include 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; }; diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index c14e84b1c9a822223694e6baabe2b938389c1cbe..56670603e42120dc94b6d464a1e45d0005fad158 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -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)