qgroundcontrol icon indicating copy to clipboard operation
qgroundcontrol copied to clipboard

Derive additional action availability from model

Open rubenp02 opened this issue 1 month ago • 7 comments

Derive additional action availability from model

Description

Replace hardcoded expression with iteration over the model to determine whether any entry is visible, in both the AdditionalActionsList and the AdditionalCustomActionsList.

This removes the maintenance burden of updating the expression whenever actions are added, removed, or a special condition is added to their availability (e.g., only appearing in Advanced Mode).

Checklist:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

rubenp02 avatar Nov 14 '25 12:11 rubenp02

Not sure if those copilot suggestions matter but if so maybe something like this could help. I've been wanting to try it out.

HTRamsey avatar Nov 14 '25 20:11 HTRamsey

I think they're nonsense (the suggested changes sure are) since I tested it and it was reactive. But I'll test it out a bit more thoroughly when I can.

rubenp02 avatar Nov 14 '25 20:11 rubenp02

The reactivity bug Copilot mentions doesn't actually exist because the model is recomputed whenever a visibility flag changes. But if the model is mutated in place rather than reassigned then yes, anyActionAvailable may be out of date. But of course, the same was true with the old code. Neither a Syncronizer nor a Binding alone would fix this, since we're using a plain JS array of vars for the model: I think that would also require using a Qt model like a ListModel or to keep the JS array but to make its elements QtObjects.

The changes work but I guess the implementation isn't the best, that much is true.

rubenp02 avatar Nov 15 '25 18:11 rubenp02

I think the discussion above is about what happens when 'visible' on an item changes with respect anyActionAvailable. I still don't see how the Additional Actions buttons will show/hide when either all actions go invisible or it transitions from all actions invisible to one or more visible.

DonLakeFlyer avatar Nov 24 '25 12:11 DonLakeFlyer

I think the discussion above is about what happens when 'visible' on an item changes with respect anyActionAvailable. I still don't see how the Additional Actions buttons will show/hide when either all actions go invisible or it transitions from all actions invisible to one or more visible.

Yes, this change is non-functional. It's just meant to avoid having to change anyActionAvailable whenever you add an action, since it can be easily derived from the model itself. In our QGC custom build we have a couple custom actions that are nonetheless implemented as normal AdditionalActions (rather than AdditionalCustomActions) and everytime something is added or removed upstream it causes merge conflicts on that line.

rubenp02 avatar Nov 30 '25 10:11 rubenp02

Not sure what to do with this since it doesn't work?

DonLakeFlyer avatar Dec 04 '25 17:12 DonLakeFlyer

Not sure what to do with this since it doesn't work?

What do you mean? I think it works.

Edit: By non-functional I mean that it doesn't intend to change any of the functionality. It's just a simple change from a hardcoded visibility expression to a generic one.

rubenp02 avatar Dec 04 '25 18:12 rubenp02