Try to force a native menu item sync after adding the item

Hopefully this makes it visible and enabled properly.
pull/1855/head
Nicolas Werner 3 weeks ago
parent e9bbd61110
commit 5fe8ebf335
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
  1. 6
      resources/qml/MessageView.qml
  2. 2
      resources/qml/components/SpaceMenuLevel.qml
  3. 13
      src/ui/NhekoMenuVisibilityFilter.cpp

@ -420,12 +420,12 @@ Item {
else else
link = ""; link = "";
messageActionsCFilter.updateTarget();
if (showAt_) if (showAt_)
popup(showAt_); popup(showAt_);
else else
popup(); popup();
messageActionsCFilter.updateTarget();
} }
Component { Component {
@ -659,8 +659,8 @@ Item {
link = link_; link = link_;
eventId = eventId_; eventId = eventId_;
popup();
replyContextMenuCFilter.updateTarget(); replyContextMenuCFilter.updateTarget();
popup();
} }
Component.onCompleted: { Component.onCompleted: {

@ -17,7 +17,7 @@ Menu {
title: modelData != undefined ? modelData.name : qsTr("Add or remove from community") title: modelData != undefined ? modelData.name : qsTr("Add or remove from community")
property bool loadChildren: false property bool loadChildren: false
onOpened: { onAboutToShow: {
loadChildren = true; loadChildren = true;
menuFilter.updateTarget(); menuFilter.updateTarget();
} }

@ -6,6 +6,7 @@
#include <QQmlListReference> #include <QQmlListReference>
#include <QQuickItem> #include <QQuickItem>
#include <QTimer>
#include "Logging.h" #include "Logging.h"
@ -130,6 +131,18 @@ NhekoMenuVisibilityFilter::updateTarget()
} }
} }
QTimer::singleShot(0, this, [this] {
auto createdItems = qvariant_cast<QQmlListReference>(targetProperty.read());
// newItems.clear(); <- does not remove the visual items
for (qsizetype i = createdItems.size(); i > 0; i--) {
// only remove items, not other random stuff in there!
if (auto item = qobject_cast<QQuickItem *>(createdItems.at(i - 1))) {
item->enabledChanged();
}
}
});
// targetProperty.write(QVariant::fromValue(std::move(newItems))); // targetProperty.write(QVariant::fromValue(std::move(newItems)));
} }

Loading…
Cancel
Save