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