mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 14:18:24 +02:00
saving work progress
This commit is contained in:
parent
5454dca82e
commit
7f355c48b1
1 changed files with 30 additions and 5 deletions
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include <QtQml>
|
#include <QtQml>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#include "OffscreenUi.h"
|
#include "OffscreenUi.h"
|
||||||
|
|
||||||
|
@ -217,6 +218,7 @@ void VrMenu::insertAction(QAction* before, QAction* action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
class QQuickMenuBase;
|
class QQuickMenuBase;
|
||||||
|
class QQuickMenu1;
|
||||||
|
|
||||||
void VrMenu::removeAction(QAction* action) {
|
void VrMenu::removeAction(QAction* action) {
|
||||||
if (!action) {
|
if (!action) {
|
||||||
|
@ -228,10 +230,33 @@ void VrMenu::removeAction(QAction* action) {
|
||||||
qWarning("Attempted to remove menu action with no found QML object");
|
qWarning("Attempted to remove menu action with no found QML object");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QObject* parent = action->menu();
|
||||||
|
QObject* qmlParent = nullptr;
|
||||||
|
|
||||||
|
QMenu* parentMenu = dynamic_cast<QMenu*>(parent);
|
||||||
|
if (parentMenu) {
|
||||||
|
MenuUserData* MenuUserData = MenuUserData::forObject(parentMenu->menuAction());
|
||||||
|
if (!MenuUserData) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
qmlParent = findMenuObject(MenuUserData->uuid.toString());
|
||||||
|
} else if (dynamic_cast<QMenuBar*>(parent)) {
|
||||||
|
qmlParent = _rootMenu;
|
||||||
|
} else {
|
||||||
|
Q_ASSERT(false);
|
||||||
|
}
|
||||||
|
|
||||||
QObject* item = findMenuObject(userData->uuid.toString());
|
QObject* item = findMenuObject(userData->uuid.toString());
|
||||||
QObject* menu = item->parent();
|
|
||||||
// Proxy QuickItem requests through the QML layer
|
QQuickMenu1* menu = nullptr;
|
||||||
QQuickMenuBase* qmlItem = reinterpret_cast<QQuickMenuBase*>(item);
|
QMetaObject::invokeMethod(item, "parentMenu", Qt::DirectConnection, Q_RETURN_ARG(QQuickMenu1*, menu));
|
||||||
QMetaObject::invokeMethod(menu, "removeItem", Qt::DirectConnection, Q_ARG(QQuickMenuBase*, qmlItem));
|
|
||||||
|
if (!menu) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QQuickMenuBase* menuItem = reinterpret_cast<QQuickMenuBase*>(item);
|
||||||
|
QObject* baseMenu = reinterpret_cast<QObject*>(menu);
|
||||||
|
|
||||||
|
QMetaObject::invokeMethod(baseMenu, "removeItem", Qt::DirectConnection, Q_ARG(QQuickMenuBase*, menuItem));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue