54 #ifndef QT_NO_ACCESSIBILITY 58 # include <private/qeffects_p.h> 60 #ifndef QT_NO_WHATSTHIS 69 #include <private/qpushbutton_p.h> 70 #include <private/qaction_p.h> 71 #include <private/qsoftkeymanager_p.h> 77 # include <private/qt_x11_p.h> 80 #if defined(Q_WS_MAC) && !defined(QT_NO_EFFECTS) 81 # include <private/qcore_mac_p.h> 82 # include <private/qt_cocoa_helpers_mac_p.h> 86 # include "private/qt_s60_p.h" 129 for(
int i = 0; i < items.count(); i++)
135 if(menu !=
d->causedMenu)
158 #ifndef QT_NO_WHATSTHIS 170 #ifdef QT_SOFTKEYS_ENABLED 175 q->addAction(selectAction);
176 q->addAction(cancelAction);
180 if (S60->avkonComponentsSupportTransparency) {
199 #elif defined Q_WS_X11 214 #elif defined Q_WS_X11 230 ret += qtmenu->d_func()->causedStack;
232 widget = qmenu->d_func()->causedPopup.widget;
259 int max_column_width = 0,
293 bool previousWasSeparator =
true;
294 for(
int i = 0; i <= lastVisibleAction; i++) {
305 q->initStyleOption(&opt, action);
310 sz = w->sizeHint().
expandedTo(w->minimumSize()).expandedTo(w->minimumSizeHint()).boundedTo(w->maximumSize());
321 #ifndef QT_NO_SHORTCUT 343 max_column_width =
qMax(max_column_width, sz.
width());
346 y+sz.
height()+vmargin > dh - (deskFw * 2)) {
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);
362 const int base_y = vmargin + fw +
topmargin +
373 y+rect.
height() > dh - deskFw * 2) {
374 x += max_column_width + hmargin;
406 for (;lastVisibleAction >= 0; --lastVisibleAction) {
415 return lastVisibleAction;
431 #if defined(Q_WS_MAC) 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);
450 if (
QMenu *m = qobject_cast<QMenu*>(caused)) {
451 caused = m->d_func()->causedPopup.widget;
452 if (!m->d_func()->tornoff)
455 m->d_func()->setCurrentAction(0);
459 #if defined(Q_WS_MAC) 475 #if !defined(QT_NO_EFFECTS) 501 #if defined(Q_WS_MAC) 513 #endif // QT_NO_EFFECTS 523 q->internalDelayedPopup();
526 if (activateFirst && action->
menu())
527 action->
menu()->d_func()->setFirstActionActive();
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;
597 #ifndef QT_NO_STATUSTIP 601 emitHighlighted = action;
627 if (!q->hasFocus()) {
636 #ifndef QT_NO_STATUSTIP 637 }
else if (previousAction) {
641 if (hideActiveMenu) {
643 #ifndef QT_NO_EFFECTS 656 while (
QMenu* m = qobject_cast<QMenu *>(top))
657 top = m->d_func()->causedPopup.widget;
663 if (!q_func()->
rect().contains(p))
713 return d_func()->menuAction;
729 return d_func()->menuAction->text();
734 d_func()->menuAction->setText(text);
751 return d_func()->menuAction->icon();
756 d_func()->menuAction->setIcon(icon);
776 newOffset = topScroll - saccum;
786 newOffset = ((q->height() / 2) - botScroll) - (saccum - topScroll);
788 newOffset = (q->height() - botScroll) - saccum;
800 int saccum = newOffset;
803 if (saccum > q->height()) {
810 newOffset = q->height() - (saccum - newOffset) - fw*2 - vmargin;
817 if (newScrollFlags & QMenuScroller::ScrollUp)
818 newOffset -= vmargin;
822 if (q->height() < screen.
height()-(desktopFrame*2)-1) {
823 QRect geom = q->geometry();
826 if(newHeight > geom.
height())
830 if (newTop < desktopFrame+screen.
top())
831 newTop = desktopFrame+screen.
top();
832 if (newTop < geom.
top()) {
840 if (geom.
top() < desktopFrame+screen.
top())
842 if (geom != q->geometry()) {
844 if (newScrollFlags & QMenuScroller::ScrollDown &&
845 q->geometry().top() - geom.
top() >= -newOffset)
846 newScrollFlags &= ~QMenuScroller::ScrollDown;
848 q->setGeometry(geom);
862 w->setGeometry(current);
921 const int offset = topScroll ? topScroll-vmargin : 0;
925 if (saccum <= scroll->scrollOffset-offset) {
931 bool scrolled =
false;
935 if (saccum <= scroll->scrollOffset-offset) {
936 const int scrollerArea = q->height() - botScroll - fw*2;
940 if (visible > scrollerArea - topScroll) {
963 bool isScroll =
false;
964 if (pos.
x() >= 0 && pos.
x() < q->width()) {
1006 if (q->frameGeometry().contains(e->
globalPos()))
1010 bool passOnEvent =
false;
1013 #ifndef QT_NO_MENUBAR 1014 if (
QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
1015 passOnEvent = mb->rect().contains(cpos);
1018 if (
QMenu *m = qobject_cast<QMenu*>(caused)) {
1019 passOnEvent = m->rect().contains(cpos);
1020 next_widget = m->d_func()->causedPopup.widget;
1031 caused = next_widget;
1040 const int actionId = q_func()->findIdForAction(action);
1050 if (
QMenu *qmenu = qobject_cast<QMenu*>(widget)) {
1051 widget = qmenu->d_func()->causedPopup.widget;
1053 emit qmenu->triggered(action);
1055 emit qmenu->hovered(action);
1057 if (emitHighlighted) {
1058 emit qmenu->highlighted(actionId);
1059 emitHighlighted =
false;
1063 #ifndef QT_NO_MENUBAR 1073 if (emitHighlighted) {
1075 emitHighlighted =
false;
1088 #ifndef QT_NO_WHATSTHIS 1093 #ifndef QT_NO_WHATSTHIS 1104 #ifndef QT_NO_WHATSTHIS 1105 if (!inWhatsThisMode)
1113 if (
QMenu *qmenu = qobject_cast<QMenu*>(
widget)) {
1116 widget = qmenu->d_func()->causedPopup.widget;
1123 #ifndef QT_NO_WHATSTHIS 1124 if (inWhatsThisMode) {
1139 #ifndef QT_NO_ACCESSIBILITY 1141 int actionIndex =
indexOf(action) + 1;
1155 if (
QAction *action = qobject_cast<QAction *>(q->sender())) {
1159 const int id = q->findIdForAction(action);
1161 emit q->triggered(action);
1163 emit q->activated(
id);
1171 if (qobject_cast<QMenu*>(
widget)
1172 #ifndef QT_NO_MENUBAR 1190 if (
QAction * action = qobject_cast<QAction *>(q->sender())) {
1193 const int id = q->findIdForAction(action);
1195 emit q->hovered(action);
1197 if (emitHighlighted) {
1198 emit q->highlighted(
id);
1199 emitHighlighted =
false;
1224 if (!option || !action)
1243 if (
d->currentAction &&
d->currentAction == action && !
d->currentAction->isSeparator()) {
1260 else if (
d->defaultAction == action)
1267 #ifndef QT_NO_SHORTCUT 1274 option->
text = textAndAccel;
1407 d->menuAction->setText(title);
1425 if (!
d->widgetItems.isEmpty()) {
1427 for (; it !=
d->widgetItems.end(); ++
it) {
1437 d->eventLoop->exit();
1496 #ifdef QT_NO_SHORTCUT 1524 #ifdef QT_NO_SHORTCUT 1629 d_func()->defaultAction = act;
1639 return d_func()->defaultAction;
1661 if (
d->tearoff == b)
1667 d->itemsDirty =
true;
1674 return d_func()->tearoff;
1686 if (d_func()->tornPopup)
1687 return d_func()->tornPopup->isVisible();
1699 if (
QWidget *w = d_func()->tornPopup)
1710 d->setCurrentAction(act, 0);
1722 return d_func()->currentAction;
1759 for(
int i = 0; i < acts.
size(); i++) {
1760 #ifdef QT_SOFTKEYS_ENABLED 1763 if(acts[i] ==
d->selectAction || acts[i] ==
d->cancelAction)
1767 if (acts[i]->
parent() ==
this && acts[i]->d_func()->widgets.
isEmpty())
1781 return d_func()->ncols;
1799 return d_func()->actionRect(act);
1808 d->updateActionRects();
1811 for (
int i = 0; i <
d->actionRects.count(); ++i) {
1850 #ifndef Q_OS_SYMBIAN 1852 if (
d->scroll->scrollOffset)
1854 d->scroll->scrollOffset = 0;
1858 d->tearoffHighlighted = 0;
1860 d->doChildEffects =
true;
1861 d->updateLayoutDirection();
1863 #ifndef QT_NO_MENUBAR 1871 const bool actionListChanged =
d->itemsDirty;
1872 d->updateActionRects();
1875 if (actionListChanged && causedButton)
1882 #ifndef QT_NO_GRAPHICSVIEW 1885 screen =
d->popupGeometry(
this);
1894 size =
d->adjustMenuSizeForScreen(screen);
1895 adjustToDesktop =
true;
1899 size =
d->adjustMenuSizeForScreen(screen);
1900 adjustToDesktop =
true;
1904 #ifdef QT_KEYPAD_NAVIGATION 1905 if (!atAction && QApplication::keypadNavigationEnabled()) {
1907 if (
d->defaultAction &&
d->defaultAction->isEnabled()) {
1908 atAction =
d->defaultAction;
1911 foreach (
QAction *action,
d->actions)
1917 d->currentAction = atAction;
1921 pos.
setY(screen.
top() + desktopFrame);
1922 }
else if (atAction) {
1923 for (
int i = 0, above_height = 0; i <
d->actions.count(); i++) {
1924 QAction *action =
d->actions.at(i);
1925 if (action == atAction) {
1926 int newY = pos.
y() - above_height;
1927 if (
d->scroll && newY < desktopFrame) {
1928 d->scroll->scrollFlags =
d->scroll->scrollFlags
1930 d->scroll->scrollOffset = newY;
1931 newY = desktopFrame;
1937 int below_height = above_height +
d->scroll->scrollOffset;
1938 for (
int i2 = i; i2 <
d->actionRects.count(); i2++)
1939 below_height +=
d->actionRects.at(i2).height();
1944 above_height +=
d->actionRects.at(i).height();
1950 d->mousePopupPos = mouse;
1951 const bool snapToMouse = !
d->causedPopup.widget && (
QRect(p.
x() - 3, p.
y() - 3, 6, 6).contains(mouse));
1954 if (adjustToDesktop) {
1960 #ifndef QT_NO_MENUBAR 1962 if (qobject_cast<QMenuBar*>(
d->causedPopup.widget))
1964 #endif //QT_NO_MENUBAR 1966 if (pos.
x() < screen.
left() + desktopFrame)
1968 if (pos.
x() + size.
width() - 1 > screen.
right() - desktopFrame)
1971 if (pos.
x() + size.
width() - 1 > screen.
right() - desktopFrame)
1973 if (pos.
x() < screen.
left() + desktopFrame)
1974 pos.
setX(screen.
left() + desktopFrame);
1976 if (pos.
y() + size.
height() - 1 > screen.
bottom() - desktopFrame) {
1981 }
else if (pos.
y() < screen.
top() + desktopFrame) {
1982 pos.
setY(screen.
top() + desktopFrame);
1985 if (pos.
y() < screen.
top() + desktopFrame)
1986 pos.
setY(screen.
top() + desktopFrame);
1987 if (pos.
y() + menuSize.
height() - 1 > screen.
bottom() - desktopFrame) {
1990 int y =
qMax(screen.
y(),pos.
y());
2001 QRect parentActionRect(caused->d_func()->actionRect(caused->d_func()->currentAction));
2005 if ((pos.
x() + menuSize.
width() > parentActionRect.
left() - subMenuOffset)
2006 && (pos.
x() < parentActionRect.
right()))
2008 pos.
rx() = parentActionRect.
left() - menuSize.
width();
2009 if (pos.
x() < screen.
x())
2010 pos.
rx() = parentActionRect.
right();
2011 if (pos.
x() + menuSize.
width() > screen.
x() + screen.
width())
2012 pos.
rx() = screen.
x();
2015 if ((pos.
x() < parentActionRect.
right() + subMenuOffset)
2016 && (pos.
x() + menuSize.
width() > parentActionRect.
left()))
2018 pos.
rx() = parentActionRect.
right();
2019 if (pos.
x() + menuSize.
width() > screen.
x() + screen.
width())
2020 pos.
rx() = parentActionRect.
left() - menuSize.
width();
2021 if (pos.
x() < screen.
x())
2027 #ifndef QT_NO_EFFECTS 2031 if ((snapToMouse && (pos.
x() + size.
width() / 2 > mouse.
x())) ||
2035 if ((snapToMouse && (pos.
x() + size.
width() / 2 < mouse.
x())) ||
2040 #ifndef QT_NO_MENUBAR 2041 if ((snapToMouse && (pos.
y() + size.
height() / 2 < mouse.
y())) ||
2043 pos.
y() + size.
width() / 2 <
d->causedPopup.widget->mapToGlobal(
d->causedPopup.widget->pos()).
y()))
2047 bool doChildEffects =
true;
2048 #ifndef QT_NO_MENUBAR 2049 if (
QMenuBar *mb = qobject_cast<QMenuBar*>(
d->causedPopup.widget)) {
2050 doChildEffects = mb->d_func()->doChildEffects;
2051 mb->d_func()->doChildEffects =
false;
2054 if (
QMenu *m = qobject_cast<QMenu*>(
d->causedPopup.widget)) {
2055 doChildEffects = m->d_func()->doChildEffects;
2056 m->d_func()->doChildEffects =
false;
2059 if (doChildEffects) {
2062 else if (
d->causedPopup.widget)
2063 qScrollEffect(
this, qobject_cast<QMenu*>(
d->causedPopup.widget) ? hGuess : vGuess);
2079 #ifndef QT_NO_ACCESSIBILITY 2147 d->eventLoop = &eventLoop;
2151 (void) eventLoop.
exec();
2155 action =
d->syncAction;
2190 return menu.
exec(pos, at);
2218 return exec(actions, pos, at, 0);
2229 d->eventLoop->exit();
2230 d->setCurrentAction(0);
2231 #ifndef QT_NO_ACCESSIBILITY 2234 #ifndef QT_NO_MENUBAR 2235 if (
QMenuBar *mb = qobject_cast<QMenuBar*>(
d->causedPopup.widget))
2236 mb->d_func()->setCurrentAction(0);
2239 d->hasHadMouse =
false;
2240 d->causedPopup.widget = 0;
2241 d->causedPopup.action = 0;
2243 d->scroll->scrollTimer.stop();
2252 d->updateActionRects();
2265 for (
int i = 0; i <
d->actions.count(); ++i) {
2266 QAction *action =
d->actions.at(i);
2267 QRect adjustedActionRect =
d->actionRects.at(i);
2269 ||
d->widgetItems.value(action))
2272 QRegion adjustedActionReg(adjustedActionRect);
2273 emptyArea -= adjustedActionReg;
2278 opt.
rect = adjustedActionRect;
2295 d->scrollerHeight());
2312 if (
d->tearoffHighlighted)
2324 emptyArea -= borderReg;
2344 #ifndef QT_NO_WHEELEVENT 2351 if (
d->scroll &&
rect().contains(e->
pos()))
2352 d->scrollMenu(e->
delta() > 0 ?
2363 if (
d->aboutToHide ||
d->mouseEventTaken(e))
2371 d->hideUpToMenuBar();
2374 d->mouseDown =
this;
2377 d->setCurrentAction(action, 20);
2387 if (
d->aboutToHide ||
d->mouseEventTaken(e))
2389 if(
d->mouseDown !=
this) {
2398 if (action && action ==
d->currentAction) {
2399 if (!action->
menu()){
2400 #if defined(Q_WS_WIN) 2406 }
else if (
d->hasMouseMoved(e->
globalPos())) {
2407 d->hideUpToMenuBar();
2426 }
else if (!
d->scroll) {
2434 #if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) 2450 switch (e->
type()) {
2452 d->updateLayoutDirection();
2473 if(
d->menuDelayTimer.isActive()) {
2474 d->menuDelayTimer.stop();
2486 d->updateActionRects();
2490 d->updateActionRects();
2491 if (
d->currentAction)
2492 d->popupAction(
d->currentAction, 0,
false);
2494 #ifndef QT_NO_WHATSTHIS 2497 if (
QAction *action =
d->actionAt(static_cast<QHelpEvent*>(e)->pos())) {
2498 if (action->whatsThis().size() || action->menu())
2503 #ifdef QT_SOFTKEYS_ENABLED 2533 d->updateActionRects();
2548 bool key_consumed =
false;
2551 key_consumed =
true;
2556 key_consumed =
true;
2561 key_consumed =
true;
2562 if (
d->currentAction &&
d->scroll) {
2570 key_consumed =
true;
2571 if (
d->currentAction &&
d->scroll) {
2580 key_consumed =
true;
2583 if (!
d->currentAction) {
2585 for(
int i = 0; i <
d->actions.count(); ++i) {
2587 if (
d->actionRects.at(i).isNull())
2597 for(
int i =
d->actions.count()-1; i >= 0; --i) {
2599 if (
d->actionRects.at(i).isNull())
2610 for(
int i = 0,
y = 0; !nextAction && i <
d->actions.count(); i++) {
2612 if (act ==
d->currentAction) {
2614 for(
int next_i = i-1;
true; next_i--) {
2620 next_i =
d->actionRects.count()-1;
2622 QAction *next =
d->actions.at(next_i);
2623 if (next ==
d->currentAction)
2625 if (
d->actionRects.at(next_i).isNull())
2633 int topVisible =
d->scrollerHeight();
2636 if (((
y +
d->scroll->scrollOffset) - topVisible) <=
d->actionRects.at(next_i).height())
2641 if (!nextAction &&
d->tearoff)
2642 d->tearoffHighlighted = 1;
2644 y +=
d->actionRects.at(i).height();
2645 for(
int next_i = i+1;
true; next_i++) {
2646 if (next_i ==
d->actionRects.count()) {
2653 QAction *next =
d->actions.at(next_i);
2654 if (next ==
d->currentAction)
2656 if (
d->actionRects.at(next_i).isNull())
2664 int bottomVisible =
height() -
d->scrollerHeight();
2666 bottomVisible -=
d->scrollerHeight();
2669 if ((
y +
d->scroll->scrollOffset +
d->actionRects.at(next_i).height()) > bottomVisible)
2677 y +=
d->actionRects.at(i).height();
2682 d->scroll->scrollTimer.stop();
2683 d->scrollMenu(nextAction, scroll_loc);
2690 if (
d->currentAction &&
d->currentAction->isEnabled() &&
d->currentAction->menu()) {
2691 d->popupAction(
d->currentAction, 0,
true);
2692 key_consumed =
true;
2697 if (
d->currentAction && !
d->scroll) {
2700 QRect actionR =
d->actionRect(
d->currentAction);
2701 for(
int x = actionR.
left()-1; !nextAction &&
x >= 0; x--)
2704 QRect actionR =
d->actionRect(
d->currentAction);
2705 for(
int x = actionR.
right()+1; !nextAction &&
x <
width();
x++)
2710 key_consumed =
true;
2713 if (!key_consumed && key ==
Qt::Key_Left && qobject_cast<QMenu*>(
d->causedPopup.widget)) {
2718 key_consumed =
true;
2726 key_consumed =
true;
2730 #ifndef QT_NO_MENUBAR 2732 mb->d_func()->setKeyboardMode(
false);
2739 #ifdef QT_KEYPAD_NAVIGATION 2742 key_consumed =
true;
2750 #ifndef QT_NO_MENUBAR 2751 if (
QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
2752 mb->d_func()->setCurrentAction(
d->menuAction);
2753 mb->d_func()->setKeyboardMode(
true);
2763 #ifdef QT_KEYPAD_NAVIGATION 2768 if (!
d->currentAction) {
2769 d->setFirstActionActive();
2770 key_consumed =
true;
2776 if (
d->currentAction->menu())
2777 d->popupAction(
d->currentAction, 0,
true);
2780 key_consumed =
true;
2783 #ifndef QT_NO_WHATSTHIS 2785 if (!
d->currentAction ||
d->currentAction->whatsThis().isNull())
2792 key_consumed =
false;
2795 if (!key_consumed) {
2798 bool activateAction =
false;
2801 int best_match_count = 0;
2802 d->searchBufferTimer.start(2000,
this);
2803 d->searchBuffer += e->
text();
2804 for(
int i = 0; i <
d->actions.size(); ++i) {
2805 int match_count = 0;
2806 if (
d->actionRects.at(i).isNull())
2810 for(
int c = 0;
c <
d->searchBuffer.size(); ++
c) {
2814 if(match_count > best_match_count) {
2815 best_match_count = match_count;
2820 #ifndef QT_NO_SHORTCUT 2823 QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0;
2825 for(
int i = 0; i <
d->actions.size(); ++i) {
2826 if (
d->actionRects.at(i).isNull())
2830 int key = sequence[0] & 0xffff;
2835 if (act ==
d->currentAction)
2836 currentSelected = act;
2837 else if (!firstAfterCurrent && currentSelected)
2838 firstAfterCurrent = act;
2841 if (clashCount == 1)
2842 activateAction =
true;
2843 if (clashCount >= 1) {
2844 if (clashCount == 1 || !currentSelected || !firstAfterCurrent)
2847 nextAction = firstAfterCurrent;
2852 key_consumed =
true;
2856 if (!nextAction->
menu() && activateAction) {
2862 if (!key_consumed) {
2863 #ifndef QT_NO_MENUBAR 2864 if (
QMenuBar *mb = qobject_cast<QMenuBar*>(
d->topCausedWidget())) {
2865 QAction *oldAct = mb->d_func()->currentAction;
2867 if (mb->d_func()->currentAction != oldAct)
2868 key_consumed =
true;
2876 #endif // Q_OS_WIN32 2890 if (!
isVisible() ||
d->aboutToHide ||
d->mouseEventTaken(e))
2893 if (
d->motions == 0)
2900 &&
d->sloppyDelayTimer == 0
2901 && (!
d->currentAction || (action && action->
isSeparator())
2902 || !(
d->currentAction->menu() &&
d->currentAction->menu()->isVisible())))
2903 d->setCurrentAction(0);
2906 d->mouseDown =
this;
2908 if (
d->sloppyRegion.contains(e->
pos())) {
2909 if (
d->sloppyAction != action &&
d->sloppyDelayTimer != 0) {
2911 d->sloppyDelayTimer = 0;
2913 if (
d->sloppyDelayTimer == 0) {
2914 d->sloppyAction = action;
2917 }
else if (action !=
d->currentAction) {
2927 d_func()->motions = -1;
2936 d->sloppyAction = 0;
2937 if (!
d->sloppyRegion.isEmpty())
2939 if (!
d->activeMenu &&
d->currentAction)
2950 if (
d->scroll &&
d->scroll->scrollTimer.timerId() == e->
timerId()) {
2953 d->scroll->scrollTimer.stop();
2954 }
else if(
d->menuDelayTimer.timerId() == e->
timerId()) {
2955 d->menuDelayTimer.stop();
2957 }
else if (
d->sloppyDelayTimer == e->
timerId()) {
2959 d->sloppyDelayTimer = 0;
2961 }
else if(
d->searchBufferTimer.timerId() == e->
timerId()) {
2962 d->searchBuffer.clear();
2975 d->tornPopup->syncWithMenu(
this, e);
2984 d->widgetItems.insert(wa, widget);
2988 if (e->
action() ==
d->currentAction)
2989 d->currentAction = 0;
2992 wa->releaseWidget(
widget);
2994 d->widgetItems.remove(e->
action());
3000 d->mac_menu->addAction(e->
action(),
d->mac_menu->findAction(e->
before()),
d);
3002 d->mac_menu->removeAction(e->
action());
3004 d->mac_menu->syncAction(e->
action());
3008 #if defined(Q_WS_WINCE) && !defined(QT_NO_MENUBAR) 3012 d->wce_menu->addAction(e->
action(),
d->wce_menu->findAction(e->
before()));
3014 d->wce_menu->removeAction(e->
action());
3016 d->wce_menu->syncAction(e->
action());
3020 if (!
d->symbian_menu)
3021 d->symbian_menu =
new QMenuPrivate::QSymbianMenuPrivate;
3023 d->symbian_menu->addAction(e->
action(),
d->symbian_menu->findAction(e->
before()));
3025 d->symbian_menu->removeAction(e->
action());
3027 d->symbian_menu->syncAction(e->
action());
3030 d->updateActionRects();
3041 if (d_func()->sloppyAction)
3042 d_func()->setCurrentAction(d_func()->sloppyAction, 0);
3053 if (
QMenu *menu =
d->activeMenu) {
3058 if (!
d->currentAction || !
d->currentAction->isEnabled() || !
d->currentAction->menu() ||
3059 !
d->currentAction->menu()->isEnabled() ||
d->currentAction->menu()->isVisible())
3063 d->activeMenu =
d->currentAction->menu();
3064 d->activeMenu->d_func()->causedPopup.widget =
this;
3065 d->activeMenu->d_func()->causedPopup.action =
d->currentAction;
3068 const QRect actionRect(
d->actionRect(
d->currentAction));
3069 const QSize menuSize(
d->activeMenu->sizeHint());
3079 pts[0] =
QPoint(cur.
x(), cur.
y() - 2);
3080 pts[3] =
QPoint(cur.
x(), cur.
y() + 2);
3081 if (pos.x() >= cur.
x()) {
3085 pts[1] =
QPoint(pos.x() + menuSize.width(), pos.y());
3086 pts[2] =
QPoint(pos.x() + menuSize.width(), pos.y() + menuSize.height());
3089 for(
int i = 0; i < 4; i++)
3096 d->activeMenu->popup(pos);
3167 d_func()->noReplayFor = noReplayFor;
3191 return d->collapsibleSeparators;
3197 if (
d->collapsibleSeparators == collapse)
3200 d->collapsibleSeparators = collapse;
3203 d->updateActionRects();
3208 d->syncSeparatorsCollapsible(collapse);
3219 static_cast<QMenuItem*
>(act)->setId(
id);
3226 if (receiver && member)
3228 if (index == -1 || index >=
actions().count())
3232 return findIdForAction(act);
3238 int QMenu::insertItem(QMenuItem *item,
int id,
int index)
3240 if (index == -1 || index >=
actions().count())
3245 item->d_func()->id = id;
3246 return findIdForAction(item);
3257 if (index == -1 || index >=
actions().count())
3261 return findIdForAction(act);
3264 QAction *QMenu::findActionForId(
int id)
const 3267 for (
int i = 0; i <
d->actions.size(); ++i) {
3269 if (findIdForAction(act)==
id)
3278 QMenuItem *QMenu::findPopup(
QMenu *popup,
int *
index )
3281 for (
int i = 0; i < list.
size(); ++i) {
3284 QMenuItem *item =
static_cast<QMenuItem *
>(act);
3286 *index = act->d_func()->id;
3297 bool QMenu::setItemParameter(
int id,
int param)
3299 if (
QAction *act = findActionForId(
id)) {
3300 act->d_func()->param = param;
3309 int QMenu::itemParameter(
int id)
const 3311 if (
QAction *act = findActionForId(
id))
3312 return act->d_func()->param;
3319 void QMenu::setId(
int index,
int id)
3322 act->d_func()->id = id;
3328 int QMenu::frameWidth()
const 3333 int QMenu::findIdForAction(
QAction *act)
const 3337 return act->d_func()->id;
3339 #endif // QT3_SUPPORT 3755 #include "moc_qmenu.cpp" 3756 #include "qmenu.moc" 3758 #endif // QT_NO_MENU
bool isSeparator() const
Returns true if this action is a separator action; otherwise it returns false.
int startTimer(int interval)
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer...
The QPainter class performs low-level painting on widgets and other paint devices.
QAction * before() const
If type() is ActionAdded , returns the action that should appear before action(). ...
static Qt::LayoutDirection layoutDirection()
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object's accessibility information.
bool blockSignals(bool b)
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke...
The QKeyEvent class describes a key event.
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
void setShortcut(const QKeySequence &shortcut)
void setHeight(int h)
Sets the height of the rectangle to the given height.
static QString standardSoftKeyText(StandardSoftKey standardKey)
static void beep()
Sounds the bell, using the default volume and sound.
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
The QFontMetrics class provides font metrics information.
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
const QChar at(int i) const
Returns the character at the given index position in the string.
QKeySequence shortcut
the action's primary shortcut key
bool showStatusText(QWidget *widget=0)
Updates the relevant status bar for the widget specified by sending a QStatusTipEvent to its parent w...
void activate(ActionEvent event)
Sends the relevant signals for ActionEvent event.
void setSeparator(bool b)
If b is true then this action will be considered a separator.
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QVector< T > & fill(const T &t, int size=-1)
Assigns value to all items in the vector.
QStyle::State state
the style flags that are used when drawing the control
#define it(className, varName)
bool isNull() const
Returns true if the referenced object has been destroyed or if there is no referenced object; otherwi...
int count(const T &t) const
Returns the number of occurrences of value in the vector.
The QWheelEvent class contains parameters that describe a wheel event.
ActionEvent
This enum type is used when calling QAction::activate()
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.
#define at(className, varName)
static QKeySequence mnemonic(const QString &text)
Returns the shortcut key sequence for the mnemonic in text, or an empty key sequence if no mnemonics ...
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation...
int length() const
Returns the number of characters in this string.
void setAccepted(bool accepted)
QString text
the action's descriptive text
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.
int left() const
Returns the x-coordinate of the rectangle's left edge.
bool isActive() const
Returns true if the timer is running and has not been stopped; otherwise returns false.
int width() const
Returns the width of the rectangle.
void init(const QWidget *w)
Use initFrom(widget) instead.
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
The QActionEvent class provides an event that is generated when a QAction is added, removed, or changed.
The QPolygon class provides a vector of points using integer precision.
T & value() const
Returns a modifiable reference to the current item's value.
int height() const
Returns the height of the rectangle.
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
The QString class provides a Unicode character string.
QFontMetrics fontMetrics
the font metrics that should be used when drawing text in the control
void setHeight(int h)
Sets the height to the given height.
T * qobject_cast(QObject *object)
The QObject class is the base class of all Qt objects.
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
The QChar class provides a 16-bit Unicode character.
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
const T value(const Key &key) const
Returns the value associated with the key.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
void resize(int size)
Sets the size of the vector to size.
void setWidth(int w)
Sets the width to the given width.
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...
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
void setCurrentColorGroup(ColorGroup cg)
Set the palette's current color group to cg.
int key() const
Returns the code of the key that was pressed or released.
QFont resolve(const QFont &) const
Returns a new QFont that has attributes copied from other that have not been previously set on this f...
int lineWidth
the line width for drawing the frame
int width() const
Returns the width.
static QAction * createKeyedAction(StandardSoftKey standardKey, Qt::Key key, QWidget *actionWidget)
Creates a QAction and registers the 'triggered' signal to send the given key event to actionWidget as...
void append(const T &t)
Inserts value at the end of the list.
bool isIconVisibleInMenu() const
#define QT_BEGIN_NAMESPACE
This macro expands to.
static QMacWindowFader * currentFader()
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
void destroyed(QObject *=0)
This signal is emitted immediately before the object obj is destroyed, and can not be blocked...
The QEventLoop class provides a means of entering and leaving an event loop.
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
void qScrollEffect(QWidget *w, QEffects::DirFlags orient, int time)
Scroll widget w in time ms.
The QStyleOption class stores the parameters used by QStyle functions.
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...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
void initFrom(const QWidget *w)
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
QSize size() const
Returns the size of the rectangle.
void setFadeDuration(float durationInSecs)
const T & at(int i) const
Returns the item at index position i in the list.
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
The QHideEvent class provides an event which is sent after a widget is hidden.
QFont font
the action's font
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
const char * styleHint(const QFontDef &request)
QIcon icon
the action's icon
int & rx()
Returns a reference to the x coordinate of this point.
void setText(const QString &text)
int delta() const
Returns the distance that the wheel is rotated, in eighths of a degree.
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
The QStyleOptionFrame class is used to describe the parameters for drawing a frame.
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QAction * action() const
Returns the action that is changed, added, or removed.
static bool inWhatsThisMode()
Returns true if the user interface is in "What's This?" mode; otherwise returns false.
QChar toUpper() const
Returns the uppercase equivalent if the character is lowercase or titlecase; otherwise returns the ch...
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QRegion class specifies a clip region for a painter.
static int startDragDistance()
const Key & key() const
Returns the current item's key as a const reference.
void registerWindowToFade(QWidget *window)
bool isEmpty() const
Returns true if the key sequence is empty; otherwise returns false.
Qt::MouseButton button() const
Returns the button that caused the event.
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...
void moveTopLeft(const QPoint &p)
Moves the rectangle, leaving the top-left corner at the given position.
const T & at(int i) const
Returns the item at index position i in the vector.
void stop()
Stops the timer.
static bool isActive()
Returns true if an accessibility implementation has been requested during the runtime of the applicat...
The QMouseEvent class contains parameters that describe a mouse event.
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
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...
const QPoint & pos() const
Returns the position of the mouse cursor relative to the widget that received the event...
QPalette palette
the palette that should be used when painting the control
QPoint center() const
Returns the center point of the rectangle.
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.
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...
The QStyleHintReturnMask class provides style hints that return a QRegion.
void setY(int y)
Sets the y coordinate of this point to the given y coordinate.
QMenu * menu() const
Returns the menu contained by this action.
int top() const
Returns the y-coordinate of the rectangle's top edge.
static bool isEffectEnabled(Qt::UIEffect)
Returns true if effect is enabled; otherwise returns false.
#define Q_DECLARE_PUBLIC(Class)
static QWidget * activePopupWidget()
Returns the active popup widget.
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
int right() const
Returns the x-coordinate of the rectangle's right edge.
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...
The QTimerEvent class contains parameters that describe a timer event.
int y() const
Returns the y-coordinate of the rectangle's top edge.
QString text() const
Returns the Unicode text that this key generated.
int midLineWidth
the mid-line width for drawing the frame
int x() const
Returns the x-coordinate of the rectangle's left edge.
QObject * parent() const
Returns a pointer to the parent object.
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle's top-left corner to ({x}, {y}), and its size to the given widt...
static QTestResult::TestLocation location
The QPoint class defines a point in the plane using integer precision.
bool singleShot
This static function calls a slot after a given time interval.
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given element with the provided painter with the style options specified by option...
int size() const
Returns the number of items in the list.
QString whatsThis
the action's "What's This?" help text
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
int & rheight()
Returns a reference to the height.
void setWidth(int w)
Sets the width of the rectangle to the given width.
int height() const
Returns the height.
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
void setIcon(const QIcon &icon)
int y() const
Returns the y coordinate of this point.
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
The QSize class defines the size of a two-dimensional object using integer point precision.
#define Q_DECLARE_PRIVATE(Class)
bool intersects(const QRect &r) const
Returns true if this rectangle intersects with the given rectangle (i.
int x() const
Returns the x coordinate of this point.
QActionGroup * actionGroup() const
Returns the action group for this action.
QRegion region
the region for style hints that return a QRegion
void moveTop(int pos)
Moves the rectangle vertically, leaving the rectangle's top edge at the given y coordinate.
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
const QRect & rect() const
Returns the rectangle that needs to be updated.
int height() const
Returns the height of the font.
static void showText(const QPoint &pos, const QString &text, QWidget *w=0)
Shows text as a "What's This?" window, at global position pos.
The QPaintEvent class contains event parameters for paint events.
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...
void qFadeEffect(QWidget *w, int time)
Fade in widget w in time ms.
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
const QPoint & globalPos() const
Returns the global position of the mouse cursor at the time of the event.
void setX(int x)
Sets the x coordinate of this point to the given x coordinate.
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
QRect rect
the area that should be used for various calculations and painting
int exec(ProcessEventsFlags flags=AllEvents)
Enters the main event loop and waits until exit() is called.
The QAction class provides an abstract user interface action that can be inserted into widgets...
void start(int msec, QObject *obj)
Starts (or restarts) the timer with a msec milliseconds timeout.
static void enterWhatsThisMode()
This function switches the user interface into "What's This?" mode.
int & rwidth()
Returns a reference to the width.
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
The QWeakPointer class holds a weak reference to a shared pointer.
The QList class is a template class that provides lists.
void killTimer(int id)
Kills the timer with timer identifier, id.
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.
Qt::LayoutDirection direction
void macWindowFade(void *window, float durationSeconds)
The QIcon class provides scalable icons in different modes and states.