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

#include <qmenubar_p.h>

Inheritance diagram for QMenuBarPrivate:
QWidgetPrivate QObjectPrivate QObjectData

Classes

struct  QMacMenuBarPrivate
 
struct  QWceMenuBarPrivate
 

Public Functions

void _q_actionHovered ()
 
void _q_actionTriggered ()
 
void _q_internalShortcutActivated (int)
 
void _q_updateDefaultAction ()
 
void _q_updateLayout ()
 
QActionactionAt (QPoint p) const
 
QRect actionRect (QAction *) const
 
void activateAction (QAction *, QAction::ActionEvent)
 
void calcActionRects (int max_width, int start) const
 
void focusFirstAction ()
 
QActiongetNextAction (const int start, const int increment) const
 
void handleReparent ()
 
void init ()
 
bool isVisible (QAction *action)
 
void macCreateMenuBar (QWidget *)
 
void macDestroyMenuBar ()
 
OSMenuRef macMenu ()
 
bool macWidgetHasNativeMenubar (QWidget *widget)
 
QRect menuRect (bool) const
 
void popupAction (QAction *, bool)
 
 QMenuBarPrivate ()
 
void setCurrentAction (QAction *, bool=false, bool=false)
 
void setKeyboardMode (bool)
 
void updateCornerWidgetToolBar ()
 
void updateGeometries ()
 
void wceCommands (uint command)
 
void wceCreateMenuBar (QWidget *)
 
void wceDestroyMenuBar ()
 
bool wceEmitSignals (QList< QWceMenuAction *> actions, uint command)
 
void wceRefresh ()
 
 ~QMenuBarPrivate ()
 
- 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 bool macUpdateMenuBarImmediatly ()
 
- 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

QVector< QRectactionRects
 
QPointer< QMenuactiveMenu
 
uint altPressed: 1
 
QBasicTimer autoReleaseTimer
 
uint closePopupMode: 1
 
QWidgetcornerWidgetContainer
 
QToolBarcornerWidgetToolBar
 
QPointer< QActioncurrentAction
 
QPointer< QActiondefaultAction
 
uint defaultPopDown
 
bool doChildEffects
 
QMenuBarExtensionextension
 
QList< QAction * > hiddenActions
 
uint itemsDirty: 1
 
QPointer< QWidgetkeyboardFocusWidget
 
uint keyboardState: 1
 
QPointer< QWidgetleftWidget
 
struct QMenuBarPrivate::QMacMenuBarPrivatemac_menubar
 
uint mouseDown: 1
 
QWidgetoldParent
 
QWidgetoldWindow
 
QAbstractPlatformMenuBarplatformMenuBar
 
uint popupState: 1
 
QPointer< QWidgetrightWidget
 
QVector< int > shortcutIndexMap
 
struct QMenuBarPrivate::QWceMenuBarPrivatewce_menubar
 
bool wceClassicMenu
 
- 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
 

Additional Inherited Members

- 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 **)
 
- 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 80 of file qmenubar_p.h.

Constructors and Destructors

◆ QMenuBarPrivate()

QMenuBarPrivate::QMenuBarPrivate ( )
inline

Definition at line 84 of file qmenubar_p.h.

84  : itemsDirty(0), currentAction(0), mouseDown(0),
86 #ifndef Q_WS_X11
87  , nativeMenuBar(-1)
88 #endif
89  , doChildEffects(false)
90 #ifdef QT3_SUPPORT
91  , doAutoResize(false)
92 #endif
93 #ifdef Q_WS_MAC
94  , mac_menubar(0)
95 #endif
96 #ifdef Q_WS_X11
97  , platformMenuBar(0)
98 #endif
99 #ifdef Q_WS_WINCE
100  , wce_menubar(0), wceClassicMenu(false)
101 #endif
102 #ifdef Q_WS_S60
103  , symbian_menubar(0)
104 #endif
105 
106  { }
struct QMenuBarPrivate::QWceMenuBarPrivate * wce_menubar
QPointer< QAction > currentAction
Definition: qmenubar_p.h:136
struct QMenuBarPrivate::QMacMenuBarPrivate * mac_menubar
QAbstractPlatformMenuBar * platformMenuBar
Definition: qmenubar_p.h:191

◆ ~QMenuBarPrivate()

QMenuBarPrivate::~QMenuBarPrivate ( )
inline

Definition at line 107 of file qmenubar_p.h.

108  {
109 #ifdef Q_WS_X11
110  delete platformMenuBar;
111 #endif
112 #ifdef Q_WS_MAC
113  delete mac_menubar;
114 #endif
115 #ifdef Q_WS_WINCE
116  delete wce_menubar;
117 #endif
118 #ifdef Q_WS_S60
119  delete symbian_menubar;
120 #endif
121  }
struct QMenuBarPrivate::QWceMenuBarPrivate * wce_menubar
struct QMenuBarPrivate::QMacMenuBarPrivate * mac_menubar
QAbstractPlatformMenuBar * platformMenuBar
Definition: qmenubar_p.h:191

Functions

◆ _q_actionHovered()

void QMenuBarPrivate::_q_actionHovered ( )

Definition at line 557 of file qmenubar.cpp.

558 {
559  Q_Q(QMenuBar);
560  if (QAction *action = qobject_cast<QAction *>(q->sender())) {
561  emit q->hovered(action);
562 #ifndef QT_NO_ACCESSIBILITY
563  if (QAccessible::isActive()) {
564  int actionIndex = actions.indexOf(action);
565  ++actionIndex;
568  }
569 #endif //QT_NO_ACCESSIBILITY
570 #ifdef QT3_SUPPORT
571  emit q->highlighted(q->findIdForAction(action));
572 #endif
573  }
574 }
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
#define Q_Q(Class)
Definition: qglobal.h:2483
#define emit
Definition: qobjectdefs.h:76
static bool isActive()
Returns true if an accessibility implementation has been requested during the runtime of the applicat...
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
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
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

◆ _q_actionTriggered()

void QMenuBarPrivate::_q_actionTriggered ( )

Definition at line 546 of file qmenubar.cpp.

547 {
548  Q_Q(QMenuBar);
549  if (QAction *action = qobject_cast<QAction *>(q->sender())) {
550  emit q->triggered(action);
551 #ifdef QT3_SUPPORT
552  emit q->activated(q->findIdForAction(action));
553 #endif
554  }
555 }
#define Q_Q(Class)
Definition: qglobal.h:2483
#define emit
Definition: qobjectdefs.h:76
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64

◆ _q_internalShortcutActivated()

void QMenuBarPrivate::_q_internalShortcutActivated ( int  id)
Warning
This function is not part of the public interface.

Definition at line 1901 of file qmenubar.cpp.

1902 {
1903  Q_Q(QMenuBar);
1904  QAction *act = actions.at(id);
1905 #ifdef Q_WS_X11
1906  if (q->isNativeMenuBar()) {
1908  } else {
1909 #endif
1910  setCurrentAction(act, true, true);
1911 #ifdef Q_WS_X11
1912  }
1913 #endif
1914  if (act && !act->menu()) {
1916  //100 is the same as the default value in QPushButton::animateClick
1917  autoReleaseTimer.start(100, q);
1918  } else if (act && q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, q)) {
1919  // When we open a menu using a shortcut, we should end up in keyboard state
1920  setKeyboardMode(true);
1921  }
1922 }
QBasicTimer autoReleaseTimer
Definition: qmenubar_p.h:186
void setKeyboardMode(bool)
Definition: qmenubar.cpp:313
#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
void setCurrentAction(QAction *, bool=false, bool=false)
Definition: qmenubar.cpp:391
QMenu * menu() const
Returns the menu contained by this action.
Definition: qaction.cpp:793
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
QAbstractPlatformMenuBar * platformMenuBar
Definition: qmenubar_p.h:191
QList< QAction * > actions
Definition: qwidget_p.h:760
virtual void popupAction(QAction *)=0
void activateAction(QAction *, QAction::ActionEvent)
Definition: qmenubar.cpp:530
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
void start(int msec, QObject *obj)
Starts (or restarts) the timer with a msec milliseconds timeout.

◆ _q_updateDefaultAction()

void QMenuBarPrivate::_q_updateDefaultAction ( )

Definition at line 553 of file qmenu_wince.cpp.

554 {
555  if (wce_menubar)
556  wce_menubar->rebuild();
557 }
struct QMenuBarPrivate::QWceMenuBarPrivate * wce_menubar

◆ _q_updateLayout()

void QMenuBarPrivate::_q_updateLayout ( )

Definition at line 1924 of file qmenubar.cpp.

1925 {
1926  Q_Q(QMenuBar);
1927  itemsDirty = true;
1928  if (q->isVisible()) {
1929  updateGeometries();
1930  q->update();
1931  }
1932 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
void updateGeometries()
Definition: qmenubar.cpp:175

◆ actionAt()

QAction * QMenuBarPrivate::actionAt ( QPoint  p) const
Warning
This function is not part of the public interface.

Definition at line 127 of file qmenubar.cpp.

128 {
129  for(int i = 0; i < actions.size(); ++i) {
130  if(actionRect(actions.at(i)).contains(p))
131  return actions.at(i);
132  }
133  return 0;
134 }
QRect actionRect(QAction *) const
Definition: qmenubar.cpp:289
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QList< QAction * > actions
Definition: qwidget_p.h:760

◆ actionRect()

QRect QMenuBarPrivate::actionRect ( QAction act) const

Definition at line 289 of file qmenubar.cpp.

290 {
291  const int index = actions.indexOf(act);
292 
293  //makes sure the geometries are up-to-date
294  const_cast<QMenuBarPrivate*>(this)->updateGeometries();
295 
296  if (index < 0 || index >= actionRects.count())
297  return QRect(); // that can happen in case of native menubar
298 
299  return actionRects.at(index);
300 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QVector< QRect > actionRects
Definition: qmenubar_p.h:130
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
void updateGeometries()
Definition: qmenubar.cpp:175
quint16 index

◆ activateAction()

void QMenuBarPrivate::activateAction ( QAction action,
QAction::ActionEvent  action_e 
)

Definition at line 530 of file qmenubar.cpp.

531 {
532  Q_Q(QMenuBar);
533  if (!action || !action->isEnabled())
534  return;
535  action->activate(action_e);
536  if (action_e == QAction::Hover)
537  action->showStatusText(q);
538 
539 // if(action_e == QAction::Trigger)
540 // emit q->activated(action);
541 // else if(action_e == QAction::Hover)
542 // emit q->highlighted(action);
543 }
bool isEnabled() const
Definition: qaction.cpp:1208
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
void activate(ActionEvent event)
Sends the relevant signals for ActionEvent event.
Definition: qaction.cpp:1326
#define Q_Q(Class)
Definition: qglobal.h:2483
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62

◆ calcActionRects()

void QMenuBarPrivate::calcActionRects ( int  max_width,
int  start 
) const

Definition at line 434 of file qmenubar.cpp.

435 {
436  Q_Q(const QMenuBar);
437 
438  if(!itemsDirty)
439  return;
440 
441  //let's reinitialize the buffer
444 
445  const QStyle *style = q->style();
446 
447  const int itemSpacing = style->pixelMetric(QStyle::PM_MenuBarItemSpacing, 0, q);
448  int max_item_height = 0, separator = -1, separator_start = 0, separator_len = 0;
449 
450  //calculate size
451  const QFontMetrics fm = q->fontMetrics();
452  const int hmargin = style->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q),
453  vmargin = style->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q),
454  icone = style->pixelMetric(QStyle::PM_SmallIconSize, 0, q);
455  for(int i = 0; i < actions.count(); i++) {
456  QAction *action = actions.at(i);
457  if(!action->isVisible())
458  continue;
459 
460  QSize sz;
461 
462  //calc what I think the size is..
463  if(action->isSeparator()) {
464  if (style->styleHint(QStyle::SH_DrawMenuBarSeparator, 0, q))
465  separator = i;
466  continue; //we don't really position these!
467  } else {
468  const QString s = action->text();
469  QIcon is = action->icon();
470  // If an icon is set, only the icon is visible
471  if (!is.isNull())
472  sz = sz.expandedTo(QSize(icone, icone));
473  else if (!s.isEmpty())
474  sz = fm.size(Qt::TextShowMnemonic, s);
475  }
476 
477  //let the style modify the above size..
479  q->initStyleOption(&opt, action);
480  sz = q->style()->sizeFromContents(QStyle::CT_MenuBarItem, &opt, sz, q);
481 
482  if(!sz.isEmpty()) {
483  { //update the separator state
484  int iWidth = sz.width() + itemSpacing;
485  if(separator == -1)
486  separator_start += iWidth;
487  else
488  separator_len += iWidth;
489  }
490  //maximum height
491  max_item_height = qMax(max_item_height, sz.height());
492  //append
493  actionRects[i] = QRect(0, 0, sz.width(), sz.height());
494  }
495  }
496 
497  //calculate position
498  const int fw = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);
499  int x = fw + ((start == -1) ? hmargin : start) + itemSpacing;
500  int y = fw + vmargin;
501  for(int i = 0; i < actions.count(); i++) {
502  QRect &rect = actionRects[i];
503  if (rect.isNull())
504  continue;
505 
506  //resize
507  rect.setHeight(max_item_height);
508 
509  //move
510  if(separator != -1 && i >= separator) { //after the separator
511  int left = (max_width - separator_len - hmargin - itemSpacing) + (x - separator_start - hmargin);
512  if(left < separator_start) { //wrap
513  separator_start = x = hmargin;
514  y += max_item_height;
515  }
516  rect.moveLeft(left);
517  } else {
518  rect.moveLeft(x);
519  }
520  rect.moveTop(y);
521 
522  //keep moving along..
523  x += rect.width() + itemSpacing;
524 
525  //make sure we follow the layout direction
526  rect = QStyle::visualRect(q->layoutDirection(), q->rect(), rect);
527  }
528 }
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
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
void moveLeft(int pos)
Moves the rectangle horizontally, leaving the rectangle&#39;s left edge at the given x coordinate...
Definition: qrect.h:350
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
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
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...
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
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
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
QVector< QRect > actionRects
Definition: qmenubar_p.h:130
int width() const
Returns the width.
Definition: qsize.h:126
QSize size(int flags, const QString &str, int tabstops=0, int *tabarray=0) const
Returns the size in pixels of text.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
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
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
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
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void moveTop(int pos)
Moves the rectangle vertically, leaving the rectangle&#39;s top edge at the given y coordinate.
Definition: qrect.h:353
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
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
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

◆ focusFirstAction()

void QMenuBarPrivate::focusFirstAction ( )

Definition at line 302 of file qmenubar.cpp.

303 {
304  if(!currentAction) {
306  int index = 0;
307  while (index < actions.count() && actionRects.at(index).isNull()) ++index;
308  if (index < actions.count())
309  setCurrentAction(actions.at(index));
310  }
311 }
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
QPointer< QAction > currentAction
Definition: qmenubar_p.h:136
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QVector< QRect > actionRects
Definition: qmenubar_p.h:130
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
void setCurrentAction(QAction *, bool=false, bool=false)
Definition: qmenubar.cpp:391
QList< QAction * > actions
Definition: qwidget_p.h:760
void updateGeometries()
Definition: qmenubar.cpp:175
quint16 index

◆ getNextAction()

QAction * QMenuBarPrivate::getNextAction ( const int  start,
const int  increment 
) const

Definition at line 795 of file qmenubar.cpp.

Referenced by ~QMenuBarPrivate().

796 {
797  Q_Q(const QMenuBar);
798  const_cast<QMenuBarPrivate*>(this)->updateGeometries();
799  bool allowActiveAndDisabled = q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q);
800  const int start = (_start == -1 && increment == -1) ? actions.count() : _start;
801  const int end = increment == -1 ? 0 : actions.count() - 1;
802 
803  for (int i = start; i != end;) {
804  i += increment;
805  QAction *current = actions.at(i);
806  if (!actionRects.at(i).isNull() && (allowActiveAndDisabled || current->isEnabled()))
807  return current;
808  }
809 
810  if (_start != -1) //let's try from the beginning or the end
811  return getNextAction(-1, increment);
812 
813  return 0;
814 }
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
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QAction * getNextAction(const int start, const int increment) const
Definition: qmenubar.cpp:795
#define Q_Q(Class)
Definition: qglobal.h:2483
QVector< QRect > actionRects
Definition: qmenubar_p.h:130
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 QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
QList< QAction * > actions
Definition: qwidget_p.h:760
void updateGeometries()
Definition: qmenubar.cpp:175
static const KeyPair *const end
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64

◆ handleReparent()

void QMenuBarPrivate::handleReparent ( )

Definition at line 1404 of file qmenubar.cpp.

1405 {
1406  Q_Q(QMenuBar);
1407  QWidget *newParent = q->parentWidget();
1408  //Note: if parent is reparented, then window may change even if parent doesn't
1409 
1410  // we need to install an event filter on parent, and remove the old one
1411 
1412  if (oldParent != newParent) {
1413  if (oldParent)
1415  if (newParent)
1416  newParent->installEventFilter(q);
1417  }
1418 
1419  //we also need event filter on top-level (for shortcuts)
1420  QWidget *newWindow = newParent ? newParent->window() : 0;
1421 
1422  if (oldWindow != newWindow) {
1423  if (oldParent && oldParent != oldWindow)
1425 
1426  if (newParent && newParent != newWindow)
1427  newWindow->installEventFilter(q);
1428  }
1429 
1430 #ifdef Q_WS_X11
1431  platformMenuBar->handleReparent(oldParent, newParent, oldWindow, newWindow);
1432 #endif
1433 
1434  oldParent = newParent;
1435  oldWindow = newWindow;
1436 
1437 #ifdef Q_WS_MAC
1438  if (q->isNativeMenuBar() && !macWidgetHasNativeMenubar(newParent)) {
1439  // If the new parent got a native menubar from before, keep that
1440  // menubar rather than replace it with this one (because a parents
1441  // menubar has precedence over children menubars).
1443  macCreateMenuBar(newParent);
1444  }
1445 #endif
1446 
1447 #ifdef Q_WS_WINCE
1449  wce_menubar->rebuild();
1450 #endif
1451 #ifdef Q_WS_S60
1452 
1453  // Construct symbian_menubar when this code path is entered first time
1454  // and when newParent != NULL
1455  if (!symbian_menubar)
1456  symbianCreateMenuBar(newParent);
1457 
1458  // Reparent and rebuild menubar when parent is changed
1459  if (symbian_menubar) {
1460  if (oldParent != newParent)
1461  reparentMenuBar(oldParent, newParent);
1462  q->hide();
1463  symbian_menubar->rebuild();
1464  }
1465 
1466 #ifdef QT_SOFTKEYS_ENABLED
1467  // Constuct menuBarAction when this code path is entered first time
1468  if (!menuBarAction) {
1469  if (newParent) {
1470  menuBarAction = QSoftKeyManager::createAction(QSoftKeyManager::MenuSoftKey, newParent);
1471  newParent->addAction(menuBarAction);
1472  }
1473  } else {
1474  // If reparenting i.e. we already have menuBarAction, remove it from old parent
1475  // and add for a new parent
1476  if (oldParent)
1477  oldParent->removeAction(menuBarAction);
1478  if (newParent)
1479  newParent->addAction(menuBarAction);
1480  }
1481 #endif // QT_SOFTKEYS_ENABLED
1482 #endif // Q_WS_S60
1483 }
bool qt_wince_is_mobile()
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
struct QMenuBarPrivate::QWceMenuBarPrivate * wce_menubar
void removeEventFilter(QObject *)
Removes an event filter object obj from this object.
Definition: qobject.cpp:2099
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
virtual void handleReparent(QWidget *oldParent, QWidget *newParent, QWidget *oldWindow, QWidget *newWindow)=0
void addAction(QAction *action)
Appends the action action to this widget&#39;s list of actions.
Definition: qwidget.cpp:3317
void macCreateMenuBar(QWidget *)
Definition: qmenu_mac.mm:1790
#define Q_Q(Class)
Definition: qglobal.h:2483
QWidget * oldWindow
Definition: qmenubar_p.h:180
void macDestroyMenuBar()
Definition: qmenu_mac.mm:1824
static QAction * createAction(StandardSoftKey standardKey, QWidget *actionWidget)
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
QAbstractPlatformMenuBar * platformMenuBar
Definition: qmenubar_p.h:191
QWidget * oldParent
Definition: qmenubar_p.h:179
void removeAction(QAction *action)
Removes the action action from this widget&#39;s list of actions.
Definition: qwidget.cpp:3386
void installEventFilter(QObject *)
Installs an event filter filterObj on this object.
Definition: qobject.cpp:2070
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
bool macWidgetHasNativeMenubar(QWidget *widget)
Definition: qmenu_mac.mm:1779

◆ init()

void QMenuBarPrivate::init ( )

Definition at line 749 of file qmenubar.cpp.

Referenced by ~QMenuBarPrivate().

750 {
751  Q_Q(QMenuBar);
753  q->setAttribute(Qt::WA_CustomWhatsThis);
754 #ifdef Q_WS_MAC
755  macCreateMenuBar(q->parentWidget());
756  if(mac_menubar)
757  q->hide();
758 #endif
759 #ifdef Q_WS_WINCE
760  if (qt_wince_is_mobile()) {
761  wceCreateMenuBar(q->parentWidget());
762  if(wce_menubar)
763  q->hide();
764  }
765  else {
767  }
768 #endif
769 #ifdef Q_WS_X11
771  platformMenuBar->init(q);
772 #endif
773 
774  q->setBackgroundRole(QPalette::Button);
775  oldWindow = oldParent = 0;
776 #ifdef QT3_SUPPORT
777  doAutoResize = false;
778 #endif
779 #ifdef QT_SOFTKEYS_ENABLED
780  menuBarAction = 0;
781 #endif
782 #ifdef Q_WS_X11
785 #endif
786  handleReparent();
787  q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, q));
788 
789  extension = new QMenuBarExtension(q);
791  extension->hide();
792 }
bool qt_wince_is_mobile()
struct QMenuBarPrivate::QWceMenuBarPrivate * wce_menubar
QWidget * cornerWidgetContainer
Definition: qmenubar_p.h:297
virtual QAbstractPlatformMenuBar * create()=0
QToolBar * cornerWidgetToolBar
Definition: qmenubar_p.h:296
QMenuBarExtension * extension
Definition: qmenubar_p.h:169
static void setAttribute(Qt::ApplicationAttribute attribute, bool on=true)
Sets the attribute attribute if on is true; otherwise clears the attribute.
void macCreateMenuBar(QWidget *)
Definition: qmenu_mac.mm:1790
#define Q_Q(Class)
Definition: qglobal.h:2483
void wceCreateMenuBar(QWidget *)
QWidget * oldWindow
Definition: qmenubar_p.h:180
QPlatformMenuBarFactoryInterface * qt_guiPlatformMenuBarFactory()
void handleReparent()
Definition: qmenubar.cpp:1404
void hide()
Hides the widget.
Definition: qwidget.h:501
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
struct QMenuBarPrivate::QMacMenuBarPrivate * mac_menubar
QAbstractPlatformMenuBar * platformMenuBar
Definition: qmenubar_p.h:191
QWidget * oldParent
Definition: qmenubar_p.h:179
virtual void init(QMenuBar *)=0
void setFocusPolicy(Qt::FocusPolicy policy)
Definition: qwidget.cpp:7631

◆ isVisible()

bool QMenuBarPrivate::isVisible ( QAction action)

Definition at line 170 of file qmenubar.cpp.

171 {
172  return !hiddenActions.contains(action);
173 }
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
QList< QAction * > hiddenActions
Definition: qmenubar_p.h:182

◆ macCreateMenuBar()

void QMenuBarPrivate::macCreateMenuBar ( QWidget parent)

Definition at line 1790 of file qmenu_mac.mm.

Referenced by QMenuBarPrivate::QMacMenuBarPrivate::findAction().

1791 {
1792  Q_Q(QMenuBar);
1793  static int dontUseNativeMenuBar = -1;
1794  // We call the isNativeMenuBar function here
1795  // because that will make sure that local overrides
1796  // are dealt with correctly. q->isNativeMenuBar() will, if not
1797  // overridden, depend on the attribute Qt::AA_DontUseNativeMenuBar:
1798  bool qt_mac_no_native_menubar = !q->isNativeMenuBar();
1799  if (qt_mac_no_native_menubar == false && dontUseNativeMenuBar < 0) {
1800  // The menubar is set to be native. Let's check (one time only
1801  // for all menubars) if this is OK with the rest of the environment.
1802  // As a result, Qt::AA_DontUseNativeMenuBar is set. NB: the application
1803  // might still choose to not respect, or change, this flag.
1805  bool environmentSaysNo = !qgetenv("QT_MAC_NO_NATIVE_MENUBAR").isEmpty();
1806  dontUseNativeMenuBar = isPlugin || environmentSaysNo;
1808  qt_mac_no_native_menubar = !q->isNativeMenuBar();
1809  }
1810  if (qt_mac_no_native_menubar == false) {
1811  // INVARIANT: Use native menubar.
1812  extern void qt_event_request_menubarupdate(); //qapplication_mac.cpp
1814  if (!parent && !fallback) {
1815  fallback = q;
1816  mac_menubar = new QMacMenuBarPrivate;
1817  } else if (parent && parent->isWindow()) {
1818  menubars()->insert(q->window(), q);
1819  mac_menubar = new QMacMenuBarPrivate;
1820  }
1821  }
1822 }
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
static void setAttribute(Qt::ApplicationAttribute attribute, bool on=true)
Sets the attribute attribute if on is true; otherwise clears the attribute.
#define Q_Q(Class)
Definition: qglobal.h:2483
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
struct QMenuBarPrivate::QMacMenuBarPrivate * mac_menubar
static QCoreApplication * instance()
Returns a pointer to the application&#39;s QCoreApplication (or QApplication) instance.
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
static bool testAttribute(Qt::ApplicationAttribute attribute)
Returns true if attribute attribute is set; otherwise returns false.
void qt_event_request_menubarupdate()
static QMenuBar * fallback
Definition: qmenu_mac.mm:1617

◆ macDestroyMenuBar()

void QMenuBarPrivate::macDestroyMenuBar ( )

Definition at line 1824 of file qmenu_mac.mm.

Referenced by QMenuBarPrivate::QMacMenuBarPrivate::findAction().

1825 {
1826  Q_Q(QMenuBar);
1828  if (fallback == q)
1829  fallback = 0;
1830  delete mac_menubar;
1831  QWidget *tlw = q->window();
1832  menubars()->remove(tlw);
1833  mac_menubar = 0;
1834 
1835  if (!qt_mac_current_menubar.qmenubar || qt_mac_current_menubar.qmenubar == q) {
1836 #ifdef QT_MAC_USE_COCOA
1837  QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
1838  [loader removeActionsFromAppMenu];
1839 #else
1841 #endif
1842  extern void qt_event_request_menubarupdate(); //qapplication_mac.cpp
1844  }
1845 }
static void cancelAllMenuTracking()
Definition: qmenu_mac.mm:178
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_Q(Class)
Definition: qglobal.h:2483
static struct @304 qt_mac_current_menubar
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
struct QMenuBarPrivate::QMacMenuBarPrivate * mac_menubar
#define QT_MANGLE_NAMESPACE(name)
Definition: qglobal.h:106
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
void qt_event_request_menubarupdate()
static QMenuBar * fallback
Definition: qmenu_mac.mm:1617

◆ macMenu()

OSMenuRef QMenuBarPrivate::macMenu ( )

Definition at line 1847 of file qmenu_mac.mm.

Referenced by QMenuBarPrivate::QMacMenuBarPrivate::findAction().

1848 {
1849  Q_Q(QMenuBar);
1850  if (!q->isNativeMenuBar() || !mac_menubar) {
1851  return 0;
1852  } else if (!mac_menubar->menu) {
1854 #ifdef QT_MAC_USE_COCOA
1855  [mac_menubar->menu setAutoenablesItems:NO];
1856 #endif
1857  ProcessSerialNumber mine, front;
1858  if (GetCurrentProcess(&mine) == noErr && GetFrontProcess(&front) == noErr) {
1861 #ifndef QT_MAC_USE_COCOA
1862  MenuItemIndex index;
1863  AppendMenuItemTextWithCFString(mac_menubar->menu, 0, 0, 0, &index);
1864 
1865  SetMenuTitleWithCFString(mac_menubar->apple_menu, QCFString(QString(QChar(0x14))));
1866  SetMenuItemHierarchicalMenu(mac_menubar->menu, index, mac_menubar->apple_menu);
1867  SetMenuItemProperty(mac_menubar->apple_menu, 0, kMenuCreatorQt, kMenuPropertyQWidget, sizeof(q), &q);
1868 #else
1869  [mac_menubar->apple_menu setTitle:qt_mac_QStringToNSString(QString(QChar(0x14)))];
1870  NSMenuItem *apple_menuItem = [[NSMenuItem alloc] init];
1871  [apple_menuItem setSubmenu:mac_menubar->menu];
1872  [mac_menubar->apple_menu addItem:apple_menuItem];
1873  [apple_menuItem release];
1874 #endif
1875  }
1876  if (mac_menubar->apple_menu) {
1877 #ifndef QT_MAC_USE_COCOA
1878  SetMenuItemProperty(mac_menubar->menu, 0, kMenuCreatorQt, kMenuPropertyMergeMenu,
1880 #else
1882 #endif
1883  }
1884  QList<QAction*> items = q->actions();
1885  for(int i = 0; i < items.count(); i++)
1886  mac_menubar->addAction(items[i]);
1887  }
1888  }
1889  return mac_menubar->menu;
1890 }
bool qt_mac_no_menubar_merge
Definition: qmenu_mac.mm:74
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
void addAction(QAction *, QAction *=0)
Definition: qmenu_mac.mm:1646
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
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
void NSMenuItem
Definition: qmenu_p.h:80
const UInt32 kMenuCreatorQt
Definition: qmenu_mac.mm:82
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
static OSMenuRef qt_mac_create_menu(QWidget *w)
Definition: qmenu_mac.mm:2193
struct QMenuBarPrivate::QMacMenuBarPrivate * mac_menubar
quint16 index
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ macUpdateMenuBarImmediatly()

bool QMenuBarPrivate::macUpdateMenuBarImmediatly ( )
static

Definition at line 2066 of file qmenu_mac.mm.

Referenced by QMenuBarPrivate::QMacMenuBarPrivate::findAction(), and QMenuBar::macUpdateMenuBar().

2067 {
2068  bool ret = false;
2071  QMenuBar *mb = findMenubarForWindow(w);
2072  extern bool qt_mac_app_fullscreen; //qapplication_mac.mm
2073 
2074  // We need to see if we are in full screen mode, if so we need to
2075  // switch the full screen mode to be able to show or hide the menubar.
2076  if(w && mb) {
2077  // This case means we are creating a menubar, check if full screen
2078  if(w->isFullScreen()) {
2079  // Ok, switch to showing the menubar when hovering over it.
2080  SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar);
2081  qt_mac_app_fullscreen = true;
2082  }
2083  } else if(w) {
2084  // Removing a menubar
2085  if(w->isFullScreen()) {
2086  // Ok, switch to not showing the menubar when hovering on it
2087  SetSystemUIMode(kUIModeAllHidden, 0);
2088  qt_mac_app_fullscreen = true;
2089  }
2090  }
2091 
2092  if (mb && mb->isNativeMenuBar()) {
2094 #ifdef QT_MAC_USE_COCOA
2096 #endif
2097  if (OSMenuRef menu = mb->macMenu()) {
2098 #ifndef QT_MAC_USE_COCOA
2099  SetRootMenu(menu);
2100 #else
2101  QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
2102  [loader ensureAppMenuInMenu:menu];
2103  [NSApp setMainMenu:menu];
2104  syncMenuBarItemsVisiblity(mb->d_func()->mac_menubar);
2105 
2106  if (OSMenuRef tmpMerge = QMenuPrivate::mergeMenuHash.value(menu)) {
2107  if (QMenuMergeList *mergeList
2108  = QMenuPrivate::mergeMenuItemsHash.value(tmpMerge)) {
2109  const int mergeListSize = mergeList->size();
2110 
2111  for (int i = 0; i < mergeListSize; ++i) {
2112  const QMenuMergeItem &mergeItem = mergeList->at(i);
2113  // Ideally we would call QMenuPrivate::syncAction, but that requires finding
2114  // the original QMen and likely doing more work than we need.
2115  // For example, enabled is handled below.
2116  [mergeItem.menuItem setTag:reinterpret_cast<long>(
2117  static_cast<QAction *>(mergeItem.action->action))];
2118  [mergeItem.menuItem setHidden:!(mergeItem.action->action->isVisible())];
2119  }
2120  }
2121  }
2122 #endif
2123  // Check if menu is modally shaddowed and should be disabled:
2124  modal = qt_mac_should_disable_menu(mb);
2125  if (mb != qt_mac_current_menubar.qmenubar || modal != qt_mac_current_menubar.modal)
2126  qt_mac_set_modal_state(menu, modal);
2127  }
2128  qt_mac_current_menubar.qmenubar = mb;
2129  qt_mac_current_menubar.modal = modal;
2130  ret = true;
2131  } else if (qt_mac_current_menubar.qmenubar && qt_mac_current_menubar.qmenubar->isNativeMenuBar()) {
2132  // INVARIANT: The currently active menu bar (if any) is not native. But we do have a
2133  // native menu bar from before. So we need to decide whether or not is should be enabled:
2134  const bool modal = qt_mac_should_disable_menu(qt_mac_current_menubar.qmenubar);
2135  if (modal != qt_mac_current_menubar.modal) {
2136  ret = true;
2137  if (OSMenuRef menu = qt_mac_current_menubar.qmenubar->macMenu()) {
2138 #ifndef QT_MAC_USE_COCOA
2139  SetRootMenu(menu);
2140 #else
2141  QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
2142  [loader ensureAppMenuInMenu:menu];
2143  [NSApp setMainMenu:menu];
2144  syncMenuBarItemsVisiblity(qt_mac_current_menubar.qmenubar->d_func()->mac_menubar);
2145 #endif
2146  qt_mac_set_modal_state(menu, modal);
2147  }
2148  qt_mac_current_menubar.modal = modal;
2149  }
2150  }
2151 
2152  if (!ret) {
2154  }
2155  return ret;
2156 }
static void cancelAllMenuTracking()
Definition: qmenu_mac.mm:178
static bool qt_mac_should_disable_menu(QMenuBar *menuBar)
Definition: qmenu_mac.mm:1929
static QMenuBar * findMenubarForWindow(QWidget *w)
Definition: qmenu_mac.mm:1989
static void qt_mac_set_modal_state(OSMenuRef menu, bool on)
Definition: qmenu_mac.mm:701
QMacMenuAction * action
Definition: qmenu_p.h:121
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static QHash< OSMenuRef, OSMenuRef > mergeMenuHash
Definition: qmenu_p.h:334
bool isVisible() const
Definition: qaction.cpp:1246
static QWidget * findWindowThatShouldDisplayMenubar()
Definition: qmenu_mac.mm:1970
bool isNativeMenuBar() const
Definition: qmenubar.cpp:2095
static struct @304 qt_mac_current_menubar
MenuRef OSMenuRef
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
#define QT_MANGLE_NAMESPACE(name)
Definition: qglobal.h:106
bool qt_mac_app_fullscreen
bool isFullScreen() const
Definition: qwidget.cpp:3153
OSMenuRef macMenu()
Definition: qmenu_mac.mm:1903
bool modal
Definition: qmenu_mac.mm:99
void qt_mac_clear_menubar()
Definition: qmenu_mac.mm:2015
static QHash< OSMenuRef, QMenuMergeList * > mergeMenuItemsHash
Definition: qmenu_p.h:335
QPointer< QAction > action
Definition: qmenu_p.h:108
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ macWidgetHasNativeMenubar()

bool QMenuBarPrivate::macWidgetHasNativeMenubar ( QWidget widget)

Definition at line 1779 of file qmenu_mac.mm.

Referenced by QMenuBarPrivate::QMacMenuBarPrivate::findAction().

1780 {
1781  // This function is different from q->isNativeMenuBar(), as
1782  // it returns true only if a native menu bar is actually
1783  // _created_.
1784  if (!widget)
1785  return false;
1786  return menubars()->contains(widget->window());
1787 }
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492

◆ menuRect()

QRect QMenuBarPrivate::menuRect ( bool  extVisible) const

Definition at line 136 of file qmenubar.cpp.

137 {
138  Q_Q(const QMenuBar);
139 
140  int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);
141  QRect result = q->rect();
142  result.adjust(hmargin, 0, -hmargin, 0);
143 
144  if (extVisible) {
145  if (q->isRightToLeft())
146  result.setLeft(result.left() + extension->sizeHint().width());
147  else
148  result.setWidth(result.width() - extension->sizeHint().width());
149  }
150 
151  if (leftWidget && leftWidget->isVisible()) {
152  QSize sz = leftWidget->sizeHint();
153  if (q->isRightToLeft())
154  result.setRight(result.right() - sz.width());
155  else
156  result.setLeft(result.left() + sz.width());
157  }
158 
159  if (rightWidget && rightWidget->isVisible()) {
160  QSize sz = rightWidget->sizeHint();
161  if (q->isRightToLeft())
162  result.setLeft(result.left() + sz.width());
163  else
164  result.setRight(result.right() - sz.width());
165  }
166 
167  return result;
168 }
bool isVisible() const
Definition: qwidget.h:1005
QMenuBarExtension * extension
Definition: qmenubar_p.h:169
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
#define Q_Q(Class)
Definition: qglobal.h:2483
QPointer< QWidget > leftWidget
Definition: qmenubar_p.h:168
int width() const
Returns the width.
Definition: qsize.h:126
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:264
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QSize sizeHint
the recommended size for the widget
Definition: qwidget.h:195
QPointer< QWidget > rightWidget
Definition: qmenubar_p.h:168
QSize sizeHint() const
Definition: qmenubar.cpp:117

◆ popupAction()

void QMenuBarPrivate::popupAction ( QAction action,
bool  activateFirst 
)

Definition at line 339 of file qmenubar.cpp.

340 {
341  Q_Q(QMenuBar);
342  if(!action || !action->menu() || closePopupMode)
343  return;
344  popupState = true;
345  if (action->isEnabled() && action->menu()->isEnabled()) {
346  closePopupMode = 0;
347  activeMenu = action->menu();
348  activeMenu->d_func()->causedPopup.widget = q;
349  activeMenu->d_func()->causedPopup.action = action;
350 
351  QRect adjustedActionRect = actionRect(action);
352  QPoint pos(q->mapToGlobal(QPoint(adjustedActionRect.left(), adjustedActionRect.bottom() + 1)));
353  QSize popup_size = activeMenu->sizeHint();
354 
355  //we put the popup menu on the screen containing the bottom-center of the action rect
356  QRect screenRect = QApplication::desktop()->screenGeometry(pos + QPoint(adjustedActionRect.width() / 2, 0));
357  pos = QPoint(qMax(pos.x(), screenRect.x()), qMax(pos.y(), screenRect.y()));
358 
359  const bool fitUp = (q->mapToGlobal(adjustedActionRect.topLeft()).y() >= popup_size.height());
360  const bool fitDown = (pos.y() + popup_size.height() <= screenRect.bottom());
361  const bool rtl = q->isRightToLeft();
362  const int actionWidth = adjustedActionRect.width();
363 
364  if (!fitUp && !fitDown) { //we should shift the menu
365  bool shouldShiftToRight = !rtl;
366  if (rtl && popup_size.width() > pos.x())
367  shouldShiftToRight = true;
368  else if (actionWidth + popup_size.width() + pos.x() > screenRect.right())
369  shouldShiftToRight = false;
370 
371  if (shouldShiftToRight) {
372  pos.rx() += actionWidth + (rtl ? popup_size.width() : 0);
373  } else {
374  //shift to left
375  if (!rtl)
376  pos.rx() -= popup_size.width();
377  }
378  } else if (rtl) {
379  pos.rx() += actionWidth;
380  }
381 
382  if(!defaultPopDown || (fitUp && !fitDown))
383  pos.setY(qMax(screenRect.y(), q->mapToGlobal(QPoint(0, adjustedActionRect.top()-popup_size.height())).y()));
384  activeMenu->popup(pos);
385  if(activateFirst)
386  activeMenu->d_func()->setFirstActionActive();
387  }
388  q->update(actionRect(action));
389 }
bool isEnabled() const
Definition: qaction.cpp:1208
QRect actionRect(QAction *) const
Definition: qmenubar.cpp:289
void popup(const QPoint &pos, QAction *at=0)
Displays the menu so that the action atAction will be at the specified global position p...
Definition: qmenu.cpp:1847
QSize sizeHint() const
Reimplemented Function
Definition: qmenu.cpp:1805
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
#define Q_Q(Class)
Definition: qglobal.h:2483
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
bool isEnabled() const
Definition: qwidget.h:948
QPointer< QMenu > activeMenu
Definition: qmenubar_p.h:144
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
QMenu * menu() const
Returns the menu contained by this action.
Definition: qaction.cpp:793
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
const QRect screenGeometry(int screen=-1) const
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
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
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ setCurrentAction()

void QMenuBarPrivate::setCurrentAction ( QAction action,
bool  popup = false,
bool  activateFirst = false 
)

Definition at line 391 of file qmenubar.cpp.

392 {
393  if(currentAction == action && popup == popupState)
394  return;
395 
397 
398  doChildEffects = (popup && !activeMenu);
399  Q_Q(QMenuBar);
400  QWidget *fw = 0;
401  if(QMenu *menu = activeMenu) {
402  activeMenu = 0;
403  if (popup) {
404  fw = q->window()->focusWidget();
406  }
407  menu->hide();
408  }
409 
410  if(currentAction)
411  q->update(actionRect(currentAction));
412 
413  popupState = popup;
414 #ifndef QT_NO_STATUSTIP
415  QAction *previousAction = currentAction;
416 #endif
417  currentAction = action;
418  if (action) {
420  if(popup)
421  popupAction(action, activateFirst);
422  q->update(actionRect(action));
423 #ifndef QT_NO_STATUSTIP
424  } else if (previousAction) {
425  QString empty;
426  QStatusTipEvent tip(empty);
427  QApplication::sendEvent(q, &tip);
428 #endif
429  }
430  if (fw)
432 }
QBasicTimer autoReleaseTimer
Definition: qmenubar_p.h:186
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
QRect actionRect(QAction *) const
Definition: qmenubar.cpp:289
QPointer< QAction > currentAction
Definition: qmenubar_p.h:136
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
#define Q_Q(Class)
Definition: qglobal.h:2483
void popupAction(QAction *, bool)
Definition: qmenubar.cpp:339
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
QPointer< QMenu > activeMenu
Definition: qmenubar_p.h:144
void stop()
Stops the timer.
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
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
The QStatusTipEvent class provides an event that is used to show messages in a status bar...
Definition: qevent.h:606
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
void activateAction(QAction *, QAction::ActionEvent)
Definition: qmenubar.cpp:530
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64

◆ setKeyboardMode()

void QMenuBarPrivate::setKeyboardMode ( bool  b)

Definition at line 313 of file qmenubar.cpp.

314 {
315  Q_Q(QMenuBar);
316  if (b && !q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, q)) {
317  setCurrentAction(0);
318  return;
319  }
320  keyboardState = b;
321  if(b) {
323  if (fw != q)
324  keyboardFocusWidget = fw;
326  q->setFocus(Qt::MenuBarFocusReason);
327  } else {
328  if(!popupState)
329  setCurrentAction(0);
330  if(keyboardFocusWidget) {
331  if (QApplication::focusWidget() == q)
334  }
335  }
336  q->update();
337 }
QPointer< QWidget > keyboardFocusWidget
Definition: qmenubar_p.h:150
void focusFirstAction()
Definition: qmenubar.cpp:302
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 update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
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
void setCurrentAction(QAction *, bool=false, bool=false)
Definition: qmenubar.cpp:391
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...

◆ updateCornerWidgetToolBar()

void QMenuBarPrivate::updateCornerWidgetToolBar ( )

Definition at line 1935 of file qmenubar.cpp.

1936 {
1937  Q_Q(QMenuBar);
1938  if (!cornerWidgetToolBar) {
1939  QMainWindow *window = qobject_cast<QMainWindow *>(q->window());
1940  if (!window) {
1941  qWarning() << "Menubar parent is not a QMainWindow, not showing corner widgets";
1942  return;
1943  }
1944  cornerWidgetToolBar = window->addToolBar(QApplication::translate("QMenuBar", "Corner Toolbar"));
1945  cornerWidgetToolBar->setObjectName(QLatin1String("CornerToolBar"));
1949  } else {
1951  while (layout->count() > 0) {
1952  layout->takeAt(0);
1953  }
1954  }
1955  if (leftWidget) {
1958  }
1959  if (rightWidget) {
1962  }
1963 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
QWidget * cornerWidgetContainer
Definition: qmenubar_p.h:297
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
QLayout * layout
Definition: qwidget_p.h:704
QToolBar * cornerWidgetToolBar
Definition: qmenubar_p.h:296
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
#define Q_Q(Class)
Definition: qglobal.h:2483
QPointer< QWidget > leftWidget
Definition: qmenubar_p.h:168
NSWindow * window
virtual QLayoutItem * takeAt(int index)=0
Must be implemented in subclasses to remove the layout item at index from the layout, and return the item.
The QLayout class is the base class of geometry managers.
Definition: qlayout.h:90
Q_CORE_EXPORT void qWarning(const char *,...)
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
void addToolBar(Qt::ToolBarArea area, QToolBar *toolbar)
Adds the toolbar into the specified area in this main window.
virtual int count() const =0
Must be implemented in subclasses to return the number of items in the layout.
void addWidget(QWidget *w)
Adds widget w to this layout in a manner specific to the layout.
Definition: qlayout.cpp:319
QAction * addWidget(QWidget *widget)
Adds the given widget to the toolbar as the toolbar&#39;s last item.
Definition: qtoolbar.cpp:973
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
The QHBoxLayout class lines up widgets horizontally.
Definition: qboxlayout.h:129
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
QPointer< QWidget > rightWidget
Definition: qmenubar_p.h:168

◆ updateGeometries()

void QMenuBarPrivate::updateGeometries ( )

Definition at line 175 of file qmenubar.cpp.

176 {
177  Q_Q(QMenuBar);
178  if(!itemsDirty)
179  return;
180  int q_width = q->width()-(q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q)*2);
181  int q_start = -1;
182  if(
183 #ifdef Q_WS_X11
185 #endif
186  (leftWidget || rightWidget)) {
187  int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q)
188  + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);
189  int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q)
190  + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);
191  if (leftWidget && leftWidget->isVisible()) {
192  QSize sz = leftWidget->sizeHint();
193  q_width -= sz.width();
194  q_start = sz.width();
195  QPoint pos(hmargin, (q->height() - leftWidget->height()) / 2);
196  QRect vRect = QStyle::visualRect(q->layoutDirection(), q->rect(), QRect(pos, sz));
197  leftWidget->setGeometry(vRect);
198  }
199  if (rightWidget && rightWidget->isVisible()) {
200  QSize sz = rightWidget->sizeHint();
201  q_width -= sz.width();
202  QPoint pos(q->width() - sz.width() - hmargin, vmargin);
203  QRect vRect = QStyle::visualRect(q->layoutDirection(), q->rect(), QRect(pos, sz));
204  rightWidget->setGeometry(vRect);
205  }
206  }
207 
208 #ifdef Q_WS_MAC
209  if(q->isNativeMenuBar()) {//nothing to see here folks, move along..
210  itemsDirty = false;
211  return;
212  }
213 #endif
214  calcActionRects(q_width, q_start);
215  currentAction = 0;
216 #ifndef QT_NO_SHORTCUT
217  if(
218 #ifdef Q_WS_X11
220 #endif
221  itemsDirty) {
222  for(int j = 0; j < shortcutIndexMap.size(); ++j)
223  q->releaseShortcut(shortcutIndexMap.value(j));
224  shortcutIndexMap.resize(0); // faster than clear
225  for(int i = 0; i < actions.count(); i++)
226  shortcutIndexMap.append(q->grabShortcut(QKeySequence::mnemonic(actions.at(i)->text())));
227  }
228 #endif
229 #ifdef Q_WS_X11
230  if(q->isNativeMenuBar()) {//nothing to see here folks, move along..
231  itemsDirty = false;
232  return;
233  }
234 #endif
235  itemsDirty = false;
236 
238  //this is the menu rectangle without any extension
239  QRect menuRect = this->menuRect(false);
240 
241  //we try to see if the actions will fit there
242  bool hasHiddenActions = false;
243  for (int i = 0; i < actions.count(); ++i) {
244  const QRect &rect = actionRects.at(i);
245  if (rect.isValid() && !menuRect.contains(rect)) {
246  hasHiddenActions = true;
247  break;
248  }
249  }
250 
251  //...and if not, determine the ones that fit on the menu with the extension visible
252  if (hasHiddenActions) {
253  menuRect = this->menuRect(true);
254  for (int i = 0; i < actions.count(); ++i) {
255  const QRect &rect = actionRects.at(i);
256  if (rect.isValid() && !menuRect.contains(rect)) {
258  }
259  }
260  }
261 
262  if (hiddenActions.count() > 0) {
263  QMenu *pop = extension->menu();
264  if (!pop) {
265  pop = new QMenu(q);
266  extension->setMenu(pop);
267  }
268  pop->clear();
270 
271  int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q);
272  int x = q->isRightToLeft()
273  ? menuRect.left() - extension->sizeHint().width() + 1
274  : menuRect.right();
275  extension->setGeometry(x, vmargin, extension->sizeHint().width(), menuRect.height() - vmargin*2);
276  extension->show();
277  } else {
278  extension->hide();
279  }
280  q->updateGeometry();
281 #ifdef QT3_SUPPORT
282  if (parent) {
283  QMenubarUpdatedEvent menubarUpdated(q);
284  QApplication::sendEvent(parent, &menubarUpdated);
285  }
286 #endif
287 }
QPointer< QAction > currentAction
Definition: qmenubar_p.h:136
bool isVisible() const
Definition: qwidget.h:1005
static QKeySequence mnemonic(const QString &text)
Returns the shortcut key sequence for the mnemonic in text, or an empty key sequence if no mnemonics ...
QMenuBarExtension * extension
Definition: qmenubar_p.h:169
QString text
the action&#39;s descriptive text
Definition: qaction.h:76
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
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
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
#define Q_Q(Class)
Definition: qglobal.h:2483
QPointer< QWidget > leftWidget
Definition: qmenubar_p.h:168
QVector< QRect > actionRects
Definition: qmenubar_p.h:130
int width() const
Returns the width.
Definition: qsize.h:126
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
void calcActionRects(int max_width, int start) const
Definition: qmenubar.cpp:434
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
T value(int i) const
Returns the value at index position i in the vector.
Definition: qvector.h:559
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
virtual bool shortcutsHandledByNativeMenuBar() const =0
Return true if the native menubar is capable of listening to the shortcut keys.
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
void clear()
Removes all items from the list.
Definition: qlist.h:764
QList< QAction * > hiddenActions
Definition: qmenubar_p.h:182
void show()
Shows the widget and its child widgets.
void addActions(QList< QAction *> actions)
Appends the actions actions to this widget&#39;s list of actions.
Definition: qwidget.cpp:3327
void clear()
Removes all the menu&#39;s actions.
Definition: qmenu.cpp:1755
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
void hide()
Hides the widget.
Definition: qwidget.h:501
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
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
QAbstractPlatformMenuBar * platformMenuBar
Definition: qmenubar_p.h:191
void setMenu(QMenu *menu)
Associates the given menu with this tool button.
QMenu * menu() const
Returns the associated menu, or 0 if no menu has been defined.
QRect menuRect(bool) const
Definition: qmenubar.cpp:136
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
virtual bool allowCornerWidgets() const =0
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QList< QAction * > actions
Definition: qwidget_p.h:760
QObject * parent
Definition: qobject.h:92
QVector< int > shortcutIndexMap
Definition: qmenubar_p.h:129
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QSize sizeHint
the recommended size for the widget
Definition: qwidget.h:195
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QPointer< QWidget > rightWidget
Definition: qmenubar_p.h:168
QSize sizeHint() const
Definition: qmenubar.cpp:117

◆ wceCommands()

void QMenuBarPrivate::wceCommands ( uint  command)

Definition at line 345 of file qmenu_wince.cpp.

Referenced by QMenuBar::wceCommands().

346 {
347  if (wceClassicMenu) {
348  for (int i = 0; i < wce_menubar->actionItemsClassic.size(); ++i)
350  } else {
351  if (wceEmitSignals(wce_menubar->actionItems, command)) {
352  return;
353  }
354  else if (wce_menubar->leftButtonIsMenu) {//check if command is on the left quick button
356  }
357  else if ((wce_menubar->leftButtonAction) && (command == wce_menubar->leftButtonCommand)) {
358  emit q_func()->triggered(wce_menubar->leftButtonAction);
360  }
361  }
362 }
QList< QList< QWceMenuAction * > > actionItemsClassic
Definition: qmenubar_p.h:228
struct QMenuBarPrivate::QWceMenuBarPrivate * wce_menubar
QList< QWceMenuAction * > actionItems
Definition: qmenubar_p.h:226
void activate(ActionEvent event)
Sends the relevant signals for ActionEvent event.
Definition: qaction.cpp:1326
QList< QWceMenuAction * > actionItemsLeftButton
Definition: qmenubar_p.h:227
bool wceEmitSignals(QList< QWceMenuAction *> actions, uint command)
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
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QPointer< QAction > leftButtonAction
Definition: qmenubar_p.h:234

◆ wceCreateMenuBar()

void QMenuBarPrivate::wceCreateMenuBar ( QWidget parent)

Definition at line 384 of file qmenu_wince.cpp.

Referenced by QMenuBarPrivate::QMacMenuBarPrivate::findAction().

385 {
386  Q_Q(QMenuBar);
387  wce_menubar = new QWceMenuBarPrivate(this);
388 
389  wce_menubar->parentWindowHandle = parent ? parent->winId() : q->winId();
391 
393  Q_ASSERT_X(wce_menubar->menubarHandle, "wceCreateMenuBar", "cannot create empty menu bar");
394  DrawMenuBar(wce_menubar->menubarHandle);
395  nativeMenuBars.append(q);
397 }
struct QMenuBarPrivate::QWceMenuBarPrivate * wce_menubar
#define SHCMBF_EMPTYBAR
Definition: qmenu_wince.cpp:70
bool qt_wince_is_pocket_pc()
#define Q_Q(Class)
Definition: qglobal.h:2483
static QList< QMenuBar * > nativeMenuBars
Definition: qmenu_wince.cpp:89
static HWND qt_wce_create_menubar(HWND parentHandle, HINSTANCE resourceHandle, int toolbarID, int flags=0)
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
QPointer< QAction > defaultAction
Definition: qmenubar_p.h:184
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
Q_CORE_EXPORT HINSTANCE qWinAppInst()
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557
QPointer< QAction > leftButtonAction
Definition: qmenubar_p.h:234
bool qt_wince_is_smartphone()

◆ wceDestroyMenuBar()

void QMenuBarPrivate::wceDestroyMenuBar ( )

Definition at line 399 of file qmenu_wince.cpp.

Referenced by QMenuBarPrivate::QMacMenuBarPrivate::findAction().

400 {
401  Q_Q(QMenuBar);
402  int index = nativeMenuBars.indexOf(q);
403  nativeMenuBars.removeAt(index);
404  if (wce_menubar) {
405  delete wce_menubar;
406  wce_menubar = 0;
407  }
408 }
struct QMenuBarPrivate::QWceMenuBarPrivate * wce_menubar
#define Q_Q(Class)
Definition: qglobal.h:2483
static QList< QMenuBar * > nativeMenuBars
Definition: qmenu_wince.cpp:89
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
quint16 index

◆ wceEmitSignals()

bool QMenuBarPrivate::wceEmitSignals ( QList< QWceMenuAction *>  actions,
uint  command 
)

Definition at line 323 of file qmenu_wince.cpp.

324 {
325  QAction *foundAction = 0;
326  for (int i = 0; i < actions.size(); ++i) {
327  QWceMenuAction *action = actions.at(i);
328  if (action->action->menu()) {
329  foundAction = action->action->menu()->wceCommands(command);
330  if (foundAction)
331  break;
332  }
333  else if (action->command == command) {
334  action->action->activate(QAction::Trigger);
335  return true;
336  }
337  }
338  if (foundAction) {
339  emit q_func()->triggered(foundAction);
340  return true;
341  }
342  return false;
343 }
void activate(ActionEvent event)
Sends the relevant signals for ActionEvent event.
Definition: qaction.cpp:1326
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

◆ wceRefresh()

void QMenuBarPrivate::wceRefresh ( )

Definition at line 283 of file qmenu_wince.cpp.

284 {
285  DrawMenuBar(wce_menubar->menubarHandle);
286 }
struct QMenuBarPrivate::QWceMenuBarPrivate * wce_menubar

Properties

◆ actionRects

QVector<QRect> QMenuBarPrivate::actionRects
mutable

Definition at line 130 of file qmenubar_p.h.

◆ activeMenu

QPointer<QMenu> QMenuBarPrivate::activeMenu

Definition at line 144 of file qmenubar_p.h.

◆ altPressed

uint QMenuBarPrivate::altPressed

Definition at line 149 of file qmenubar_p.h.

◆ autoReleaseTimer

QBasicTimer QMenuBarPrivate::autoReleaseTimer

Definition at line 186 of file qmenubar_p.h.

◆ closePopupMode

uint QMenuBarPrivate::closePopupMode

Definition at line 137 of file qmenubar_p.h.

◆ cornerWidgetContainer

QWidget* QMenuBarPrivate::cornerWidgetContainer

Definition at line 297 of file qmenubar_p.h.

◆ cornerWidgetToolBar

QToolBar* QMenuBarPrivate::cornerWidgetToolBar

Definition at line 296 of file qmenubar_p.h.

◆ currentAction

QPointer<QAction> QMenuBarPrivate::currentAction

Definition at line 136 of file qmenubar_p.h.

◆ defaultAction

QPointer<QAction> QMenuBarPrivate::defaultAction

Definition at line 184 of file qmenubar_p.h.

◆ defaultPopDown

uint QMenuBarPrivate::defaultPopDown

Definition at line 137 of file qmenubar_p.h.

◆ doChildEffects

bool QMenuBarPrivate::doChildEffects

Definition at line 173 of file qmenubar_p.h.

◆ extension

QMenuBarExtension* QMenuBarPrivate::extension

Definition at line 169 of file qmenubar_p.h.

◆ hiddenActions

QList<QAction*> QMenuBarPrivate::hiddenActions

Definition at line 182 of file qmenubar_p.h.

◆ itemsDirty

uint QMenuBarPrivate::itemsDirty

Definition at line 127 of file qmenubar_p.h.

◆ keyboardFocusWidget

QPointer<QWidget> QMenuBarPrivate::keyboardFocusWidget

Definition at line 150 of file qmenubar_p.h.

◆ keyboardState

uint QMenuBarPrivate::keyboardState

Definition at line 149 of file qmenubar_p.h.

◆ leftWidget

QPointer<QWidget> QMenuBarPrivate::leftWidget

Definition at line 168 of file qmenubar_p.h.

◆ mac_menubar

struct QMenuBarPrivate::QMacMenuBarPrivate * QMenuBarPrivate::mac_menubar

◆ mouseDown

uint QMenuBarPrivate::mouseDown

Definition at line 137 of file qmenubar_p.h.

◆ oldParent

QWidget* QMenuBarPrivate::oldParent

Definition at line 179 of file qmenubar_p.h.

◆ oldWindow

QWidget* QMenuBarPrivate::oldWindow

Definition at line 180 of file qmenubar_p.h.

◆ platformMenuBar

QAbstractPlatformMenuBar* QMenuBarPrivate::platformMenuBar

Definition at line 191 of file qmenubar_p.h.

Referenced by ~QMenuBarPrivate().

◆ popupState

uint QMenuBarPrivate::popupState

Definition at line 143 of file qmenubar_p.h.

◆ rightWidget

QPointer<QWidget> QMenuBarPrivate::rightWidget

Definition at line 168 of file qmenubar_p.h.

◆ shortcutIndexMap

QVector<int> QMenuBarPrivate::shortcutIndexMap

Definition at line 129 of file qmenubar_p.h.

◆ wce_menubar

struct QMenuBarPrivate::QWceMenuBarPrivate * QMenuBarPrivate::wce_menubar

◆ wceClassicMenu

bool QMenuBarPrivate::wceClassicMenu

Definition at line 256 of file qmenubar_p.h.


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