185 else if (m_parentMenu && m_parentMenu
->handle())
186 m_handle = m_parentMenu
->handle()->createSubMenu();
187#if QT_CONFIG(systemtrayicon)
188 else if (m_systemTrayIcon && m_systemTrayIcon->handle())
189 m_handle = m_systemTrayIcon->handle()->createMenu();
197 m_handle = QGuiApplicationPrivate::platformTheme()->createPlatformMenu();
202 qCDebug(qtLabsPlatformMenus) <<
"Menu ->" << m_handle;
205 connect(m_handle, &QPlatformMenu::aboutToShow,
this, &QQuickLabsPlatformMenu::aboutToShow);
206 connect(m_handle, &QPlatformMenu::aboutToHide,
this, &QQuickLabsPlatformMenu::aboutToHide);
208 for (QQuickLabsPlatformMenuItem *item : std::as_const(m_items))
209 m_handle->insertMenuItem(item->create(),
nullptr);
212 if (QPlatformMenuItem *handle = m_menuItem
->create())
213 handle->setMenu(m_handle);
238 m_handle->setText(m_title);
239 m_handle->setEnabled(m_enabled);
240 m_handle->setVisible(m_visible);
241 m_handle->setMinimumWidth(m_minimumWidth);
242 m_handle->setMenuType(m_type);
243 m_handle->setFont(m_font);
247#if QT_CONFIG(systemtrayicon)
248 else if (m_systemTrayIcon && m_systemTrayIcon->handle())
249 m_systemTrayIcon->handle()->updateMenu(m_handle);
252 for (QQuickLabsPlatformMenuItem *item : std::as_const(m_items))
268 return QQmlListProperty<QObject>(
this,
nullptr, data_append, data_count, data_at, data_clear);
659 if (args->length() > 2) {
660 args->v4engine()->throwTypeError();
664 QV4::ExecutionEngine *v4 = args->v4engine();
665 QV4::Scope scope(v4);
667 QQuickItem *targetItem =
nullptr;
668 if (args->length() > 0) {
669 QV4::ScopedValue value(scope, (*args)[0]);
670 QV4::Scoped<QV4::QObjectWrapper> object(scope, value->as<QV4::QObjectWrapper>());
672 targetItem = qobject_cast<QQuickItem *>(object->object());
676 if (args->length() > 1) {
677 QV4::ScopedValue value(scope, (*args)[1]);
678 QV4::Scoped<QV4::QObjectWrapper> object(scope, value->as<QV4::QObjectWrapper>());
680 menuItem = qobject_cast<QQuickLabsPlatformMenuItem *>(object->object());
684 QWindow *window = findWindow(targetItem, &offset);
688 QRectF sceneBounds = targetItem->mapRectToScene(targetItem->boundingRect());
689 targetRect = sceneBounds.toAlignedRect().translated(offset);
692 QPoint pos = QCursor::pos();
694 pos = window->mapFromGlobal(pos);
695 targetRect.moveTo(pos);
698 m_handle->showPopup(window,
699 QHighDpi::toNativeLocalPosition(targetRect, window),
700 menuItem ? menuItem->handle() :
nullptr);
751 return effectiveWindow(target->window(), offset);
753 if (m_menuBar && m_menuBar->window())
754 return effectiveWindow(m_menuBar->window(), offset);
756 QObject *obj = parent();
758 QWindow *window = qobject_cast<QWindow *>(obj);
760 return effectiveWindow(window, offset);
762 QQuickItem *item = qobject_cast<QQuickItem *>(obj);
763 if (item && item->window())
764 return effectiveWindow(item->window(), offset);