core/qsmenu!: improve menu layout change UX

Exposes QsMenuOpener.children as an ObjectModel instead of a list to
allow smoother layout change handling in custom menu renderers.

Fixes QsMenuAnchor/platform menus closing whenever menu content changes.
This commit is contained in:
outfoxxed 2024-12-13 01:30:11 -08:00
parent 3fc1c914c7
commit a053373d57
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
7 changed files with 61 additions and 67 deletions

View file

@ -73,6 +73,9 @@ protected:
void insertObject(QObject* object, qsizetype index = -1);
bool removeObject(const QObject* object);
// Assumes only one instance of a specific value
void diffUpdate(const QVector<QObject*>& newValues);
QVector<QObject*> valuesList;
private:
@ -97,6 +100,11 @@ public:
void removeObject(const T* object) { this->UntypedObjectModel::removeObject(object); }
// Assumes only one instance of a specific value
void diffUpdate(const QVector<T*>& newValues) {
this->UntypedObjectModel::diffUpdate(*std::bit_cast<const QVector<QObject*>*>(&newValues));
}
static ObjectModel<T>* emptyInstance() {
return static_cast<ObjectModel<T>*>(UntypedObjectModel::emptyInstance());
}