From 5fe8ebf335add0c90f2db6c23f165d4edd63691c Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 10 Jan 2025 01:15:56 +0100 Subject: [PATCH] Try to force a native menu item sync after adding the item Hopefully this makes it visible and enabled properly. --- resources/qml/MessageView.qml | 6 +++--- resources/qml/components/SpaceMenuLevel.qml | 2 +- src/ui/NhekoMenuVisibilityFilter.cpp | 13 +++++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml index dd5dd77a..ea46b6ef 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml @@ -420,12 +420,12 @@ Item { else link = ""; + messageActionsCFilter.updateTarget(); + if (showAt_) popup(showAt_); else popup(); - - messageActionsCFilter.updateTarget(); } Component { @@ -659,8 +659,8 @@ Item { link = link_; eventId = eventId_; - popup(); replyContextMenuCFilter.updateTarget(); + popup(); } Component.onCompleted: { diff --git a/resources/qml/components/SpaceMenuLevel.qml b/resources/qml/components/SpaceMenuLevel.qml index 11123353..6c3c0d1a 100644 --- a/resources/qml/components/SpaceMenuLevel.qml +++ b/resources/qml/components/SpaceMenuLevel.qml @@ -17,7 +17,7 @@ Menu { title: modelData != undefined ? modelData.name : qsTr("Add or remove from community") property bool loadChildren: false - onOpened: { + onAboutToShow: { loadChildren = true; menuFilter.updateTarget(); } diff --git a/src/ui/NhekoMenuVisibilityFilter.cpp b/src/ui/NhekoMenuVisibilityFilter.cpp index 597cba9c..16f0844f 100644 --- a/src/ui/NhekoMenuVisibilityFilter.cpp +++ b/src/ui/NhekoMenuVisibilityFilter.cpp @@ -6,6 +6,7 @@ #include #include +#include #include "Logging.h" @@ -130,6 +131,18 @@ NhekoMenuVisibilityFilter::updateTarget() } } + QTimer::singleShot(0, this, [this] { + auto createdItems = qvariant_cast(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(createdItems.at(i - 1))) { + item->enabledChanged(); + } + } + }); + // targetProperty.write(QVariant::fromValue(std::move(newItems))); }