Unable to edit flight modes in FlightModeMenu.qml

Hey all, I’ve been running into a roadblock with editing the flight modes that show up in the flight mode drop down.

Essentially we have access types and we want to limit the flight modes you can see based on the access mode the user is using.

I have made a custom FlightModeMenu.qml which I’m using to attempt to limit the modes with. This solution has worked in the past but doesn’t seem to work on newer versions.

Not only have I been unable to limit the modes shown, I have been completely unable to change any of the UI elements within at all. It’s like I have no changes made to the file. I have console.logs running through the function in this QML so I know that it’s running the right QML code. It’s just not seeming to want to update any of the UI.

Any help or pointing in the right direction is appreciated.

I will attach the code below:

/****************************************************************************
 *
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

import QtQuick                      2.12
import QtQuick.Controls             2.12

import QGroundControl               1.0
import QGroundControl.Controls      1.0
import QGroundControl.ScreenTools   1.0

// Label control whichs pop up a flight mode change menu when clicked
// Any changes made here should also be reflected in MainRootWindow.qml
QGCLabel {
    id:     _root

    property var    currentVehicle:         QGroundControl.multiVehicleManager.activeVehicle
    property real   mouseAreaLeftMargin:    0
    property string accessType: QGroundControl.corePlugin.accessType

    Menu {
        id: flightModesMenu
    }

    Component {
        id: flightModeMenuItemComponent

        MenuItem {
            enabled: true
            onTriggered: currentVehicle.flightMode = text
        }
    }

    property var flightModesMenuItems: []

    function updateFlightModesMenu() {
        if (currentVehicle && currentVehicle.flightModeSetAvailable) {
            var i;
            for (i = 0; i < flightModesMenuItems.length; i++) {
                flightModesMenu.removeItem(flightModesMenuItems[i])
            }
            flightModesMenuItems.length = 0
            for (i = 0; i < currentVehicle.flightModes.length; i++) {
                var menuItem = flightModeMenuItemComponent.createObject(null, { "text": currentVehicle.flightModes[i] })
                if (accessType == "Basic") {
                    if (currentVehicle.flightModes[i] === "Smart RTL" ) {
                        flightModesMenuItems.push(menuItem)
                        flightModesMenu.insertItem(i, menuItem)
                    }
                }
                else if (accessType == "Expert") {
                    if (currentVehicle.flightModes[i] === "Stabilize" || currentVehicle.flightModes[i] === "Altitude Hold" ||
                            currentVehicle.flightModes[i] === "Auto" || currentVehicle.flightModes[i] === "Loiter" ||
                            currentVehicle.flightModes[i] === "RTL" || currentVehicle.flightModes[i] === "Circle" ||
                            currentVehicle.flightModes[i] === "Land" || currentVehicle.flightModes[i] === "Position Hold" ||
                            currentVehicle.flightModes[i] === "Brake" || currentVehicle.flightModes[i] === "Smart RTL" ||
                            currentVehicle.flightModes[i] === "Drift" || currentVehicle.flightModes[i] === "Guided") {
                        flightModesMenuItems.push(menuItem)
                        flightModesMenu.insertItem(i, menuItem)
                    }
                }
                else if (accessType == "Factory") {
                    flightModesMenuItems.push(menuItem)
                    flightModesMenu.insertItem(i, menuItem)
                }
            }
        }
    }

    Component.onCompleted: _root.updateFlightModesMenu()

    Connections {
        target:                 QGroundControl.multiVehicleManager
        onActiveVehicleChanged: _root.updateFlightModesMenu()
    }

    MouseArea {
        id:                 mouseArea
        visible:            currentVehicle && currentVehicle.flightModeSetAvailable
        anchors.leftMargin: mouseAreaLeftMargin
        anchors.fill:       parent
        onClicked:          flightModesMenu.popup((_root.width - flightModesMenu.width) / 2, _root.height)
    }
}