@ -14,6 +14,10 @@ import QGroundControl.Palette 1.0
@@ -14,6 +14,10 @@ import QGroundControl.Palette 1.0
Rectangle {
id: _root
height: editorLoader . y + editorLoader . height + ( _margin * 2 )
color: missionItem . isCurrentItem ? qgcPal.buttonHighlight : qgcPal . windowShade
radius: _radius
property var missionItem / / / < M i s s i o n I t e m a s s o c i a t e d w i t h t h i s e d i t o r
property bool readOnly / / / < t r u e : r e a d o n l y v i e w , f a l s e : f u l l e d i t i n g v i e w
property var qgcView / / / < Q G C V i e w c o n t r o l u s e d f o r s h o w i n g d i a l o g s
@ -23,21 +27,127 @@ Rectangle {
@@ -23,21 +27,127 @@ Rectangle {
signal insert ( int i )
signal moveHomeToMapCenter
height: innerItem . height + ( _margin * 3 )
color: missionItem . isCurrentItem ? qgcPal.buttonHighlight : qgcPal . windowShade
radius: _radius
readonly property real _editFieldWidth : ScreenTools . defaultFontPixelWidth * 16
readonly property real _margin : ScreenTools . defaultFontPixelWidth / 2
readonly property real _radius : ScreenTools . defaultFontPixelWidth / 2
readonly property real _editFieldWidth : ScreenTools . defaultFontPixelWidth * 16
readonly property real _margin : ScreenTools . defaultFontPixelWidth / 2
readonly property real _radius : ScreenTools . defaultFontPixelWidth / 2
property color _outerTextColor : missionItem . isCurrentItem ? "black" : qgcPal . text
property bool _showValues : missionItem . isCurrentItem
QGCPalette {
id: qgcPal
colorGroupEnabled: enabled
}
MouseArea {
anchors.fill: parent
visible: ! missionItem . isCurrentItem
onClicked: _root . clicked ( )
}
QGCLabel {
id: label
anchors.verticalCenter: commandPicker . verticalCenter
anchors.leftMargin: _margin
anchors.left: parent . left
text: missionItem . sequenceNumber == 0 ? "H" : missionItem . sequenceNumber
color: _outerTextColor
}
Image {
id: hamburger
anchors.rightMargin: ScreenTools . defaultFontPixelWidth
anchors.right: parent . right
anchors.verticalCenter: commandPicker . verticalCenter
width: commandPicker . height
height: commandPicker . height
source: "qrc:/qmlimages/Hamburger.svg"
visible: missionItem . isCurrentItem && missionItem . sequenceNumber != 0
MouseArea {
anchors.fill: parent
onClicked: hamburgerMenu . popup ( )
Menu {
id: hamburgerMenu
MenuItem {
text: "Insert"
onTriggered: insert ( missionItem . sequenceNumber )
}
MenuItem {
text: "Delete"
onTriggered: remove ( )
}
MenuSeparator {
visible: ! missionItem . simpleItem
}
MenuItem {
text: "Show all values"
checkable: true
checked: missionItem . rawEdit
visible: ! missionItem . simpleItem
onTriggered: {
if ( missionItem . rawEdit ) {
if ( missionItem . friendlyEditAllowed ) {
missionItem . rawEdit = false
} else {
qgcView . showMessage ( "Mission Edit" , "You have made changes to the mission item which cannot be shown in Simple Mode" , StandardButton . Ok )
}
} else {
missionItem . rawEdit = true
}
checked = missionItem . rawEdit
}
}
}
}
}
QGCButton {
id: commandPicker
anchors.leftMargin: ScreenTools . defaultFontPixelWidth * 2
anchors.rightMargin: ScreenTools . defaultFontPixelWidth
anchors.left: label . right
anchors.right: hamburger . left
visible: missionItem . sequenceNumber != 0 && missionItem . isCurrentItem && ! missionItem . rawEdit && missionItem . simpleItem
text: missionItem . commandName
Component {
id: commandDialog
MissionCommandDialog {
missionItem: _root . missionItem
}
}
onClicked: qgcView . showDialog ( commandDialog , "Select Mission Command" , qgcView . showDialogDefaultWidth , StandardButton . Cancel )
}
QGCLabel {
anchors.fill: commandPicker
visible: missionItem . sequenceNumber == 0 || ! missionItem . isCurrentItem || ! missionItem . simpleItem
verticalAlignment: Text . AlignVCenter
text: missionItem . sequenceNumber == 0 ? "Home Position" : ( missionItem . simpleItem ? missionItem.commandName : "Survey" )
color: _outerTextColor
}
Loader {
id: editorLoader
anchors.leftMargin: _margin
anchors.topMargin: _margin
anchors.left: parent . left
anchors.top: commandPicker . bottom
sourceComponent: missionItem . simpleItem ? simpleMissionItemEditor : complexMissionItemEditor
/ / / H o w w i d e t h e l o a d e d c o m p o n e n t s h o u l d b e
property real availableWidth: _root . width - ( _margin * 2 )
}
Component {
id: valuesComponent
@ -54,7 +164,7 @@ Rectangle {
@@ -54,7 +164,7 @@ Rectangle {
anchors.left: parent . left
anchors.right: parent . right
anchors.top: parent . top
height: valuesColumn . height + _margin
height: valuesColumn . height + ( _margin * 2 )
Column {
id: valuesColumn
@ -69,8 +179,8 @@ Rectangle {
@@ -69,8 +179,8 @@ Rectangle {
text: missionItem . sequenceNumber == 0 ?
"Planned home position." :
( missionItem . rawEdit ?
"Provides advanced access to all commands/parameters. Be very careful!" :
missionItem . commandDescription )
"Provides advanced access to all commands/parameters. Be very careful!" :
missionItem . commandDescription )
}
Repeater {
@ -150,114 +260,73 @@ Rectangle {
@@ -150,114 +260,73 @@ Rectangle {
}
Item {
id: innerItem
anchors.margins: _margin
anchors.top: parent . top
anchors.left: parent . left
anchors.right: parent . right
height: _showValues ? valuesLoader . y + valuesLoader.height : valuesLoader . y
Component {
id: simpleMissionItemEditor
MouseArea {
anchors.fill: parent
visible: ! missionItem . isCurrentItem
Item {
id: innerItem
width: availableWidth
height: _showValues ? valuesLoader . y + valuesLoader.height : valuesLoader . y
onClicked: _root . clicked ( )
}
property bool _showValues : missionItem . isCurrentItem
QGCLabel {
id: label
anchors.verticalCenter: commandPicker . verticalCenter
color: missionItem . isCurrentItem ? qgcPal.buttonHighlightText : qgcPal . buttonText
text: missionItem . sequenceNumber == 0 ? "H" : missionItem . sequenceNumber
}
Loader {
id: valuesLoader
anchors.left: parent . left
anchors.right: parent . right
sourceComponent: _showValues ? valuesComponent : undefined
}
} / / I t e m
} / / C o m p o n e n t - s i m p l e M i s s i o n I t e m E d i t o r
Image {
id: hamburger
anchors.rightMargin: ScreenTools . defaultFontPixelWidth
anchors.right: parent . right
anchors.verticalCenter: commandPicker . verticalCenter
width: commandPicker . height
height: commandPicker . height
source: "qrc:/qmlimages/Hamburger.svg"
visible: missionItem . isCurrentItem && missionItem . sequenceNumber != 0
MouseArea {
anchors.fill: parent
onClicked: hamburgerMenu . popup ( )
Menu {
id: hamburgerMenu
MenuItem {
text: "Insert"
onTriggered: insert ( missionItem . sequenceNumber )
}
Component {
id: complexMissionItemEditor
MenuItem {
text: "Delete"
onTriggered: remove ( )
}
Rectangle {
id: outerRect
height: editorColumn . height + ( _margin * 2 )
width: availableWidth
color: qgcPal . windowShadeDark
radius: _radius
MenuSeparator { }
property bool addPointsMode: false
MenuItem {
text: "Show all values"
checkable: true
checked: missionItem . rawEdit
Column {
id: editorColumn
anchors.margins: _margin
anchors.top: parent . top
anchors.left: parent . left
width: availableWidth
spacing: _margin
onTriggered: {
if ( missionItem . rawEdit ) {
if ( missionItem . friendlyEditAllowed ) {
missionItem . rawEdit = false
} else {
qgcView . showMessage ( "Mission Edit" , "You have made changes to the mission item which cannot be shown in Simple Mode" , StandardButton . Ok )
}
} else {
missionItem . rawEdit = true
}
checked = missionItem . rawEdit
Connections {
target: editorMap
onMapClicked: {
if ( addPointsMode ) {
missionItem . addPolygonCoordinate ( coordinate )
}
}
}
}
}
QGCButton {
id: commandPicker
anchors.leftMargin: ScreenTools . defaultFontPixelWidth * 2
anchors.rightMargin: ScreenTools . defaultFontPixelWidth
anchors.left: label . right
anchors.right: hamburger . left
visible: missionItem . sequenceNumber != 0 && missionItem . isCurrentItem && ! missionItem . rawEdit
text: missionItem . commandName
Component {
id: commandDialog
QGCLabel {
text: "Fly a grid pattern over a defined area."
wrapMode: Text . WordWrap
}
MissionCommandDialog {
missionItem: _root . missionItem
QGCButton {
text: addPointsMode ? "Finished" : "Draw Polygon"
onClicked: {
if ( addPointsMode ) {
addPointsMode = false
} else {
missionItem . clearPolygon ( )
addPointsMode = true
}
}
}
}
onClicked: qgcView . showDialog ( commandDialog , "Select Mission Command" , qgcView . showDialogDefaultWidth , StandardButton . Cancel )
}
QGCLabel {
anchors.fill: commandPicker
visible: missionItem . sequenceNumber == 0 || ! missionItem . isCurrentItem
verticalAlignment: Text . AlignVCenter
text: missionItem . sequenceNumber == 0 ? "Home Position" : missionItem . commandName
color: qgcPal . buttonText
}
} / / C o m p o n e n t - c o m p l e x M i s s i o n I t e m E d i t o r
Loader {
id: valuesLoader
anchors.topMargin: _margin
anchors.top: commandPicker . bottom
anchors.left: parent . left
anchors.right: parent . right
sourceComponent: _showValues ? valuesComponent : undefined
}
} / / I t e m
} / / R e c t a n g l e