13#include <QtGui/qevent.h>
14#include <QtGui/qcursor.h>
15#if QT_CONFIG(shortcut)
16#include <QtGui/qkeysequence.h>
18#include <QtGui/qpa/qplatformintegration.h>
19#include <QtGui/private/qguiapplication_p.h>
20#include <QtQml/qqmlcontext.h>
21#include <QtQml/qqmlcomponent.h>
22#include <QtQml/private/qqmlengine_p.h>
23#include <QtQml/private/qv4scopedvalue_p.h>
24#include <QtQml/private/qv4variantobject_p.h>
25#include <QtQml/private/qv4qobjectwrapper_p.h>
26#include <private/qqmlobjectmodel_p.h>
27#include <QtQuick/private/qquickitem_p.h>
28#include <QtQuick/private/qquickitemchangelistener_p.h>
29#include <QtQuick/private/qquickevents_p_p.h>
30#include <QtQuick/private/qquickwindow_p.h>
324 button->setAction(action);
335 if (!
p->widthValid()) {
337 p->widthValidFlag =
false;
371 for (
int i = 0;
i < siblings.
size(); ++
i) {
418 if (
p->popupItem->isMirrored())
420 else if (
p->parentItem)
421 menu->setPosition(
QPointF(
p->parentItem->width() +
p->parentMenu->rightPadding() -
menu->overlap(), -
menu->topPadding()));
424 p->parentMenu->y() + (
p->parentMenu->height() -
menu->
height()) / 2));
447 q->resetClosePolicy();
463 subMenu = currentSubMenuItem ? currentSubMenuItem->subMenu() :
nullptr;
487 if (oldCurrentItem) {
494 if (subMenu && subMenu->
cascade())
510 subMenu->popup(subMenuPrivate->firstEnabledMenuItem());
520 if (!
item->hasActiveFocus())
561 if (
item &&
item->subMenu() == subMenu)
571 q->resetParentItem();
619 if (!newCurrentItem &&
window) {
625 if (newCurrentItem) {
633 emit q->currentIndexChanged();
653 while (--
index >= 0) {
687 item =
p->createItem(action);
696 }
else if (
p->contentModel->indexOf(
item,
nullptr) == -1) {
700 p->contentData.append(
obj);
742 while (
d->contentModel->count() > 0)
743 d->removeItem(0,
d->itemAt(0));
745 if (
d->contentItem) {
783 const int count =
d->contentModel->count();
784 if (index < 0 || index >
count)
787 int oldIndex =
d->contentModel->indexOf(
item,
nullptr);
788 if (oldIndex != -1) {
789 if (oldIndex <
index)
791 if (oldIndex !=
index)
792 d->moveItem(oldIndex,
index);
806 const int count =
d->contentModel->count();
807 if (from < 0 || from >
count - 1)
809 if (to < 0 || to >
count - 1)
813 d->moveItem(from, to);
828 const int index =
d->contentModel->indexOf(
item,
nullptr);
847 const int count =
d->contentModel->count();
848 if (index < 0 || index >=
count)
871 return item->subMenu();
883 insertMenu(
d->contentModel->count(),
menu);
913 const int count =
d->contentModel->count();
964 return item->action();
976 insertAction(
d->contentModel->count(),
action);
1006 const int count =
d->contentModel->count();
1039 item->deleteLater();
1088 if (!
d->contentItem)
1145 if (
icon ==
d->icon)
1148 d->icon.ensureRelativeSourceResolved(
this);
1179 d->resolveParentItem();
1218 emit overlapChanged();
1251 emit delegateChanged();
1267 return d->currentIndex;
1286 return d->contentModel->count();
1295#if QT_CONFIG(cursor)
1301 if (
pos.isNull &&
d->parentItem)
1311#if QT_CONFIG(cursor)
1365 args->v4engine()->throwTypeError();
1381 if (
item && !
d->popupItem->isAncestorOf(
item))
1383 }
else if (firstArg->isUndefined()) {
1385 parentItem =
d->parentItem;
1392 if (
item &&
d->popupItem->isAncestorOf(
item))
1397 if (
len >= 3 || (!parentItem &&
len >= 2)) {
1405 if (
pos.isNull && (
len >= 2 || (!parentItem &&
len >= 1))) {
1414 setParentItem(parentItem);
1436void QQuickMenu::dismiss()
1466 d->contentItem = newItem;
1475 if (!
data.boolValue &&
d->cascade) {
1494 switch (
event->key()) {
1496 if (!
d->activatePreviousItem())
1497 d->propagateKeyEvent(
event);
1501 d->activateNextItem();
1508 if (
d->parentMenu &&
d->currentItem) {
1510 d->parentMenu->open();
1517 subMenu->
popup(subMenuPrivate->firstEnabledMenuItem());
1521 if (!
event->isAccepted())
1522 d->propagateKeyEvent(
event);
1525#if QT_CONFIG(shortcut)
1542 if (
event->timerId() ==
d->hoverTimer) {
1545 d->stopHoverTimer();
1556#if QT_CONFIG(accessibility)
1557QAccessible::Role QQuickMenu::accessibleRole()
const
1559 return QAccessible::PopupMenu;
1565#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 ...
qsizetype size() const noexcept
bool removeOne(const AT &t)
qsizetype length() const noexcept
const_reference at(qsizetype i) const noexcept
T value(qsizetype i) const
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)
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
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.
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
int count() const override
\qmlproperty int QtQml.Models::ObjectModel::count
int indexOf(QObject *object, QObject *objectContext) const override
virtual void executeContentItem(bool complete=false)
static QQuickControlPrivate * get(QQuickControl *control)
Qt::FocusReason focusReason
void updateOrAddGeometryChangeListener(QQuickItemChangeListener *listener, QQuickGeometryChange types)
QPointer< QQuickItem > subFocusItem
void removeItemChangeListener(QQuickItemChangeListener *, ChangeTypes types)
void addItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types)
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.
Q_INVOKABLE void forceActiveFocus()
\qmlmethod point QtQuick::Item::mapToItem(Item item, real x, real y) \qmlmethod point QtQuick::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)
void clearFocusInScope(QQuickItem *scope, QQuickItem *item, Qt::FocusReason reason)
\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)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent