Qt 4.8
Classes | Public Types | Public Functions | Static Public Functions | Public Variables | Static Public Variables | List of all members
QMenuPrivate Class Reference

#include <qmenu_p.h>

Inheritance diagram for QMenuPrivate:
QWidgetPrivate QObjectPrivate QObjectData QTornOffMenu::QTornOffMenuPrivate

Classes

struct  QMacMenuPrivate
 
struct  QMenuCaused
 
struct  QMenuScroller
 
struct  QWceMenuPrivate
 

Public Types

enum  SelectionReason { SelectedFromKeyboard, SelectedFromElsewhere }
 
- Public Types inherited from QWidgetPrivate
enum  CloseMode { CloseNoEvent, CloseWithEvent, CloseWithSpontaneousEvent }
 
enum  Direction { DirectionNorth = 0x01, DirectionEast = 0x10, DirectionSouth = 0x02, DirectionWest = 0x20 }
 
enum  DrawWidgetFlags {
  DrawAsRoot = 0x01, DrawPaintOnScreen = 0x02, DrawRecursive = 0x04, DrawInvisible = 0x08,
  DontSubtractOpaqueChildren = 0x10, DontSetCompositionMode = 0x20, DontDrawOpaqueChildren = 0x40, DontDrawNativeChildren = 0x80
}
 
- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 

Public Functions

void _q_actionHovered ()
 
void _q_actionTriggered ()
 
void _q_overrideMenuActionDestroyed ()
 
QActionactionAt (QPoint p) const
 
QActionactionAt (int i) const
 
QRect actionRect (QAction *) const
 
void activateAction (QAction *, QAction::ActionEvent, bool self=true)
 
void activateCausedStack (const QList< QPointer< QWidget > > &, QAction *, QAction::ActionEvent, bool)
 
QSize adjustMenuSizeForScreen (const QRect &screen)
 
virtual QList< QPointer< QWidget > > calcCausedStack () const
 
int getLastVisibleAction () const
 
bool hasMouseMoved (const QPoint &globalPos)
 
void hideMenu (QMenu *menu, bool justRegister=false)
 
void hideUpToMenuBar ()
 
int indexOf (QAction *act) const
 
void init ()
 
OSMenuRef macMenu (OSMenuRef merge)
 
bool mouseEventTaken (QMouseEvent *)
 
void popupAction (QAction *, int, bool)
 
QRect popupGeometry (const QWidget *widget) const
 
QRect popupGeometry (int screen=-1) const
 
 QMenuPrivate ()
 
int scrollerHeight () const
 
void scrollMenu (QMenuScroller::ScrollLocation location, bool active=false)
 
void scrollMenu (QMenuScroller::ScrollDirection direction, bool page=false, bool active=false)
 
void scrollMenu (QAction *action, QMenuScroller::ScrollLocation location, bool active=false)
 
void setCurrentAction (QAction *, int popup=-1, SelectionReason reason=SelectedFromElsewhere, bool activateFirst=false)
 
void setFirstActionActive ()
 
void setMacMenuEnabled (bool enable=true)
 
void setOverrideMenuAction (QAction *)
 
void setSyncAction ()
 
void syncSeparatorsCollapsible (bool collapsible)
 
QWidgettopCausedWidget () const
 
void updateActionRects () const
 
void updateActionRects (const QRect &screen) const
 
void updateLayoutDirection ()
 
QActionwceCommands (uint command)
 
HMENU wceMenu ()
 
 ~QMenuPrivate ()
 
- Public Functions inherited from QWidgetPrivate
void _q_showIfNotHidden ()
 
virtual void aboutToDestroy ()
 
void activateChildLayoutsRecursively ()
 
QSize adjustedSize () const
 
void adjustQuitOnCloseAttribute ()
 
QInputContextassignedInputContext () const
 
QPainterbeginSharedPainter ()
 
QWidgetchildAt_helper (const QPoint &, bool) const
 
QWidgetchildAtRecursiveHelper (const QPoint &p, bool, bool includeFrame=false) const
 
QRect clipRect () const
 
QRegion clipRegion () const
 
void clipToEffectiveMask (QRegion &region) const
 
bool close_helper (CloseMode mode)
 
void create_sys (WId window, bool initializeWindow, bool destroyOldWindow)
 
QWindowSurfacecreateDefaultWindowSurface ()
 
QWindowSurfacecreateDefaultWindowSurface_sys ()
 
void createExtra ()
 Creates the widget extra data. More...
 
void createRecursively ()
 
void createSysExtra ()
 
void createTLExtra ()
 
void createTLSysExtra ()
 
void createWinId (WId id=0)
 
void deactivateWidgetCleanup ()
 
void deleteExtra ()
 Deletes the widget extra data. More...
 
void deleteSysExtra ()
 
void deleteTLSysExtra ()
 
void drawWidget (QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter=0, QWidgetBackingStore *backingStore=0)
 
QWidgeteffectiveFocusWidget ()
 
QRect effectiveRectFor (const QRect &rect) const
 
bool endSharedPainter ()
 
void enforceNativeChildren ()
 
QWExtraextraData () const
 
QRect frameStrut () const
 
void getLayoutItemMargins (int *left, int *top, int *right, int *bottom) const
 
const QRegiongetOpaqueChildren () const
 
void handleSoftwareInputPanel (Qt::MouseButton button, bool clickCausedFocus)
 
virtual bool hasHeightForWidth () const
 
void hide_helper ()
 
void hide_sys ()
 Platform-specific part of QWidget::hide(). More...
 
void hideChildren (bool spontaneous)
 
void inheritStyle ()
 
void init (QWidget *desktopWidget, Qt::WindowFlags f)
 
QInputContextinputContext () const
 
void invalidateBuffer (const QRegion &)
 Invalidates the rgn (in widget's coordinates) of the backing store, i.e. More...
 
void invalidateBuffer (const QRect &)
 This function is equivalent to calling invalidateBuffer(QRegion(rect), ...), but is more efficient as it eliminates QRegion operations/allocations and can use the rect more precisely for additional cut-offs. More...
 
void invalidateBuffer_resizeHelper (const QPoint &oldPos, const QSize &oldSize)
 Invalidates the buffer when the widget is resized. More...
 
void invalidateGraphicsEffectsRecursively ()
 
bool isAboutToShow () const
 
bool isBackgroundInherited () const
 
bool isOverlapped (const QRect &) const
 
void lower_sys ()
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QWidgetBackingStoremaybeBackingStore () const
 
QTLWExtramaybeTopData () const
 
void moveRect (const QRect &, int dx, int dy)
 
bool nativeChildrenForced () const
 
QFont naturalWidgetFont (uint inheritedMask) const
 
QPalette naturalWidgetPalette (uint inheritedMask) const
 Returns the palette that the widget w inherits from its ancestors and QApplication::palette. More...
 
void paintBackground (QPainter *, const QRegion &, int flags=DrawAsRoot) const
 
bool paintOnScreen () const
 
void paintSiblingsRecursive (QPaintDevice *pdev, const QObjectList &children, int index, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter, QWidgetBackingStore *backingStore)
 
bool pointInsideRectAndMask (const QPoint &) const
 
QRegion prepareToRender (const QRegion &region, QWidget::RenderFlags renderFlags)
 
void propagatePaletteChange ()
 Propagate this widget's palette to all children, except style sheet widgets, and windows that don't enable window propagation (palettes don't normally propagate to windows). More...
 
 QWidgetPrivate (int version=QObjectPrivateVersion)
 
void raise_sys ()
 
QPaintDeviceredirected (QPoint *offset) const
 
void registerDropSite (bool)
 
void render (QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags, bool readyToRender)
 
void render_helper (QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
 
void repaint_sys (const QRegion &rgn)
 
void reparentFocusWidgets (QWidget *oldtlw)
 
void resolveFont ()
 Determine which font is implicitly imposed on this widget by its ancestors and QApplication::font, resolve this against its own font (attributes from the implicit font are copied over). More...
 
void resolveLayoutDirection ()
 
void resolveLocale ()
 
void resolvePalette ()
 Determine which palette is inherited from this widget's ancestors and QApplication::palette, resolve this against this widget's palette (attributes from the inherited palette are copied over this widget's palette). More...
 
void restoreRedirected ()
 
void scroll_sys (int dx, int dy)
 
void scroll_sys (int dx, int dy, const QRect &r)
 
void scrollChildren (int dx, int dy)
 
void scrollRect (const QRect &, int dx, int dy)
 
void sendPendingMoveAndResizeEvents (bool recursive=false, bool disableUpdates=false)
 
void sendStartupMessage (const char *message) const
 Platform-specific part of QWidget::show(). More...
 
void setConstraints_sys ()
 
void setCursor_sys (const QCursor &cursor)
 
void setDirtyOpaqueRegion ()
 
void setEnabled_helper (bool)
 
void setFocus_sys ()
 
void setFont_helper (const QFont &font)
 
void setGeometry_sys (int, int, int, int, bool)
 
void setLayoutDirection_helper (Qt::LayoutDirection)
 
void setLayoutItemMargins (int left, int top, int right, int bottom)
 
void setLayoutItemMargins (QStyle::SubElement element, const QStyleOption *opt=0)
 
void setLocale_helper (const QLocale &l, bool forceUpdate=false)
 
void setMask_sys (const QRegion &)
 
bool setMaximumSize_helper (int &maxw, int &maxh)
 
bool setMinimumSize_helper (int &minw, int &minh)
 
void setModal_sys ()
 
void setNetWmWindowTypes ()
 
void setOpaque (bool opaque)
 
void setPalette_helper (const QPalette &)
 
void setParent_sys (QWidget *parent, Qt::WindowFlags)
 
void setRedirected (QPaintDevice *replacement, const QPoint &offset)
 
void setSharedPainter (QPainter *painter)
 
void setStyle_helper (QStyle *newStyle, bool propagate, bool metalHack=false)
 
void setUpdatesEnabled_helper (bool)
 
void setWindowFilePath_helper (const QString &filePath)
 
void setWindowIcon_helper ()
 
void setWindowIcon_sys (bool forceReset=false)
 
void setWindowIconText_helper (const QString &cap)
 
void setWindowIconText_sys (const QString &cap)
 
void setWindowOpacity_sys (qreal opacity)
 
void setWindowRole ()
 
void setWindowTitle_helper (const QString &cap)
 
void setWindowTitle_sys (const QString &cap)
 
void setWinId (WId)
 
QPaintersharedPainter () const
 
void show_helper ()
 
void show_recursive ()
 Makes the widget visible in the isVisible() meaning of the word. More...
 
void show_sys ()
 Platform-specific part of QWidget::show(). More...
 
void showChildren (bool spontaneous)
 
void stackUnder_sys (QWidget *)
 
void subtractOpaqueChildren (QRegion &rgn, const QRect &clipRect) const
 
void subtractOpaqueSiblings (QRegion &source, bool *hasDirtySiblingsAbove=0, bool alsoNonOpaque=false) const
 
void syncBackingStore ()
 
void syncBackingStore (const QRegion &region)
 
QTLWExtratopData () const
 
void unsetCursor_sys ()
 
void updateFont (const QFont &)
 Assign font to this widget, and propagate it to all children, except style sheet widgets (handled differently) and windows that don't enable window propagation. More...
 
void updateFrameStrut ()
 Computes the frame rectangle when needed. More...
 
void updateGeometry_helper (bool forceUpdate)
 
void updateIsOpaque ()
 
void updateIsTranslucent ()
 
void updateSystemBackground ()
 
void updateX11AcceptFocus ()
 
void x11UpdateIsOpaque ()
 
 ~QWidgetPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Static Public Functions

static QMenuPrivateget (QMenu *m)
 
- Static Public Functions inherited from QWidgetPrivate
static void adjustFlags (Qt::WindowFlags &flags, QWidget *w=0)
 
static QGraphicsProxyWidgetnearestGraphicsProxyWidget (const QWidget *origin)
 Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this widget and its ancestors. More...
 
static int pointToRect (const QPoint &p, const QRect &r)
 
static QRect screenGeometry (const QWidget *widget)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Public Variables

uint aboutToHide: 1
 
QPointer< QActionactionAboutToTrigger
 
QVector< QRectactionRects
 
bool activationRecursionGuard
 
QPointer< QMenuactiveMenu
 
QMenuCaused causedPopup
 
uint collapsibleSeparators: 1
 
QActioncurrentAction
 
QPointer< QActiondefaultAction
 
QActiondefaultMenuAction
 
bool doChildEffects
 
QEventLoopeventLoop
 
bool hasCheckableItems
 
uint hasHadMouse: 1
 
uint itemsDirty: 1
 
struct QMenuPrivate::QMacMenuPrivatemac_menu
 
uint maxIconWidth
 
QActionmenuAction
 
QBasicTimer menuDelayTimer
 
int motions
 
QPoint mousePopupPos
 
uint ncols: 4
 
QPointer< QWidgetnoReplayFor
 
struct QMenuPrivate::QMenuScrollerscroll
 
QString searchBuffer
 
QBasicTimer searchBufferTimer
 
QActionsloppyAction
 
int sloppyDelayTimer
 
QRegion sloppyRegion
 
QPointer< QActionsyncAction
 
uint tabWidth
 
uint tearoff: 1
 
uint tearoffHighlighted: 1
 
uint tornoff: 1
 
QPointer< QTornOffMenutornPopup
 
struct QMenuPrivate::QWceMenuPrivatewce_menu
 
QHash< QAction *, QWidget * > widgetItems
 
- Public Variables inherited from QWidgetPrivate
QString accessibleDescription
 
QString accessibleName
 
QList< QAction * > actions
 
QPalette::ColorRole bg_role: 8
 
signed char bottomLayoutItemMargin
 
short bottommargin
 
QWidgetData data
 
QRegion dirty
 
uint dirtyOpaqueChildren: 1
 
QWExtraextra
 
QPaintEngineextraPaintEngine
 
QPalette::ColorRole fg_role: 8
 
QWidgetfocus_child
 
QWidgetfocus_next
 
QWidgetfocus_prev
 
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
 
QGraphicsEffectgraphicsEffect
 
Qt::HANDLE hd
 
uint high_attributes [4]
 
QPointer< QInputContextic
 
Qt::InputMethodHints imHints
 
uint inDirtyList: 1
 
uint inheritedFontResolveMask
 
uint inheritedPaletteResolveMask
 
uint inheritsInputMethodHints: 1
 
uint inSetParent: 1
 
uint isGLWidget: 1
 
uint isMoved: 1
 
uint isOpaque: 1
 
uint isScrolled: 1
 
QLayoutlayout
 
signed char leftLayoutItemMargin
 
short leftmargin
 
QLocale locale
 
QRegionneedsFlush
 
QRegion opaqueChildren
 
Qt::HANDLE picture
 
const QMetaObjectpolished
 
QPaintDeviceredirectDev
 
QPoint redirectOffset
 
signed char rightLayoutItemMargin
 
short rightmargin
 
QSizePolicy size_policy
 
QString statusTip
 
QString toolTip
 
signed char topLayoutItemMargin
 
short topmargin
 
uint usesDoubleBufferedGLContext: 1
 
QString whatsThis
 
QWidgetItemV2widgetItem
 
QX11Info xinfo
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Static Public Variables

static QHash< OSMenuRef, OSMenuRefmergeMenuHash
 
static QHash< OSMenuRef, QMenuMergeList * > mergeMenuItemsHash
 
static QMenumouseDown = 0
 
- Static Public Variables inherited from QWidgetPrivate
static QWidgetSetallWidgets = 0
 
static int instanceCounter = 0
 
static QWidgetkeyboardGrabber = 0
 
static QWidgetMappermapper = 0
 
static int maxInstances = 0
 
static QWidgetmouseGrabber = 0
 

Detailed Description

Definition at line 144 of file qmenu_p.h.

Enumerations

◆ SelectionReason

Enumerator
SelectedFromKeyboard 
SelectedFromElsewhere 

Definition at line 219 of file qmenu_p.h.

Constructors and Destructors

◆ QMenuPrivate()

QMenuPrivate::QMenuPrivate ( )
inline

Definition at line 148 of file qmenu_p.h.

148  : itemsDirty(0), maxIconWidth(0), tabWidth(0), ncols(0),
150  currentAction(0),
151 #ifdef QT_KEYPAD_NAVIGATION
152  selectAction(0),
153  cancelAction(0),
154 #endif
157 #ifdef QT3_SUPPORT
158  ,emitHighlighted(false)
159 #endif
160 #ifdef Q_WS_MAC
161  ,mac_menu(0)
162 #endif
163 #if defined(Q_WS_WINCE) && !defined(QT_NO_MENUBAR)
164  ,wce_menu(0)
165 #endif
166 #ifdef Q_WS_S60
167  ,symbian_menu(0)
168 #endif
169  { }
uint tearoff
Definition: qmenu_p.h:272
uint hasHadMouse
Definition: qmenu_p.h:210
uint collapsibleSeparators
Definition: qmenu_p.h:201
struct QMenuPrivate::QMenuScroller * scroll
int motions
Definition: qmenu_p.h:212
struct QMenuPrivate::QWceMenuPrivate * wce_menu
bool activationRecursionGuard
Definition: qmenu_p.h:205
int sloppyDelayTimer
Definition: qmenu_p.h:278
uint tornoff
Definition: qmenu_p.h:272
uint itemsDirty
Definition: qmenu_p.h:190
uint maxIconWidth
Definition: qmenu_p.h:191
QAction * sloppyAction
Definition: qmenu_p.h:279
uint ncols
Definition: qmenu_p.h:200
uint tearoffHighlighted
Definition: qmenu_p.h:272
QEventLoop * eventLoop
Definition: qmenu_p.h:246
uint aboutToHide
Definition: qmenu_p.h:211
QAction * currentAction
Definition: qmenu_p.h:213
uint tabWidth
Definition: qmenu_p.h:191
bool hasCheckableItems
Definition: qmenu_p.h:275
struct QMenuPrivate::QMacMenuPrivate * mac_menu
bool doChildEffects
Definition: qmenu_p.h:303

◆ ~QMenuPrivate()

QMenuPrivate::~QMenuPrivate ( )
inline

Definition at line 170 of file qmenu_p.h.

171  {
172  delete scroll;
173 #ifdef Q_WS_MAC
174  delete mac_menu;
175 #endif
176 #if defined(Q_WS_WINCE) && !defined(QT_NO_MENUBAR)
177  delete wce_menu;
178 #endif
179 #ifdef Q_WS_S60
180  delete symbian_menu;
181 #endif
182 
183  }
struct QMenuPrivate::QMenuScroller * scroll
struct QMenuPrivate::QWceMenuPrivate * wce_menu
struct QMenuPrivate::QMacMenuPrivate * mac_menu

Functions

◆ _q_actionHovered()

void QMenuPrivate::_q_actionHovered ( )

Definition at line 1187 of file qmenu.cpp.

1188 {
1189  Q_Q(QMenu);
1190  if (QAction * action = qobject_cast<QAction *>(q->sender())) {
1191 #ifdef QT3_SUPPORT
1192  //we store it here because the action might be deleted/changed by connected slots
1193  const int id = q->findIdForAction(action);
1194 #endif
1195  emit q->hovered(action);
1196 #ifdef QT3_SUPPORT
1197  if (emitHighlighted) {
1198  emit q->highlighted(id);
1199  emitHighlighted = false;
1200  }
1201 #endif
1202  }
1203 }
#define Q_Q(Class)
Definition: qglobal.h:2483
#define emit
Definition: qobjectdefs.h:76
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64

◆ _q_actionTriggered()

void QMenuPrivate::_q_actionTriggered ( )

Definition at line 1152 of file qmenu.cpp.

1153 {
1154  Q_Q(QMenu);
1155  if (QAction *action = qobject_cast<QAction *>(q->sender())) {
1156  QWeakPointer<QAction> actionGuard = action;
1157 #ifdef QT3_SUPPORT
1158  //we store it here because the action might be deleted/changed by connected slots
1159  const int id = q->findIdForAction(action);
1160 #endif
1161  emit q->triggered(action);
1162 #ifdef QT3_SUPPORT
1163  emit q->activated(id);
1164 #endif
1165 
1166  if (!activationRecursionGuard && actionGuard) {
1167  //in case the action has not been activated by the mouse
1168  //we check the parent hierarchy
1169  QList< QPointer<QWidget> > list;
1170  for(QWidget *widget = q->parentWidget(); widget; ) {
1171  if (qobject_cast<QMenu*>(widget)
1172 #ifndef QT_NO_MENUBAR
1174 #endif
1175  ) {
1176  list.append(widget);
1177  widget = widget->parentWidget();
1178  } else {
1179  break;
1180  }
1181  }
1182  activateCausedStack(list, action, QAction::Trigger, false);
1183  }
1184  }
1185 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QPointer< QWidget > widget
bool activationRecursionGuard
Definition: qmenu_p.h:205
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_Q(Class)
Definition: qglobal.h:2483
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
#define emit
Definition: qobjectdefs.h:76
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
void activateCausedStack(const QList< QPointer< QWidget > > &, QAction *, QAction::ActionEvent, bool)
Definition: qmenu.cpp:1036
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
The QWeakPointer class holds a weak reference to a shared pointer.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ _q_overrideMenuActionDestroyed()

void QMenuPrivate::_q_overrideMenuActionDestroyed ( )

Definition at line 685 of file qmenu.cpp.

Referenced by setOverrideMenuAction().

686 {
688 }
QAction * defaultMenuAction
Definition: qmenu_p.h:286
QAction * menuAction
Definition: qmenu_p.h:285

◆ actionAt() [1/2]

QAction * QMenuPrivate::actionAt ( QPoint  p) const

Definition at line 661 of file qmenu.cpp.

662 {
663  if (!q_func()->rect().contains(p)) //sanity check
664  return 0;
665 
666  for(int i = 0; i < actionRects.count(); i++) {
667  if (actionRects.at(i).contains(p))
668  return actions.at(i);
669  }
670  return 0;
671 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QList< QAction * > actions
Definition: qwidget_p.h:760
QVector< QRect > actionRects
Definition: qmenu_p.h:194

◆ actionAt() [2/2]

QAction* QMenuPrivate::actionAt ( int  i) const
inline

Definition at line 268 of file qmenu_p.h.

268 { return q_func()->actions().at(i); }

◆ actionRect()

QRect QMenuPrivate::actionRect ( QAction act) const

Definition at line 419 of file qmenu.cpp.

Referenced by activateAction(), and setCurrentAction().

420 {
421  int index = actions.indexOf(act);
422  if (index == -1)
423  return QRect();
424 
426 
427  //we found the action
428  return actionRects.at(index);
429 }
void updateActionRects() const
Definition: qmenu.cpp:239
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the list, searching forward from index...
Definition: qlist.h:847
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QList< QAction * > actions
Definition: qwidget_p.h:760
quint16 index
QVector< QRect > actionRects
Definition: qmenu_p.h:194

◆ activateAction()

void QMenuPrivate::activateAction ( QAction action,
QAction::ActionEvent  action_e,
bool  self = true 
)

Definition at line 1085 of file qmenu.cpp.

Referenced by setCurrentAction().

1086 {
1087  Q_Q(QMenu);
1088 #ifndef QT_NO_WHATSTHIS
1089  bool inWhatsThisMode = QWhatsThis::inWhatsThisMode();
1090 #endif
1091  if (!action || !q->isEnabled()
1092  || (action_e == QAction::Trigger
1093 #ifndef QT_NO_WHATSTHIS
1094  && !inWhatsThisMode
1095 #endif
1096  && (action->isSeparator() ||!action->isEnabled())))
1097  return;
1098 
1099  /* I have to save the caused stack here because it will be undone after popup execution (ie in the hide).
1100  Then I iterate over the list to actually send the events. --Sam
1101  */
1102  const QList<QPointer<QWidget> > causedStack = calcCausedStack();
1103  if (action_e == QAction::Trigger) {
1104 #ifndef QT_NO_WHATSTHIS
1105  if (!inWhatsThisMode)
1106  actionAboutToTrigger = action;
1107 #endif
1108 
1109  if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
1110  hideUpToMenuBar();
1111  } else {
1113  if (QMenu *qmenu = qobject_cast<QMenu*>(widget)) {
1114  if(qmenu == q)
1115  hideUpToMenuBar();
1116  widget = qmenu->d_func()->causedPopup.widget;
1117  } else {
1118  break;
1119  }
1120  }
1121  }
1122 
1123 #ifndef QT_NO_WHATSTHIS
1124  if (inWhatsThisMode) {
1125  QString s = action->whatsThis();
1126  if (s.isEmpty())
1127  s = whatsThis;
1128  QWhatsThis::showText(q->mapToGlobal(actionRect(action).center()), s, q);
1129  return;
1130  }
1131 #endif
1132  }
1133 
1134 
1135  activateCausedStack(causedStack, action, action_e, self);
1136 
1137 
1138  if (action_e == QAction::Hover) {
1139 #ifndef QT_NO_ACCESSIBILITY
1140  if (QAccessible::isActive()) {
1141  int actionIndex = indexOf(action) + 1;
1144  }
1145 #endif
1146  action->showStatusText(topCausedWidget());
1147  } else {
1149  }
1150 }
bool isSeparator() const
Returns true if this action is a separator action; otherwise it returns false.
Definition: qaction.cpp:839
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
bool isEnabled() const
Definition: qaction.cpp:1208
int indexOf(QAction *act) const
Definition: qmenu_p.h:269
QPointer< QWidget > widget
bool showStatusText(QWidget *widget=0)
Updates the relevant status bar for the widget specified by sending a QStatusTipEvent to its parent w...
Definition: qaction.cpp:1315
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual QList< QPointer< QWidget > > calcCausedStack() const
Definition: qmenu.cpp:224
#define Q_Q(Class)
Definition: qglobal.h:2483
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static bool inWhatsThisMode()
Returns true if the user interface is in "What&#39;s This?" mode; otherwise returns false.
Definition: qwhatsthis.cpp:648
void hideUpToMenuBar()
Definition: qmenu.cpp:435
static bool isActive()
Returns true if an accessibility implementation has been requested during the runtime of the applicat...
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
static QWidget * activePopupWidget()
Returns the active popup widget.
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
QRect actionRect(QAction *) const
Definition: qmenu.cpp:419
QString whatsThis
the action&#39;s "What&#39;s This?" help text
Definition: qaction.h:80
QString whatsThis
Definition: qwidget_p.h:734
QPointer< QAction > actionAboutToTrigger
Definition: qmenu_p.h:338
QWidget * topCausedWidget() const
Definition: qmenu.cpp:653
void activateCausedStack(const QList< QPointer< QWidget > > &, QAction *, QAction::ActionEvent, bool)
Definition: qmenu.cpp:1036
static void showText(const QPoint &pos, const QString &text, QWidget *w=0)
Shows text as a "What&#39;s This?" window, at global position pos.
Definition: qwhatsthis.cpp:754
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ activateCausedStack()

void QMenuPrivate::activateCausedStack ( const QList< QPointer< QWidget > > &  causedStack,
QAction action,
QAction::ActionEvent  action_e,
bool  self 
)

Definition at line 1036 of file qmenu.cpp.

Referenced by _q_actionTriggered(), and activateAction().

1037 {
1039 #ifdef QT3_SUPPORT
1040  const int actionId = q_func()->findIdForAction(action);
1041 #endif
1042  if(self)
1043  action->activate(action_e);
1044 
1045  for(int i = 0; i < causedStack.size(); ++i) {
1046  QPointer<QWidget> widget = causedStack.at(i);
1047  if (!widget)
1048  continue;
1049  //fire
1050  if (QMenu *qmenu = qobject_cast<QMenu*>(widget)) {
1051  widget = qmenu->d_func()->causedPopup.widget;
1052  if (action_e == QAction::Trigger) {
1053  emit qmenu->triggered(action);
1054  } else if (action_e == QAction::Hover) {
1055  emit qmenu->hovered(action);
1056 #ifdef QT3_SUPPORT
1057  if (emitHighlighted) {
1058  emit qmenu->highlighted(actionId);
1059  emitHighlighted = false;
1060  }
1061 #endif
1062  }
1063 #ifndef QT_NO_MENUBAR
1064  } else if (QMenuBar *qmenubar = qobject_cast<QMenuBar*>(widget)) {
1065  if (action_e == QAction::Trigger) {
1066  emit qmenubar->triggered(action);
1067 #ifdef QT3_SUPPORT
1068  emit qmenubar->activated(actionId);
1069 #endif
1070  } else if (action_e == QAction::Hover) {
1071  emit qmenubar->hovered(action);
1072 #ifdef QT3_SUPPORT
1073  if (emitHighlighted) {
1074  emit qmenubar->highlighted(actionId);
1075  emitHighlighted = false;
1076  }
1077 #endif
1078  }
1079  break; //nothing more..
1080 #endif
1081  }
1082  }
1083 }
QPointer< QWidget > widget
void activate(ActionEvent event)
Sends the relevant signals for ActionEvent event.
Definition: qaction.cpp:1326
bool activationRecursionGuard
Definition: qmenu_p.h:205
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
QPointer< QMenuBar > qmenubar
Definition: qmenu_mac.mm:98
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
void triggered(QAction *action)
This signal is emitted when an action in a menu belonging to this menubar is triggered as a result of...
void hovered(QAction *action)
This signal is emitted when a menu action is highlighted; action is the action that caused the event ...

◆ adjustMenuSizeForScreen()

QSize QMenuPrivate::adjustMenuSizeForScreen ( const QRect screen)

Definition at line 391 of file qmenu.cpp.

392 {
393  Q_Q(QMenu);
394  QSize ret = screen.size();
395  itemsDirty = true;
396  updateActionRects(screen);
397  const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q);
399  return ret;
400 }
void updateActionRects() const
Definition: qmenu.cpp:239
uint itemsDirty
Definition: qmenu_p.h:190
#define Q_Q(Class)
Definition: qglobal.h:2483
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
int getLastVisibleAction() const
Definition: qmenu.cpp:402
QVector< QRect > actionRects
Definition: qmenu_p.h:194
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ calcCausedStack()

QList< QPointer< QWidget > > QMenuPrivate::calcCausedStack ( ) const
virtual

Reimplemented in QTornOffMenu::QTornOffMenuPrivate.

Definition at line 224 of file qmenu.cpp.

225 {
227  for(QWidget *widget = causedPopup.widget; widget; ) {
228  ret.append(widget);
229  if (QTornOffMenu *qtmenu = qobject_cast<QTornOffMenu*>(widget))
230  ret += qtmenu->d_func()->causedStack;
231  if (QMenu *qmenu = qobject_cast<QMenu*>(widget))
232  widget = qmenu->d_func()->causedPopup.widget;
233  else
234  break;
235  }
236  return ret;
237 }
QPointer< QWidget > widget
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QMenuCaused causedPopup
Definition: qmenu_p.h:263
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
QPointer< QWidget > widget
Definition: qmenu_p.h:259
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ get()

static QMenuPrivate* QMenuPrivate::get ( QMenu m)
inlinestatic

Definition at line 186 of file qmenu_p.h.

Referenced by QPushButtonPrivate::_q_popupPressed().

186 { return m->d_func(); }

◆ getLastVisibleAction()

int QMenuPrivate::getLastVisibleAction ( ) const

Definition at line 402 of file qmenu.cpp.

Referenced by adjustMenuSizeForScreen(), and updateActionRects().

403 {
404  //let's try to get the last visible action
405  int lastVisibleAction = actions.count() - 1;
406  for (;lastVisibleAction >= 0; --lastVisibleAction) {
407  const QAction *action = actions.at(lastVisibleAction);
408  if (action->isVisible()) {
409  //removing trailing separators
410  if (action->isSeparator() && collapsibleSeparators)
411  continue;
412  break;
413  }
414  }
415  return lastVisibleAction;
416 }
bool isSeparator() const
Returns true if this action is a separator action; otherwise it returns false.
Definition: qaction.cpp:839
uint collapsibleSeparators
Definition: qmenu_p.h:201
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
bool isVisible() const
Definition: qaction.cpp:1246
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< QAction * > actions
Definition: qwidget_p.h:760
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64

◆ hasMouseMoved()

bool QMenuPrivate::hasMouseMoved ( const QPoint globalPos)

Definition at line 1205 of file qmenu.cpp.

Referenced by mouseEventTaken().

1206 {
1207  //determines if the mouse has moved (ie its initial position has
1208  //changed by more than QApplication::startDragDistance()
1209  //or if there were at least 6 mouse motions)
1210  return motions > 6 ||
1211  QApplication::startDragDistance() < (mousePopupPos - globalPos).manhattanLength();
1212 }
int motions
Definition: qmenu_p.h:212
QPoint mousePopupPos
Definition: qmenu_p.h:209
static int startDragDistance()

◆ hideMenu()

void QMenuPrivate::hideMenu ( QMenu menu,
bool  justRegister = false 
)

Definition at line 471 of file qmenu.cpp.

Referenced by hideUpToMenuBar(), popupAction(), and setCurrentAction().

472 {
473  if (!menu)
474  return;
475 #if !defined(QT_NO_EFFECTS)
476  menu->blockSignals(true);
477  aboutToHide = true;
478  // Flash item which is about to trigger (if any).
481  && menu->actions().contains(currentAction)) {
483  QAction *activeAction = currentAction;
484 
485  menu->setActiveAction(0);
486  QTimer::singleShot(60, &eventLoop, SLOT(quit()));
487  eventLoop.exec();
488 
489  // Select and wait 20 ms.
490  menu->setActiveAction(activeAction);
491  QTimer::singleShot(20, &eventLoop, SLOT(quit()));
492  eventLoop.exec();
493  }
494 
495  // Fade out.
497  // ### Qt 4.4:
498  // Should be something like: q->transitionWindow(Qt::FadeOutTransition, MenuFadeTimeInSec);
499  // Hopefully we'll integrate qt/research/windowtransitions into main before 4.4.
500  // Talk to Richard, Trenton or Bjoern.
501 #if defined(Q_WS_MAC)
502  if (justRegister) {
505  } else {
507  }
508 
509 #endif // Q_WS_MAC
510  }
511  aboutToHide = false;
512  menu->blockSignals(false);
513 #endif // QT_NO_EFFECTS
514  if (!justRegister)
515  menu->close();
516 }
void setActiveAction(QAction *act)
Sets the currently highlighted action to act.
Definition: qmenu.cpp:1707
bool blockSignals(bool b)
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke...
Definition: qobject.cpp:1406
#define SLOT(a)
Definition: qobjectdefs.h:226
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
QStyle * style() const
Definition: qwidget.cpp:2742
OSWindowRef qt_mac_window_for(const QWidget *)
Definition: qwidget_mac.mm:484
static QMacWindowFader * currentFader()
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
The QEventLoop class provides a means of entering and leaving an event loop.
Definition: qeventloop.h:55
void setFadeDuration(float durationInSecs)
Definition: qt_mac_p.h:136
static const qreal MenuFadeTimeInSec
Definition: qmenu.cpp:432
void registerWindowToFade(QWidget *window)
QEventLoop * eventLoop
Definition: qmenu_p.h:246
uint aboutToHide
Definition: qmenu_p.h:211
QAction * currentAction
Definition: qmenu_p.h:213
bool singleShot
This static function calls a slot after a given time interval.
Definition: qtimer.h:59
QList< QAction * > actions() const
Returns the (possibly empty) list of this widget&#39;s actions.
Definition: qwidget.cpp:3407
bool close()
Closes this widget.
Definition: qwidget.cpp:8305
QPointer< QAction > actionAboutToTrigger
Definition: qmenu_p.h:338
int exec(ProcessEventsFlags flags=AllEvents)
Enters the main event loop and waits until exit() is called.
Definition: qeventloop.cpp:181
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
void macWindowFade(void *window, float durationSeconds)

◆ hideUpToMenuBar()

void QMenuPrivate::hideUpToMenuBar ( )

Definition at line 435 of file qmenu.cpp.

Referenced by activateAction(), and mouseEventTaken().

436 {
437  Q_Q(QMenu);
438  bool fadeMenus = q->style()->styleHint(QStyle::SH_Menu_FadeOutOnHide);
439  if (!tornoff) {
440  QWidget *caused = causedPopup.widget;
441  hideMenu(q); //hide after getting causedPopup
442  while(caused) {
443 #ifndef QT_NO_MENUBAR
444  if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
445  mb->d_func()->setCurrentAction(0);
446  mb->d_func()->setKeyboardMode(false);
447  caused = 0;
448  } else
449 #endif
450  if (QMenu *m = qobject_cast<QMenu*>(caused)) {
451  caused = m->d_func()->causedPopup.widget;
452  if (!m->d_func()->tornoff)
453  hideMenu(m, fadeMenus);
454  if (!fadeMenus) // Mac doesn't clear the action until after hidden.
455  m->d_func()->setCurrentAction(0);
456  } else { caused = 0;
457  }
458  }
459 #if defined(Q_WS_MAC)
460  if (fadeMenus) {
462  QTimer::singleShot(int(MenuFadeTimeInSec * 1000), &eventLoop, SLOT(quit()));
464  eventLoop.exec();
465  }
466 #endif
467  }
468  setCurrentAction(0);
469 }
#define SLOT(a)
Definition: qobjectdefs.h:226
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setCurrentAction(QAction *, int popup=-1, SelectionReason reason=SelectedFromElsewhere, bool activateFirst=false)
Definition: qmenu.cpp:576
uint tornoff
Definition: qmenu_p.h:272
#define Q_Q(Class)
Definition: qglobal.h:2483
static QMacWindowFader * currentFader()
The QEventLoop class provides a means of entering and leaving an event loop.
Definition: qeventloop.h:55
static const qreal MenuFadeTimeInSec
Definition: qmenu.cpp:432
QMenuCaused causedPopup
Definition: qmenu_p.h:263
void hideMenu(QMenu *menu, bool justRegister=false)
Definition: qmenu.cpp:471
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
QEventLoop * eventLoop
Definition: qmenu_p.h:246
bool singleShot
This static function calls a slot after a given time interval.
Definition: qtimer.h:59
QPointer< QWidget > widget
Definition: qmenu_p.h:259
int exec(ProcessEventsFlags flags=AllEvents)
Enters the main event loop and waits until exit() is called.
Definition: qeventloop.cpp:181

◆ indexOf()

int QMenuPrivate::indexOf ( QAction act) const
inline

Definition at line 269 of file qmenu_p.h.

Referenced by activateAction().

269 { return q_func()->actions().indexOf(act); }

◆ init()

void QMenuPrivate::init ( )

Definition at line 155 of file qmenu.cpp.

Referenced by QMenuBarPrivate::macMenu(), and qt_mac_create_menu().

156 {
157  Q_Q(QMenu);
158 #ifndef QT_NO_WHATSTHIS
159  q->setAttribute(Qt::WA_CustomWhatsThis);
160 #endif
161  q->setAttribute(Qt::WA_X11NetWmWindowTypePopupMenu);
163  menuAction->d_func()->menu = q;
164  q->setMouseTracking(q->style()->styleHint(QStyle::SH_Menu_MouseTracking, 0, q));
165  if (q->style()->styleHint(QStyle::SH_Menu_Scrollable, 0, q)) {
168  }
169 
170 #ifdef QT_SOFTKEYS_ENABLED
173  selectAction->setPriority(QAction::HighPriority);
174  cancelAction->setPriority(QAction::HighPriority);
175  q->addAction(selectAction);
176  q->addAction(cancelAction);
177 #endif
178 
179 #ifdef Q_WS_S60
180  if (S60->avkonComponentsSupportTransparency) {
181  bool noSystemBackground = q->testAttribute(Qt::WA_NoSystemBackground);
182  q->setAttribute(Qt::WA_TranslucentBackground); // also sets WA_NoSystemBackground
183  q->setAttribute(Qt::WA_NoSystemBackground, noSystemBackground); // restore system background attribute
184  }
185 #endif
186 }
struct QMenuPrivate::QMenuScroller * scroll
QAction * defaultMenuAction
Definition: qmenu_p.h:286
#define Q_Q(Class)
Definition: qglobal.h:2483
static QAction * createKeyedAction(StandardSoftKey standardKey, Qt::Key key, QWidget *actionWidget)
Creates a QAction and registers the &#39;triggered&#39; signal to send the given key event to actionWidget as...
QAction * menuAction
Definition: qmenu_p.h:285
void setMouseTracking(bool enable)
Definition: qwidget.h:990
QMenu * menu() const
Returns the menu contained by this action.
Definition: qaction.cpp:793
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64

◆ macMenu()

OSMenuRef QMenuPrivate::macMenu ( OSMenuRef  merge)

Definition at line 1529 of file qmenu_mac.mm.

Referenced by setMacMenuEnabled().

1530 {
1531  Q_UNUSED(merge);
1532  Q_Q(QMenu);
1533  if (mac_menu && mac_menu->menu)
1534  return mac_menu->menu;
1535  if (!mac_menu)
1536  mac_menu = new QMacMenuPrivate;
1538  if (merge) {
1539 #ifndef QT_MAC_USE_COCOA
1540  SetMenuItemProperty(mac_menu->menu, 0, kMenuCreatorQt, kMenuPropertyMergeMenu, sizeof(merge), &merge);
1541 #else
1542  mergeMenuHash.insert(mac_menu->menu, merge);
1543 #endif
1544  }
1545  QList<QAction*> items = q->actions();
1546  for(int i = 0; i < items.count(); i++)
1547  mac_menu->addAction(items[i], 0, this);
1549  return mac_menu->menu;
1550 }
uint collapsibleSeparators
Definition: qmenu_p.h:201
void syncSeparatorsCollapsible(bool collapsible)
Definition: qmenu_mac.mm:1556
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
static QHash< OSMenuRef, OSMenuRef > mergeMenuHash
Definition: qmenu_p.h:334
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
#define Q_Q(Class)
Definition: qglobal.h:2483
const UInt32 kMenuCreatorQt
Definition: qmenu_mac.mm:82
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
static OSMenuRef qt_mac_create_menu(QWidget *w)
Definition: qmenu_mac.mm:2193
void addAction(QAction *, QMacMenuAction *=0, QMenuPrivate *qmenu=0)
Definition: qmenu_mac.mm:1042
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
struct QMenuPrivate::QMacMenuPrivate * mac_menu
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ mouseEventTaken()

bool QMenuPrivate::mouseEventTaken ( QMouseEvent e)

Definition at line 958 of file qmenu.cpp.

959 {
960  Q_Q(QMenu);
961  QPoint pos = q->mapFromGlobal(e->globalPos());
962  if (scroll && !activeMenu) { //let the scroller "steal" the event
963  bool isScroll = false;
964  if (pos.x() >= 0 && pos.x() < q->width()) {
965  for(int dir = QMenuScroller::ScrollUp; dir <= QMenuScroller::ScrollDown; dir = dir << 1) {
966  if (scroll->scrollFlags & dir) {
967  if (dir == QMenuScroller::ScrollUp)
968  isScroll = (pos.y() <= scrollerHeight());
969  else if (dir == QMenuScroller::ScrollDown)
970  isScroll = (pos.y() >= q->height() - scrollerHeight());
971  if (isScroll) {
972  scroll->scrollDirection = dir;
973  break;
974  }
975  }
976  }
977  }
978  if (isScroll) {
979  scroll->scrollTimer.start(50, q);
980  return true;
981  } else {
983  }
984  }
985 
986  if (tearoff) { //let the tear off thingie "steal" the event..
987  QRect tearRect(0, 0, q->width(), q->style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, q));
989  tearRect.translate(0, scrollerHeight());
990  q->update(tearRect);
991  if (tearRect.contains(pos) && hasMouseMoved(e->globalPos())) {
992  setCurrentAction(0);
993  tearoffHighlighted = 1;
994  if (e->type() == QEvent::MouseButtonRelease) {
995  if (!tornPopup)
996  tornPopup = new QTornOffMenu(q);
997  tornPopup->setGeometry(q->geometry());
998  tornPopup->show();
999  hideUpToMenuBar();
1000  }
1001  return true;
1002  }
1003  tearoffHighlighted = 0;
1004  }
1005 
1006  if (q->frameGeometry().contains(e->globalPos())) //otherwise if the event is in our rect we want it..
1007  return false;
1008 
1009  for(QWidget *caused = causedPopup.widget; caused;) {
1010  bool passOnEvent = false;
1011  QWidget *next_widget = 0;
1012  QPoint cpos = caused->mapFromGlobal(e->globalPos());
1013 #ifndef QT_NO_MENUBAR
1014  if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
1015  passOnEvent = mb->rect().contains(cpos);
1016  } else
1017 #endif
1018  if (QMenu *m = qobject_cast<QMenu*>(caused)) {
1019  passOnEvent = m->rect().contains(cpos);
1020  next_widget = m->d_func()->causedPopup.widget;
1021  }
1022  if (passOnEvent) {
1023  if(e->type() != QEvent::MouseButtonRelease || mouseDown == caused) {
1024  QMouseEvent new_e(e->type(), cpos, e->button(), e->buttons(), e->modifiers());
1025  QApplication::sendEvent(caused, &new_e);
1026  return true;
1027  }
1028  }
1029  if (!next_widget)
1030  break;
1031  caused = next_widget;
1032  }
1033  return false;
1034 }
uint tearoff
Definition: qmenu_p.h:272
static QMenu * mouseDown
Definition: qmenu_p.h:208
struct QMenuPrivate::QMenuScroller * scroll
QPointer< QMenu > activeMenu
Definition: qmenu_p.h:254
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setCurrentAction(QAction *, int popup=-1, SelectionReason reason=SelectedFromElsewhere, bool activateFirst=false)
Definition: qmenu.cpp:576
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
#define Q_Q(Class)
Definition: qglobal.h:2483
int scrollerHeight() const
Definition: qmenu.cpp:188
bool hasMouseMoved(const QPoint &globalPos)
Definition: qmenu.cpp:1205
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
void show()
Shows the widget and its child widgets.
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
uint tearoffHighlighted
Definition: qmenu_p.h:272
void hideUpToMenuBar()
Definition: qmenu.cpp:435
QMenuCaused causedPopup
Definition: qmenu_p.h:263
void stop()
Stops the timer.
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition: qevent.h:102
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QPointer< QTornOffMenu > tornPopup
Definition: qmenu_p.h:273
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
const QPoint & globalPos() const
Returns the global position of the mouse cursor at the time of the event.
Definition: qevent.h:96
QPointer< QWidget > widget
Definition: qmenu_p.h:259
void start(int msec, QObject *obj)
Starts (or restarts) the timer with a msec milliseconds timeout.

◆ popupAction()

void QMenuPrivate::popupAction ( QAction action,
int  delay,
bool  activateFirst 
)

Definition at line 518 of file qmenu.cpp.

Referenced by setCurrentAction().

519 {
520  Q_Q(QMenu);
521  if (action && action->isEnabled()) {
522  if (!delay)
523  q->internalDelayedPopup();
524  else if (!menuDelayTimer.isActive() && (!action->menu() || !action->menu()->isVisible()))
525  menuDelayTimer.start(delay, q);
526  if (activateFirst && action->menu())
527  action->menu()->d_func()->setFirstActionActive();
528  } else if (QMenu *menu = activeMenu) { //hide the current item
529  activeMenu = 0;
530  hideMenu(menu);
531  }
532 }
bool isEnabled() const
Definition: qaction.cpp:1208
QPointer< QMenu > activeMenu
Definition: qmenu_p.h:254
QBasicTimer menuDelayTimer
Definition: qmenu_p.h:218
bool isVisible() const
Definition: qwidget.h:1005
bool isActive() const
Returns true if the timer is running and has not been stopped; otherwise returns false.
Definition: qbasictimer.h:62
#define Q_Q(Class)
Definition: qglobal.h:2483
QMenu * menu() const
Returns the menu contained by this action.
Definition: qaction.cpp:793
void hideMenu(QMenu *menu, bool justRegister=false)
Definition: qmenu.cpp:471
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
void start(int msec, QObject *obj)
Starts (or restarts) the timer with a msec milliseconds timeout.

◆ popupGeometry() [1/2]

QRect QMenuPrivate::popupGeometry ( const QWidget widget) const

Definition at line 195 of file qmenu.cpp.

Referenced by scrollMenu(), and updateActionRects().

196 {
197 #ifdef Q_WS_WIN
198  return QApplication::desktop()->screenGeometry(widget);
199 #elif defined Q_WS_X11
200  if (X11->desktopEnvironment == DE_KDE)
201  return QApplication::desktop()->screenGeometry(widget);
202  else
203  return QApplication::desktop()->availableGeometry(widget);
204 #else
205  return QApplication::desktop()->availableGeometry(widget);
206 #endif
207 }
#define X11
Definition: qt_x11_p.h:724
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
const QRect screenGeometry(int screen=-1) const
const QRect availableGeometry(int screen=-1) const

◆ popupGeometry() [2/2]

QRect QMenuPrivate::popupGeometry ( int  screen = -1) const

Definition at line 210 of file qmenu.cpp.

211 {
212 #ifdef Q_WS_WIN
213  return QApplication::desktop()->screenGeometry(screen);
214 #elif defined Q_WS_X11
215  if (X11->desktopEnvironment == DE_KDE)
216  return QApplication::desktop()->screenGeometry(screen);
217  else
218  return QApplication::desktop()->availableGeometry(screen);
219 #else
220  return QApplication::desktop()->availableGeometry(screen);
221 #endif
222 }
#define X11
Definition: qt_x11_p.h:724
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
const QRect screenGeometry(int screen=-1) const
const QRect availableGeometry(int screen=-1) const

◆ scrollerHeight()

int QMenuPrivate::scrollerHeight ( ) const

Definition at line 188 of file qmenu.cpp.

Referenced by mouseEventTaken(), scrollMenu(), and setFirstActionActive().

189 {
190  Q_Q(const QMenu);
191  return qMax(QApplication::globalStrut().height(), q->style()->pixelMetric(QStyle::PM_MenuScrollerHeight, 0, q));
192 }
static QSize globalStrut()
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
#define Q_Q(Class)
Definition: qglobal.h:2483
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72

◆ scrollMenu() [1/3]

void QMenuPrivate::scrollMenu ( QMenuScroller::ScrollLocation  location,
bool  active = false 
)

Definition at line 873 of file qmenu.cpp.

Referenced by scrollMenu().

874 {
875  Q_Q(QMenu);
878  for(int i = actions.size()-1; i >= 0; --i) {
879  QAction *act = actions.at(i);
880  if (actionRects.at(i).isNull())
881  continue;
882  if (!act->isSeparator() &&
883  (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)
884  || act->isEnabled())) {
887  else if(active)
889  break;
890  }
891  }
892  } else if(location == QMenuScroller::ScrollTop) {
893  for(int i = 0; i < actions.size(); ++i) {
894  QAction *act = actions.at(i);
895  if (actionRects.at(i).isNull())
896  continue;
897  if (!act->isSeparator() &&
898  (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)
899  || act->isEnabled())) {
902  else if(active)
904  break;
905  }
906  }
907  }
908 }
bool isSeparator() const
Returns true if this action is a separator action; otherwise it returns false.
Definition: qaction.cpp:839
bool isEnabled() const
Definition: qaction.cpp:1208
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
void scrollMenu(QMenuScroller::ScrollLocation location, bool active=false)
Definition: qmenu.cpp:873
struct QMenuPrivate::QMenuScroller * scroll
void updateActionRects() const
Definition: qmenu.cpp:239
void setCurrentAction(QAction *, int popup=-1, SelectionReason reason=SelectedFromElsewhere, bool activateFirst=false)
Definition: qmenu.cpp:576
#define Q_Q(Class)
Definition: qglobal.h:2483
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
static QTestResult::TestLocation location
Definition: qtestresult.cpp:63
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QList< QAction * > actions
Definition: qwidget_p.h:760
QVector< QRect > actionRects
Definition: qmenu_p.h:194
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64

◆ scrollMenu() [2/3]

void QMenuPrivate::scrollMenu ( QMenuScroller::ScrollDirection  direction,
bool  page = false,
bool  active = false 
)

Definition at line 911 of file qmenu.cpp.

912 {
913  Q_Q(QMenu);
914  if (!scroll || !(scroll->scrollFlags & direction)) //not really possible...
915  return;
917  const int topScroll = (scroll->scrollFlags & QMenuScroller::ScrollUp) ? scrollerHeight() : 0;
918  const int botScroll = (scroll->scrollFlags & QMenuScroller::ScrollDown) ? scrollerHeight() : 0;
919  const int vmargin = q->style()->pixelMetric(QStyle::PM_MenuVMargin, 0, q);
920  const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q);
921  const int offset = topScroll ? topScroll-vmargin : 0;
923  for(int i = 0, saccum = 0; i < actions.count(); i++) {
924  saccum -= actionRects.at(i).height();
925  if (saccum <= scroll->scrollOffset-offset) {
927  break;
928  }
929  }
930  } else if (direction == QMenuScroller::ScrollDown) {
931  bool scrolled = false;
932  for(int i = 0, saccum = 0; i < actions.count(); i++) {
933  const int iHeight = actionRects.at(i).height();
934  saccum -= iHeight;
935  if (saccum <= scroll->scrollOffset-offset) {
936  const int scrollerArea = q->height() - botScroll - fw*2;
937  int visible = (scroll->scrollOffset-offset) - saccum;
938  for(i++ ; i < actions.count(); i++) {
939  visible += actionRects.at(i).height();
940  if (visible > scrollerArea - topScroll) {
941  scrolled = true;
943  break;
944  }
945  }
946  break;
947  }
948  }
949  if(!scrolled) {
950  scroll->scrollFlags &= ~QMenuScroller::ScrollDown;
951  q->update();
952  }
953  }
954 }
void scrollMenu(QMenuScroller::ScrollLocation location, bool active=false)
Definition: qmenu.cpp:873
struct QMenuPrivate::QMenuScroller * scroll
void updateActionRects() const
Definition: qmenu.cpp:239
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_Q(Class)
Definition: qglobal.h:2483
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int scrollerHeight() const
Definition: qmenu.cpp:188
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
QList< QAction * > actions
Definition: qwidget_p.h:760
QVector< QRect > actionRects
Definition: qmenu_p.h:194
Qt::LayoutDirection direction

◆ scrollMenu() [3/3]

void QMenuPrivate::scrollMenu ( QAction action,
QMenuScroller::ScrollLocation  location,
bool  active = false 
)

Definition at line 761 of file qmenu.cpp.

762 {
763  Q_Q(QMenu);
764  if (!scroll || !scroll->scrollFlags)
765  return;
767  int newOffset = 0;
768  const int topScroll = (scroll->scrollFlags & QMenuScroller::ScrollUp) ? scrollerHeight() : 0;
769  const int botScroll = (scroll->scrollFlags & QMenuScroller::ScrollDown) ? scrollerHeight() : 0;
770  const int vmargin = q->style()->pixelMetric(QStyle::PM_MenuVMargin, 0, q);
771  const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q);
772 
774  for(int i = 0, saccum = 0; i < actions.count(); i++) {
775  if (actions.at(i) == action) {
776  newOffset = topScroll - saccum;
777  break;
778  }
779  saccum += actionRects.at(i).height();
780  }
781  } else {
782  for(int i = 0, saccum = 0; i < actions.count(); i++) {
783  saccum += actionRects.at(i).height();
784  if (actions.at(i) == action) {
786  newOffset = ((q->height() / 2) - botScroll) - (saccum - topScroll);
787  else
788  newOffset = (q->height() - botScroll) - saccum;
789  break;
790  }
791  }
792  if(newOffset)
793  newOffset -= fw * 2;
794  }
795 
796  //figure out which scroll flags
797  uint newScrollFlags = QMenuScroller::ScrollNone;
798  if (newOffset < 0) //easy and cheap one
799  newScrollFlags |= QMenuScroller::ScrollUp;
800  int saccum = newOffset;
801  for(int i = 0; i < actionRects.count(); i++) {
802  saccum += actionRects.at(i).height();
803  if (saccum > q->height()) {
804  newScrollFlags |= QMenuScroller::ScrollDown;
805  break;
806  }
807  }
808 
809  if (!(newScrollFlags & QMenuScroller::ScrollDown) && (scroll->scrollFlags & QMenuScroller::ScrollDown)) {
810  newOffset = q->height() - (saccum - newOffset) - fw*2 - vmargin; //last item at bottom
811  }
812 
813  if (!(newScrollFlags & QMenuScroller::ScrollUp) && (scroll->scrollFlags & QMenuScroller::ScrollUp)) {
814  newOffset = 0; //first item at top
815  }
816 
817  if (newScrollFlags & QMenuScroller::ScrollUp)
818  newOffset -= vmargin;
819 
820  QRect screen = popupGeometry(q);
821  const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q);
822  if (q->height() < screen.height()-(desktopFrame*2)-1) {
823  QRect geom = q->geometry();
824  if (newOffset > scroll->scrollOffset && (scroll->scrollFlags & newScrollFlags & QMenuScroller::ScrollUp)) { //scroll up
825  const int newHeight = geom.height()-(newOffset-scroll->scrollOffset);
826  if(newHeight > geom.height())
827  geom.setHeight(newHeight);
828  } else if(scroll->scrollFlags & newScrollFlags & QMenuScroller::ScrollDown) {
829  int newTop = geom.top() + (newOffset-scroll->scrollOffset);
830  if (newTop < desktopFrame+screen.top())
831  newTop = desktopFrame+screen.top();
832  if (newTop < geom.top()) {
833  geom.setTop(newTop);
834  newOffset = 0;
835  newScrollFlags &= ~QMenuScroller::ScrollUp;
836  }
837  }
838  if (geom.bottom() > screen.bottom() - desktopFrame)
839  geom.setBottom(screen.bottom() - desktopFrame);
840  if (geom.top() < desktopFrame+screen.top())
841  geom.setTop(desktopFrame+screen.top());
842  if (geom != q->geometry()) {
843 #if 0
844  if (newScrollFlags & QMenuScroller::ScrollDown &&
845  q->geometry().top() - geom.top() >= -newOffset)
846  newScrollFlags &= ~QMenuScroller::ScrollDown;
847 #endif
848  q->setGeometry(geom);
849  }
850  }
851 
852  //actually update flags
853  const int delta = qMin(0, newOffset) - scroll->scrollOffset; //make sure the new offset is always negative
854  if (!itemsDirty && delta) {
855  //we've scrolled so we need to update the action rects
856  for (int i = 0; i < actionRects.count(); ++i) {
857  QRect &current = actionRects[i];
858  current.moveTop(current.top() + delta);
859 
860  //we need to update the widgets geometry
861  if (QWidget *w = widgetItems.value(actions.at(i)))
862  w->setGeometry(current);
863  }
864  }
865  scroll->scrollOffset += delta;
866  scroll->scrollFlags = newScrollFlags;
867  if (active)
868  setCurrentAction(action);
869 
870  q->update(); //issue an update so we see all the new state..
871 }
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:267
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
struct QMenuPrivate::QMenuScroller * scroll
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
void updateActionRects() const
Definition: qmenu.cpp:239
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void setCurrentAction(QAction *, int popup=-1, SelectionReason reason=SelectedFromElsewhere, bool activateFirst=false)
Definition: qmenu.cpp:576
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
uint itemsDirty
Definition: qmenu_p.h:190
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
#define Q_Q(Class)
Definition: qglobal.h:2483
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
QHash< QAction *, QWidget * > widgetItems
Definition: qmenu_p.h:195
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int scrollerHeight() const
Definition: qmenu.cpp:188
unsigned int uint
Definition: qglobal.h:996
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
static QTestResult::TestLocation location
Definition: qtestresult.cpp:63
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QList< QAction * > actions
Definition: qwidget_p.h:760
QVector< QRect > actionRects
Definition: qmenu_p.h:194
void moveTop(int pos)
Moves the rectangle vertically, leaving the rectangle&#39;s top edge at the given y coordinate.
Definition: qrect.h:353
QRect popupGeometry(const QWidget *widget) const
Definition: qmenu.cpp:195

◆ setCurrentAction()

void QMenuPrivate::setCurrentAction ( QAction action,
int  popup = -1,
SelectionReason  reason = SelectedFromElsewhere,
bool  activateFirst = false 
)

Definition at line 576 of file qmenu.cpp.

Referenced by hideUpToMenuBar(), mouseEventTaken(), scrollMenu(), and setFirstActionActive().

577 {
578  Q_Q(QMenu);
579  tearoffHighlighted = 0;
580  // Reselect the currently active action in case mouse moved over other menu items when
581  // moving from sub menu action to sub menu (QTBUG-20094).
582  if (reason != SelectedFromKeyboard && action == currentAction && !(action && action->menu() && action->menu() != activeMenu)) {
583  if (QMenu *menu = qobject_cast<QMenu*>(causedPopup.widget)) {
584  if (causedPopup.action && menu->d_func()->activeMenu == q)
585  menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false);
586  }
587  return;
588  }
589 
590  if (currentAction)
591  q->update(actionRect(currentAction));
592 
593  sloppyAction = 0;
594  if (!sloppyRegion.isEmpty())
595  sloppyRegion = QRegion();
596  QMenu *hideActiveMenu = activeMenu;
597 #ifndef QT_NO_STATUSTIP
598  QAction *previousAction = currentAction;
599 #endif
600 #ifdef QT3_SUPPORT
601  emitHighlighted = action;
602 #endif
603 
604  currentAction = action;
605  if (action) {
606  if (!action->isSeparator()) {
608  if (popup != -1) {
609  hideActiveMenu = 0; //will be done "later"
610  // if the menu is visible then activate the required action,
611  // otherwise we just mark the action as currentAction
612  // and activate it when the menu will be popuped.
613  if (q->isVisible())
614  popupAction(currentAction, popup, activateFirst);
615  }
616  q->update(actionRect(action));
617 
618  if (reason == SelectedFromKeyboard) {
619  QWidget *widget = widgetItems.value(action);
620  if (widget) {
621  if (widget->focusPolicy() != Qt::NoFocus)
622  widget->setFocus(Qt::TabFocusReason);
623  } else {
624  //when the action has no QWidget, the QMenu itself should
625  // get the focus
626  // Since the menu is a pop-up, it uses the popup reason.
627  if (!q->hasFocus()) {
628  q->setFocus(Qt::PopupFocusReason);
629  }
630  }
631  }
632  } else { //action is a separator
633  if (popup != -1)
634  hideActiveMenu = 0; //will be done "later"
635  }
636 #ifndef QT_NO_STATUSTIP
637  } else if (previousAction) {
638  previousAction->d_func()->showStatusText(topCausedWidget(), QString());
639 #endif
640  }
641  if (hideActiveMenu) {
642  activeMenu = 0;
643 #ifndef QT_NO_EFFECTS
644  // kill any running effect
645  qFadeEffect(0);
646  qScrollEffect(0);
647 #endif
648  hideMenu(hideActiveMenu);
649  }
650 }
bool isSeparator() const
Returns true if this action is a separator action; otherwise it returns false.
Definition: qaction.cpp:839
QPointer< QWidget > widget
QPointer< QMenu > activeMenu
Definition: qmenu_p.h:254
bool showStatusText(QWidget *widget=0)
Updates the relevant status bar for the widget specified by sending a QStatusTipEvent to its parent w...
Definition: qaction.cpp:1315
QRegion sloppyRegion
Definition: qmenu_p.h:280
Qt::FocusPolicy focusPolicy
the way the widget accepts keyboard focus
Definition: qwidget.h:187
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QString class provides a Unicode character string.
Definition: qstring.h:83
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
#define Q_Q(Class)
Definition: qglobal.h:2483
void qScrollEffect(QWidget *w, QEffects::DirFlags orient, int time)
Scroll widget w in time ms.
Definition: qeffects.cpp:562
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
QHash< QAction *, QWidget * > widgetItems
Definition: qmenu_p.h:195
void popupAction(QAction *, int, bool)
Definition: qmenu.cpp:518
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QAction * sloppyAction
Definition: qmenu_p.h:279
uint tearoffHighlighted
Definition: qmenu_p.h:272
QMenuCaused causedPopup
Definition: qmenu_p.h:263
void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432
QMenu * menu() const
Returns the menu contained by this action.
Definition: qaction.cpp:793
void hideMenu(QMenu *menu, bool justRegister=false)
Definition: qmenu.cpp:471
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
QRect actionRect(QAction *) const
Definition: qmenu.cpp:419
QAction * currentAction
Definition: qmenu_p.h:213
QWidget * topCausedWidget() const
Definition: qmenu.cpp:653
QPointer< QAction > action
Definition: qmenu_p.h:260
void qFadeEffect(QWidget *w, int time)
Fade in widget w in time ms.
Definition: qeffects.cpp:584
QPointer< QWidget > widget
Definition: qmenu_p.h:259
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
void activateAction(QAction *, QAction::ActionEvent, bool self=true)
Definition: qmenu.cpp:1085

◆ setFirstActionActive()

void QMenuPrivate::setFirstActionActive ( )

Definition at line 552 of file qmenu.cpp.

553 {
554  Q_Q(QMenu);
556  for(int i = 0, saccum = 0; i < actions.count(); i++) {
557  const QRect &rect = actionRects.at(i);
558  if (rect.isNull())
559  continue;
561  saccum -= rect.height();
562  if (saccum > scroll->scrollOffset - scrollerHeight())
563  continue;
564  }
565  QAction *act = actions.at(i);
566  if (!act->isSeparator() &&
567  (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)
568  || act->isEnabled())) {
569  setCurrentAction(act);
570  break;
571  }
572  }
573 }
bool isSeparator() const
Returns true if this action is a separator action; otherwise it returns false.
Definition: qaction.cpp:839
bool isEnabled() const
Definition: qaction.cpp:1208
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
struct QMenuPrivate::QMenuScroller * scroll
void updateActionRects() const
Definition: qmenu.cpp:239
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void setCurrentAction(QAction *, int popup=-1, SelectionReason reason=SelectedFromElsewhere, bool activateFirst=false)
Definition: qmenu.cpp:576
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_Q(Class)
Definition: qglobal.h:2483
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int scrollerHeight() const
Definition: qmenu.cpp:188
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QList< QAction * > actions
Definition: qwidget_p.h:760
QVector< QRect > actionRects
Definition: qmenu_p.h:194
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64

◆ setMacMenuEnabled()

void QMenuPrivate::setMacMenuEnabled ( bool  enable = true)
Warning
This function is not part of the public interface.

Definition at line 1574 of file qmenu_mac.mm.

1575 {
1576  if (!macMenu(0))
1577  return;
1578 
1580  if (enable) {
1581  for (int i = 0; i < mac_menu->actionItems.count(); ++i) {
1582  QMacMenuAction *menuItem = mac_menu->actionItems.at(i);
1583  if (menuItem && menuItem->action && menuItem->action->isEnabled()) {
1584  // Only enable those items which contains an enabled QAction.
1585  // i == 0 -> the menu itself, hence i + 1 for items.
1586  EnableMenuItem(mac_menu->menu, i + 1);
1587  }
1588  }
1589  } else {
1590  DisableAllMenuItems(mac_menu->menu);
1591  }
1592 }
bool isEnabled() const
Definition: qaction.cpp:1208
QList< QMacMenuAction * > actionItems
Definition: qmenu_p.h:308
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QPointer< QAction > action
Definition: qmenu_p.h:108
OSMenuRef macMenu(OSMenuRef merge)
Definition: qmenu_mac.mm:1529
struct QMenuPrivate::QMacMenuPrivate * mac_menu

◆ setOverrideMenuAction()

void QMenuPrivate::setOverrideMenuAction ( QAction a)

Definition at line 673 of file qmenu.cpp.

674 {
675  Q_Q(QMenu);
677  if (a) {
678  menuAction = a;
680  } else { //we revert back to the default action created by the QMenu itself
682  }
683 }
void _q_overrideMenuActionDestroyed()
Definition: qmenu.cpp:685
#define SLOT(a)
Definition: qobjectdefs.h:226
QAction * defaultMenuAction
Definition: qmenu_p.h:286
long ASN1_INTEGER_get ASN1_INTEGER * a
#define Q_Q(Class)
Definition: qglobal.h:2483
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
QAction * menuAction
Definition: qmenu_p.h:285
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72

◆ setSyncAction()

void QMenuPrivate::setSyncAction ( )

Definition at line 534 of file qmenu.cpp.

535 {
536  Q_Q(QMenu);
537  QAction *current = currentAction;
538  if(current && (!current->isEnabled() || current->menu() || current->isSeparator()))
539  current = 0;
540  for(QWidget *caused = q; caused;) {
541  if (QMenu *m = qobject_cast<QMenu*>(caused)) {
542  caused = m->d_func()->causedPopup.widget;
543  if (m->d_func()->eventLoop)
544  m->d_func()->syncAction = current; // synchronous operation
545  } else {
546  break;
547  }
548  }
549 }
bool isSeparator() const
Returns true if this action is a separator action; otherwise it returns false.
Definition: qaction.cpp:839
bool isEnabled() const
Definition: qaction.cpp:1208
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_Q(Class)
Definition: qglobal.h:2483
QMenu * menu() const
Returns the menu contained by this action.
Definition: qaction.cpp:793
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
QAction * currentAction
Definition: qmenu_p.h:213
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64

◆ syncSeparatorsCollapsible()

void QMenuPrivate::syncSeparatorsCollapsible ( bool  collapse)
Warning
This function is not part of the public interface.

Definition at line 1556 of file qmenu_mac.mm.

Referenced by macMenu().

1557 {
1558 #ifndef QT_MAC_USE_COCOA
1559  if (collapse)
1560  ChangeMenuAttributes(mac_menu->menu, kMenuAttrCondenseSeparators, 0);
1561  else
1562  ChangeMenuAttributes(mac_menu->menu, 0, kMenuAttrCondenseSeparators);
1563 #else
1564  qt_mac_menu_collapseSeparators(mac_menu->menu, collapse);
1565 #endif
1566 }
struct QMenuPrivate::QMacMenuPrivate * mac_menu

◆ topCausedWidget()

QWidget * QMenuPrivate::topCausedWidget ( ) const

Definition at line 653 of file qmenu.cpp.

Referenced by activateAction(), and setCurrentAction().

654 {
655  QWidget* top = causedPopup.widget;
656  while (QMenu* m = qobject_cast<QMenu *>(top))
657  top = m->d_func()->causedPopup.widget;
658  return top;
659 }
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QMenuCaused causedPopup
Definition: qmenu_p.h:263
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
QPointer< QWidget > widget
Definition: qmenu_p.h:259

◆ updateActionRects() [1/2]

void QMenuPrivate::updateActionRects ( ) const

Definition at line 239 of file qmenu.cpp.

Referenced by actionRect(), adjustMenuSizeForScreen(), scrollMenu(), and setFirstActionActive().

240 {
241  Q_Q(const QMenu);
243 }
void updateActionRects() const
Definition: qmenu.cpp:239
#define Q_Q(Class)
Definition: qglobal.h:2483
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
QRect popupGeometry(const QWidget *widget) const
Definition: qmenu.cpp:195

◆ updateActionRects() [2/2]

void QMenuPrivate::updateActionRects ( const QRect screen) const

Definition at line 245 of file qmenu.cpp.

246 {
247  Q_Q(const QMenu);
248  if (!itemsDirty)
249  return;
250 
251  q->ensurePolished();
252 
253  //let's reinitialize the buffer
256 
257  int lastVisibleAction = getLastVisibleAction();
258 
259  int max_column_width = 0,
260  dh = screen.height(),
261  y = 0;
262  QStyle *style = q->style();
263  QStyleOption opt;
264  opt.init(q);
265  const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, &opt, q),
266  vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, &opt, q),
267  icone = style->pixelMetric(QStyle::PM_SmallIconSize, &opt, q);
268  const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q);
269  const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q);
270  const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0;
271 
272  //for compatibility now - will have to refactor this away
273  tabWidth = 0;
274  maxIconWidth = 0;
275  hasCheckableItems = false;
276  ncols = 1;
277  sloppyAction = 0;
278 
279  for (int i = 0; i < actions.count(); ++i) {
280  QAction *action = actions.at(i);
281  if (action->isSeparator() || !action->isVisible() || widgetItems.contains(action))
282  continue;
283  //..and some members
284  hasCheckableItems |= action->isCheckable();
285  QIcon is = action->icon();
286  if (!is.isNull()) {
287  maxIconWidth = qMax<uint>(maxIconWidth, icone + 4);
288  }
289  }
290 
291  //calculate size
292  QFontMetrics qfm = q->fontMetrics();
293  bool previousWasSeparator = true; // this is true to allow removing the leading separators
294  for(int i = 0; i <= lastVisibleAction; i++) {
295  QAction *action = actions.at(i);
296 
297  if (!action->isVisible() ||
298  (collapsibleSeparators && previousWasSeparator && action->isSeparator()))
299  continue; // we continue, this action will get an empty QRect
300 
301  previousWasSeparator = action->isSeparator();
302 
303  //let the style modify the above size..
305  q->initStyleOption(&opt, action);
306  const QFontMetrics &fm = opt.fontMetrics;
307 
308  QSize sz;
309  if (QWidget *w = widgetItems.value(action)) {
310  sz = w->sizeHint().expandedTo(w->minimumSize()).expandedTo(w->minimumSizeHint()).boundedTo(w->maximumSize());
311  } else {
312  //calc what I think the size is..
313  if (action->isSeparator()) {
314  sz = QSize(2, 2);
315  } else {
316  QString s = action->text();
317  int t = s.indexOf(QLatin1Char('\t'));
318  if (t != -1) {
319  tabWidth = qMax(int(tabWidth), qfm.width(s.mid(t+1)));
320  s = s.left(t);
321  #ifndef QT_NO_SHORTCUT
322  } else {
323  QKeySequence seq = action->shortcut();
324  if (!seq.isEmpty())
325  tabWidth = qMax(int(tabWidth), qfm.width(seq));
326  #endif
327  }
329  sz.setHeight(qMax(fm.height(), qfm.height()));
330 
331  QIcon is = action->icon();
332  if (!is.isNull()) {
333  QSize is_sz = QSize(icone, icone);
334  if (is_sz.height() > sz.height())
335  sz.setHeight(is_sz.height());
336  }
337  }
338  sz = style->sizeFromContents(QStyle::CT_MenuItem, &opt, sz, q);
339  }
340 
341 
342  if (!sz.isEmpty()) {
343  max_column_width = qMax(max_column_width, sz.width());
344  //wrapping
345  if (!scroll &&
346  y+sz.height()+vmargin > dh - (deskFw * 2)) {
347  ncols++;
348  y = vmargin;
349  }
350  y += sz.height();
351  //update the item
352  actionRects[i] = QRect(0, 0, sz.width(), sz.height());
353  }
354  }
355 
356  max_column_width += tabWidth; //finally add in the tab width
357  const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width();
358  const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin));
359  max_column_width = qMax(min_column_width, max_column_width);
360 
361  //calculate position
362  const int base_y = vmargin + fw + topmargin +
363  (scroll ? scroll->scrollOffset : 0) +
364  tearoffHeight;
365  int x = hmargin + fw + leftmargin;
366  y = base_y;
367 
368  for(int i = 0; i < actions.count(); i++) {
369  QRect &rect = actionRects[i];
370  if (rect.isNull())
371  continue;
372  if (!scroll &&
373  y+rect.height() > dh - deskFw * 2) {
374  x += max_column_width + hmargin;
375  y = base_y;
376  }
377  rect.translate(x, y); //move
378  rect.setWidth(max_column_width); //uniform width
379 
380  //we need to update the widgets geometry
381  if (QWidget *widget = widgetItems.value(actions.at(i))) {
382  widget->setGeometry(rect);
384  }
385 
386  y += rect.height();
387  }
388  itemsDirty = 0;
389 }
uint tearoff
Definition: qmenu_p.h:272
bool isSeparator() const
Returns true if this action is a separator action; otherwise it returns false.
Definition: qaction.cpp:839
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
short rightmargin
Definition: qwidget_p.h:746
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
uint collapsibleSeparators
Definition: qmenu_p.h:201
struct QMenuPrivate::QMenuScroller * scroll
QPointer< QWidget > widget
QKeySequence shortcut
the action&#39;s primary shortcut key
Definition: qaction.h:83
short topmargin
Definition: qwidget_p.h:745
QVector< T > & fill(const T &t, int size=-1)
Assigns value to all items in the vector.
Definition: qvector.h:665
The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item...
Definition: qstyleoption.h:435
static QSize globalStrut()
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
QString text
the action&#39;s descriptive text
Definition: qaction.h:76
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
void init(const QWidget *w)
Use initFrom(widget) instead.
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
QFontMetrics fontMetrics
the font metrics that should be used when drawing text in the control
Definition: qstyleoption.h:91
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
uint itemsDirty
Definition: qmenu_p.h:190
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
#define Q_Q(Class)
Definition: qglobal.h:2483
bool isVisible() const
Definition: qaction.cpp:1246
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
QRect boundingRect(QChar) const
Returns the rectangle that is covered by ink if character ch were to be drawn at the origin of the co...
int width() const
Returns the width.
Definition: qsize.h:126
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
QHash< QAction *, QWidget * > widgetItems
Definition: qmenu_p.h:195
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition: qicon.cpp:769
QIcon icon
the action&#39;s icon
Definition: qaction.h:75
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
uint maxIconWidth
Definition: qmenu_p.h:191
short leftmargin
Definition: qwidget_p.h:744
QAction * sloppyAction
Definition: qmenu_p.h:279
bool isEmpty() const
Returns true if the key sequence is empty; otherwise returns false.
uint ncols
Definition: qmenu_p.h:200
virtual void setVisible(bool visible)
Definition: qwidget.cpp:7991
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=0) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Definition: qkeysequence.h:72
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
bool isCheckable() const
Definition: qaction.cpp:1105
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QList< QAction * > actions
Definition: qwidget_p.h:760
int getLastVisibleAction() const
Definition: qmenu.cpp:402
QVector< QRect > actionRects
Definition: qmenu_p.h:194
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
Definition: qsize.h:120
int height() const
Returns the height of the font.
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
uint tabWidth
Definition: qmenu_p.h:191
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
bool hasCheckableItems
Definition: qmenu_p.h:275
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60

◆ updateLayoutDirection()

void QMenuPrivate::updateLayoutDirection ( )

Definition at line 691 of file qmenu.cpp.

692 {
693  Q_Q(QMenu);
694  //we need to mimic the cause of the popup's layout direction
695  //to allow setting it on a mainwindow for example
696  //we call setLayoutDirection_helper to not overwrite a user-defined value
697  if (!q->testAttribute(Qt::WA_SetLayoutDirection)) {
698  if (QWidget *w = causedPopup.widget)
699  setLayoutDirection_helper(w->layoutDirection());
700  else if (QWidget *w = q->parentWidget())
701  setLayoutDirection_helper(w->layoutDirection());
702  else
704  }
705 }
static Qt::LayoutDirection layoutDirection()
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setLayoutDirection_helper(Qt::LayoutDirection)
Definition: qwidget.cpp:5153
#define Q_Q(Class)
Definition: qglobal.h:2483
QMenuCaused causedPopup
Definition: qmenu_p.h:263
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
QPointer< QWidget > widget
Definition: qmenu_p.h:259

◆ wceCommands()

QAction * QMenuPrivate::wceCommands ( uint  command)

Definition at line 364 of file qmenu_wince.cpp.

365 {
366  QAction *foundAction = 0;
367  for (int i = 0; i < wce_menu->actionItems.size(); ++i) {
368  if (foundAction)
369  break;
370  QWceMenuAction *action = wce_menu->actionItems.at(i);
371  if (action->action->menu()) {
372  foundAction = action->action->menu()->d_func()->wceCommands(command);
373  }
374  else if (action->command == command) {
376  return action->action;
377  }
378  }
379  if (foundAction)
380  emit q_func()->triggered(foundAction);
381  return foundAction;
382 }
struct QMenuPrivate::QWceMenuPrivate * wce_menu
QList< QWceMenuAction * > actionItems
Definition: qmenu_p.h:345
QAction * wceCommands(uint command)
This function sends native Windows CE commands to Qt menus.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
QMenu * menu() const
Returns the menu contained by this action.
Definition: qaction.cpp:793
QPointer< QAction > action
Definition: qmenu_p.h:129
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
uint command
Definition: qmenu_p.h:128
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
void activateAction(QAction *, QAction::ActionEvent, bool self=true)
Definition: qmenu.cpp:1085

◆ wceMenu()

HMENU QMenuPrivate::wceMenu ( )

Definition at line 483 of file qmenu_wince.cpp.

484 {
485  if (!wce_menu)
486  wce_menu = new QWceMenuPrivate;
487  if (!wce_menu->menuHandle)
488  wce_menu->rebuild();
489  return wce_menu->menuHandle;
490 }
struct QMenuPrivate::QWceMenuPrivate * wce_menu

Properties

◆ aboutToHide

uint QMenuPrivate::aboutToHide

Definition at line 211 of file qmenu_p.h.

Referenced by hideMenu().

◆ actionAboutToTrigger

QPointer<QAction> QMenuPrivate::actionAboutToTrigger

Definition at line 338 of file qmenu_p.h.

Referenced by activateAction(), and hideMenu().

◆ actionRects

QVector<QRect> QMenuPrivate::actionRects
mutable

◆ activationRecursionGuard

bool QMenuPrivate::activationRecursionGuard

Definition at line 205 of file qmenu_p.h.

Referenced by _q_actionTriggered(), and activateCausedStack().

◆ activeMenu

QPointer<QMenu> QMenuPrivate::activeMenu

Definition at line 254 of file qmenu_p.h.

Referenced by mouseEventTaken(), popupAction(), and setCurrentAction().

◆ causedPopup

QMenuCaused QMenuPrivate::causedPopup

◆ collapsibleSeparators

uint QMenuPrivate::collapsibleSeparators

Definition at line 201 of file qmenu_p.h.

Referenced by getLastVisibleAction(), macMenu(), and updateActionRects().

◆ currentAction

QAction* QMenuPrivate::currentAction

Definition at line 213 of file qmenu_p.h.

Referenced by hideMenu(), setCurrentAction(), and setSyncAction().

◆ defaultAction

QPointer<QAction> QMenuPrivate::defaultAction

Definition at line 283 of file qmenu_p.h.

◆ defaultMenuAction

QAction* QMenuPrivate::defaultMenuAction

Definition at line 286 of file qmenu_p.h.

Referenced by _q_overrideMenuActionDestroyed(), init(), and setOverrideMenuAction().

◆ doChildEffects

bool QMenuPrivate::doChildEffects

Definition at line 303 of file qmenu_p.h.

◆ eventLoop

QEventLoop* QMenuPrivate::eventLoop

Definition at line 246 of file qmenu_p.h.

Referenced by hideMenu(), and hideUpToMenuBar().

◆ hasCheckableItems

bool QMenuPrivate::hasCheckableItems
mutable

Definition at line 275 of file qmenu_p.h.

Referenced by updateActionRects().

◆ hasHadMouse

uint QMenuPrivate::hasHadMouse

Definition at line 210 of file qmenu_p.h.

◆ itemsDirty

uint QMenuPrivate::itemsDirty
mutable

Definition at line 190 of file qmenu_p.h.

Referenced by adjustMenuSizeForScreen(), scrollMenu(), and updateActionRects().

◆ mac_menu

struct QMenuPrivate::QMacMenuPrivate * QMenuPrivate::mac_menu

◆ maxIconWidth

uint QMenuPrivate::maxIconWidth
mutable

Definition at line 191 of file qmenu_p.h.

Referenced by updateActionRects().

◆ menuAction

QAction* QMenuPrivate::menuAction

Definition at line 285 of file qmenu_p.h.

Referenced by _q_overrideMenuActionDestroyed(), init(), and setOverrideMenuAction().

◆ menuDelayTimer

QBasicTimer QMenuPrivate::menuDelayTimer

Definition at line 218 of file qmenu_p.h.

Referenced by popupAction().

◆ mergeMenuHash

QHash< OSMenuRef, OSMenuRef > QMenuPrivate::mergeMenuHash
static

◆ mergeMenuItemsHash

QHash< OSMenuRef, QMenuMergeList * > QMenuPrivate::mergeMenuItemsHash
static

◆ motions

int QMenuPrivate::motions

Definition at line 212 of file qmenu_p.h.

Referenced by hasMouseMoved().

◆ mouseDown

QMenu * QMenuPrivate::mouseDown = 0
static

Definition at line 208 of file qmenu_p.h.

Referenced by mouseEventTaken().

◆ mousePopupPos

QPoint QMenuPrivate::mousePopupPos

Definition at line 209 of file qmenu_p.h.

Referenced by hasMouseMoved().

◆ ncols

uint QMenuPrivate::ncols
mutable

Definition at line 200 of file qmenu_p.h.

Referenced by updateActionRects().

◆ noReplayFor

QPointer<QWidget> QMenuPrivate::noReplayFor

Definition at line 390 of file qmenu_p.h.

◆ scroll

struct QMenuPrivate::QMenuScroller * QMenuPrivate::scroll

◆ searchBuffer

QString QMenuPrivate::searchBuffer

Definition at line 250 of file qmenu_p.h.

◆ searchBufferTimer

QBasicTimer QMenuPrivate::searchBufferTimer

Definition at line 251 of file qmenu_p.h.

◆ sloppyAction

QAction* QMenuPrivate::sloppyAction
mutable

Definition at line 279 of file qmenu_p.h.

Referenced by setCurrentAction(), and updateActionRects().

◆ sloppyDelayTimer

int QMenuPrivate::sloppyDelayTimer

Definition at line 278 of file qmenu_p.h.

◆ sloppyRegion

QRegion QMenuPrivate::sloppyRegion

Definition at line 280 of file qmenu_p.h.

Referenced by setCurrentAction().

◆ syncAction

QPointer<QAction> QMenuPrivate::syncAction

Definition at line 247 of file qmenu_p.h.

◆ tabWidth

uint QMenuPrivate::tabWidth
mutable

Definition at line 191 of file qmenu_p.h.

Referenced by updateActionRects().

◆ tearoff

uint QMenuPrivate::tearoff

Definition at line 272 of file qmenu_p.h.

Referenced by mouseEventTaken(), and updateActionRects().

◆ tearoffHighlighted

uint QMenuPrivate::tearoffHighlighted

Definition at line 272 of file qmenu_p.h.

Referenced by mouseEventTaken(), and setCurrentAction().

◆ tornoff

uint QMenuPrivate::tornoff

◆ tornPopup

QPointer<QTornOffMenu> QMenuPrivate::tornPopup

Definition at line 273 of file qmenu_p.h.

Referenced by mouseEventTaken().

◆ wce_menu

struct QMenuPrivate::QWceMenuPrivate * QMenuPrivate::wce_menu

Referenced by wceMenu().

◆ widgetItems

QHash<QAction *, QWidget *> QMenuPrivate::widgetItems
mutable

The documentation for this class was generated from the following files: