Commit 6921214a authored by Don Gagne's avatar Don Gagne

Rework gear icon to hamburger with menu options

Hamburger: Delete, Delete All, Show all Values
parent 3a1f28cc
......@@ -133,6 +133,43 @@ QGCView {
}
}
property int _moveDialogMissionItemIndex
Component {
id: moveDialog
QGCViewDialog {
function accept() {
var toIndex = toCombo.currentIndex
if (toIndex == 0) {
toIndex = 1
}
controller.moveMissionItem(_moveDialogMissionItemIndex, toIndex)
hideDialog()
}
Column {
anchors.left: parent.left
anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelHeight
QGCLabel {
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
text: "Move the selected mission item to the be after following mission item:"
}
QGCComboBox {
id: toCombo
model: _missionItems.count
currentIndex: _moveDialogMissionItemIndex
}
}
}
}
QGCViewPanel {
id: panel
anchors.fill: parent
......@@ -340,12 +377,13 @@ QGCView {
onClicked: setCurrentItem(object.sequenceNumber)
onRemove: {
var newCurrentItem = object.sequenceNumber - 1
itemDragger.clearItem()
controller.removeMissionItem(object.sequenceNumber)
if (_missionItems.count > 1) {
newCurrentItem = Math.min(_missionItems.count - 1, newCurrentItem)
setCurrentItem(newCurrentItem)
}
}
onRemoveAll: {
itemDragger.clearItem()
controller.removeAllMissionItems()
}
}
} // ListView
......@@ -408,18 +446,6 @@ QGCView {
}
}
RoundButton {
id: deleteMissionItemButton
buttonImage: "/qmlimages/TrashDelete.svg"
z: QGroundControl.zOrderWidgets
onClicked: {
addMissionItemsButton.checked = false
itemDragger.clearItem()
controller.deleteCurrentMissionItem()
checked = false
}
}
DropButton {
id: syncButton
dropDirection: dropRight
......
......@@ -97,59 +97,10 @@ Rectangle {
"When enabled, add mission items by clicking on the map."
}
Image {
id: deleteHelpIcon
anchors.topMargin: ScreenTools.defaultFontPixelHeight
anchors.top: addMissionItemsHelpText.bottom
width: ScreenTools.defaultFontPixelHeight * 3
fillMode: Image.PreserveAspectFit
mipmap: true
smooth: true
source: (qgcPal.globalTheme === QGCPalette.Light) ? "/qmlimages/TrashDeleteBlack.svg" : "/qmlimages/TrashDelete.svg"
}
QGCLabel {
id: deleteHelpText
anchors.leftMargin: ScreenTools.defaultFontPixelHeight
anchors.left: mapTypeHelpIcon.right
anchors.right: parent.right
anchors.top: deleteHelpIcon.top
wrapMode: Text.WordWrap
text: "<b>Delete Mission Item</b><br>" +
"Delete the currently selected mission item."
}
/*
Home Position Manager disabled
Image {
id: homePositionManagerHelpIcon
anchors.topMargin: ScreenTools.defaultFontPixelHeight
anchors.top: deleteHelpText.bottom
width: ScreenTools.defaultFontPixelHeight * 3
fillMode: Image.PreserveAspectFit
mipmap: true
smooth: true
source: (qgcPal.globalTheme === QGCPalette.Light) ? "/qmlimages/MapHomeBlack.svg" : "/qmlimages/MapHome.svg"
}
QGCLabel {
id: homePositionManagerHelpText
anchors.leftMargin: ScreenTools.defaultFontPixelHeight
anchors.left: mapTypeHelpIcon.right
anchors.right: parent.right
anchors.top: homePositionManagerHelpIcon.top
wrapMode: Text.WordWrap
text: "<b>Flying Field Manager</b><br>" +
"When enabled, allows you to select/add/update flying field locations. " +
"You can save multiple flying field locations for use while creating missions while you are not connected to your vehicle."
}
*/
Image {
id: mapCenterHelpIcon
anchors.topMargin: ScreenTools.defaultFontPixelHeight
anchors.top: deleteHelpText.bottom
anchors.top: addMissionItemsHelpText.bottom
width: ScreenTools.defaultFontPixelHeight * 3
fillMode: Image.PreserveAspectFit
mipmap: true
......
......@@ -205,6 +205,17 @@ void MissionController::removeMissionItem(int index)
}
}
void MissionController::removeAllMissionItems(void)
{
if (_missionItems) {
_deinitAllMissionItems();
_missionItems->deleteLater();
}
_missionItems = new QmlObjectListModel(this);
_initAllMissionItems();
}
void MissionController::loadMissionFromFile(void)
{
#ifndef __mobile__
......@@ -606,17 +617,6 @@ void MissionController::_activeVehicleHomePositionChanged(const QGeoCoordinate&
_recalcWaypointLines();
}
void MissionController::deleteCurrentMissionItem(void)
{
for (int i=0; i<_missionItems->count(); i++) {
MissionItem* item = qobject_cast<MissionItem*>(_missionItems->get(i));
if (item->isCurrentItem() && i != 0) {
removeMissionItem(i);
return;
}
}
}
void MissionController::setAutoSync(bool autoSync)
{
// FIXME: AutoSync temporarily turned off
......
......@@ -53,7 +53,7 @@ public:
Q_INVOKABLE void loadMissionFromFile(void);
Q_INVOKABLE void saveMissionToFile(void);
Q_INVOKABLE void removeMissionItem(int index);
Q_INVOKABLE void deleteCurrentMissionItem(void);
Q_INVOKABLE void removeAllMissionItems(void);
// Property accessors
......
......@@ -20,6 +20,7 @@ Rectangle {
signal clicked
signal remove
signal removeAll
height: innerItem.height + (_margin * 3)
color: missionItem.isCurrentItem ? qgcPal.buttonHighlight : qgcPal.windowShade
......@@ -34,6 +35,19 @@ Rectangle {
colorGroupEnabled: enabled
}
Component {
id: deleteAllPromptDialog
QGCViewMessage {
message: "Are you sure you want to delete all mission items?"
function accept() {
removeAll()
hideDialog()
}
}
}
Item {
id: innerItem
anchors.margins: _margin
......@@ -57,18 +71,54 @@ Rectangle {
}
Image {
id: rawEdit
id: hamburger
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.right: parent.right
anchors.verticalCenter: commandPicker.verticalCenter
width: commandPicker.height
height: commandPicker.height
visible: missionItem.friendlyEditAllowed && missionItem.sequenceNumber != 0 && missionItem.isCurrentItem
source: "qrc:/qmlimages/CogWheel.svg"
source: "qrc:/qmlimages/Hamburger.svg"
visible: missionItem.isCurrentItem && missionItem.sequenceNumber != 0
MouseArea {
anchors.fill: parent
onClicked: missionItem.rawEdit = !missionItem.rawEdit
onClicked: hamburgerMenu.popup()
Menu {
id: hamburgerMenu
MenuItem {
text: "Delete"
onTriggered: remove()
}
MenuItem {
text: "Delete all"
onTriggered: qgcView.showDialog(deleteAllPromptDialog, "Delete all", 40, StandardButton.Yes | StandardButton.No)
}
MenuSeparator { }
MenuItem {
text: "Show all values"
checkable: true
checked: missionItem.rawEdit
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
}
}
}
}
}
......@@ -77,7 +127,7 @@ Rectangle {
anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.left: label.right
anchors.right: rawEdit.left
anchors.right: hamburger.left
visible: missionItem.sequenceNumber != 0 && missionItem.isCurrentItem && !missionItem.rawEdit
text: missionItem.commandName
......
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