7#include <private/qtquicktemplates2-config_p.h>
8#if QT_CONFIG(quicktemplates2_container)
16#include <QtGui/qevent.h>
17#include <QtGui/qcursor.h>
18#if QT_CONFIG(shortcut)
19#include <QtGui/qkeysequence.h>
21#include <QtGui/qpa/qplatformintegration.h>
22#include <QtGui/private/qguiapplication_p.h>
23#include <QtQml/qqmlcontext.h>
24#include <QtQml/qqmlcomponent.h>
25#include <QtQml/private/qqmlengine_p.h>
26#include <QtQml/private/qv4scopedvalue_p.h>
27#include <QtQml/private/qv4variantobject_p.h>
28#include <QtQml/private/qv4qobjectwrapper_p.h>
29#include <private/qqmlobjectmodel_p.h>
30#include <QtQuick/private/qquickitem_p.h>
31#include <QtQuick/private/qquickitemchangelistener_p.h>
32#include <QtQuick/private/qquickevents_p_p.h>
33#include <QtQuick/private/qquickwindow_p.h>
327 button->setAction(action);
338 if (!
p->widthValid()) {
340 p->widthValidFlag =
false;
374 for (
int i = 0;
i < siblings.size(); ++
i) {
421 if (
p->popupItem->isMirrored())
423 else if (
p->parentItem)
424 menu->setPosition(
QPointF(
p->parentItem->width() +
p->parentMenu->rightPadding() -
menu->overlap(), -
menu->topPadding()));
427 p->parentMenu->y() + (
p->parentMenu->height() -
menu->
height()) / 2));
450 q->resetClosePolicy();
466 subMenu = currentSubMenuItem ? currentSubMenuItem->subMenu() :
nullptr;
490 if (oldCurrentItem) {
491 QQuickMenu *subMenu = oldCurrentItem->subMenu();
497 if (subMenu && subMenu->
cascade())
513 subMenu->popup(subMenuPrivate->firstEnabledMenuItem());
523 if (!
item->hasActiveFocus())
564 if (
item &&
item->subMenu() == subMenu)
574 q->resetParentItem();
586#if QT_CONFIG(quicktemplates2_container)
624 if (!newCurrentItem &&
window) {
630 if (newCurrentItem) {
631 newCurrentItem->setHighlighted(
true);
632 newCurrentItem->forceActiveFocus(reason);
638 emit q->currentIndexChanged();
658 while (--
index >= 0) {
686 QQuickMenu *
q = qobject_cast<QQuickMenu *>(prop->object);
692 item =
p->createItem(action);
701 }
else if (
p->contentModel->indexOf(
item,
nullptr) == -1) {
705 p->contentData.append(
obj);
747 while (
d->contentModel->count() > 0)
748 d->removeItem(0,
d->itemAt(0));
750 if (
d->contentItem) {
754 const auto children =
d->contentItem->childItems();
792 const int count =
d->contentModel->count();
793 if (index < 0 || index >
count)
796 int oldIndex =
d->contentModel->indexOf(
item,
nullptr);
797 if (oldIndex != -1) {
798 if (oldIndex <
index)
800 if (oldIndex !=
index)
801 d->moveItem(oldIndex,
index);
815 const int count =
d->contentModel->count();
816 if (from < 0 || from >
count - 1)
818 if (to < 0 || to >
count - 1)
822 d->moveItem(from, to);
837 const int index =
d->contentModel->indexOf(
item,
nullptr);
856 const int count =
d->contentModel->count();
857 if (index < 0 || index >=
count)
880 return item->subMenu();
892 insertMenu(
d->contentModel->count(),
menu);
922 const int count =
d->contentModel->count();
973 return item->action();
985 insertAction(
d->contentModel->count(),
action);
1015 const int count =
d->contentModel->count();
1048 item->deleteLater();
1097 if (!
d->contentItem)
1099 return QQmlListProperty<QObject>(
this,
nullptr,
1154 if (
icon ==
d->icon)
1157 d->icon.ensureRelativeSourceResolved(
this);
1188 d->resolveParentItem();
1227 emit overlapChanged();
1260 emit delegateChanged();
1276 return d->currentIndex;
1295 return d->contentModel->count();
1303 QQmlNullableValue<QPointF>
pos;
1304#if QT_CONFIG(cursor)
1310 if (!
pos.isValid() &&
d->parentItem)
1320#if QT_CONFIG(cursor)
1374 args->v4engine()->throwTypeError();
1381 QQmlNullableValue<QPointF>
pos;
1390 if (
item && !
d->popupItem->isAncestorOf(
item))
1392 }
else if (firstArg->isUndefined()) {
1394 parentItem =
d->parentItem;
1401 if (
item &&
d->popupItem->isAncestorOf(
item))
1406 if (
len >= 3 || (!parentItem &&
len >= 2)) {
1410 if (xArg->isNumber() && yArg->isNumber())
1411 pos =
QPointF(xArg->asDouble(), yArg->asDouble());
1414 if (!
pos.isValid() && (
len >= 2 || (!parentItem &&
len >= 1))) {
1423 setParentItem(parentItem);
1445void QQuickMenu::dismiss()
1475 d->contentItem = newItem;
1484 if (!
data.boolValue &&
d->cascade) {
1503 switch (
event->key()) {
1505 if (!
d->activatePreviousItem())
1506 d->propagateKeyEvent(
event);
1510 d->activateNextItem();
1517 if (
d->parentMenu &&
d->currentItem) {
1519 d->parentMenu->open();
1526 subMenu->
popup(subMenuPrivate->firstEnabledMenuItem());
1530 if (!
event->isAccepted())
1531 d->propagateKeyEvent(
event);
1534#if QT_CONFIG(shortcut)
1551 if (
event->timerId() ==
d->hoverTimer) {
1554 d->stopHoverTimer();
1565#if QT_CONFIG(accessibility)
1566QAccessible::Role QQuickMenu::accessibleRole()
const
1568 return QAccessible::PopupMenu;
1574#include "moc_qquickmenu_p.cpp"
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static QPoint pos()
Returns the position of the cursor (hot spot) of the primary screen in global screen coordinates.
bool isEnabled() const
Returns true if the item is enabled; otherwise, false is returned.
void setParentItem(QGraphicsItem *parent)
Sets this item's parent item to newParent.
static QPlatformIntegration * platformIntegration()
The QKeyEvent class describes a key event.
static QKeySequence mnemonic(const QString &text)
Returns the shortcut key sequence for the mnemonic in text, or an empty key sequence if no mnemonics ...
bool removeOne(const AT &t)
qsizetype length() const noexcept
void append(parameter_type t)
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
static bool disconnect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot)
const QObjectList & children() const
Returns a list of child objects.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
virtual void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object.
void deleteLater()
\threadsafe
The QPalette class contains color groups for each widget state.
\inmodule QtCore\reentrant
T * data() const noexcept
The QQmlComponent class encapsulates a QML component definition.
virtual QObject * beginCreate(QQmlContext *)
Create an object instance from this component, within the specified context.
virtual void completeCreate()
This method provides advanced control over component instance creation.
QQmlContext * creationContext() const
Returns the QQmlContext the component was created in.
The QQmlContext class defines a context within a QML engine.
int count() const override
\qmlproperty int QtQml.Models::ObjectModel::count
int indexOf(QObject *object, QObject *objectContext) const override
static QQuickControlPrivate * get(QQuickControl *control)
Qt::FocusReason focusReason
static QQuickItemPrivate * get(QQuickItem *item)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
void activeFocusChanged(bool)
QList< QQuickItem * > childItems() const
Returns the children of this item.
qreal width
This property holds the width of this item.
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
static QPalette palette(Scope scope)
static QFont font(Scope scope)
static QQuickWindowPrivate * get(QQuickWindow *c)
\inmodule QtCore\reentrant
\macro QT_RESTRICTED_CAST_FROM_ASCII
QPointF toPointF() const
Returns the variant as a QPointF if the variant has userType() \l QMetaType::QPoint or \l QMetaType::...
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Combined button and popup list for selecting options.
n void setPosition(void) \n\
GLint GLsizei GLsizei height
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLdouble GLdouble GLdouble GLdouble q
QQmlContext * qmlContext(const QObject *obj)
void QQml_setParent_noEvent(QObject *object, QObject *parent)
Makes the object a child of parent.
QQuickItem * qobject_cast< QQuickItem * >(QObject *o)
#define QStringLiteral(str)
myObject disconnect()
[26]
bool contains(const AT &t) const noexcept
static QVariant toVariant(const QV4::Value &value, QMetaType typeHint, bool createJSValueForObjectsAndSymbols=true)