| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qmenu.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | - | |||||||||||||||||||||||||
| 13 | - | |||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||
| 15 | - | |||||||||||||||||||||||||
| 16 | - | |||||||||||||||||||||||||
| 17 | QMenu *QMenuPrivate::mouseDown = 0; | - | ||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||
| 19 | - | |||||||||||||||||||||||||
| 20 | - | |||||||||||||||||||||||||
| 21 | class QTornOffMenu : public QMenu | - | ||||||||||||||||||||||||
| 22 | { | - | ||||||||||||||||||||||||
| 23 | public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } | - | ||||||||||||||||||||||||
| 24 | #pragma GCC diagnostic push | - | ||||||||||||||||||||||||
| 25 | static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); | - | ||||||||||||||||||||||||
| 26 | #pragma GCC diagnostic pop | - | ||||||||||||||||||||||||
| 27 | struct QPrivateSignal {}; | - | ||||||||||||||||||||||||
| 28 | class QTornOffMenuPrivate : public QMenuPrivate | - | ||||||||||||||||||||||||
| 29 | { | - | ||||||||||||||||||||||||
| 30 | inline QMenu* q_func() { return static_cast<QMenu *>(q_ptr); } inline const QMenu* q_func() const { return static_cast<const QMenu *>(q_ptr); } friend class QMenu; | - | ||||||||||||||||||||||||
| 31 | public: | - | ||||||||||||||||||||||||
| 32 | QTornOffMenuPrivate(QMenu *p) : causedMenu(p) { | - | ||||||||||||||||||||||||
| 33 | tornoff = 1; | - | ||||||||||||||||||||||||
| 34 | causedPopup.widget = 0; | - | ||||||||||||||||||||||||
| 35 | causedPopup.action = ((QTornOffMenu*)p)->d_func()->causedPopup.action; | - | ||||||||||||||||||||||||
| 36 | causedStack = ((QTornOffMenu*)p)->d_func()->calcCausedStack(); | - | ||||||||||||||||||||||||
| 37 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 38 | QVector<QPointer<QWidget> > calcCausedStack() const override { return never executed: causedStack;return causedStack;never executed: }return causedStack; | 0 | ||||||||||||||||||||||||
| 39 | QPointer<QMenu> causedMenu; | - | ||||||||||||||||||||||||
| 40 | QVector<QPointer<QWidget> > causedStack; | - | ||||||||||||||||||||||||
| 41 | }; | - | ||||||||||||||||||||||||
| 42 | public: | - | ||||||||||||||||||||||||
| 43 | QTornOffMenu(QMenu *p) : QMenu(*(new QTornOffMenuPrivate(p))) | - | ||||||||||||||||||||||||
| 44 | { | - | ||||||||||||||||||||||||
| 45 | QTornOffMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 46 | - | |||||||||||||||||||||||||
| 47 | QWidget *parentWidget = d->causedStack.isEmpty()
| 0 | ||||||||||||||||||||||||
| 48 | if (parentWidget->parentWidget()
| 0 | ||||||||||||||||||||||||
| 49 | parentWidget = parentWidget->parentWidget(); never executed: parentWidget = parentWidget->parentWidget(); | 0 | ||||||||||||||||||||||||
| 50 | setParent(parentWidget, Qt::Window | Qt::Tool); | - | ||||||||||||||||||||||||
| 51 | setAttribute(Qt::WA_DeleteOnClose, true); | - | ||||||||||||||||||||||||
| 52 | setAttribute(Qt::WA_X11NetWmWindowTypeMenu, true); | - | ||||||||||||||||||||||||
| 53 | setWindowTitle(p->windowTitle()); | - | ||||||||||||||||||||||||
| 54 | setEnabled(p->isEnabled()); | - | ||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||
| 56 | - | |||||||||||||||||||||||||
| 57 | QList<QAction*> items = p->actions(); | - | ||||||||||||||||||||||||
| 58 | for(int i = 0; i < items.count()
| 0 | ||||||||||||||||||||||||
| 59 | addAction(items.at(i)); never executed: addAction(items.at(i)); | 0 | ||||||||||||||||||||||||
| 60 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 61 | void syncWithMenu(QMenu *menu, QActionEvent *act) | - | ||||||||||||||||||||||||
| 62 | { | - | ||||||||||||||||||||||||
| 63 | QTornOffMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 64 | if(menu != d->causedMenu
| 0 | ||||||||||||||||||||||||
| 65 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 66 | if (act->type() == QEvent::ActionAdded
| 0 | ||||||||||||||||||||||||
| 67 | insertAction(act->before(), act->action()); | - | ||||||||||||||||||||||||
| 68 | } never executed: else if (act->type() == QEvent::ActionRemovedend of block
| 0 | ||||||||||||||||||||||||
| 69 | removeAction(act->action()); never executed: removeAction(act->action()); | 0 | ||||||||||||||||||||||||
| 70 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 71 | void actionEvent(QActionEvent *e) override | - | ||||||||||||||||||||||||
| 72 | { | - | ||||||||||||||||||||||||
| 73 | QMenu::actionEvent(e); | - | ||||||||||||||||||||||||
| 74 | setFixedSize(sizeHint()); | - | ||||||||||||||||||||||||
| 75 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 76 | public : | - | ||||||||||||||||||||||||
| 77 | void onTrigger(QAction *action) { d_func()->activateAction(action, QAction::Trigger, false); } never executed: end of block | 0 | ||||||||||||||||||||||||
| 78 | void onHovered(QAction *action) { d_func()->activateAction(action, QAction::Hover, false); } never executed: end of block | 0 | ||||||||||||||||||||||||
| 79 | private: | - | ||||||||||||||||||||||||
| 80 | inline QTornOffMenuPrivate* d_func() { return never executed: reinterpret_cast<QTornOffMenuPrivate *>(qGetPtrHelper(d_ptr));return reinterpret_cast<QTornOffMenuPrivate *>(qGetPtrHelper(d_ptr));never executed: } inline const QTornOffMenuPrivate* d_func() const { returnreturn reinterpret_cast<QTornOffMenuPrivate *>(qGetPtrHelper(d_ptr));never executed: reinterpret_cast<const QTornOffMenuPrivate *>(qGetPtrHelper(d_ptr));return reinterpret_cast<const QTornOffMenuPrivate *>(qGetPtrHelper(d_ptr));never executed: } friend class QTornOffMenuPrivate;return reinterpret_cast<const QTornOffMenuPrivate *>(qGetPtrHelper(d_ptr)); | 0 | ||||||||||||||||||||||||
| 81 | friend class QMenuPrivate; | - | ||||||||||||||||||||||||
| 82 | }; | - | ||||||||||||||||||||||||
| 83 | - | |||||||||||||||||||||||||
| 84 | void QMenuPrivate::init() | - | ||||||||||||||||||||||||
| 85 | { | - | ||||||||||||||||||||||||
| 86 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 87 | - | |||||||||||||||||||||||||
| 88 | q->setAttribute(Qt::WA_CustomWhatsThis); | - | ||||||||||||||||||||||||
| 89 | - | |||||||||||||||||||||||||
| 90 | q->setAttribute(Qt::WA_X11NetWmWindowTypePopupMenu); | - | ||||||||||||||||||||||||
| 91 | defaultMenuAction = menuAction = new QAction(q); | - | ||||||||||||||||||||||||
| 92 | menuAction->d_func()->menu = q; | - | ||||||||||||||||||||||||
| 93 | q->setMouseTracking(q->style()->styleHint(QStyle::SH_Menu_MouseTracking, 0, q)); | - | ||||||||||||||||||||||||
| 94 | if (q->style()->styleHint(QStyle::SH_Menu_Scrollable, 0, q)
| 0 | ||||||||||||||||||||||||
| 95 | scroll = new QMenuPrivate::QMenuScroller; | - | ||||||||||||||||||||||||
| 96 | scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone; | - | ||||||||||||||||||||||||
| 97 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||
| 99 | setPlatformMenu(QGuiApplicationPrivate::platformTheme()->createPlatformMenu()); | - | ||||||||||||||||||||||||
| 100 | sloppyState.initialize(q); | - | ||||||||||||||||||||||||
| 101 | delayState.initialize(q); | - | ||||||||||||||||||||||||
| 102 | mousePopupDelay = q->style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, q); | - | ||||||||||||||||||||||||
| 103 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||
| 105 | void QMenuPrivate::setPlatformMenu(QPlatformMenu *menu) | - | ||||||||||||||||||||||||
| 106 | { | - | ||||||||||||||||||||||||
| 107 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 108 | if (!platformMenu.isNull()
| 0 | ||||||||||||||||||||||||
| 109 | delete platformMenu.data(); never executed: delete platformMenu.data(); | 0 | ||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||
| 111 | platformMenu = menu; | - | ||||||||||||||||||||||||
| 112 | if (!platformMenu.isNull()
| 0 | ||||||||||||||||||||||||
| 113 | QObject::connect(platformMenu, qFlagLocation("2""aboutToShow()" "\0" __FILE__ ":" "164"), q, qFlagLocation("1""_q_platformMenuAboutToShow()" "\0" __FILE__ ":" "164")); | - | ||||||||||||||||||||||||
| 114 | QObject::connect(platformMenu, qFlagLocation("2""aboutToHide()" "\0" __FILE__ ":" "165"), q, qFlagLocation("2""aboutToHide()" "\0" __FILE__ ":" "165")); | - | ||||||||||||||||||||||||
| 115 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 116 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||
| 118 | - | |||||||||||||||||||||||||
| 119 | static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *item, QPlatformMenu *itemsMenu); | - | ||||||||||||||||||||||||
| 120 | - | |||||||||||||||||||||||||
| 121 | void QMenuPrivate::syncPlatformMenu() | - | ||||||||||||||||||||||||
| 122 | { | - | ||||||||||||||||||||||||
| 123 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 124 | if (platformMenu.isNull()
| 0 | ||||||||||||||||||||||||
| 125 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||
| 127 | QPlatformMenuItem *beforeItem = nullptr; | - | ||||||||||||||||||||||||
| 128 | const QList<QAction*> actions = q->actions(); | - | ||||||||||||||||||||||||
| 129 | for (QList<QAction*>::const_reverse_iterator it = actions.rbegin(), end = actions.rend(); it != end
| 0 | ||||||||||||||||||||||||
| 130 | QPlatformMenuItem *menuItem = platformMenu->createMenuItem(); | - | ||||||||||||||||||||||||
| 131 | QAction *action = *it; | - | ||||||||||||||||||||||||
| 132 | menuItem->setTag(reinterpret_cast<quintptr>(action)); | - | ||||||||||||||||||||||||
| 133 | QObject::connect(menuItem, qFlagLocation("2""activated()" "\0" __FILE__ ":" "184"), action, qFlagLocation("1""trigger()" "\0" __FILE__ ":" "184"), Qt::QueuedConnection); | - | ||||||||||||||||||||||||
| 134 | QObject::connect(menuItem, qFlagLocation("2""hovered()" "\0" __FILE__ ":" "185"), action, qFlagLocation("2""hovered()" "\0" __FILE__ ":" "185"), Qt::QueuedConnection); | - | ||||||||||||||||||||||||
| 135 | copyActionToPlatformItem(action, menuItem, platformMenu.data()); | - | ||||||||||||||||||||||||
| 136 | platformMenu->insertMenuItem(menuItem, beforeItem); | - | ||||||||||||||||||||||||
| 137 | beforeItem = menuItem; | - | ||||||||||||||||||||||||
| 138 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 139 | platformMenu->syncSeparatorsCollapsible(collapsibleSeparators); | - | ||||||||||||||||||||||||
| 140 | platformMenu->setEnabled(q->isEnabled()); | - | ||||||||||||||||||||||||
| 141 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 142 | - | |||||||||||||||||||||||||
| 143 | int QMenuPrivate::scrollerHeight() const | - | ||||||||||||||||||||||||
| 144 | { | - | ||||||||||||||||||||||||
| 145 | const QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 146 | return never executed: qMax(QApplication::globalStrut().height(), q->style()->pixelMetric(QStyle::PM_MenuScrollerHeight, 0, q));return qMax(QApplication::globalStrut().height(), q->style()->pixelMetric(QStyle::PM_MenuScrollerHeight, 0, q));never executed: return qMax(QApplication::globalStrut().height(), q->style()->pixelMetric(QStyle::PM_MenuScrollerHeight, 0, q)); | 0 | ||||||||||||||||||||||||
| 147 | } | - | ||||||||||||||||||||||||
| 148 | - | |||||||||||||||||||||||||
| 149 | - | |||||||||||||||||||||||||
| 150 | QRect QMenuPrivate::popupGeometry(const QWidget *widget) const | - | ||||||||||||||||||||||||
| 151 | { | - | ||||||||||||||||||||||||
| 152 | if (QGuiApplicationPrivate::platformTheme()
| 0 | ||||||||||||||||||||||||
| 153 | QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()
| 0 | ||||||||||||||||||||||||
| 154 | return never executed: QApplication::desktop()->screenGeometry(widget);return QApplication::desktop()->screenGeometry(widget);never executed: return QApplication::desktop()->screenGeometry(widget); | 0 | ||||||||||||||||||||||||
| 155 | } else { | - | ||||||||||||||||||||||||
| 156 | return never executed: QApplication::desktop()->availableGeometry(widget);return QApplication::desktop()->availableGeometry(widget);never executed: return QApplication::desktop()->availableGeometry(widget); | 0 | ||||||||||||||||||||||||
| 157 | } | - | ||||||||||||||||||||||||
| 158 | } | - | ||||||||||||||||||||||||
| 159 | - | |||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||
| 161 | QRect QMenuPrivate::popupGeometry(int screen) const | - | ||||||||||||||||||||||||
| 162 | { | - | ||||||||||||||||||||||||
| 163 | if (QGuiApplicationPrivate::platformTheme()
| 0 | ||||||||||||||||||||||||
| 164 | QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()
| 0 | ||||||||||||||||||||||||
| 165 | return never executed: QApplication::desktop()->screenGeometry(screen);return QApplication::desktop()->screenGeometry(screen);never executed: return QApplication::desktop()->screenGeometry(screen); | 0 | ||||||||||||||||||||||||
| 166 | } else { | - | ||||||||||||||||||||||||
| 167 | return never executed: QApplication::desktop()->availableGeometry(screen);return QApplication::desktop()->availableGeometry(screen);never executed: return QApplication::desktop()->availableGeometry(screen); | 0 | ||||||||||||||||||||||||
| 168 | } | - | ||||||||||||||||||||||||
| 169 | } | - | ||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||
| 171 | QVector<QPointer<QWidget> > QMenuPrivate::calcCausedStack() const | - | ||||||||||||||||||||||||
| 172 | { | - | ||||||||||||||||||||||||
| 173 | QVector<QPointer<QWidget> > ret; | - | ||||||||||||||||||||||||
| 174 | for(QWidget *widget = causedPopup.widget; widget
| 0 | ||||||||||||||||||||||||
| 175 | ret.append(widget); | - | ||||||||||||||||||||||||
| 176 | if (QTornOffMenu *qtmenu = qobject_cast<QTornOffMenu*>(widget)
| 0 | ||||||||||||||||||||||||
| 177 | ret += qtmenu->d_func()->causedStack; never executed: ret += qtmenu->d_func()->causedStack; | 0 | ||||||||||||||||||||||||
| 178 | if (QMenu *qmenu = qobject_cast<QMenu*>(widget)
| 0 | ||||||||||||||||||||||||
| 179 | widget = qmenu->d_func()->causedPopup.widget; never executed: widget = qmenu->d_func()->causedPopup.widget; | 0 | ||||||||||||||||||||||||
| 180 | else | - | ||||||||||||||||||||||||
| 181 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 182 | } | - | ||||||||||||||||||||||||
| 183 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||
| 184 | } | - | ||||||||||||||||||||||||
| 185 | - | |||||||||||||||||||||||||
| 186 | void QMenuPrivate::updateActionRects() const | - | ||||||||||||||||||||||||
| 187 | { | - | ||||||||||||||||||||||||
| 188 | const QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 189 | updateActionRects(popupGeometry(q)); | - | ||||||||||||||||||||||||
| 190 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 191 | - | |||||||||||||||||||||||||
| 192 | void QMenuPrivate::updateActionRects(const QRect &screen) const | - | ||||||||||||||||||||||||
| 193 | { | - | ||||||||||||||||||||||||
| 194 | const QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 195 | if (!itemsDirty
| 0 | ||||||||||||||||||||||||
| 196 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 197 | - | |||||||||||||||||||||||||
| 198 | q->ensurePolished(); | - | ||||||||||||||||||||||||
| 199 | - | |||||||||||||||||||||||||
| 200 | - | |||||||||||||||||||||||||
| 201 | actionRects.resize(actions.count()); | - | ||||||||||||||||||||||||
| 202 | actionRects.fill(QRect()); | - | ||||||||||||||||||||||||
| 203 | - | |||||||||||||||||||||||||
| 204 | int lastVisibleAction = getLastVisibleAction(); | - | ||||||||||||||||||||||||
| 205 | - | |||||||||||||||||||||||||
| 206 | int max_column_width = 0, | - | ||||||||||||||||||||||||
| 207 | dh = screen.height(), | - | ||||||||||||||||||||||||
| 208 | y = 0; | - | ||||||||||||||||||||||||
| 209 | QStyle *style = q->style(); | - | ||||||||||||||||||||||||
| 210 | QStyleOption opt; | - | ||||||||||||||||||||||||
| 211 | opt.init(q); | - | ||||||||||||||||||||||||
| 212 | const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, &opt, q), | - | ||||||||||||||||||||||||
| 213 | vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, &opt, q), | - | ||||||||||||||||||||||||
| 214 | icone = style->pixelMetric(QStyle::PM_SmallIconSize, &opt, q); | - | ||||||||||||||||||||||||
| 215 | const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q); | - | ||||||||||||||||||||||||
| 216 | const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q); | - | ||||||||||||||||||||||||
| 217 | const int tearoffHeight = tearoff
| 0 | ||||||||||||||||||||||||
| 218 | - | |||||||||||||||||||||||||
| 219 | - | |||||||||||||||||||||||||
| 220 | tabWidth = 0; | - | ||||||||||||||||||||||||
| 221 | maxIconWidth = 0; | - | ||||||||||||||||||||||||
| 222 | hasCheckableItems = false; | - | ||||||||||||||||||||||||
| 223 | ncols = 1; | - | ||||||||||||||||||||||||
| 224 | - | |||||||||||||||||||||||||
| 225 | for (int i = 0; i < actions.count()
| 0 | ||||||||||||||||||||||||
| 226 | QAction *action = actions.at(i); | - | ||||||||||||||||||||||||
| 227 | if (action->isSeparator()
| 0 | ||||||||||||||||||||||||
| 228 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 229 | - | |||||||||||||||||||||||||
| 230 | hasCheckableItems |= action->isCheckable(); | - | ||||||||||||||||||||||||
| 231 | QIcon is = action->icon(); | - | ||||||||||||||||||||||||
| 232 | if (!is.isNull()
| 0 | ||||||||||||||||||||||||
| 233 | maxIconWidth = qMax<uint>(maxIconWidth, icone + 4); | - | ||||||||||||||||||||||||
| 234 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 235 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 236 | - | |||||||||||||||||||||||||
| 237 | - | |||||||||||||||||||||||||
| 238 | QFontMetrics qfm = q->fontMetrics(); | - | ||||||||||||||||||||||||
| 239 | bool previousWasSeparator = true; | - | ||||||||||||||||||||||||
| 240 | for(int i = 0; i <= lastVisibleAction
| 0 | ||||||||||||||||||||||||
| 241 | QAction *action = actions.at(i); | - | ||||||||||||||||||||||||
| 242 | const bool isSection = action->isSeparator()
| 0 | ||||||||||||||||||||||||
| 243 | const bool isPlainSeparator = (isSection
| 0 | ||||||||||||||||||||||||
| 244 | || (action->isSeparator()
| 0 | ||||||||||||||||||||||||
| 245 | - | |||||||||||||||||||||||||
| 246 | if (!action->isVisible()
| 0 | ||||||||||||||||||||||||
| 247 | (collapsibleSeparators
| 0 | ||||||||||||||||||||||||
| 248 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||
| 250 | previousWasSeparator = isPlainSeparator; | - | ||||||||||||||||||||||||
| 251 | - | |||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||
| 253 | QStyleOptionMenuItem opt; | - | ||||||||||||||||||||||||
| 254 | q->initStyleOption(&opt, action); | - | ||||||||||||||||||||||||
| 255 | const QFontMetrics &fm = opt.fontMetrics; | - | ||||||||||||||||||||||||
| 256 | - | |||||||||||||||||||||||||
| 257 | QSize sz; | - | ||||||||||||||||||||||||
| 258 | if (QWidget *w = widgetItems.value(action)
| 0 | ||||||||||||||||||||||||
| 259 | sz = w->sizeHint().expandedTo(w->minimumSize()).expandedTo(w->minimumSizeHint()).boundedTo(w->maximumSize()); | - | ||||||||||||||||||||||||
| 260 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 261 | - | |||||||||||||||||||||||||
| 262 | if (action->isSeparator()
| 0 | ||||||||||||||||||||||||
| 263 | sz = QSize(2, 2); | - | ||||||||||||||||||||||||
| 264 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 265 | QString s = action->text(); | - | ||||||||||||||||||||||||
| 266 | int t = s.indexOf(QLatin1Char('\t')); | - | ||||||||||||||||||||||||
| 267 | if (t != -1
| 0 | ||||||||||||||||||||||||
| 268 | tabWidth = qMax(int(tabWidth), qfm.width(s.mid(t+1))); | - | ||||||||||||||||||||||||
| 269 | s = s.left(t); | - | ||||||||||||||||||||||||
| 270 | - | |||||||||||||||||||||||||
| 271 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 272 | QKeySequence seq = action->shortcut(); | - | ||||||||||||||||||||||||
| 273 | if (!seq.isEmpty()
| 0 | ||||||||||||||||||||||||
| 274 | tabWidth = qMax(int(tabWidth), qfm.width(seq.toString(QKeySequence::NativeText))); never executed: tabWidth = qMax(int(tabWidth), qfm.width(seq.toString(QKeySequence::NativeText))); | 0 | ||||||||||||||||||||||||
| 275 | - | |||||||||||||||||||||||||
| 276 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 277 | sz.setWidth(fm.boundingRect(QRect(), Qt::TextSingleLine | Qt::TextShowMnemonic, s).width()); | - | ||||||||||||||||||||||||
| 278 | sz.setHeight(qMax(fm.height(), qfm.height())); | - | ||||||||||||||||||||||||
| 279 | - | |||||||||||||||||||||||||
| 280 | QIcon is = action->icon(); | - | ||||||||||||||||||||||||
| 281 | if (!is.isNull()
| 0 | ||||||||||||||||||||||||
| 282 | QSize is_sz = QSize(icone, icone); | - | ||||||||||||||||||||||||
| 283 | if (is_sz.height() > sz.height()
| 0 | ||||||||||||||||||||||||
| 284 | sz.setHeight(is_sz.height()); never executed: sz.setHeight(is_sz.height()); | 0 | ||||||||||||||||||||||||
| 285 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 286 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 287 | sz = style->sizeFromContents(QStyle::CT_MenuItem, &opt, sz, q); | - | ||||||||||||||||||||||||
| 288 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||
| 290 | - | |||||||||||||||||||||||||
| 291 | if (!sz.isEmpty()
| 0 | ||||||||||||||||||||||||
| 292 | max_column_width = qMax(max_column_width, sz.width()); | - | ||||||||||||||||||||||||
| 293 | - | |||||||||||||||||||||||||
| 294 | if (!scroll
| 0 | ||||||||||||||||||||||||
| 295 | y+sz.height()+vmargin > dh - (deskFw * 2)
| 0 | ||||||||||||||||||||||||
| 296 | ncols++; | - | ||||||||||||||||||||||||
| 297 | y = vmargin; | - | ||||||||||||||||||||||||
| 298 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 299 | y += sz.height(); | - | ||||||||||||||||||||||||
| 300 | - | |||||||||||||||||||||||||
| 301 | actionRects[i] = QRect(0, 0, sz.width(), sz.height()); | - | ||||||||||||||||||||||||
| 302 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 303 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 304 | - | |||||||||||||||||||||||||
| 305 | max_column_width += tabWidth; | - | ||||||||||||||||||||||||
| 306 | const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width(); | - | ||||||||||||||||||||||||
| 307 | const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin)); | - | ||||||||||||||||||||||||
| 308 | max_column_width = qMax(min_column_width, max_column_width); | - | ||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||
| 310 | - | |||||||||||||||||||||||||
| 311 | const int base_y = vmargin + fw + topmargin + | - | ||||||||||||||||||||||||
| 312 | (scroll
| 0 | ||||||||||||||||||||||||
| 313 | tearoffHeight; | - | ||||||||||||||||||||||||
| 314 | int x = hmargin + fw + leftmargin; | - | ||||||||||||||||||||||||
| 315 | y = base_y; | - | ||||||||||||||||||||||||
| 316 | - | |||||||||||||||||||||||||
| 317 | for(int i = 0; i < actions.count()
| 0 | ||||||||||||||||||||||||
| 318 | QRect &rect = actionRects[i]; | - | ||||||||||||||||||||||||
| 319 | if (rect.isNull()
| 0 | ||||||||||||||||||||||||
| 320 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 321 | if (!scroll
| 0 | ||||||||||||||||||||||||
| 322 | y+rect.height() > dh - deskFw * 2
| 0 | ||||||||||||||||||||||||
| 323 | x += max_column_width + hmargin; | - | ||||||||||||||||||||||||
| 324 | y = base_y; | - | ||||||||||||||||||||||||
| 325 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 326 | rect.translate(x, y); | - | ||||||||||||||||||||||||
| 327 | rect.setWidth(max_column_width); | - | ||||||||||||||||||||||||
| 328 | - | |||||||||||||||||||||||||
| 329 | - | |||||||||||||||||||||||||
| 330 | if (QWidget *widget = widgetItems.value(actions.at(i))
| 0 | ||||||||||||||||||||||||
| 331 | widget->setGeometry(rect); | - | ||||||||||||||||||||||||
| 332 | widget->setVisible(actions.at(i)->isVisible()); | - | ||||||||||||||||||||||||
| 333 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 334 | - | |||||||||||||||||||||||||
| 335 | y += rect.height(); | - | ||||||||||||||||||||||||
| 336 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 337 | itemsDirty = 0; | - | ||||||||||||||||||||||||
| 338 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 339 | - | |||||||||||||||||||||||||
| 340 | QSize QMenuPrivate::adjustMenuSizeForScreen(const QRect &screen) | - | ||||||||||||||||||||||||
| 341 | { | - | ||||||||||||||||||||||||
| 342 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 343 | QSize ret = screen.size(); | - | ||||||||||||||||||||||||
| 344 | itemsDirty = true; | - | ||||||||||||||||||||||||
| 345 | updateActionRects(screen); | - | ||||||||||||||||||||||||
| 346 | const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q); | - | ||||||||||||||||||||||||
| 347 | ret.setWidth(actionRects.at(getLastVisibleAction()).right() + fw); | - | ||||||||||||||||||||||||
| 348 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||
| 349 | } | - | ||||||||||||||||||||||||
| 350 | - | |||||||||||||||||||||||||
| 351 | int QMenuPrivate::getLastVisibleAction() const | - | ||||||||||||||||||||||||
| 352 | { | - | ||||||||||||||||||||||||
| 353 | - | |||||||||||||||||||||||||
| 354 | int lastVisibleAction = actions.count() - 1; | - | ||||||||||||||||||||||||
| 355 | for (;lastVisibleAction >= 0
| 0 | ||||||||||||||||||||||||
| 356 | const QAction *action = actions.at(lastVisibleAction); | - | ||||||||||||||||||||||||
| 357 | if (action->isVisible()
| 0 | ||||||||||||||||||||||||
| 358 | - | |||||||||||||||||||||||||
| 359 | if (action->isSeparator()
| 0 | ||||||||||||||||||||||||
| 360 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 361 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 362 | } | - | ||||||||||||||||||||||||
| 363 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 364 | return never executed: lastVisibleAction;return lastVisibleAction;never executed: return lastVisibleAction; | 0 | ||||||||||||||||||||||||
| 365 | } | - | ||||||||||||||||||||||||
| 366 | - | |||||||||||||||||||||||||
| 367 | - | |||||||||||||||||||||||||
| 368 | QRect QMenuPrivate::actionRect(QAction *act) const | - | ||||||||||||||||||||||||
| 369 | { | - | ||||||||||||||||||||||||
| 370 | int index = actions.indexOf(act); | - | ||||||||||||||||||||||||
| 371 | if (index == -1
| 0 | ||||||||||||||||||||||||
| 372 | return never executed: QRect();return QRect();never executed: return QRect(); | 0 | ||||||||||||||||||||||||
| 373 | - | |||||||||||||||||||||||||
| 374 | updateActionRects(); | - | ||||||||||||||||||||||||
| 375 | - | |||||||||||||||||||||||||
| 376 | - | |||||||||||||||||||||||||
| 377 | return never executed: actionRects.at(index);return actionRects.at(index);never executed: return actionRects.at(index); | 0 | ||||||||||||||||||||||||
| 378 | } | - | ||||||||||||||||||||||||
| 379 | - | |||||||||||||||||||||||||
| 380 | void QMenuPrivate::hideUpToMenuBar() | - | ||||||||||||||||||||||||
| 381 | { | - | ||||||||||||||||||||||||
| 382 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 383 | bool fadeMenus = q->style()->styleHint(QStyle::SH_Menu_FadeOutOnHide); | - | ||||||||||||||||||||||||
| 384 | if (!tornoff
| 0 | ||||||||||||||||||||||||
| 385 | QWidget *caused = causedPopup.widget; | - | ||||||||||||||||||||||||
| 386 | hideMenu(q); | - | ||||||||||||||||||||||||
| 387 | while(caused
| 0 | ||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||
| 389 | if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)
| 0 | ||||||||||||||||||||||||
| 390 | mb->d_func()->setCurrentAction(0); | - | ||||||||||||||||||||||||
| 391 | mb->d_func()->setKeyboardMode(false); | - | ||||||||||||||||||||||||
| 392 | caused = 0; | - | ||||||||||||||||||||||||
| 393 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||
| 394 | - | |||||||||||||||||||||||||
| 395 | if (QMenu *m = qobject_cast<QMenu*>(caused)
| 0 | ||||||||||||||||||||||||
| 396 | caused = m->d_func()->causedPopup.widget; | - | ||||||||||||||||||||||||
| 397 | if (!m->d_func()->tornoff
| 0 | ||||||||||||||||||||||||
| 398 | hideMenu(m); never executed: hideMenu(m); | 0 | ||||||||||||||||||||||||
| 399 | if (!fadeMenus
| 0 | ||||||||||||||||||||||||
| 400 | m->d_func()->setCurrentAction(0); never executed: m->d_func()->setCurrentAction(0); | 0 | ||||||||||||||||||||||||
| 401 | } never executed: else { caused = 0;end of block | 0 | ||||||||||||||||||||||||
| 402 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 403 | } | - | ||||||||||||||||||||||||
| 404 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 405 | setCurrentAction(0); | - | ||||||||||||||||||||||||
| 406 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 407 | - | |||||||||||||||||||||||||
| 408 | void QMenuPrivate::hideMenu(QMenu *menu) | - | ||||||||||||||||||||||||
| 409 | { | - | ||||||||||||||||||||||||
| 410 | if (!menu
| 0 | ||||||||||||||||||||||||
| 411 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 412 | - | |||||||||||||||||||||||||
| 413 | QSignalBlocker blocker(menu); | - | ||||||||||||||||||||||||
| 414 | aboutToHide = true; | - | ||||||||||||||||||||||||
| 415 | - | |||||||||||||||||||||||||
| 416 | if (menu->style()->styleHint(QStyle::SH_Menu_FlashTriggeredItem)
| 0 | ||||||||||||||||||||||||
| 417 | && currentAction
| 0 | ||||||||||||||||||||||||
| 418 | && menu->actions().contains(currentAction)
| 0 | ||||||||||||||||||||||||
| 419 | QEventLoop eventLoop; | - | ||||||||||||||||||||||||
| 420 | QAction *activeAction = currentAction; | - | ||||||||||||||||||||||||
| 421 | - | |||||||||||||||||||||||||
| 422 | menu->setActiveAction(0); | - | ||||||||||||||||||||||||
| 423 | QTimer::singleShot(60, &eventLoop, qFlagLocation("1""quit()" "\0" __FILE__ ":" "474")); | - | ||||||||||||||||||||||||
| 424 | eventLoop.exec(); | - | ||||||||||||||||||||||||
| 425 | - | |||||||||||||||||||||||||
| 426 | - | |||||||||||||||||||||||||
| 427 | menu->setActiveAction(activeAction); | - | ||||||||||||||||||||||||
| 428 | QTimer::singleShot(20, &eventLoop, qFlagLocation("1""quit()" "\0" __FILE__ ":" "479")); | - | ||||||||||||||||||||||||
| 429 | eventLoop.exec(); | - | ||||||||||||||||||||||||
| 430 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 431 | - | |||||||||||||||||||||||||
| 432 | aboutToHide = false; | - | ||||||||||||||||||||||||
| 433 | blocker.unblock(); | - | ||||||||||||||||||||||||
| 434 | - | |||||||||||||||||||||||||
| 435 | if (activeMenu == menu
| 0 | ||||||||||||||||||||||||
| 436 | activeMenu = 0; never executed: activeMenu = 0; | 0 | ||||||||||||||||||||||||
| 437 | menu->d_func()->causedPopup.action = 0; | - | ||||||||||||||||||||||||
| 438 | menu->close(); | - | ||||||||||||||||||||||||
| 439 | menu->d_func()->causedPopup.widget = 0; | - | ||||||||||||||||||||||||
| 440 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 441 | - | |||||||||||||||||||||||||
| 442 | void QMenuPrivate::popupAction(QAction *action, int delay, bool activateFirst) | - | ||||||||||||||||||||||||
| 443 | { | - | ||||||||||||||||||||||||
| 444 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 445 | if (action
| 0 | ||||||||||||||||||||||||
| 446 | if (action->isEnabled()
| 0 | ||||||||||||||||||||||||
| 447 | if (!delay
| 0 | ||||||||||||||||||||||||
| 448 | q->internalDelayedPopup(); never executed: q->internalDelayedPopup(); | 0 | ||||||||||||||||||||||||
| 449 | else if (action->menu()
| 0 | ||||||||||||||||||||||||
| 450 | delayState.start(delay, action); never executed: delayState.start(delay, action); | 0 | ||||||||||||||||||||||||
| 451 | else if (!action->menu()
| 0 | ||||||||||||||||||||||||
| 452 | delayState.stop(); never executed: delayState.stop(); | 0 | ||||||||||||||||||||||||
| 453 | if (activateFirst
| 0 | ||||||||||||||||||||||||
| 454 | action->menu()->d_func()->setFirstActionActive(); never executed: action->menu()->d_func()->setFirstActionActive(); | 0 | ||||||||||||||||||||||||
| 455 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 456 | } never executed: else if (QMenu *menu = activeMenuend of block
| 0 | ||||||||||||||||||||||||
| 457 | hideMenu(menu); | - | ||||||||||||||||||||||||
| 458 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 459 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 460 | - | |||||||||||||||||||||||||
| 461 | void QMenuPrivate::setSyncAction() | - | ||||||||||||||||||||||||
| 462 | { | - | ||||||||||||||||||||||||
| 463 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 464 | QAction *current = currentAction; | - | ||||||||||||||||||||||||
| 465 | if(current
| 0 | ||||||||||||||||||||||||
| 466 | current = 0; never executed: current = 0; | 0 | ||||||||||||||||||||||||
| 467 | for(QWidget *caused = q; caused
| 0 | ||||||||||||||||||||||||
| 468 | if (QMenu *m = qobject_cast<QMenu*>(caused)
| 0 | ||||||||||||||||||||||||
| 469 | caused = m->d_func()->causedPopup.widget; | - | ||||||||||||||||||||||||
| 470 | if (m->d_func()->eventLoop
| 0 | ||||||||||||||||||||||||
| 471 | m->d_func()->syncAction = current; never executed: m->d_func()->syncAction = current; | 0 | ||||||||||||||||||||||||
| 472 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 473 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 474 | } | - | ||||||||||||||||||||||||
| 475 | } | - | ||||||||||||||||||||||||
| 476 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 477 | - | |||||||||||||||||||||||||
| 478 | - | |||||||||||||||||||||||||
| 479 | void QMenuPrivate::setFirstActionActive() | - | ||||||||||||||||||||||||
| 480 | { | - | ||||||||||||||||||||||||
| 481 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 482 | updateActionRects(); | - | ||||||||||||||||||||||||
| 483 | for(int i = 0, saccum = 0; i < actions.count()
| 0 | ||||||||||||||||||||||||
| 484 | const QRect &rect = actionRects.at(i); | - | ||||||||||||||||||||||||
| 485 | if (rect.isNull()
| 0 | ||||||||||||||||||||||||
| 486 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 487 | if (scroll
| 0 | ||||||||||||||||||||||||
| 488 | saccum -= rect.height(); | - | ||||||||||||||||||||||||
| 489 | if (saccum > scroll->scrollOffset - scrollerHeight()
| 0 | ||||||||||||||||||||||||
| 490 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 491 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 492 | QAction *act = actions.at(i); | - | ||||||||||||||||||||||||
| 493 | if (!act->isSeparator()
| 0 | ||||||||||||||||||||||||
| 494 | (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)
| 0 | ||||||||||||||||||||||||
| 495 | || act->isEnabled()
| 0 | ||||||||||||||||||||||||
| 496 | setCurrentAction(act); | - | ||||||||||||||||||||||||
| 497 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 498 | } | - | ||||||||||||||||||||||||
| 499 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 500 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 501 | - | |||||||||||||||||||||||||
| 502 | - | |||||||||||||||||||||||||
| 503 | void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason reason, bool activateFirst) | - | ||||||||||||||||||||||||
| 504 | { | - | ||||||||||||||||||||||||
| 505 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 506 | tearoffHighlighted = 0; | - | ||||||||||||||||||||||||
| 507 | - | |||||||||||||||||||||||||
| 508 | if (action
| 0 | ||||||||||||||||||||||||
| 509 | && (action->isSeparator()
| 0 | ||||||||||||||||||||||||
| 510 | || (!action->isEnabled()
| 0 | ||||||||||||||||||||||||
| 511 | action = nullptr; never executed: action = nullptr; | 0 | ||||||||||||||||||||||||
| 512 | - | |||||||||||||||||||||||||
| 513 | - | |||||||||||||||||||||||||
| 514 | - | |||||||||||||||||||||||||
| 515 | if (reason != SelectedFromKeyboard
| 0 | ||||||||||||||||||||||||
| 516 | if (QMenu *menu = qobject_cast<QMenu*>(causedPopup.widget)
| 0 | ||||||||||||||||||||||||
| 517 | if (causedPopup.action
| 0 | ||||||||||||||||||||||||
| 518 | - | |||||||||||||||||||||||||
| 519 | if (hasReceievedEnter
| 0 | ||||||||||||||||||||||||
| 520 | menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false); never executed: menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false); | 0 | ||||||||||||||||||||||||
| 521 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 522 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 523 | - | |||||||||||||||||||||||||
| 524 | if (currentAction
| 0 | ||||||||||||||||||||||||
| 525 | q->update(actionRect(currentAction)); never executed: q->update(actionRect(currentAction)); | 0 | ||||||||||||||||||||||||
| 526 | - | |||||||||||||||||||||||||
| 527 | QMenu *hideActiveMenu = activeMenu; | - | ||||||||||||||||||||||||
| 528 | QAction *previousAction = currentAction; | - | ||||||||||||||||||||||||
| 529 | - | |||||||||||||||||||||||||
| 530 | currentAction = action; | - | ||||||||||||||||||||||||
| 531 | if (action
| 0 | ||||||||||||||||||||||||
| 532 | if (!action->isSeparator()
| 0 | ||||||||||||||||||||||||
| 533 | activateAction(action, QAction::Hover); | - | ||||||||||||||||||||||||
| 534 | if (popup != -1
| 0 | ||||||||||||||||||||||||
| 535 | - | |||||||||||||||||||||||||
| 536 | - | |||||||||||||||||||||||||
| 537 | - | |||||||||||||||||||||||||
| 538 | if (q->isVisible()
| 0 | ||||||||||||||||||||||||
| 539 | popupAction(currentAction, popup, activateFirst); never executed: popupAction(currentAction, popup, activateFirst); | 0 | ||||||||||||||||||||||||
| 540 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 541 | q->update(actionRect(action)); | - | ||||||||||||||||||||||||
| 542 | - | |||||||||||||||||||||||||
| 543 | if (reason == SelectedFromKeyboard
| 0 | ||||||||||||||||||||||||
| 544 | QWidget *widget = widgetItems.value(action); | - | ||||||||||||||||||||||||
| 545 | if (widget
| 0 | ||||||||||||||||||||||||
| 546 | if (widget->focusPolicy() != Qt::NoFocus
| 0 | ||||||||||||||||||||||||
| 547 | widget->setFocus(Qt::TabFocusReason); never executed: widget->setFocus(Qt::TabFocusReason); | 0 | ||||||||||||||||||||||||
| 548 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 549 | - | |||||||||||||||||||||||||
| 550 | - | |||||||||||||||||||||||||
| 551 | - | |||||||||||||||||||||||||
| 552 | if (!q->hasFocus()
| 0 | ||||||||||||||||||||||||
| 553 | q->setFocus(Qt::PopupFocusReason); | - | ||||||||||||||||||||||||
| 554 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 555 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 556 | } | - | ||||||||||||||||||||||||
| 557 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 558 | - | |||||||||||||||||||||||||
| 559 | } never executed: else if (previousActionend of block
| 0 | ||||||||||||||||||||||||
| 560 | previousAction->d_func()->showStatusText(topCausedWidget(), QString()); | - | ||||||||||||||||||||||||
| 561 | - | |||||||||||||||||||||||||
| 562 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 563 | if (hideActiveMenu
| 0 | ||||||||||||||||||||||||
| 564 | if (popup == -1
| 0 | ||||||||||||||||||||||||
| 565 | - | |||||||||||||||||||||||||
| 566 | - | |||||||||||||||||||||||||
| 567 | qFadeEffect(0); | - | ||||||||||||||||||||||||
| 568 | qScrollEffect(0); | - | ||||||||||||||||||||||||
| 569 | - | |||||||||||||||||||||||||
| 570 | hideMenu(hideActiveMenu); | - | ||||||||||||||||||||||||
| 571 | } never executed: else if (!currentActionend of block
| 0 | ||||||||||||||||||||||||
| 572 | sloppyState.startTimerIfNotRunning(); | - | ||||||||||||||||||||||||
| 573 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 574 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 575 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 576 | - | |||||||||||||||||||||||||
| 577 | void QMenuSloppyState::reset() | - | ||||||||||||||||||||||||
| 578 | { | - | ||||||||||||||||||||||||
| 579 | m_enabled = false; | - | ||||||||||||||||||||||||
| 580 | m_first_mouse = true; | - | ||||||||||||||||||||||||
| 581 | m_init_guard = false; | - | ||||||||||||||||||||||||
| 582 | m_uni_dir_discarded_count = 0; | - | ||||||||||||||||||||||||
| 583 | m_time.stop(); | - | ||||||||||||||||||||||||
| 584 | m_reset_action = nullptr; | - | ||||||||||||||||||||||||
| 585 | m_origin_action = nullptr; | - | ||||||||||||||||||||||||
| 586 | m_action_rect = QRect(); | - | ||||||||||||||||||||||||
| 587 | m_previous_point = QPointF(); | - | ||||||||||||||||||||||||
| 588 | if (m_sub_menu
| 0 | ||||||||||||||||||||||||
| 589 | QMenuPrivate::get(m_sub_menu)->sloppyState.m_parent = nullptr; | - | ||||||||||||||||||||||||
| 590 | m_sub_menu = nullptr; | - | ||||||||||||||||||||||||
| 591 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 592 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 593 | void QMenuSloppyState::enter() | - | ||||||||||||||||||||||||
| 594 | { | - | ||||||||||||||||||||||||
| 595 | QMenuPrivate *menuPriv = QMenuPrivate::get(m_menu); | - | ||||||||||||||||||||||||
| 596 | - | |||||||||||||||||||||||||
| 597 | if (m_discard_state_when_entering_parent
| 0 | ||||||||||||||||||||||||
| 598 | menuPriv->hideMenu(m_sub_menu); | - | ||||||||||||||||||||||||
| 599 | reset(); | - | ||||||||||||||||||||||||
| 600 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 601 | if (m_parent
| 0 | ||||||||||||||||||||||||
| 602 | m_parent->childEnter(); never executed: m_parent->childEnter(); | 0 | ||||||||||||||||||||||||
| 603 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 604 | - | |||||||||||||||||||||||||
| 605 | void QMenuSloppyState::childEnter() | - | ||||||||||||||||||||||||
| 606 | { | - | ||||||||||||||||||||||||
| 607 | stopTimer(); | - | ||||||||||||||||||||||||
| 608 | if (m_parent
| 0 | ||||||||||||||||||||||||
| 609 | m_parent->childEnter(); never executed: m_parent->childEnter(); | 0 | ||||||||||||||||||||||||
| 610 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 611 | - | |||||||||||||||||||||||||
| 612 | void QMenuSloppyState::leave() | - | ||||||||||||||||||||||||
| 613 | { | - | ||||||||||||||||||||||||
| 614 | if (!m_dont_start_time_on_leave
| 0 | ||||||||||||||||||||||||
| 615 | if (m_parent
| 0 | ||||||||||||||||||||||||
| 616 | m_parent->childLeave(); never executed: m_parent->childLeave(); | 0 | ||||||||||||||||||||||||
| 617 | startTimerIfNotRunning(); | - | ||||||||||||||||||||||||
| 618 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 619 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 620 | - | |||||||||||||||||||||||||
| 621 | void QMenuSloppyState::childLeave() | - | ||||||||||||||||||||||||
| 622 | { | - | ||||||||||||||||||||||||
| 623 | if (m_enabled
| 0 | ||||||||||||||||||||||||
| 624 | startTimerIfNotRunning(); | - | ||||||||||||||||||||||||
| 625 | if (m_parent
| 0 | ||||||||||||||||||||||||
| 626 | m_parent->childLeave(); never executed: m_parent->childLeave(); | 0 | ||||||||||||||||||||||||
| 627 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 628 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 629 | - | |||||||||||||||||||||||||
| 630 | void QMenuSloppyState::setSubMenuPopup(const QRect &actionRect, QAction *resetAction, QMenu *subMenu) | - | ||||||||||||||||||||||||
| 631 | { | - | ||||||||||||||||||||||||
| 632 | m_enabled = true; | - | ||||||||||||||||||||||||
| 633 | m_init_guard = true; | - | ||||||||||||||||||||||||
| 634 | m_time.stop(); | - | ||||||||||||||||||||||||
| 635 | m_action_rect = actionRect; | - | ||||||||||||||||||||||||
| 636 | m_sub_menu = subMenu; | - | ||||||||||||||||||||||||
| 637 | QMenuPrivate::get(subMenu)->sloppyState.m_parent = this; | - | ||||||||||||||||||||||||
| 638 | m_reset_action = resetAction; | - | ||||||||||||||||||||||||
| 639 | m_origin_action = resetAction; | - | ||||||||||||||||||||||||
| 640 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 641 | - | |||||||||||||||||||||||||
| 642 | bool QMenuSloppyState::hasParentActiveDelayTimer() const | - | ||||||||||||||||||||||||
| 643 | { | - | ||||||||||||||||||||||||
| 644 | return never executed: m_parentreturn m_parent && m_parent->m_menu && QMenuPrivate::get(m_parent->m_menu)->delayState.timer.isActive();
never executed: return m_parent && m_parent->m_menu && QMenuPrivate::get(m_parent->m_menu)->delayState.timer.isActive(); | 0 | ||||||||||||||||||||||||
| 645 | } | - | ||||||||||||||||||||||||
| 646 | - | |||||||||||||||||||||||||
| 647 | class ResetOnDestroy | - | ||||||||||||||||||||||||
| 648 | { | - | ||||||||||||||||||||||||
| 649 | public: | - | ||||||||||||||||||||||||
| 650 | ResetOnDestroy(QMenuSloppyState *sloppyState, bool *guard) | - | ||||||||||||||||||||||||
| 651 | : toReset(sloppyState) | - | ||||||||||||||||||||||||
| 652 | , guard(guard) | - | ||||||||||||||||||||||||
| 653 | { | - | ||||||||||||||||||||||||
| 654 | *guard = false; | - | ||||||||||||||||||||||||
| 655 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 656 | - | |||||||||||||||||||||||||
| 657 | ~ResetOnDestroy() | - | ||||||||||||||||||||||||
| 658 | { | - | ||||||||||||||||||||||||
| 659 | if (!*guard
| 0 | ||||||||||||||||||||||||
| 660 | toReset->reset(); never executed: toReset->reset(); | 0 | ||||||||||||||||||||||||
| 661 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 662 | - | |||||||||||||||||||||||||
| 663 | QMenuSloppyState *toReset; | - | ||||||||||||||||||||||||
| 664 | bool *guard; | - | ||||||||||||||||||||||||
| 665 | }; | - | ||||||||||||||||||||||||
| 666 | - | |||||||||||||||||||||||||
| 667 | void QMenuSloppyState::timeout() | - | ||||||||||||||||||||||||
| 668 | { | - | ||||||||||||||||||||||||
| 669 | QMenuPrivate *menu_priv = QMenuPrivate::get(m_menu); | - | ||||||||||||||||||||||||
| 670 | - | |||||||||||||||||||||||||
| 671 | bool reallyHasMouse = menu_priv->hasReceievedEnter; | - | ||||||||||||||||||||||||
| 672 | if (!reallyHasMouse
| 0 | ||||||||||||||||||||||||
| 673 | - | |||||||||||||||||||||||||
| 674 | - | |||||||||||||||||||||||||
| 675 | const QPoint lastCursorPos = QGuiApplicationPrivate::lastCursorPosition.toPoint(); | - | ||||||||||||||||||||||||
| 676 | reallyHasMouse = m_menu->frameGeometry().contains(lastCursorPos); | - | ||||||||||||||||||||||||
| 677 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 678 | - | |||||||||||||||||||||||||
| 679 | if (menu_priv->currentAction == m_reset_action
| 0 | ||||||||||||||||||||||||
| 680 | && reallyHasMouse
| 0 | ||||||||||||||||||||||||
| 681 | && (menu_priv->currentAction
| 0 | ||||||||||||||||||||||||
| 682 | && menu_priv->currentAction->menu() == menu_priv->activeMenu
| 0 | ||||||||||||||||||||||||
| 683 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 684 | } | - | ||||||||||||||||||||||||
| 685 | - | |||||||||||||||||||||||||
| 686 | ResetOnDestroy resetState(this, &m_init_guard); | - | ||||||||||||||||||||||||
| 687 | - | |||||||||||||||||||||||||
| 688 | if (hasParentActiveDelayTimer()
| 0 | ||||||||||||||||||||||||
| 689 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 690 | - | |||||||||||||||||||||||||
| 691 | if (m_sub_menu
| 0 | ||||||||||||||||||||||||
| 692 | menu_priv->hideMenu(m_sub_menu); never executed: menu_priv->hideMenu(m_sub_menu); | 0 | ||||||||||||||||||||||||
| 693 | - | |||||||||||||||||||||||||
| 694 | if (reallyHasMouse
| 0 | ||||||||||||||||||||||||
| 695 | menu_priv->setCurrentAction(m_reset_action,0); never executed: menu_priv->setCurrentAction(m_reset_action,0); | 0 | ||||||||||||||||||||||||
| 696 | else | - | ||||||||||||||||||||||||
| 697 | menu_priv->setCurrentAction(nullptr, 0); never executed: menu_priv->setCurrentAction(nullptr, 0); | 0 | ||||||||||||||||||||||||
| 698 | } | - | ||||||||||||||||||||||||
| 699 | - | |||||||||||||||||||||||||
| 700 | - | |||||||||||||||||||||||||
| 701 | QWidget *QMenuPrivate::topCausedWidget() const | - | ||||||||||||||||||||||||
| 702 | { | - | ||||||||||||||||||||||||
| 703 | QWidget* top = causedPopup.widget; | - | ||||||||||||||||||||||||
| 704 | while (QMenu* m = qobject_cast<QMenu *>(top)
| 0 | ||||||||||||||||||||||||
| 705 | top = m->d_func()->causedPopup.widget; never executed: top = m->d_func()->causedPopup.widget; | 0 | ||||||||||||||||||||||||
| 706 | return never executed: top;return top;never executed: return top; | 0 | ||||||||||||||||||||||||
| 707 | } | - | ||||||||||||||||||||||||
| 708 | - | |||||||||||||||||||||||||
| 709 | QAction *QMenuPrivate::actionAt(QPoint p) const | - | ||||||||||||||||||||||||
| 710 | { | - | ||||||||||||||||||||||||
| 711 | if (!q_func()->rect().contains(p)
| 0 | ||||||||||||||||||||||||
| 712 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 713 | - | |||||||||||||||||||||||||
| 714 | for(int i = 0; i < actionRects.count()
| 0 | ||||||||||||||||||||||||
| 715 | if (actionRects.at(i).contains(p)
| 0 | ||||||||||||||||||||||||
| 716 | return never executed: actions.at(i);return actions.at(i);never executed: return actions.at(i); | 0 | ||||||||||||||||||||||||
| 717 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 718 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 719 | } | - | ||||||||||||||||||||||||
| 720 | - | |||||||||||||||||||||||||
| 721 | void QMenuPrivate::setOverrideMenuAction(QAction *a) | - | ||||||||||||||||||||||||
| 722 | { | - | ||||||||||||||||||||||||
| 723 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 724 | QObject::disconnect(menuAction, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "775"), q, qFlagLocation("1""_q_overrideMenuActionDestroyed()" "\0" __FILE__ ":" "775")); | - | ||||||||||||||||||||||||
| 725 | if (a
| 0 | ||||||||||||||||||||||||
| 726 | menuAction = a; | - | ||||||||||||||||||||||||
| 727 | QObject::connect(a, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "778"), q, qFlagLocation("1""_q_overrideMenuActionDestroyed()" "\0" __FILE__ ":" "778")); | - | ||||||||||||||||||||||||
| 728 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 729 | menuAction = defaultMenuAction; | - | ||||||||||||||||||||||||
| 730 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 731 | } | - | ||||||||||||||||||||||||
| 732 | - | |||||||||||||||||||||||||
| 733 | void QMenuPrivate::_q_overrideMenuActionDestroyed() | - | ||||||||||||||||||||||||
| 734 | { | - | ||||||||||||||||||||||||
| 735 | menuAction=defaultMenuAction; | - | ||||||||||||||||||||||||
| 736 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 737 | - | |||||||||||||||||||||||||
| 738 | - | |||||||||||||||||||||||||
| 739 | void QMenuPrivate::updateLayoutDirection() | - | ||||||||||||||||||||||||
| 740 | { | - | ||||||||||||||||||||||||
| 741 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 742 | - | |||||||||||||||||||||||||
| 743 | - | |||||||||||||||||||||||||
| 744 | - | |||||||||||||||||||||||||
| 745 | if (!q->testAttribute(Qt::WA_SetLayoutDirection)
| 0 | ||||||||||||||||||||||||
| 746 | if (QWidget *w = causedPopup.widget
| 0 | ||||||||||||||||||||||||
| 747 | setLayoutDirection_helper(w->layoutDirection()); never executed: setLayoutDirection_helper(w->layoutDirection()); | 0 | ||||||||||||||||||||||||
| 748 | else if (QWidget *w = q->parentWidget()
| 0 | ||||||||||||||||||||||||
| 749 | setLayoutDirection_helper(w->layoutDirection()); never executed: setLayoutDirection_helper(w->layoutDirection()); | 0 | ||||||||||||||||||||||||
| 750 | else | - | ||||||||||||||||||||||||
| 751 | setLayoutDirection_helper(QApplication::layoutDirection()); never executed: setLayoutDirection_helper(QApplication::layoutDirection()); | 0 | ||||||||||||||||||||||||
| 752 | } | - | ||||||||||||||||||||||||
| 753 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 754 | - | |||||||||||||||||||||||||
| 755 | - | |||||||||||||||||||||||||
| 756 | - | |||||||||||||||||||||||||
| 757 | - | |||||||||||||||||||||||||
| 758 | - | |||||||||||||||||||||||||
| 759 | QAction *QMenu::menuAction() const | - | ||||||||||||||||||||||||
| 760 | { | - | ||||||||||||||||||||||||
| 761 | return never executed: d_func()->menuAction;return d_func()->menuAction;never executed: return d_func()->menuAction; | 0 | ||||||||||||||||||||||||
| 762 | } | - | ||||||||||||||||||||||||
| 763 | QString QMenu::title() const | - | ||||||||||||||||||||||||
| 764 | { | - | ||||||||||||||||||||||||
| 765 | return never executed: d_func()->menuAction->text();return d_func()->menuAction->text();never executed: return d_func()->menuAction->text(); | 0 | ||||||||||||||||||||||||
| 766 | } | - | ||||||||||||||||||||||||
| 767 | - | |||||||||||||||||||||||||
| 768 | void QMenu::setTitle(const QString &text) | - | ||||||||||||||||||||||||
| 769 | { | - | ||||||||||||||||||||||||
| 770 | d_func()->menuAction->setText(text); | - | ||||||||||||||||||||||||
| 771 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 772 | QIcon QMenu::icon() const | - | ||||||||||||||||||||||||
| 773 | { | - | ||||||||||||||||||||||||
| 774 | return never executed: d_func()->menuAction->icon();return d_func()->menuAction->icon();never executed: return d_func()->menuAction->icon(); | 0 | ||||||||||||||||||||||||
| 775 | } | - | ||||||||||||||||||||||||
| 776 | - | |||||||||||||||||||||||||
| 777 | void QMenu::setIcon(const QIcon &icon) | - | ||||||||||||||||||||||||
| 778 | { | - | ||||||||||||||||||||||||
| 779 | d_func()->menuAction->setIcon(icon); | - | ||||||||||||||||||||||||
| 780 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 781 | - | |||||||||||||||||||||||||
| 782 | - | |||||||||||||||||||||||||
| 783 | - | |||||||||||||||||||||||||
| 784 | void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation location, bool active) | - | ||||||||||||||||||||||||
| 785 | { | - | ||||||||||||||||||||||||
| 786 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 787 | if (!scroll
| 0 | ||||||||||||||||||||||||
| 788 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 789 | updateActionRects(); | - | ||||||||||||||||||||||||
| 790 | int newOffset = 0; | - | ||||||||||||||||||||||||
| 791 | const int topScroll = (
| 0 | ||||||||||||||||||||||||
| 792 | const int botScroll = (
| 0 | ||||||||||||||||||||||||
| 793 | const int vmargin = q->style()->pixelMetric(QStyle::PM_MenuVMargin, 0, q); | - | ||||||||||||||||||||||||
| 794 | const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q); | - | ||||||||||||||||||||||||
| 795 | - | |||||||||||||||||||||||||
| 796 | if (location == QMenuScroller::ScrollTop
| 0 | ||||||||||||||||||||||||
| 797 | for(int i = 0, saccum = 0; i < actions.count()
| 0 | ||||||||||||||||||||||||
| 798 | if (actions.at(i) == action
| 0 | ||||||||||||||||||||||||
| 799 | newOffset = topScroll - saccum; | - | ||||||||||||||||||||||||
| 800 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 801 | } | - | ||||||||||||||||||||||||
| 802 | saccum += actionRects.at(i).height(); | - | ||||||||||||||||||||||||
| 803 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 804 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 805 | for(int i = 0, saccum = 0; i < actions.count()
| 0 | ||||||||||||||||||||||||
| 806 | saccum += actionRects.at(i).height(); | - | ||||||||||||||||||||||||
| 807 | if (actions.at(i) == action
| 0 | ||||||||||||||||||||||||
| 808 | if (location == QMenuScroller::ScrollCenter
| 0 | ||||||||||||||||||||||||
| 809 | newOffset = ((q->height() / 2) - botScroll) - (saccum - topScroll); never executed: newOffset = ((q->height() / 2) - botScroll) - (saccum - topScroll); | 0 | ||||||||||||||||||||||||
| 810 | else | - | ||||||||||||||||||||||||
| 811 | newOffset = (q->height() - botScroll) - saccum; never executed: newOffset = (q->height() - botScroll) - saccum; | 0 | ||||||||||||||||||||||||
| 812 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 813 | } | - | ||||||||||||||||||||||||
| 814 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 815 | if(newOffset
| 0 | ||||||||||||||||||||||||
| 816 | newOffset -= fw * 2; never executed: newOffset -= fw * 2; | 0 | ||||||||||||||||||||||||
| 817 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 818 | - | |||||||||||||||||||||||||
| 819 | - | |||||||||||||||||||||||||
| 820 | uint newScrollFlags = QMenuScroller::ScrollNone; | - | ||||||||||||||||||||||||
| 821 | if (newOffset < 0
| 0 | ||||||||||||||||||||||||
| 822 | newScrollFlags |= QMenuScroller::ScrollUp; never executed: newScrollFlags |= QMenuScroller::ScrollUp; | 0 | ||||||||||||||||||||||||
| 823 | int saccum = newOffset; | - | ||||||||||||||||||||||||
| 824 | for(int i = 0; i < actionRects.count()
| 0 | ||||||||||||||||||||||||
| 825 | saccum += actionRects.at(i).height(); | - | ||||||||||||||||||||||||
| 826 | if (saccum > q->height()
| 0 | ||||||||||||||||||||||||
| 827 | newScrollFlags |= QMenuScroller::ScrollDown; | - | ||||||||||||||||||||||||
| 828 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 829 | } | - | ||||||||||||||||||||||||
| 830 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 831 | - | |||||||||||||||||||||||||
| 832 | if (!(newScrollFlags & QMenuScroller::ScrollDown)
| 0 | ||||||||||||||||||||||||
| 833 | newOffset = q->height() - (saccum - newOffset) - fw*2 - vmargin; | - | ||||||||||||||||||||||||
| 834 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 835 | - | |||||||||||||||||||||||||
| 836 | if (!(newScrollFlags & QMenuScroller::ScrollUp)
| 0 | ||||||||||||||||||||||||
| 837 | newOffset = 0; | - | ||||||||||||||||||||||||
| 838 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 839 | - | |||||||||||||||||||||||||
| 840 | if (newScrollFlags & QMenuScroller::ScrollUp
| 0 | ||||||||||||||||||||||||
| 841 | newOffset -= vmargin; never executed: newOffset -= vmargin; | 0 | ||||||||||||||||||||||||
| 842 | - | |||||||||||||||||||||||||
| 843 | QRect screen = popupGeometry(q); | - | ||||||||||||||||||||||||
| 844 | const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q); | - | ||||||||||||||||||||||||
| 845 | if (q->height() < screen.height()-(desktopFrame*2)-1
| 0 | ||||||||||||||||||||||||
| 846 | QRect geom = q->geometry(); | - | ||||||||||||||||||||||||
| 847 | if (newOffset > scroll->scrollOffset
| 0 | ||||||||||||||||||||||||
| 848 | const int newHeight = geom.height()-(newOffset-scroll->scrollOffset); | - | ||||||||||||||||||||||||
| 849 | if(newHeight > geom.height()
| 0 | ||||||||||||||||||||||||
| 850 | geom.setHeight(newHeight); never executed: geom.setHeight(newHeight); | 0 | ||||||||||||||||||||||||
| 851 | } never executed: else if(scroll->scrollFlags & newScrollFlags & QMenuScroller::ScrollDownend of block
| 0 | ||||||||||||||||||||||||
| 852 | int newTop = geom.top() + (newOffset-scroll->scrollOffset); | - | ||||||||||||||||||||||||
| 853 | if (newTop < desktopFrame+screen.top()
| 0 | ||||||||||||||||||||||||
| 854 | newTop = desktopFrame+screen.top(); never executed: newTop = desktopFrame+screen.top(); | 0 | ||||||||||||||||||||||||
| 855 | if (newTop < geom.top()
| 0 | ||||||||||||||||||||||||
| 856 | geom.setTop(newTop); | - | ||||||||||||||||||||||||
| 857 | newOffset = 0; | - | ||||||||||||||||||||||||
| 858 | newScrollFlags &= ~QMenuScroller::ScrollUp; | - | ||||||||||||||||||||||||
| 859 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 860 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 861 | if (geom.bottom() > screen.bottom() - desktopFrame
| 0 | ||||||||||||||||||||||||
| 862 | geom.setBottom(screen.bottom() - desktopFrame); never executed: geom.setBottom(screen.bottom() - desktopFrame); | 0 | ||||||||||||||||||||||||
| 863 | if (geom.top() < desktopFrame+screen.top()
| 0 | ||||||||||||||||||||||||
| 864 | geom.setTop(desktopFrame+screen.top()); never executed: geom.setTop(desktopFrame+screen.top()); | 0 | ||||||||||||||||||||||||
| 865 | if (geom != q->geometry()
| 0 | ||||||||||||||||||||||||
| 866 | - | |||||||||||||||||||||||||
| 867 | - | |||||||||||||||||||||||||
| 868 | - | |||||||||||||||||||||||||
| 869 | - | |||||||||||||||||||||||||
| 870 | - | |||||||||||||||||||||||||
| 871 | q->setGeometry(geom); | - | ||||||||||||||||||||||||
| 872 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 873 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 874 | - | |||||||||||||||||||||||||
| 875 | - | |||||||||||||||||||||||||
| 876 | const int delta = qMin(0, newOffset) - scroll->scrollOffset; | - | ||||||||||||||||||||||||
| 877 | if (!itemsDirty
| 0 | ||||||||||||||||||||||||
| 878 | - | |||||||||||||||||||||||||
| 879 | for (int i = 0; i < actionRects.count()
| 0 | ||||||||||||||||||||||||
| 880 | QRect ¤t = actionRects[i]; | - | ||||||||||||||||||||||||
| 881 | current.moveTop(current.top() + delta); | - | ||||||||||||||||||||||||
| 882 | - | |||||||||||||||||||||||||
| 883 | - | |||||||||||||||||||||||||
| 884 | if (QWidget *w = widgetItems.value(actions.at(i))
| 0 | ||||||||||||||||||||||||
| 885 | w->setGeometry(current); never executed: w->setGeometry(current); | 0 | ||||||||||||||||||||||||
| 886 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 887 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 888 | scroll->scrollOffset += delta; | - | ||||||||||||||||||||||||
| 889 | scroll->scrollFlags = newScrollFlags; | - | ||||||||||||||||||||||||
| 890 | if (active
| 0 | ||||||||||||||||||||||||
| 891 | setCurrentAction(action); never executed: setCurrentAction(action); | 0 | ||||||||||||||||||||||||
| 892 | - | |||||||||||||||||||||||||
| 893 | q->update(); | - | ||||||||||||||||||||||||
| 894 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 895 | - | |||||||||||||||||||||||||
| 896 | void QMenuPrivate::scrollMenu(QMenuScroller::ScrollLocation location, bool active) | - | ||||||||||||||||||||||||
| 897 | { | - | ||||||||||||||||||||||||
| 898 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 899 | updateActionRects(); | - | ||||||||||||||||||||||||
| 900 | if(location == QMenuScroller::ScrollBottom
| 0 | ||||||||||||||||||||||||
| 901 | for(int i = actions.size()-1; i >= 0
| 0 | ||||||||||||||||||||||||
| 902 | QAction *act = actions.at(i); | - | ||||||||||||||||||||||||
| 903 | if (actionRects.at(i).isNull()
| 0 | ||||||||||||||||||||||||
| 904 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 905 | if (!act->isSeparator()
| 0 | ||||||||||||||||||||||||
| 906 | (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)
| 0 | ||||||||||||||||||||||||
| 907 | || act->isEnabled()
| 0 | ||||||||||||||||||||||||
| 908 | if(scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown
| 0 | ||||||||||||||||||||||||
| 909 | scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollBottom, active); never executed: scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollBottom, active); | 0 | ||||||||||||||||||||||||
| 910 | else if(active
| 0 | ||||||||||||||||||||||||
| 911 | setCurrentAction(act, -1, QMenuPrivate::SelectedFromKeyboard); never executed: setCurrentAction(act, -1, QMenuPrivate::SelectedFromKeyboard); | 0 | ||||||||||||||||||||||||
| 912 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 913 | } | - | ||||||||||||||||||||||||
| 914 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 915 | } never executed: else if(location == QMenuScroller::ScrollTopend of block
| 0 | ||||||||||||||||||||||||
| 916 | for(int i = 0; i < actions.size()
| 0 | ||||||||||||||||||||||||
| 917 | QAction *act = actions.at(i); | - | ||||||||||||||||||||||||
| 918 | if (actionRects.at(i).isNull()
| 0 | ||||||||||||||||||||||||
| 919 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 920 | if (!act->isSeparator()
| 0 | ||||||||||||||||||||||||
| 921 | (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)
| 0 | ||||||||||||||||||||||||
| 922 | || act->isEnabled()
| 0 | ||||||||||||||||||||||||
| 923 | if(scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp
| 0 | ||||||||||||||||||||||||
| 924 | scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollTop, active); never executed: scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollTop, active); | 0 | ||||||||||||||||||||||||
| 925 | else if(active
| 0 | ||||||||||||||||||||||||
| 926 | setCurrentAction(act, -1, QMenuPrivate::SelectedFromKeyboard); never executed: setCurrentAction(act, -1, QMenuPrivate::SelectedFromKeyboard); | 0 | ||||||||||||||||||||||||
| 927 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 928 | } | - | ||||||||||||||||||||||||
| 929 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 930 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 931 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 932 | - | |||||||||||||||||||||||||
| 933 | - | |||||||||||||||||||||||||
| 934 | void QMenuPrivate::scrollMenu(QMenuScroller::ScrollDirection direction, bool page, bool active) | - | ||||||||||||||||||||||||
| 935 | { | - | ||||||||||||||||||||||||
| 936 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 937 | if (!scroll
| 0 | ||||||||||||||||||||||||
| 938 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 939 | updateActionRects(); | - | ||||||||||||||||||||||||
| 940 | const int topScroll = (
| 0 | ||||||||||||||||||||||||
| 941 | const int botScroll = (
| 0 | ||||||||||||||||||||||||
| 942 | const int vmargin = q->style()->pixelMetric(QStyle::PM_MenuVMargin, 0, q); | - | ||||||||||||||||||||||||
| 943 | const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q); | - | ||||||||||||||||||||||||
| 944 | const int offset = topScroll
| 0 | ||||||||||||||||||||||||
| 945 | if (direction == QMenuScroller::ScrollUp
| 0 | ||||||||||||||||||||||||
| 946 | for(int i = 0, saccum = 0; i < actions.count()
| 0 | ||||||||||||||||||||||||
| 947 | saccum -= actionRects.at(i).height(); | - | ||||||||||||||||||||||||
| 948 | if (saccum <= scroll->scrollOffset-offset
| 0 | ||||||||||||||||||||||||
| 949 | scrollMenu(actions.at(i), page ? QMenuScroller::ScrollBottom : QMenuScroller::ScrollTop, active); | - | ||||||||||||||||||||||||
| 950 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 951 | } | - | ||||||||||||||||||||||||
| 952 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 953 | } never executed: else if (direction == QMenuScroller::ScrollDownend of block
| 0 | ||||||||||||||||||||||||
| 954 | bool scrolled = false; | - | ||||||||||||||||||||||||
| 955 | for(int i = 0, saccum = 0; i < actions.count()
| 0 | ||||||||||||||||||||||||
| 956 | const int iHeight = actionRects.at(i).height(); | - | ||||||||||||||||||||||||
| 957 | saccum -= iHeight; | - | ||||||||||||||||||||||||
| 958 | if (saccum <= scroll->scrollOffset-offset
| 0 | ||||||||||||||||||||||||
| 959 | const int scrollerArea = q->height() - botScroll - fw*2; | - | ||||||||||||||||||||||||
| 960 | int visible = (scroll->scrollOffset-offset) - saccum; | - | ||||||||||||||||||||||||
| 961 | for(i++ ; i < actions.count()
| 0 | ||||||||||||||||||||||||
| 962 | visible += actionRects.at(i).height(); | - | ||||||||||||||||||||||||
| 963 | if (visible > scrollerArea - topScroll
| 0 | ||||||||||||||||||||||||
| 964 | scrolled = true; | - | ||||||||||||||||||||||||
| 965 | scrollMenu(actions.at(i), page ? QMenuScroller::ScrollTop : QMenuScroller::ScrollBottom, active); | - | ||||||||||||||||||||||||
| 966 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 967 | } | - | ||||||||||||||||||||||||
| 968 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 969 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 970 | } | - | ||||||||||||||||||||||||
| 971 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 972 | if(!scrolled
| 0 | ||||||||||||||||||||||||
| 973 | scroll->scrollFlags &= ~QMenuScroller::ScrollDown; | - | ||||||||||||||||||||||||
| 974 | q->update(); | - | ||||||||||||||||||||||||
| 975 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 976 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 977 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 978 | - | |||||||||||||||||||||||||
| 979 | - | |||||||||||||||||||||||||
| 980 | - | |||||||||||||||||||||||||
| 981 | bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) | - | ||||||||||||||||||||||||
| 982 | { | - | ||||||||||||||||||||||||
| 983 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 984 | QPoint pos = q->mapFromGlobal(e->globalPos()); | - | ||||||||||||||||||||||||
| 985 | if (scroll
| 0 | ||||||||||||||||||||||||
| 986 | bool isScroll = false; | - | ||||||||||||||||||||||||
| 987 | if (pos.x() >= 0
| 0 | ||||||||||||||||||||||||
| 988 | for(int dir = QMenuScroller::ScrollUp; dir <= QMenuScroller::ScrollDown
| 0 | ||||||||||||||||||||||||
| 989 | if (scroll->scrollFlags & dir
| 0 | ||||||||||||||||||||||||
| 990 | if (dir == QMenuScroller::ScrollUp
| 0 | ||||||||||||||||||||||||
| 991 | isScroll = (pos.y() <= scrollerHeight()); never executed: isScroll = (pos.y() <= scrollerHeight()); | 0 | ||||||||||||||||||||||||
| 992 | else if (dir == QMenuScroller::ScrollDown
| 0 | ||||||||||||||||||||||||
| 993 | isScroll = (pos.y() >= q->height() - scrollerHeight()); never executed: isScroll = (pos.y() >= q->height() - scrollerHeight()); | 0 | ||||||||||||||||||||||||
| 994 | if (isScroll
| 0 | ||||||||||||||||||||||||
| 995 | scroll->scrollDirection = dir; | - | ||||||||||||||||||||||||
| 996 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 997 | } | - | ||||||||||||||||||||||||
| 998 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 999 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1000 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1001 | if (isScroll
| 0 | ||||||||||||||||||||||||
| 1002 | scroll->scrollTimer.start(50, q); | - | ||||||||||||||||||||||||
| 1003 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 1004 | } else { | - | ||||||||||||||||||||||||
| 1005 | scroll->scrollTimer.stop(); | - | ||||||||||||||||||||||||
| 1006 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1007 | } | - | ||||||||||||||||||||||||
| 1008 | - | |||||||||||||||||||||||||
| 1009 | if (tearoff
| 0 | ||||||||||||||||||||||||
| 1010 | QRect tearRect(0, 0, q->width(), q->style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, q)); | - | ||||||||||||||||||||||||
| 1011 | if (scroll
| 0 | ||||||||||||||||||||||||
| 1012 | tearRect.translate(0, scrollerHeight()); never executed: tearRect.translate(0, scrollerHeight()); | 0 | ||||||||||||||||||||||||
| 1013 | q->update(tearRect); | - | ||||||||||||||||||||||||
| 1014 | if (tearRect.contains(pos)
| 0 | ||||||||||||||||||||||||
| 1015 | setCurrentAction(0); | - | ||||||||||||||||||||||||
| 1016 | tearoffHighlighted = 1; | - | ||||||||||||||||||||||||
| 1017 | if (e->type() == QEvent::MouseButtonRelease
| 0 | ||||||||||||||||||||||||
| 1018 | if (!tornPopup
| 0 | ||||||||||||||||||||||||
| 1019 | tornPopup = new QTornOffMenu(q); never executed: tornPopup = new QTornOffMenu(q); | 0 | ||||||||||||||||||||||||
| 1020 | tornPopup->setGeometry(q->geometry()); | - | ||||||||||||||||||||||||
| 1021 | tornPopup->show(); | - | ||||||||||||||||||||||||
| 1022 | hideUpToMenuBar(); | - | ||||||||||||||||||||||||
| 1023 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1024 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 1025 | } | - | ||||||||||||||||||||||||
| 1026 | tearoffHighlighted = 0; | - | ||||||||||||||||||||||||
| 1027 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1028 | - | |||||||||||||||||||||||||
| 1029 | if (q->frameGeometry().contains(e->globalPos())
| 0 | ||||||||||||||||||||||||
| 1030 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1031 | - | |||||||||||||||||||||||||
| 1032 | for(QWidget *caused = causedPopup.widget; caused
| 0 | ||||||||||||||||||||||||
| 1033 | bool passOnEvent = false; | - | ||||||||||||||||||||||||
| 1034 | QWidget *next_widget = 0; | - | ||||||||||||||||||||||||
| 1035 | QPoint cpos = caused->mapFromGlobal(e->globalPos()); | - | ||||||||||||||||||||||||
| 1036 | - | |||||||||||||||||||||||||
| 1037 | if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)
| 0 | ||||||||||||||||||||||||
| 1038 | passOnEvent = mb->rect().contains(cpos); | - | ||||||||||||||||||||||||
| 1039 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||
| 1040 | - | |||||||||||||||||||||||||
| 1041 | if (QMenu *m = qobject_cast<QMenu*>(caused)
| 0 | ||||||||||||||||||||||||
| 1042 | passOnEvent = m->rect().contains(cpos); | - | ||||||||||||||||||||||||
| 1043 | next_widget = m->d_func()->causedPopup.widget; | - | ||||||||||||||||||||||||
| 1044 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1045 | if (passOnEvent
| 0 | ||||||||||||||||||||||||
| 1046 | if (e->type() != QEvent::MouseButtonRelease
| 0 | ||||||||||||||||||||||||
| 1047 | QMouseEvent new_e(e->type(), cpos, caused->mapTo(caused->topLevelWidget(), cpos), e->screenPos(), | - | ||||||||||||||||||||||||
| 1048 | e->button(), e->buttons(), e->modifiers(), e->source()); | - | ||||||||||||||||||||||||
| 1049 | QApplication::sendEvent(caused, &new_e); | - | ||||||||||||||||||||||||
| 1050 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 1051 | } | - | ||||||||||||||||||||||||
| 1052 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1053 | caused = next_widget; | - | ||||||||||||||||||||||||
| 1054 | if (!caused
| 0 | ||||||||||||||||||||||||
| 1055 | sloppyState.leave(); never executed: sloppyState.leave(); | 0 | ||||||||||||||||||||||||
| 1056 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1057 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1058 | } | - | ||||||||||||||||||||||||
| 1059 | - | |||||||||||||||||||||||||
| 1060 | void QMenuPrivate::activateCausedStack(const QVector<QPointer<QWidget> > &causedStack, QAction *action, QAction::ActionEvent action_e, bool self) | - | ||||||||||||||||||||||||
| 1061 | { | - | ||||||||||||||||||||||||
| 1062 | QBoolBlocker guard(activationRecursionGuard); | - | ||||||||||||||||||||||||
| 1063 | if(self
| 0 | ||||||||||||||||||||||||
| 1064 | action->activate(action_e); never executed: action->activate(action_e); | 0 | ||||||||||||||||||||||||
| 1065 | - | |||||||||||||||||||||||||
| 1066 | for(int i = 0; i < causedStack.size()
| 0 | ||||||||||||||||||||||||
| 1067 | QPointer<QWidget> widget = causedStack.at(i); | - | ||||||||||||||||||||||||
| 1068 | if (!widget
| 0 | ||||||||||||||||||||||||
| 1069 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1070 | - | |||||||||||||||||||||||||
| 1071 | if (QMenu *qmenu = qobject_cast<QMenu*>(widget)
| 0 | ||||||||||||||||||||||||
| 1072 | widget = qmenu->d_func()->causedPopup.widget; | - | ||||||||||||||||||||||||
| 1073 | if (action_e == QAction::Trigger
| 0 | ||||||||||||||||||||||||
| 1074 | qmenu->triggered(action); | - | ||||||||||||||||||||||||
| 1075 | } never executed: else if (action_e == QAction::Hoverend of block
| 0 | ||||||||||||||||||||||||
| 1076 | qmenu->hovered(action); | - | ||||||||||||||||||||||||
| 1077 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1078 | - | |||||||||||||||||||||||||
| 1079 | } never executed: else if (QMenuBar *qmenubar = qobject_cast<QMenuBar*>(widget)end of block
| 0 | ||||||||||||||||||||||||
| 1080 | if (action_e == QAction::Trigger
| 0 | ||||||||||||||||||||||||
| 1081 | qmenubar->triggered(action); | - | ||||||||||||||||||||||||
| 1082 | } never executed: else if (action_e == QAction::Hoverend of block
| 0 | ||||||||||||||||||||||||
| 1083 | qmenubar->hovered(action); | - | ||||||||||||||||||||||||
| 1084 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1085 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1086 | - | |||||||||||||||||||||||||
| 1087 | } | - | ||||||||||||||||||||||||
| 1088 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1089 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1090 | - | |||||||||||||||||||||||||
| 1091 | void QMenuPrivate::activateAction(QAction *action, QAction::ActionEvent action_e, bool self) | - | ||||||||||||||||||||||||
| 1092 | { | - | ||||||||||||||||||||||||
| 1093 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 1094 | - | |||||||||||||||||||||||||
| 1095 | bool inWhatsThisMode = QWhatsThis::inWhatsThisMode(); | - | ||||||||||||||||||||||||
| 1096 | - | |||||||||||||||||||||||||
| 1097 | if (!action
| 0 | ||||||||||||||||||||||||
| 1098 | || (action_e == QAction::Trigger
| 0 | ||||||||||||||||||||||||
| 1099 | - | |||||||||||||||||||||||||
| 1100 | && !inWhatsThisMode
| 0 | ||||||||||||||||||||||||
| 1101 | - | |||||||||||||||||||||||||
| 1102 | && (action->isSeparator()
| 0 | ||||||||||||||||||||||||
| 1103 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1104 | - | |||||||||||||||||||||||||
| 1105 | - | |||||||||||||||||||||||||
| 1106 | - | |||||||||||||||||||||||||
| 1107 | - | |||||||||||||||||||||||||
| 1108 | const QVector<QPointer<QWidget> > causedStack = calcCausedStack(); | - | ||||||||||||||||||||||||
| 1109 | if (action_e == QAction::Trigger
| 0 | ||||||||||||||||||||||||
| 1110 | - | |||||||||||||||||||||||||
| 1111 | if (!inWhatsThisMode
| 0 | ||||||||||||||||||||||||
| 1112 | actionAboutToTrigger = action; never executed: actionAboutToTrigger = action; | 0 | ||||||||||||||||||||||||
| 1113 | - | |||||||||||||||||||||||||
| 1114 | - | |||||||||||||||||||||||||
| 1115 | if (q->testAttribute(Qt::WA_DontShowOnScreen)
| 0 | ||||||||||||||||||||||||
| 1116 | hideUpToMenuBar(); | - | ||||||||||||||||||||||||
| 1117 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1118 | for(QWidget *widget = QApplication::activePopupWidget(); widget
| 0 | ||||||||||||||||||||||||
| 1119 | if (QMenu *qmenu = qobject_cast<QMenu*>(widget)
| 0 | ||||||||||||||||||||||||
| 1120 | if(qmenu == q
| 0 | ||||||||||||||||||||||||
| 1121 | hideUpToMenuBar(); never executed: hideUpToMenuBar(); | 0 | ||||||||||||||||||||||||
| 1122 | widget = qmenu->d_func()->causedPopup.widget; | - | ||||||||||||||||||||||||
| 1123 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1124 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1125 | } | - | ||||||||||||||||||||||||
| 1126 | } | - | ||||||||||||||||||||||||
| 1127 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1128 | - | |||||||||||||||||||||||||
| 1129 | - | |||||||||||||||||||||||||
| 1130 | if (inWhatsThisMode
| 0 | ||||||||||||||||||||||||
| 1131 | QString s = action->whatsThis(); | - | ||||||||||||||||||||||||
| 1132 | if (s.isEmpty()
| 0 | ||||||||||||||||||||||||
| 1133 | s = whatsThis; never executed: s = whatsThis; | 0 | ||||||||||||||||||||||||
| 1134 | QWhatsThis::showText(q->mapToGlobal(actionRect(action).center()), s, q); | - | ||||||||||||||||||||||||
| 1135 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1136 | } | - | ||||||||||||||||||||||||
| 1137 | - | |||||||||||||||||||||||||
| 1138 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1139 | - | |||||||||||||||||||||||||
| 1140 | - | |||||||||||||||||||||||||
| 1141 | activateCausedStack(causedStack, action, action_e, self); | - | ||||||||||||||||||||||||
| 1142 | - | |||||||||||||||||||||||||
| 1143 | - | |||||||||||||||||||||||||
| 1144 | if (action_e == QAction::Hover
| 0 | ||||||||||||||||||||||||
| 1145 | - | |||||||||||||||||||||||||
| 1146 | if (QAccessible::isActive()
| 0 | ||||||||||||||||||||||||
| 1147 | int actionIndex = indexOf(action); | - | ||||||||||||||||||||||||
| 1148 | QAccessibleEvent focusEvent(q, QAccessible::Focus); | - | ||||||||||||||||||||||||
| 1149 | focusEvent.setChild(actionIndex); | - | ||||||||||||||||||||||||
| 1150 | QAccessible::updateAccessibility(&focusEvent); | - | ||||||||||||||||||||||||
| 1151 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1152 | - | |||||||||||||||||||||||||
| 1153 | action->showStatusText(topCausedWidget()); | - | ||||||||||||||||||||||||
| 1154 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1155 | actionAboutToTrigger = 0; | - | ||||||||||||||||||||||||
| 1156 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1157 | } | - | ||||||||||||||||||||||||
| 1158 | - | |||||||||||||||||||||||||
| 1159 | void QMenuPrivate::_q_actionTriggered() | - | ||||||||||||||||||||||||
| 1160 | { | - | ||||||||||||||||||||||||
| 1161 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 1162 | if (QAction *action = qobject_cast<QAction *>(q->sender())
| 0 | ||||||||||||||||||||||||
| 1163 | QPointer<QAction> actionGuard = action; | - | ||||||||||||||||||||||||
| 1164 | if (platformMenu
| 0 | ||||||||||||||||||||||||
| 1165 | platformMenu->dismiss(); never executed: platformMenu->dismiss(); | 0 | ||||||||||||||||||||||||
| 1166 | q->triggered(action); | - | ||||||||||||||||||||||||
| 1167 | if (!activationRecursionGuard
| 0 | ||||||||||||||||||||||||
| 1168 | - | |||||||||||||||||||||||||
| 1169 | - | |||||||||||||||||||||||||
| 1170 | QVector< QPointer<QWidget> > list; | - | ||||||||||||||||||||||||
| 1171 | for(QWidget *widget = q->parentWidget(); widget
| 0 | ||||||||||||||||||||||||
| 1172 | if (qobject_cast<QMenu*>(widget)
| 0 | ||||||||||||||||||||||||
| 1173 | - | |||||||||||||||||||||||||
| 1174 | || qobject_cast<QMenuBar*>(widget)
| 0 | ||||||||||||||||||||||||
| 1175 | - | |||||||||||||||||||||||||
| 1176 | ) { | - | ||||||||||||||||||||||||
| 1177 | list.append(widget); | - | ||||||||||||||||||||||||
| 1178 | widget = widget->parentWidget(); | - | ||||||||||||||||||||||||
| 1179 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1180 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1181 | } | - | ||||||||||||||||||||||||
| 1182 | } | - | ||||||||||||||||||||||||
| 1183 | activateCausedStack(list, action, QAction::Trigger, false); | - | ||||||||||||||||||||||||
| 1184 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1185 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1186 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1187 | - | |||||||||||||||||||||||||
| 1188 | void QMenuPrivate::_q_actionHovered() | - | ||||||||||||||||||||||||
| 1189 | { | - | ||||||||||||||||||||||||
| 1190 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 1191 | if (QAction * action = qobject_cast<QAction *>(q->sender())
| 0 | ||||||||||||||||||||||||
| 1192 | q->hovered(action); | - | ||||||||||||||||||||||||
| 1193 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1194 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1195 | - | |||||||||||||||||||||||||
| 1196 | void QMenuPrivate::_q_platformMenuAboutToShow() | - | ||||||||||||||||||||||||
| 1197 | { | - | ||||||||||||||||||||||||
| 1198 | QMenu * const q = q_func(); | - | ||||||||||||||||||||||||
| 1199 | q->aboutToShow(); | - | ||||||||||||||||||||||||
| 1200 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1201 | - | |||||||||||||||||||||||||
| 1202 | bool QMenuPrivate::hasMouseMoved(const QPoint &globalPos) | - | ||||||||||||||||||||||||
| 1203 | { | - | ||||||||||||||||||||||||
| 1204 | - | |||||||||||||||||||||||||
| 1205 | - | |||||||||||||||||||||||||
| 1206 | - | |||||||||||||||||||||||||
| 1207 | return never executed: motions > 6return motions > 6 || QApplication::startDragDistance() < (mousePopupPos - globalPos).manhattanLength();
never executed: return motions > 6 || QApplication::startDragDistance() < (mousePopupPos - globalPos).manhattanLength(); | 0 | ||||||||||||||||||||||||
| 1208 | QApplication::startDragDistance() < (mousePopupPos - globalPos).manhattanLength()
never executed: return motions > 6 || QApplication::startDragDistance() < (mousePopupPos - globalPos).manhattanLength(); | 0 | ||||||||||||||||||||||||
| 1209 | } | - | ||||||||||||||||||||||||
| 1210 | void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const | - | ||||||||||||||||||||||||
| 1211 | { | - | ||||||||||||||||||||||||
| 1212 | if (!option
| 0 | ||||||||||||||||||||||||
| 1213 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1214 | - | |||||||||||||||||||||||||
| 1215 | const QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1216 | option->initFrom(this); | - | ||||||||||||||||||||||||
| 1217 | option->palette = palette(); | - | ||||||||||||||||||||||||
| 1218 | option->state = QStyle::State_None; | - | ||||||||||||||||||||||||
| 1219 | - | |||||||||||||||||||||||||
| 1220 | if (window()->isActiveWindow()
| 0 | ||||||||||||||||||||||||
| 1221 | option->state |= QStyle::State_Active; never executed: option->state |= QStyle::State_Active; | 0 | ||||||||||||||||||||||||
| 1222 | if (isEnabled()
| 0 | ||||||||||||||||||||||||
| 1223 | && (!action->menu()
| 0 | ||||||||||||||||||||||||
| 1224 | option->state |= QStyle::State_Enabled; never executed: option->state |= QStyle::State_Enabled; | 0 | ||||||||||||||||||||||||
| 1225 | else | - | ||||||||||||||||||||||||
| 1226 | option->palette.setCurrentColorGroup(QPalette::Disabled); never executed: option->palette.setCurrentColorGroup(QPalette::Disabled); | 0 | ||||||||||||||||||||||||
| 1227 | - | |||||||||||||||||||||||||
| 1228 | option->font = action->font().resolve(font()); | - | ||||||||||||||||||||||||
| 1229 | option->fontMetrics = QFontMetrics(option->font); | - | ||||||||||||||||||||||||
| 1230 | - | |||||||||||||||||||||||||
| 1231 | if (d->currentAction
| 0 | ||||||||||||||||||||||||
| 1232 | option->state |= QStyle::State_Selected | - | ||||||||||||||||||||||||
| 1233 | | (d->mouseDown ? QStyle::State_Sunken : QStyle::State_None); | - | ||||||||||||||||||||||||
| 1234 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1235 | - | |||||||||||||||||||||||||
| 1236 | option->menuHasCheckableItems = d->hasCheckableItems; | - | ||||||||||||||||||||||||
| 1237 | if (!action->isCheckable()
| 0 | ||||||||||||||||||||||||
| 1238 | option->checkType = QStyleOptionMenuItem::NotCheckable; | - | ||||||||||||||||||||||||
| 1239 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1240 | option->checkType = (action->actionGroup()
| 0 | ||||||||||||||||||||||||
| 1241 | ? QStyleOptionMenuItem::Exclusive : QStyleOptionMenuItem::NonExclusive; | - | ||||||||||||||||||||||||
| 1242 | option->checked = action->isChecked(); | - | ||||||||||||||||||||||||
| 1243 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1244 | if (action->menu()
| 0 | ||||||||||||||||||||||||
| 1245 | option->menuItemType = QStyleOptionMenuItem::SubMenu; never executed: option->menuItemType = QStyleOptionMenuItem::SubMenu; | 0 | ||||||||||||||||||||||||
| 1246 | else if (action->isSeparator()
| 0 | ||||||||||||||||||||||||
| 1247 | option->menuItemType = QStyleOptionMenuItem::Separator; never executed: option->menuItemType = QStyleOptionMenuItem::Separator; | 0 | ||||||||||||||||||||||||
| 1248 | else if (d->defaultAction == action
| 0 | ||||||||||||||||||||||||
| 1249 | option->menuItemType = QStyleOptionMenuItem::DefaultItem; never executed: option->menuItemType = QStyleOptionMenuItem::DefaultItem; | 0 | ||||||||||||||||||||||||
| 1250 | else | - | ||||||||||||||||||||||||
| 1251 | option->menuItemType = QStyleOptionMenuItem::Normal; never executed: option->menuItemType = QStyleOptionMenuItem::Normal; | 0 | ||||||||||||||||||||||||
| 1252 | if (action->isIconVisibleInMenu()
| 0 | ||||||||||||||||||||||||
| 1253 | option->icon = action->icon(); never executed: option->icon = action->icon(); | 0 | ||||||||||||||||||||||||
| 1254 | QString textAndAccel = action->text(); | - | ||||||||||||||||||||||||
| 1255 | - | |||||||||||||||||||||||||
| 1256 | if (textAndAccel.indexOf(QLatin1Char('\t')) == -1
| 0 | ||||||||||||||||||||||||
| 1257 | QKeySequence seq = action->shortcut(); | - | ||||||||||||||||||||||||
| 1258 | if (!seq.isEmpty()
| 0 | ||||||||||||||||||||||||
| 1259 | textAndAccel += QLatin1Char('\t') + seq.toString(QKeySequence::NativeText); never executed: textAndAccel += QLatin1Char('\t') + seq.toString(QKeySequence::NativeText); | 0 | ||||||||||||||||||||||||
| 1260 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1261 | - | |||||||||||||||||||||||||
| 1262 | option->text = textAndAccel; | - | ||||||||||||||||||||||||
| 1263 | option->tabWidth = d->tabWidth; | - | ||||||||||||||||||||||||
| 1264 | option->maxIconWidth = d->maxIconWidth; | - | ||||||||||||||||||||||||
| 1265 | option->menuRect = rect(); | - | ||||||||||||||||||||||||
| 1266 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1267 | QMenu::QMenu(QWidget *parent) | - | ||||||||||||||||||||||||
| 1268 | : QWidget(*new QMenuPrivate, parent, Qt::Popup) | - | ||||||||||||||||||||||||
| 1269 | { | - | ||||||||||||||||||||||||
| 1270 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1271 | d->init(); | - | ||||||||||||||||||||||||
| 1272 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1273 | QMenu::QMenu(const QString &title, QWidget *parent) | - | ||||||||||||||||||||||||
| 1274 | : QWidget(*new QMenuPrivate, parent, Qt::Popup) | - | ||||||||||||||||||||||||
| 1275 | { | - | ||||||||||||||||||||||||
| 1276 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1277 | d->init(); | - | ||||||||||||||||||||||||
| 1278 | d->menuAction->setText(title); | - | ||||||||||||||||||||||||
| 1279 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1280 | - | |||||||||||||||||||||||||
| 1281 | - | |||||||||||||||||||||||||
| 1282 | - | |||||||||||||||||||||||||
| 1283 | QMenu::QMenu(QMenuPrivate &dd, QWidget *parent) | - | ||||||||||||||||||||||||
| 1284 | : QWidget(dd, parent, Qt::Popup) | - | ||||||||||||||||||||||||
| 1285 | { | - | ||||||||||||||||||||||||
| 1286 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1287 | d->init(); | - | ||||||||||||||||||||||||
| 1288 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1289 | - | |||||||||||||||||||||||||
| 1290 | - | |||||||||||||||||||||||||
| 1291 | - | |||||||||||||||||||||||||
| 1292 | - | |||||||||||||||||||||||||
| 1293 | QMenu::~QMenu() | - | ||||||||||||||||||||||||
| 1294 | { | - | ||||||||||||||||||||||||
| 1295 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1296 | if (!d->widgetItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 1297 | QHash<QAction *, QWidget *>::iterator it = d->widgetItems.begin(); | - | ||||||||||||||||||||||||
| 1298 | for (; it != d->widgetItems.end()
| 0 | ||||||||||||||||||||||||
| 1299 | if (QWidget *widget = it.value()
| 0 | ||||||||||||||||||||||||
| 1300 | QWidgetAction *action = static_cast<QWidgetAction *>(it.key()); | - | ||||||||||||||||||||||||
| 1301 | action->releaseWidget(widget); | - | ||||||||||||||||||||||||
| 1302 | *it = 0; | - | ||||||||||||||||||||||||
| 1303 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1304 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1305 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1306 | - | |||||||||||||||||||||||||
| 1307 | if (d->eventLoop
| 0 | ||||||||||||||||||||||||
| 1308 | d->eventLoop->exit(); never executed: d->eventLoop->exit(); | 0 | ||||||||||||||||||||||||
| 1309 | hideTearOffMenu(); | - | ||||||||||||||||||||||||
| 1310 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1311 | QAction *QMenu::addAction(const QString &text) | - | ||||||||||||||||||||||||
| 1312 | { | - | ||||||||||||||||||||||||
| 1313 | QAction *ret = new QAction(text, this); | - | ||||||||||||||||||||||||
| 1314 | addAction(ret); | - | ||||||||||||||||||||||||
| 1315 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||
| 1316 | } | - | ||||||||||||||||||||||||
| 1317 | QAction *QMenu::addAction(const QIcon &icon, const QString &text) | - | ||||||||||||||||||||||||
| 1318 | { | - | ||||||||||||||||||||||||
| 1319 | QAction *ret = new QAction(icon, text, this); | - | ||||||||||||||||||||||||
| 1320 | addAction(ret); | - | ||||||||||||||||||||||||
| 1321 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||
| 1322 | } | - | ||||||||||||||||||||||||
| 1323 | QAction *QMenu::addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut) | - | ||||||||||||||||||||||||
| 1324 | { | - | ||||||||||||||||||||||||
| 1325 | QAction *action = new QAction(text, this); | - | ||||||||||||||||||||||||
| 1326 | - | |||||||||||||||||||||||||
| 1327 | - | |||||||||||||||||||||||||
| 1328 | - | |||||||||||||||||||||||||
| 1329 | action->setShortcut(shortcut); | - | ||||||||||||||||||||||||
| 1330 | - | |||||||||||||||||||||||||
| 1331 | QObject::connect(action, qFlagLocation("2""triggered(bool)" "\0" __FILE__ ":" "1574"), receiver, member); | - | ||||||||||||||||||||||||
| 1332 | addAction(action); | - | ||||||||||||||||||||||||
| 1333 | return never executed: action;return action;never executed: return action; | 0 | ||||||||||||||||||||||||
| 1334 | } | - | ||||||||||||||||||||||||
| 1335 | QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver, | - | ||||||||||||||||||||||||
| 1336 | const char* member, const QKeySequence &shortcut) | - | ||||||||||||||||||||||||
| 1337 | { | - | ||||||||||||||||||||||||
| 1338 | QAction *action = new QAction(icon, text, this); | - | ||||||||||||||||||||||||
| 1339 | - | |||||||||||||||||||||||||
| 1340 | - | |||||||||||||||||||||||||
| 1341 | - | |||||||||||||||||||||||||
| 1342 | action->setShortcut(shortcut); | - | ||||||||||||||||||||||||
| 1343 | - | |||||||||||||||||||||||||
| 1344 | QObject::connect(action, qFlagLocation("2""triggered(bool)" "\0" __FILE__ ":" "1695"), receiver, member); | - | ||||||||||||||||||||||||
| 1345 | addAction(action); | - | ||||||||||||||||||||||||
| 1346 | return never executed: action;return action;never executed: return action; | 0 | ||||||||||||||||||||||||
| 1347 | } | - | ||||||||||||||||||||||||
| 1348 | QAction *QMenu::addMenu(QMenu *menu) | - | ||||||||||||||||||||||||
| 1349 | { | - | ||||||||||||||||||||||||
| 1350 | QAction *action = menu->menuAction(); | - | ||||||||||||||||||||||||
| 1351 | addAction(action); | - | ||||||||||||||||||||||||
| 1352 | return never executed: action;return action;never executed: return action; | 0 | ||||||||||||||||||||||||
| 1353 | } | - | ||||||||||||||||||||||||
| 1354 | - | |||||||||||||||||||||||||
| 1355 | - | |||||||||||||||||||||||||
| 1356 | - | |||||||||||||||||||||||||
| 1357 | - | |||||||||||||||||||||||||
| 1358 | - | |||||||||||||||||||||||||
| 1359 | - | |||||||||||||||||||||||||
| 1360 | - | |||||||||||||||||||||||||
| 1361 | QMenu *QMenu::addMenu(const QString &title) | - | ||||||||||||||||||||||||
| 1362 | { | - | ||||||||||||||||||||||||
| 1363 | QMenu *menu = new QMenu(title, this); | - | ||||||||||||||||||||||||
| 1364 | addAction(menu->menuAction()); | - | ||||||||||||||||||||||||
| 1365 | return never executed: menu;return menu;never executed: return menu; | 0 | ||||||||||||||||||||||||
| 1366 | } | - | ||||||||||||||||||||||||
| 1367 | - | |||||||||||||||||||||||||
| 1368 | - | |||||||||||||||||||||||||
| 1369 | - | |||||||||||||||||||||||||
| 1370 | - | |||||||||||||||||||||||||
| 1371 | - | |||||||||||||||||||||||||
| 1372 | - | |||||||||||||||||||||||||
| 1373 | - | |||||||||||||||||||||||||
| 1374 | QMenu *QMenu::addMenu(const QIcon &icon, const QString &title) | - | ||||||||||||||||||||||||
| 1375 | { | - | ||||||||||||||||||||||||
| 1376 | QMenu *menu = new QMenu(title, this); | - | ||||||||||||||||||||||||
| 1377 | menu->setIcon(icon); | - | ||||||||||||||||||||||||
| 1378 | addAction(menu->menuAction()); | - | ||||||||||||||||||||||||
| 1379 | return never executed: menu;return menu;never executed: return menu; | 0 | ||||||||||||||||||||||||
| 1380 | } | - | ||||||||||||||||||||||||
| 1381 | QAction *QMenu::addSeparator() | - | ||||||||||||||||||||||||
| 1382 | { | - | ||||||||||||||||||||||||
| 1383 | QAction *action = new QAction(this); | - | ||||||||||||||||||||||||
| 1384 | action->setSeparator(true); | - | ||||||||||||||||||||||||
| 1385 | addAction(action); | - | ||||||||||||||||||||||||
| 1386 | return never executed: action;return action;never executed: return action; | 0 | ||||||||||||||||||||||||
| 1387 | } | - | ||||||||||||||||||||||||
| 1388 | QAction *QMenu::addSection(const QString &text) | - | ||||||||||||||||||||||||
| 1389 | { | - | ||||||||||||||||||||||||
| 1390 | QAction *action = new QAction(text, this); | - | ||||||||||||||||||||||||
| 1391 | action->setSeparator(true); | - | ||||||||||||||||||||||||
| 1392 | addAction(action); | - | ||||||||||||||||||||||||
| 1393 | return never executed: action;return action;never executed: return action; | 0 | ||||||||||||||||||||||||
| 1394 | } | - | ||||||||||||||||||||||||
| 1395 | QAction *QMenu::addSection(const QIcon &icon, const QString &text) | - | ||||||||||||||||||||||||
| 1396 | { | - | ||||||||||||||||||||||||
| 1397 | QAction *action = new QAction(icon, text, this); | - | ||||||||||||||||||||||||
| 1398 | action->setSeparator(true); | - | ||||||||||||||||||||||||
| 1399 | addAction(action); | - | ||||||||||||||||||||||||
| 1400 | return never executed: action;return action;never executed: return action; | 0 | ||||||||||||||||||||||||
| 1401 | } | - | ||||||||||||||||||||||||
| 1402 | - | |||||||||||||||||||||||||
| 1403 | - | |||||||||||||||||||||||||
| 1404 | - | |||||||||||||||||||||||||
| 1405 | - | |||||||||||||||||||||||||
| 1406 | - | |||||||||||||||||||||||||
| 1407 | - | |||||||||||||||||||||||||
| 1408 | - | |||||||||||||||||||||||||
| 1409 | QAction *QMenu::insertMenu(QAction *before, QMenu *menu) | - | ||||||||||||||||||||||||
| 1410 | { | - | ||||||||||||||||||||||||
| 1411 | QAction *action = menu->menuAction(); | - | ||||||||||||||||||||||||
| 1412 | insertAction(before, action); | - | ||||||||||||||||||||||||
| 1413 | return never executed: action;return action;never executed: return action; | 0 | ||||||||||||||||||||||||
| 1414 | } | - | ||||||||||||||||||||||||
| 1415 | QAction *QMenu::insertSeparator(QAction *before) | - | ||||||||||||||||||||||||
| 1416 | { | - | ||||||||||||||||||||||||
| 1417 | QAction *action = new QAction(this); | - | ||||||||||||||||||||||||
| 1418 | action->setSeparator(true); | - | ||||||||||||||||||||||||
| 1419 | insertAction(before, action); | - | ||||||||||||||||||||||||
| 1420 | return never executed: action;return action;never executed: return action; | 0 | ||||||||||||||||||||||||
| 1421 | } | - | ||||||||||||||||||||||||
| 1422 | QAction *QMenu::insertSection(QAction *before, const QString &text) | - | ||||||||||||||||||||||||
| 1423 | { | - | ||||||||||||||||||||||||
| 1424 | QAction *action = new QAction(text, this); | - | ||||||||||||||||||||||||
| 1425 | action->setSeparator(true); | - | ||||||||||||||||||||||||
| 1426 | insertAction(before, action); | - | ||||||||||||||||||||||||
| 1427 | return never executed: action;return action;never executed: return action; | 0 | ||||||||||||||||||||||||
| 1428 | } | - | ||||||||||||||||||||||||
| 1429 | QAction *QMenu::insertSection(QAction *before, const QIcon &icon, const QString &text) | - | ||||||||||||||||||||||||
| 1430 | { | - | ||||||||||||||||||||||||
| 1431 | QAction *action = new QAction(icon, text, this); | - | ||||||||||||||||||||||||
| 1432 | action->setSeparator(true); | - | ||||||||||||||||||||||||
| 1433 | insertAction(before, action); | - | ||||||||||||||||||||||||
| 1434 | return never executed: action;return action;never executed: return action; | 0 | ||||||||||||||||||||||||
| 1435 | } | - | ||||||||||||||||||||||||
| 1436 | void QMenu::setDefaultAction(QAction *act) | - | ||||||||||||||||||||||||
| 1437 | { | - | ||||||||||||||||||||||||
| 1438 | d_func()->defaultAction = act; | - | ||||||||||||||||||||||||
| 1439 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1440 | - | |||||||||||||||||||||||||
| 1441 | - | |||||||||||||||||||||||||
| 1442 | - | |||||||||||||||||||||||||
| 1443 | - | |||||||||||||||||||||||||
| 1444 | - | |||||||||||||||||||||||||
| 1445 | - | |||||||||||||||||||||||||
| 1446 | QAction *QMenu::defaultAction() const | - | ||||||||||||||||||||||||
| 1447 | { | - | ||||||||||||||||||||||||
| 1448 | return never executed: d_func()->defaultAction;return d_func()->defaultAction;never executed: return d_func()->defaultAction; | 0 | ||||||||||||||||||||||||
| 1449 | } | - | ||||||||||||||||||||||||
| 1450 | void QMenu::setTearOffEnabled(bool b) | - | ||||||||||||||||||||||||
| 1451 | { | - | ||||||||||||||||||||||||
| 1452 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1453 | if (d->tearoff == b
| 0 | ||||||||||||||||||||||||
| 1454 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1455 | if (!b
| 0 | ||||||||||||||||||||||||
| 1456 | hideTearOffMenu(); never executed: hideTearOffMenu(); | 0 | ||||||||||||||||||||||||
| 1457 | d->tearoff = b; | - | ||||||||||||||||||||||||
| 1458 | - | |||||||||||||||||||||||||
| 1459 | d->itemsDirty = true; | - | ||||||||||||||||||||||||
| 1460 | if (isVisible()
| 0 | ||||||||||||||||||||||||
| 1461 | resize(sizeHint()); never executed: resize(sizeHint()); | 0 | ||||||||||||||||||||||||
| 1462 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1463 | - | |||||||||||||||||||||||||
| 1464 | bool QMenu::isTearOffEnabled() const | - | ||||||||||||||||||||||||
| 1465 | { | - | ||||||||||||||||||||||||
| 1466 | return never executed: d_func()->tearoff;return d_func()->tearoff;never executed: return d_func()->tearoff; | 0 | ||||||||||||||||||||||||
| 1467 | } | - | ||||||||||||||||||||||||
| 1468 | bool QMenu::isTearOffMenuVisible() const | - | ||||||||||||||||||||||||
| 1469 | { | - | ||||||||||||||||||||||||
| 1470 | if (d_func()->tornPopup
| 0 | ||||||||||||||||||||||||
| 1471 | return never executed: d_func()->tornPopup->isVisible();return d_func()->tornPopup->isVisible();never executed: return d_func()->tornPopup->isVisible(); | 0 | ||||||||||||||||||||||||
| 1472 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1473 | } | - | ||||||||||||||||||||||||
| 1474 | - | |||||||||||||||||||||||||
| 1475 | - | |||||||||||||||||||||||||
| 1476 | - | |||||||||||||||||||||||||
| 1477 | - | |||||||||||||||||||||||||
| 1478 | - | |||||||||||||||||||||||||
| 1479 | - | |||||||||||||||||||||||||
| 1480 | - | |||||||||||||||||||||||||
| 1481 | void QMenu::hideTearOffMenu() | - | ||||||||||||||||||||||||
| 1482 | { | - | ||||||||||||||||||||||||
| 1483 | if (QWidget *w = d_func()->tornPopup
| 0 | ||||||||||||||||||||||||
| 1484 | w->close(); never executed: w->close(); | 0 | ||||||||||||||||||||||||
| 1485 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1486 | - | |||||||||||||||||||||||||
| 1487 | - | |||||||||||||||||||||||||
| 1488 | - | |||||||||||||||||||||||||
| 1489 | - | |||||||||||||||||||||||||
| 1490 | - | |||||||||||||||||||||||||
| 1491 | void QMenu::setActiveAction(QAction *act) | - | ||||||||||||||||||||||||
| 1492 | { | - | ||||||||||||||||||||||||
| 1493 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1494 | d->setCurrentAction(act, 0); | - | ||||||||||||||||||||||||
| 1495 | if (d->scroll
| 0 | ||||||||||||||||||||||||
| 1496 | d->scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollCenter); never executed: d->scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollCenter); | 0 | ||||||||||||||||||||||||
| 1497 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1498 | - | |||||||||||||||||||||||||
| 1499 | - | |||||||||||||||||||||||||
| 1500 | - | |||||||||||||||||||||||||
| 1501 | - | |||||||||||||||||||||||||
| 1502 | - | |||||||||||||||||||||||||
| 1503 | - | |||||||||||||||||||||||||
| 1504 | QAction *QMenu::activeAction() const | - | ||||||||||||||||||||||||
| 1505 | { | - | ||||||||||||||||||||||||
| 1506 | return never executed: d_func()->currentAction;return d_func()->currentAction;never executed: return d_func()->currentAction; | 0 | ||||||||||||||||||||||||
| 1507 | } | - | ||||||||||||||||||||||||
| 1508 | bool QMenu::isEmpty() const | - | ||||||||||||||||||||||||
| 1509 | { | - | ||||||||||||||||||||||||
| 1510 | bool ret = true; | - | ||||||||||||||||||||||||
| 1511 | for(int i = 0; ret
| 0 | ||||||||||||||||||||||||
| 1512 | const QAction *action = actions().at(i); | - | ||||||||||||||||||||||||
| 1513 | if (!action->isSeparator()
| 0 | ||||||||||||||||||||||||
| 1514 | ret = false; | - | ||||||||||||||||||||||||
| 1515 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1516 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1517 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||
| 1518 | } | - | ||||||||||||||||||||||||
| 1519 | - | |||||||||||||||||||||||||
| 1520 | - | |||||||||||||||||||||||||
| 1521 | - | |||||||||||||||||||||||||
| 1522 | - | |||||||||||||||||||||||||
| 1523 | - | |||||||||||||||||||||||||
| 1524 | - | |||||||||||||||||||||||||
| 1525 | - | |||||||||||||||||||||||||
| 1526 | void QMenu::clear() | - | ||||||||||||||||||||||||
| 1527 | { | - | ||||||||||||||||||||||||
| 1528 | QList<QAction*> acts = actions(); | - | ||||||||||||||||||||||||
| 1529 | - | |||||||||||||||||||||||||
| 1530 | for(int i = 0; i < acts.size()
| 0 | ||||||||||||||||||||||||
| 1531 | removeAction(acts[i]); | - | ||||||||||||||||||||||||
| 1532 | if (acts[i]->parent() == this
| 0 | ||||||||||||||||||||||||
| 1533 | delete acts[i]; never executed: delete acts[i]; | 0 | ||||||||||||||||||||||||
| 1534 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1535 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1536 | int QMenu::columnCount() const | - | ||||||||||||||||||||||||
| 1537 | { | - | ||||||||||||||||||||||||
| 1538 | return never executed: d_func()->ncols;return d_func()->ncols;never executed: return d_func()->ncols; | 0 | ||||||||||||||||||||||||
| 1539 | } | - | ||||||||||||||||||||||||
| 1540 | - | |||||||||||||||||||||||||
| 1541 | - | |||||||||||||||||||||||||
| 1542 | - | |||||||||||||||||||||||||
| 1543 | - | |||||||||||||||||||||||||
| 1544 | QAction *QMenu::actionAt(const QPoint &pt) const | - | ||||||||||||||||||||||||
| 1545 | { | - | ||||||||||||||||||||||||
| 1546 | if (QAction *ret = d_func()->actionAt(pt)
| 0 | ||||||||||||||||||||||||
| 1547 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||
| 1548 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1549 | } | - | ||||||||||||||||||||||||
| 1550 | - | |||||||||||||||||||||||||
| 1551 | - | |||||||||||||||||||||||||
| 1552 | - | |||||||||||||||||||||||||
| 1553 | - | |||||||||||||||||||||||||
| 1554 | QRect QMenu::actionGeometry(QAction *act) const | - | ||||||||||||||||||||||||
| 1555 | { | - | ||||||||||||||||||||||||
| 1556 | return never executed: d_func()->actionRect(act);return d_func()->actionRect(act);never executed: return d_func()->actionRect(act); | 0 | ||||||||||||||||||||||||
| 1557 | } | - | ||||||||||||||||||||||||
| 1558 | - | |||||||||||||||||||||||||
| 1559 | - | |||||||||||||||||||||||||
| 1560 | - | |||||||||||||||||||||||||
| 1561 | - | |||||||||||||||||||||||||
| 1562 | QSize QMenu::sizeHint() const | - | ||||||||||||||||||||||||
| 1563 | { | - | ||||||||||||||||||||||||
| 1564 | const QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1565 | d->updateActionRects(); | - | ||||||||||||||||||||||||
| 1566 | - | |||||||||||||||||||||||||
| 1567 | QSize s; | - | ||||||||||||||||||||||||
| 1568 | for (int i = 0; i < d->actionRects.count()
| 0 | ||||||||||||||||||||||||
| 1569 | const QRect &rect = d->actionRects.at(i); | - | ||||||||||||||||||||||||
| 1570 | if (rect.isNull()
| 0 | ||||||||||||||||||||||||
| 1571 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1572 | if (rect.bottom() >= s.height()
| 0 | ||||||||||||||||||||||||
| 1573 | s.setHeight(rect.y() + rect.height()); never executed: s.setHeight(rect.y() + rect.height()); | 0 | ||||||||||||||||||||||||
| 1574 | if (rect.right() >= s.width()
| 0 | ||||||||||||||||||||||||
| 1575 | s.setWidth(rect.x() + rect.width()); never executed: s.setWidth(rect.x() + rect.width()); | 0 | ||||||||||||||||||||||||
| 1576 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1577 | - | |||||||||||||||||||||||||
| 1578 | - | |||||||||||||||||||||||||
| 1579 | - | |||||||||||||||||||||||||
| 1580 | QStyleOption opt(0); | - | ||||||||||||||||||||||||
| 1581 | opt.init(this); | - | ||||||||||||||||||||||||
| 1582 | const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, this); | - | ||||||||||||||||||||||||
| 1583 | s.rwidth() += style()->pixelMetric(QStyle::PM_MenuHMargin, &opt, this) + fw + d->rightmargin; | - | ||||||||||||||||||||||||
| 1584 | s.rheight() += style()->pixelMetric(QStyle::PM_MenuVMargin, &opt, this) + fw + d->bottommargin; | - | ||||||||||||||||||||||||
| 1585 | - | |||||||||||||||||||||||||
| 1586 | return never executed: style()->sizeFromContents(QStyle::CT_Menu, &opt,return style()->sizeFromContents(QStyle::CT_Menu, &opt, s.expandedTo(QApplication::globalStrut()), this);never executed: return style()->sizeFromContents(QStyle::CT_Menu, &opt, s.expandedTo(QApplication::globalStrut()), this); | 0 | ||||||||||||||||||||||||
| 1587 | s.expandedTo(QApplication::globalStrut()), this); never executed: return style()->sizeFromContents(QStyle::CT_Menu, &opt, s.expandedTo(QApplication::globalStrut()), this); | 0 | ||||||||||||||||||||||||
| 1588 | } | - | ||||||||||||||||||||||||
| 1589 | void QMenu::popup(const QPoint &p, QAction *atAction) | - | ||||||||||||||||||||||||
| 1590 | { | - | ||||||||||||||||||||||||
| 1591 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1592 | if (d->scroll
| 0 | ||||||||||||||||||||||||
| 1593 | if (d->scroll->scrollOffset
| 0 | ||||||||||||||||||||||||
| 1594 | d->itemsDirty = 1; never executed: d->itemsDirty = 1; | 0 | ||||||||||||||||||||||||
| 1595 | d->scroll->scrollOffset = 0; | - | ||||||||||||||||||||||||
| 1596 | d->scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone; | - | ||||||||||||||||||||||||
| 1597 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1598 | d->tearoffHighlighted = 0; | - | ||||||||||||||||||||||||
| 1599 | d->motions = 0; | - | ||||||||||||||||||||||||
| 1600 | d->doChildEffects = true; | - | ||||||||||||||||||||||||
| 1601 | d->updateLayoutDirection(); | - | ||||||||||||||||||||||||
| 1602 | - | |||||||||||||||||||||||||
| 1603 | - | |||||||||||||||||||||||||
| 1604 | - | |||||||||||||||||||||||||
| 1605 | - | |||||||||||||||||||||||||
| 1606 | setAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu, qobject_cast<QMenuBar *>(d->topCausedWidget()) != 0); | - | ||||||||||||||||||||||||
| 1607 | - | |||||||||||||||||||||||||
| 1608 | - | |||||||||||||||||||||||||
| 1609 | ensurePolished(); | - | ||||||||||||||||||||||||
| 1610 | aboutToShow(); | - | ||||||||||||||||||||||||
| 1611 | const bool actionListChanged = d->itemsDirty; | - | ||||||||||||||||||||||||
| 1612 | d->updateActionRects(); | - | ||||||||||||||||||||||||
| 1613 | QPoint pos; | - | ||||||||||||||||||||||||
| 1614 | QPushButton *causedButton = qobject_cast<QPushButton*>(d->causedPopup.widget); | - | ||||||||||||||||||||||||
| 1615 | if (actionListChanged
| 0 | ||||||||||||||||||||||||
| 1616 | pos = QPushButtonPrivate::get(causedButton)->adjustedMenuPosition(); never executed: pos = QPushButtonPrivate::get(causedButton)->adjustedMenuPosition(); | 0 | ||||||||||||||||||||||||
| 1617 | else | - | ||||||||||||||||||||||||
| 1618 | pos = p; never executed: pos = p; | 0 | ||||||||||||||||||||||||
| 1619 | - | |||||||||||||||||||||||||
| 1620 | QSize size = sizeHint(); | - | ||||||||||||||||||||||||
| 1621 | QRect screen; | - | ||||||||||||||||||||||||
| 1622 | - | |||||||||||||||||||||||||
| 1623 | bool isEmbedded = !bypassGraphicsProxyWidget(this)
| 0 | ||||||||||||||||||||||||
| 1624 | if (isEmbedded
| 0 | ||||||||||||||||||||||||
| 1625 | screen = d->popupGeometry(this); never executed: screen = d->popupGeometry(this); | 0 | ||||||||||||||||||||||||
| 1626 | else | - | ||||||||||||||||||||||||
| 1627 | - | |||||||||||||||||||||||||
| 1628 | screen = d->popupGeometry(QApplication::desktop()->screenNumber(p)); never executed: screen = d->popupGeometry(QApplication::desktop()->screenNumber(p)); | 0 | ||||||||||||||||||||||||
| 1629 | const int desktopFrame = style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, this); | - | ||||||||||||||||||||||||
| 1630 | bool adjustToDesktop = !window()->testAttribute(Qt::WA_DontShowOnScreen); | - | ||||||||||||||||||||||||
| 1631 | - | |||||||||||||||||||||||||
| 1632 | - | |||||||||||||||||||||||||
| 1633 | if (size.height() > screen.height()
| 0 | ||||||||||||||||||||||||
| 1634 | size = d->adjustMenuSizeForScreen(screen); | - | ||||||||||||||||||||||||
| 1635 | adjustToDesktop = true; | - | ||||||||||||||||||||||||
| 1636 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1637 | - | |||||||||||||||||||||||||
| 1638 | if (d->ncols >1
| 0 | ||||||||||||||||||||||||
| 1639 | size = d->adjustMenuSizeForScreen(screen); | - | ||||||||||||||||||||||||
| 1640 | adjustToDesktop = true; | - | ||||||||||||||||||||||||
| 1641 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1642 | if (d->ncols > 1
| 0 | ||||||||||||||||||||||||
| 1643 | pos.setY(screen.top() + desktopFrame); | - | ||||||||||||||||||||||||
| 1644 | } never executed: else if (atActionend of block
| 0 | ||||||||||||||||||||||||
| 1645 | for (int i = 0, above_height = 0; i < d->actions.count()
| 0 | ||||||||||||||||||||||||
| 1646 | QAction *action = d->actions.at(i); | - | ||||||||||||||||||||||||
| 1647 | if (action == atAction
| 0 | ||||||||||||||||||||||||
| 1648 | int newY = pos.y() - above_height; | - | ||||||||||||||||||||||||
| 1649 | if (d->scroll
| 0 | ||||||||||||||||||||||||
| 1650 | d->scroll->scrollFlags = d->scroll->scrollFlags | - | ||||||||||||||||||||||||
| 1651 | | QMenuPrivate::QMenuScroller::ScrollUp; | - | ||||||||||||||||||||||||
| 1652 | d->scroll->scrollOffset = newY; | - | ||||||||||||||||||||||||
| 1653 | newY = desktopFrame; | - | ||||||||||||||||||||||||
| 1654 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1655 | pos.setY(newY); | - | ||||||||||||||||||||||||
| 1656 | - | |||||||||||||||||||||||||
| 1657 | if (d->scroll
| 0 | ||||||||||||||||||||||||
| 1658 | && !style()->styleHint(QStyle::SH_Menu_FillScreenWithScroll, 0, this)
| 0 | ||||||||||||||||||||||||
| 1659 | int below_height = above_height + d->scroll->scrollOffset; | - | ||||||||||||||||||||||||
| 1660 | for (int i2 = i; i2 < d->actionRects.count()
| 0 | ||||||||||||||||||||||||
| 1661 | below_height += d->actionRects.at(i2).height(); never executed: below_height += d->actionRects.at(i2).height(); | 0 | ||||||||||||||||||||||||
| 1662 | size.setHeight(below_height); | - | ||||||||||||||||||||||||
| 1663 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1664 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1665 | } else { | - | ||||||||||||||||||||||||
| 1666 | above_height += d->actionRects.at(i).height(); | - | ||||||||||||||||||||||||
| 1667 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1668 | } | - | ||||||||||||||||||||||||
| 1669 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1670 | - | |||||||||||||||||||||||||
| 1671 | QPoint mouse = QCursor::pos(); | - | ||||||||||||||||||||||||
| 1672 | d->mousePopupPos = mouse; | - | ||||||||||||||||||||||||
| 1673 | const bool snapToMouse = !d->causedPopup.widget
| 0 | ||||||||||||||||||||||||
| 1674 | - | |||||||||||||||||||||||||
| 1675 | const QSize menuSize(sizeHint()); | - | ||||||||||||||||||||||||
| 1676 | if (adjustToDesktop
| 0 | ||||||||||||||||||||||||
| 1677 | - | |||||||||||||||||||||||||
| 1678 | if (isRightToLeft()
| 0 | ||||||||||||||||||||||||
| 1679 | if (snapToMouse
| 0 | ||||||||||||||||||||||||
| 1680 | pos.setX(mouse.x() - size.width()); never executed: pos.setX(mouse.x() - size.width()); | 0 | ||||||||||||||||||||||||
| 1681 | - | |||||||||||||||||||||||||
| 1682 | - | |||||||||||||||||||||||||
| 1683 | - | |||||||||||||||||||||||||
| 1684 | if (qobject_cast<QMenuBar*>(d->causedPopup.widget)
| 0 | ||||||||||||||||||||||||
| 1685 | pos.rx() -= size.width(); never executed: pos.rx() -= size.width(); | 0 | ||||||||||||||||||||||||
| 1686 | - | |||||||||||||||||||||||||
| 1687 | - | |||||||||||||||||||||||||
| 1688 | if (pos.x() < screen.left() + desktopFrame
| 0 | ||||||||||||||||||||||||
| 1689 | pos.setX(qMax(p.x(), screen.left() + desktopFrame)); never executed: pos.setX(qMax(p.x(), screen.left() + desktopFrame)); | 0 | ||||||||||||||||||||||||
| 1690 | if (pos.x() + size.width() - 1 > screen.right() - desktopFrame
| 0 | ||||||||||||||||||||||||
| 1691 | pos.setX(qMax(p.x() - size.width(), screen.right() - desktopFrame - size.width() + 1)); never executed: pos.setX(qMax(p.x() - size.width(), screen.right() - desktopFrame - size.width() + 1)); | 0 | ||||||||||||||||||||||||
| 1692 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1693 | if (pos.x() + size.width() - 1 > screen.right() - desktopFrame
| 0 | ||||||||||||||||||||||||
| 1694 | pos.setX(screen.right() - desktopFrame - size.width() + 1); never executed: pos.setX(screen.right() - desktopFrame - size.width() + 1); | 0 | ||||||||||||||||||||||||
| 1695 | if (pos.x() < screen.left() + desktopFrame
| 0 | ||||||||||||||||||||||||
| 1696 | pos.setX(screen.left() + desktopFrame); never executed: pos.setX(screen.left() + desktopFrame); | 0 | ||||||||||||||||||||||||
| 1697 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1698 | if (pos.y() + size.height() - 1 > screen.bottom() - desktopFrame
| 0 | ||||||||||||||||||||||||
| 1699 | if(snapToMouse
| 0 | ||||||||||||||||||||||||
| 1700 | pos.setY(qMin(mouse.y() - (size.height() + desktopFrame), screen.bottom()-desktopFrame-size.height()+1)); never executed: pos.setY(qMin(mouse.y() - (size.height() + desktopFrame), screen.bottom()-desktopFrame-size.height()+1)); | 0 | ||||||||||||||||||||||||
| 1701 | else | - | ||||||||||||||||||||||||
| 1702 | pos.setY(qMax(p.y() - (size.height() + desktopFrame), screen.bottom()-desktopFrame-size.height()+1)); never executed: pos.setY(qMax(p.y() - (size.height() + desktopFrame), screen.bottom()-desktopFrame-size.height()+1)); | 0 | ||||||||||||||||||||||||
| 1703 | } else if (pos.y() < screen.top() + desktopFrame
| 0 | ||||||||||||||||||||||||
| 1704 | pos.setY(screen.top() + desktopFrame); | - | ||||||||||||||||||||||||
| 1705 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1706 | - | |||||||||||||||||||||||||
| 1707 | if (pos.y() < screen.top() + desktopFrame
| 0 | ||||||||||||||||||||||||
| 1708 | pos.setY(screen.top() + desktopFrame); never executed: pos.setY(screen.top() + desktopFrame); | 0 | ||||||||||||||||||||||||
| 1709 | if (pos.y() + menuSize.height() - 1 > screen.bottom() - desktopFrame
| 0 | ||||||||||||||||||||||||
| 1710 | if (d->scroll
| 0 | ||||||||||||||||||||||||
| 1711 | d->scroll->scrollFlags |= uint(QMenuPrivate::QMenuScroller::ScrollDown); | - | ||||||||||||||||||||||||
| 1712 | int y = qMax(screen.y(),pos.y()); | - | ||||||||||||||||||||||||
| 1713 | size.setHeight(screen.bottom() - (desktopFrame * 2) - y); | - | ||||||||||||||||||||||||
| 1714 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1715 | - | |||||||||||||||||||||||||
| 1716 | pos.setY(screen.bottom() - size.height() + 1); | - | ||||||||||||||||||||||||
| 1717 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1718 | } | - | ||||||||||||||||||||||||
| 1719 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1720 | const int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this); | - | ||||||||||||||||||||||||
| 1721 | QMenu *caused = qobject_cast<QMenu*>(d_func()->causedPopup.widget); | - | ||||||||||||||||||||||||
| 1722 | if (caused
| 0 | ||||||||||||||||||||||||
| 1723 | QRect parentActionRect(caused->d_func()->actionRect(caused->d_func()->currentAction)); | - | ||||||||||||||||||||||||
| 1724 | const QPoint actionTopLeft = caused->mapToGlobal(parentActionRect.topLeft()); | - | ||||||||||||||||||||||||
| 1725 | parentActionRect.moveTopLeft(actionTopLeft); | - | ||||||||||||||||||||||||
| 1726 | if (isRightToLeft()
| 0 | ||||||||||||||||||||||||
| 1727 | if ((
| 0 | ||||||||||||||||||||||||
| 1728 | && (
| 0 | ||||||||||||||||||||||||
| 1729 | { | - | ||||||||||||||||||||||||
| 1730 | pos.rx() = parentActionRect.left() - menuSize.width(); | - | ||||||||||||||||||||||||
| 1731 | if (pos.x() < screen.x()
| 0 | ||||||||||||||||||||||||
| 1732 | pos.rx() = parentActionRect.right(); never executed: pos.rx() = parentActionRect.right(); | 0 | ||||||||||||||||||||||||
| 1733 | if (pos.x() + menuSize.width() > screen.x() + screen.width()
| 0 | ||||||||||||||||||||||||
| 1734 | pos.rx() = screen.x(); never executed: pos.rx() = screen.x(); | 0 | ||||||||||||||||||||||||
| 1735 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1736 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1737 | if ((
| 0 | ||||||||||||||||||||||||
| 1738 | && (
| 0 | ||||||||||||||||||||||||
| 1739 | { | - | ||||||||||||||||||||||||
| 1740 | pos.rx() = parentActionRect.right(); | - | ||||||||||||||||||||||||
| 1741 | if (pos.x() + menuSize.width() > screen.x() + screen.width()
| 0 | ||||||||||||||||||||||||
| 1742 | pos.rx() = parentActionRect.left() - menuSize.width(); never executed: pos.rx() = parentActionRect.left() - menuSize.width(); | 0 | ||||||||||||||||||||||||
| 1743 | if (pos.x() < screen.x()
| 0 | ||||||||||||||||||||||||
| 1744 | pos.rx() = screen.x() + screen.width() - menuSize.width(); never executed: pos.rx() = screen.x() + screen.width() - menuSize.width(); | 0 | ||||||||||||||||||||||||
| 1745 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1746 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1747 | } | - | ||||||||||||||||||||||||
| 1748 | setGeometry(QRect(pos, size)); | - | ||||||||||||||||||||||||
| 1749 | - | |||||||||||||||||||||||||
| 1750 | int hGuess = isRightToLeft()
| 0 | ||||||||||||||||||||||||
| 1751 | int vGuess = QEffects::DownScroll; | - | ||||||||||||||||||||||||
| 1752 | if (isRightToLeft()
| 0 | ||||||||||||||||||||||||
| 1753 | if ((snapToMouse
| 0 | ||||||||||||||||||||||||
| 1754 | (qobject_cast<QMenu*>(d->causedPopup.widget)
| 0 | ||||||||||||||||||||||||
| 1755 | hGuess = QEffects::RightScroll; never executed: hGuess = QEffects::RightScroll; | 0 | ||||||||||||||||||||||||
| 1756 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1757 | if ((snapToMouse
| 0 | ||||||||||||||||||||||||
| 1758 | (qobject_cast<QMenu*>(d->causedPopup.widget)
| 0 | ||||||||||||||||||||||||
| 1759 | hGuess = QEffects::LeftScroll; never executed: hGuess = QEffects::LeftScroll; | 0 | ||||||||||||||||||||||||
| 1760 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1761 | - | |||||||||||||||||||||||||
| 1762 | - | |||||||||||||||||||||||||
| 1763 | if ((snapToMouse
| 0 | ||||||||||||||||||||||||
| 1764 | (qobject_cast<QMenuBar*>(d->causedPopup.widget)
| 0 | ||||||||||||||||||||||||
| 1765 | pos.y() + size.width() / 2 < d->causedPopup.widget->mapToGlobal(d->causedPopup.widget->pos()).y()
| 0 | ||||||||||||||||||||||||
| 1766 | vGuess = QEffects::UpScroll; never executed: vGuess = QEffects::UpScroll; | 0 | ||||||||||||||||||||||||
| 1767 | - | |||||||||||||||||||||||||
| 1768 | if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu)
| 0 | ||||||||||||||||||||||||
| 1769 | bool doChildEffects = true; | - | ||||||||||||||||||||||||
| 1770 | - | |||||||||||||||||||||||||
| 1771 | if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget)
| 0 | ||||||||||||||||||||||||
| 1772 | doChildEffects = mb->d_func()->doChildEffects; | - | ||||||||||||||||||||||||
| 1773 | mb->d_func()->doChildEffects = false; | - | ||||||||||||||||||||||||
| 1774 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||
| 1775 | - | |||||||||||||||||||||||||
| 1776 | if (QMenu *m = qobject_cast<QMenu*>(d->causedPopup.widget)
| 0 | ||||||||||||||||||||||||
| 1777 | doChildEffects = m->d_func()->doChildEffects; | - | ||||||||||||||||||||||||
| 1778 | m->d_func()->doChildEffects = false; | - | ||||||||||||||||||||||||
| 1779 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1780 | - | |||||||||||||||||||||||||
| 1781 | if (doChildEffects
| 0 | ||||||||||||||||||||||||
| 1782 | if (QApplication::isEffectEnabled(Qt::UI_FadeMenu)
| 0 | ||||||||||||||||||||||||
| 1783 | qFadeEffect(this); never executed: qFadeEffect(this); | 0 | ||||||||||||||||||||||||
| 1784 | else if (d->causedPopup.widget
| 0 | ||||||||||||||||||||||||
| 1785 | qScrollEffect(this, qobject_cast<QMenu*>(d->causedPopup.widget) ? hGuess : vGuess); never executed: qScrollEffect(this, qobject_cast<QMenu*>(d->causedPopup.widget) ? hGuess : vGuess); | 0 | ||||||||||||||||||||||||
| 1786 | else | - | ||||||||||||||||||||||||
| 1787 | qScrollEffect(this, hGuess | vGuess); never executed: qScrollEffect(this, hGuess | vGuess); | 0 | ||||||||||||||||||||||||
| 1788 | } else { | - | ||||||||||||||||||||||||
| 1789 | - | |||||||||||||||||||||||||
| 1790 | qFadeEffect(0); | - | ||||||||||||||||||||||||
| 1791 | qScrollEffect(0); | - | ||||||||||||||||||||||||
| 1792 | - | |||||||||||||||||||||||||
| 1793 | show(); | - | ||||||||||||||||||||||||
| 1794 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1795 | } else | - | ||||||||||||||||||||||||
| 1796 | - | |||||||||||||||||||||||||
| 1797 | { | - | ||||||||||||||||||||||||
| 1798 | show(); | - | ||||||||||||||||||||||||
| 1799 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1800 | - | |||||||||||||||||||||||||
| 1801 | - | |||||||||||||||||||||||||
| 1802 | QAccessibleEvent event(this, QAccessible::PopupMenuStart); | - | ||||||||||||||||||||||||
| 1803 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||
| 1804 | - | |||||||||||||||||||||||||
| 1805 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1806 | QAction *QMenu::exec() | - | ||||||||||||||||||||||||
| 1807 | { | - | ||||||||||||||||||||||||
| 1808 | return never executed: exec(pos());return exec(pos());never executed: return exec(pos()); | 0 | ||||||||||||||||||||||||
| 1809 | } | - | ||||||||||||||||||||||||
| 1810 | QAction *QMenu::exec(const QPoint &p, QAction *action) | - | ||||||||||||||||||||||||
| 1811 | { | - | ||||||||||||||||||||||||
| 1812 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1813 | ensurePolished(); | - | ||||||||||||||||||||||||
| 1814 | createWinId(); | - | ||||||||||||||||||||||||
| 1815 | QEventLoop eventLoop; | - | ||||||||||||||||||||||||
| 1816 | d->eventLoop = &eventLoop; | - | ||||||||||||||||||||||||
| 1817 | popup(p, action); | - | ||||||||||||||||||||||||
| 1818 | - | |||||||||||||||||||||||||
| 1819 | QPointer<QObject> guard = this; | - | ||||||||||||||||||||||||
| 1820 | (void) eventLoop.exec(); | - | ||||||||||||||||||||||||
| 1821 | if (guard.isNull()
| 0 | ||||||||||||||||||||||||
| 1822 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1823 | - | |||||||||||||||||||||||||
| 1824 | action = d->syncAction; | - | ||||||||||||||||||||||||
| 1825 | d->syncAction = 0; | - | ||||||||||||||||||||||||
| 1826 | d->eventLoop = 0; | - | ||||||||||||||||||||||||
| 1827 | return never executed: action;return action;never executed: return action; | 0 | ||||||||||||||||||||||||
| 1828 | } | - | ||||||||||||||||||||||||
| 1829 | QAction *QMenu::exec(QList<QAction*> actions, const QPoint &pos, QAction *at, QWidget *parent) | - | ||||||||||||||||||||||||
| 1830 | - | |||||||||||||||||||||||||
| 1831 | { | - | ||||||||||||||||||||||||
| 1832 | QMenu menu(parent); | - | ||||||||||||||||||||||||
| 1833 | menu.addActions(actions); | - | ||||||||||||||||||||||||
| 1834 | return never executed: menu.exec(pos, at);return menu.exec(pos, at);never executed: return menu.exec(pos, at); | 0 | ||||||||||||||||||||||||
| 1835 | } | - | ||||||||||||||||||||||||
| 1836 | - | |||||||||||||||||||||||||
| 1837 | - | |||||||||||||||||||||||||
| 1838 | - | |||||||||||||||||||||||||
| 1839 | - | |||||||||||||||||||||||||
| 1840 | void QMenu::hideEvent(QHideEvent *) | - | ||||||||||||||||||||||||
| 1841 | { | - | ||||||||||||||||||||||||
| 1842 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1843 | aboutToHide(); | - | ||||||||||||||||||||||||
| 1844 | if (d->eventLoop
| 0 | ||||||||||||||||||||||||
| 1845 | d->eventLoop->exit(); never executed: d->eventLoop->exit(); | 0 | ||||||||||||||||||||||||
| 1846 | d->setCurrentAction(0); | - | ||||||||||||||||||||||||
| 1847 | - | |||||||||||||||||||||||||
| 1848 | QAccessibleEvent event(this, QAccessible::PopupMenuEnd); | - | ||||||||||||||||||||||||
| 1849 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||
| 1850 | - | |||||||||||||||||||||||||
| 1851 | - | |||||||||||||||||||||||||
| 1852 | if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget)
| 0 | ||||||||||||||||||||||||
| 1853 | mb->d_func()->setCurrentAction(0); never executed: mb->d_func()->setCurrentAction(0); | 0 | ||||||||||||||||||||||||
| 1854 | - | |||||||||||||||||||||||||
| 1855 | d->mouseDown = 0; | - | ||||||||||||||||||||||||
| 1856 | d->hasHadMouse = false; | - | ||||||||||||||||||||||||
| 1857 | if (d->activeMenu
| 0 | ||||||||||||||||||||||||
| 1858 | d->hideMenu(d->activeMenu); never executed: d->hideMenu(d->activeMenu); | 0 | ||||||||||||||||||||||||
| 1859 | d->causedPopup.widget = 0; | - | ||||||||||||||||||||||||
| 1860 | d->causedPopup.action = 0; | - | ||||||||||||||||||||||||
| 1861 | if (d->scroll
| 0 | ||||||||||||||||||||||||
| 1862 | d->scroll->scrollTimer.stop(); never executed: d->scroll->scrollTimer.stop(); | 0 | ||||||||||||||||||||||||
| 1863 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1864 | - | |||||||||||||||||||||||||
| 1865 | - | |||||||||||||||||||||||||
| 1866 | - | |||||||||||||||||||||||||
| 1867 | - | |||||||||||||||||||||||||
| 1868 | void QMenu::paintEvent(QPaintEvent *e) | - | ||||||||||||||||||||||||
| 1869 | { | - | ||||||||||||||||||||||||
| 1870 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1871 | d->updateActionRects(); | - | ||||||||||||||||||||||||
| 1872 | QPainter p(this); | - | ||||||||||||||||||||||||
| 1873 | QRegion emptyArea = QRegion(rect()); | - | ||||||||||||||||||||||||
| 1874 | - | |||||||||||||||||||||||||
| 1875 | QStyleOptionMenuItem menuOpt; | - | ||||||||||||||||||||||||
| 1876 | menuOpt.initFrom(this); | - | ||||||||||||||||||||||||
| 1877 | menuOpt.state = QStyle::State_None; | - | ||||||||||||||||||||||||
| 1878 | menuOpt.checkType = QStyleOptionMenuItem::NotCheckable; | - | ||||||||||||||||||||||||
| 1879 | menuOpt.maxIconWidth = 0; | - | ||||||||||||||||||||||||
| 1880 | menuOpt.tabWidth = 0; | - | ||||||||||||||||||||||||
| 1881 | style()->drawPrimitive(QStyle::PE_PanelMenu, &menuOpt, &p, this); | - | ||||||||||||||||||||||||
| 1882 | - | |||||||||||||||||||||||||
| 1883 | - | |||||||||||||||||||||||||
| 1884 | for (int i = 0; i < d->actions.count()
| 0 | ||||||||||||||||||||||||
| 1885 | QAction *action = d->actions.at(i); | - | ||||||||||||||||||||||||
| 1886 | QRect adjustedActionRect = d->actionRects.at(i); | - | ||||||||||||||||||||||||
| 1887 | if (!e->rect().intersects(adjustedActionRect)
| 0 | ||||||||||||||||||||||||
| 1888 | || d->widgetItems.value(action)
| 0 | ||||||||||||||||||||||||
| 1889 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1890 | - | |||||||||||||||||||||||||
| 1891 | QRegion adjustedActionReg(adjustedActionRect); | - | ||||||||||||||||||||||||
| 1892 | emptyArea -= adjustedActionReg; | - | ||||||||||||||||||||||||
| 1893 | p.setClipRegion(adjustedActionReg); | - | ||||||||||||||||||||||||
| 1894 | - | |||||||||||||||||||||||||
| 1895 | QStyleOptionMenuItem opt; | - | ||||||||||||||||||||||||
| 1896 | initStyleOption(&opt, action); | - | ||||||||||||||||||||||||
| 1897 | opt.rect = adjustedActionRect; | - | ||||||||||||||||||||||||
| 1898 | style()->drawControl(QStyle::CE_MenuItem, &opt, &p, this); | - | ||||||||||||||||||||||||
| 1899 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1900 | - | |||||||||||||||||||||||||
| 1901 | const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this); | - | ||||||||||||||||||||||||
| 1902 | - | |||||||||||||||||||||||||
| 1903 | if (d->scroll
| 0 | ||||||||||||||||||||||||
| 1904 | menuOpt.menuItemType = QStyleOptionMenuItem::Scroller; | - | ||||||||||||||||||||||||
| 1905 | menuOpt.state |= QStyle::State_Enabled; | - | ||||||||||||||||||||||||
| 1906 | if (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp
| 0 | ||||||||||||||||||||||||
| 1907 | menuOpt.rect.setRect(fw, fw, width() - (fw * 2), d->scrollerHeight()); | - | ||||||||||||||||||||||||
| 1908 | emptyArea -= QRegion(menuOpt.rect); | - | ||||||||||||||||||||||||
| 1909 | p.setClipRect(menuOpt.rect); | - | ||||||||||||||||||||||||
| 1910 | style()->drawControl(QStyle::CE_MenuScroller, &menuOpt, &p, this); | - | ||||||||||||||||||||||||
| 1911 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1912 | if (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown
| 0 | ||||||||||||||||||||||||
| 1913 | menuOpt.rect.setRect(fw, height() - d->scrollerHeight() - fw, width() - (fw * 2), | - | ||||||||||||||||||||||||
| 1914 | d->scrollerHeight()); | - | ||||||||||||||||||||||||
| 1915 | emptyArea -= QRegion(menuOpt.rect); | - | ||||||||||||||||||||||||
| 1916 | menuOpt.state |= QStyle::State_DownArrow; | - | ||||||||||||||||||||||||
| 1917 | p.setClipRect(menuOpt.rect); | - | ||||||||||||||||||||||||
| 1918 | style()->drawControl(QStyle::CE_MenuScroller, &menuOpt, &p, this); | - | ||||||||||||||||||||||||
| 1919 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1920 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1921 | - | |||||||||||||||||||||||||
| 1922 | if (d->tearoff
| 0 | ||||||||||||||||||||||||
| 1923 | menuOpt.menuItemType = QStyleOptionMenuItem::TearOff; | - | ||||||||||||||||||||||||
| 1924 | menuOpt.rect.setRect(fw, fw, width() - (fw * 2), | - | ||||||||||||||||||||||||
| 1925 | style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this)); | - | ||||||||||||||||||||||||
| 1926 | if (d->scroll
| 0 | ||||||||||||||||||||||||
| 1927 | menuOpt.rect.translate(0, d->scrollerHeight()); never executed: menuOpt.rect.translate(0, d->scrollerHeight()); | 0 | ||||||||||||||||||||||||
| 1928 | emptyArea -= QRegion(menuOpt.rect); | - | ||||||||||||||||||||||||
| 1929 | p.setClipRect(menuOpt.rect); | - | ||||||||||||||||||||||||
| 1930 | menuOpt.state = QStyle::State_None; | - | ||||||||||||||||||||||||
| 1931 | if (d->tearoffHighlighted
| 0 | ||||||||||||||||||||||||
| 1932 | menuOpt.state |= QStyle::State_Selected; never executed: menuOpt.state |= QStyle::State_Selected; | 0 | ||||||||||||||||||||||||
| 1933 | style()->drawControl(QStyle::CE_MenuTearoff, &menuOpt, &p, this); | - | ||||||||||||||||||||||||
| 1934 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1935 | - | |||||||||||||||||||||||||
| 1936 | if (fw
| 0 | ||||||||||||||||||||||||
| 1937 | QRegion borderReg; | - | ||||||||||||||||||||||||
| 1938 | borderReg += QRect(0, 0, fw, height()); | - | ||||||||||||||||||||||||
| 1939 | borderReg += QRect(width()-fw, 0, fw, height()); | - | ||||||||||||||||||||||||
| 1940 | borderReg += QRect(0, 0, width(), fw); | - | ||||||||||||||||||||||||
| 1941 | borderReg += QRect(0, height()-fw, width(), fw); | - | ||||||||||||||||||||||||
| 1942 | p.setClipRegion(borderReg); | - | ||||||||||||||||||||||||
| 1943 | emptyArea -= borderReg; | - | ||||||||||||||||||||||||
| 1944 | QStyleOptionFrame frame; | - | ||||||||||||||||||||||||
| 1945 | frame.rect = rect(); | - | ||||||||||||||||||||||||
| 1946 | frame.palette = palette(); | - | ||||||||||||||||||||||||
| 1947 | frame.state = QStyle::State_None; | - | ||||||||||||||||||||||||
| 1948 | frame.lineWidth = style()->pixelMetric(QStyle::PM_MenuPanelWidth); | - | ||||||||||||||||||||||||
| 1949 | frame.midLineWidth = 0; | - | ||||||||||||||||||||||||
| 1950 | style()->drawPrimitive(QStyle::PE_FrameMenu, &frame, &p, this); | - | ||||||||||||||||||||||||
| 1951 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1952 | - | |||||||||||||||||||||||||
| 1953 | - | |||||||||||||||||||||||||
| 1954 | p.setClipRegion(emptyArea); | - | ||||||||||||||||||||||||
| 1955 | menuOpt.state = QStyle::State_None; | - | ||||||||||||||||||||||||
| 1956 | menuOpt.menuItemType = QStyleOptionMenuItem::EmptyArea; | - | ||||||||||||||||||||||||
| 1957 | menuOpt.checkType = QStyleOptionMenuItem::NotCheckable; | - | ||||||||||||||||||||||||
| 1958 | menuOpt.rect = rect(); | - | ||||||||||||||||||||||||
| 1959 | menuOpt.menuRect = rect(); | - | ||||||||||||||||||||||||
| 1960 | style()->drawControl(QStyle::CE_MenuEmptyArea, &menuOpt, &p, this); | - | ||||||||||||||||||||||||
| 1961 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1962 | - | |||||||||||||||||||||||||
| 1963 | - | |||||||||||||||||||||||||
| 1964 | - | |||||||||||||||||||||||||
| 1965 | - | |||||||||||||||||||||||||
| 1966 | - | |||||||||||||||||||||||||
| 1967 | void QMenu::wheelEvent(QWheelEvent *e) | - | ||||||||||||||||||||||||
| 1968 | { | - | ||||||||||||||||||||||||
| 1969 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1970 | if (d->scroll
| 0 | ||||||||||||||||||||||||
| 1971 | d->scrollMenu(e->delta() > 0 ? never executed: d->scrollMenu(e->delta() > 0 ? QMenuPrivate::QMenuScroller::ScrollUp : QMenuPrivate::QMenuScroller::ScrollDown); | 0 | ||||||||||||||||||||||||
| 1972 | QMenuPrivate::QMenuScroller::ScrollUp : QMenuPrivate::QMenuScroller::ScrollDown); never executed: d->scrollMenu(e->delta() > 0 ? QMenuPrivate::QMenuScroller::ScrollUp : QMenuPrivate::QMenuScroller::ScrollDown); | 0 | ||||||||||||||||||||||||
| 1973 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1974 | - | |||||||||||||||||||||||||
| 1975 | - | |||||||||||||||||||||||||
| 1976 | - | |||||||||||||||||||||||||
| 1977 | - | |||||||||||||||||||||||||
| 1978 | - | |||||||||||||||||||||||||
| 1979 | void QMenu::mousePressEvent(QMouseEvent *e) | - | ||||||||||||||||||||||||
| 1980 | { | - | ||||||||||||||||||||||||
| 1981 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1982 | if (d->aboutToHide
| 0 | ||||||||||||||||||||||||
| 1983 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1984 | - | |||||||||||||||||||||||||
| 1985 | - | |||||||||||||||||||||||||
| 1986 | - | |||||||||||||||||||||||||
| 1987 | - | |||||||||||||||||||||||||
| 1988 | if ((e->pos().isNull()
| 0 | ||||||||||||||||||||||||
| 1989 | if (d->noReplayFor
| 0 | ||||||||||||||||||||||||
| 1990 | && QRect(d->noReplayFor->mapToGlobal(QPoint()), d->noReplayFor->size()).contains(e->globalPos())
| 0 | ||||||||||||||||||||||||
| 1991 | setAttribute(Qt::WA_NoMouseReplay); never executed: setAttribute(Qt::WA_NoMouseReplay); | 0 | ||||||||||||||||||||||||
| 1992 | if (d->eventLoop
| 0 | ||||||||||||||||||||||||
| 1993 | d->syncAction = 0; never executed: d->syncAction = 0; | 0 | ||||||||||||||||||||||||
| 1994 | d->hideUpToMenuBar(); | - | ||||||||||||||||||||||||
| 1995 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1996 | } | - | ||||||||||||||||||||||||
| 1997 | d->mouseDown = this; | - | ||||||||||||||||||||||||
| 1998 | - | |||||||||||||||||||||||||
| 1999 | QAction *action = d->actionAt(e->pos()); | - | ||||||||||||||||||||||||
| 2000 | d->setCurrentAction(action, 20); | - | ||||||||||||||||||||||||
| 2001 | update(); | - | ||||||||||||||||||||||||
| 2002 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2003 | - | |||||||||||||||||||||||||
| 2004 | - | |||||||||||||||||||||||||
| 2005 | - | |||||||||||||||||||||||||
| 2006 | - | |||||||||||||||||||||||||
| 2007 | void QMenu::mouseReleaseEvent(QMouseEvent *e) | - | ||||||||||||||||||||||||
| 2008 | { | - | ||||||||||||||||||||||||
| 2009 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2010 | if (d->aboutToHide
| 0 | ||||||||||||||||||||||||
| 2011 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2012 | if(d->mouseDown != this
| 0 | ||||||||||||||||||||||||
| 2013 | d->mouseDown = 0; | - | ||||||||||||||||||||||||
| 2014 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2015 | } | - | ||||||||||||||||||||||||
| 2016 | - | |||||||||||||||||||||||||
| 2017 | d->mouseDown = 0; | - | ||||||||||||||||||||||||
| 2018 | d->setSyncAction(); | - | ||||||||||||||||||||||||
| 2019 | QAction *action = d->actionAt(e->pos()); | - | ||||||||||||||||||||||||
| 2020 | - | |||||||||||||||||||||||||
| 2021 | if (action
| 0 | ||||||||||||||||||||||||
| 2022 | if (!action->menu()
| 0 | ||||||||||||||||||||||||
| 2023 | - | |||||||||||||||||||||||||
| 2024 | - | |||||||||||||||||||||||||
| 2025 | - | |||||||||||||||||||||||||
| 2026 | - | |||||||||||||||||||||||||
| 2027 | d->activateAction(action, QAction::Trigger); | - | ||||||||||||||||||||||||
| 2028 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2029 | } never executed: else if ((!actionend of block
| 0 | ||||||||||||||||||||||||
| 2030 | d->hideUpToMenuBar(); | - | ||||||||||||||||||||||||
| 2031 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2032 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2033 | - | |||||||||||||||||||||||||
| 2034 | - | |||||||||||||||||||||||||
| 2035 | - | |||||||||||||||||||||||||
| 2036 | - | |||||||||||||||||||||||||
| 2037 | void QMenu::changeEvent(QEvent *e) | - | ||||||||||||||||||||||||
| 2038 | { | - | ||||||||||||||||||||||||
| 2039 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2040 | if (e->type() == QEvent::StyleChange
| 0 | ||||||||||||||||||||||||
| 2041 | e->type() == QEvent::LayoutDirectionChange
| 0 | ||||||||||||||||||||||||
| 2042 | d->itemsDirty = 1; | - | ||||||||||||||||||||||||
| 2043 | setMouseTracking(style()->styleHint(QStyle::SH_Menu_MouseTracking, 0, this)); | - | ||||||||||||||||||||||||
| 2044 | if (isVisible()
| 0 | ||||||||||||||||||||||||
| 2045 | resize(sizeHint()); never executed: resize(sizeHint()); | 0 | ||||||||||||||||||||||||
| 2046 | if (!style()->styleHint(QStyle::SH_Menu_Scrollable, 0, this)
| 0 | ||||||||||||||||||||||||
| 2047 | delete d->scroll; | - | ||||||||||||||||||||||||
| 2048 | d->scroll = 0; | - | ||||||||||||||||||||||||
| 2049 | } never executed: else if (!d->scrollend of block
| 0 | ||||||||||||||||||||||||
| 2050 | d->scroll = new QMenuPrivate::QMenuScroller; | - | ||||||||||||||||||||||||
| 2051 | d->scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone; | - | ||||||||||||||||||||||||
| 2052 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2053 | } never executed: else if (e->type() == QEvent::EnabledChangeend of block
| 0 | ||||||||||||||||||||||||
| 2054 | if (d->tornPopup
| 0 | ||||||||||||||||||||||||
| 2055 | d->tornPopup->setEnabled(isEnabled()); never executed: d->tornPopup->setEnabled(isEnabled()); | 0 | ||||||||||||||||||||||||
| 2056 | d->menuAction->setEnabled(isEnabled()); | - | ||||||||||||||||||||||||
| 2057 | if (!d->platformMenu.isNull()
| 0 | ||||||||||||||||||||||||
| 2058 | d->platformMenu->setEnabled(isEnabled()); never executed: d->platformMenu->setEnabled(isEnabled()); | 0 | ||||||||||||||||||||||||
| 2059 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2060 | QWidget::changeEvent(e); | - | ||||||||||||||||||||||||
| 2061 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2062 | - | |||||||||||||||||||||||||
| 2063 | - | |||||||||||||||||||||||||
| 2064 | - | |||||||||||||||||||||||||
| 2065 | - | |||||||||||||||||||||||||
| 2066 | - | |||||||||||||||||||||||||
| 2067 | bool | - | ||||||||||||||||||||||||
| 2068 | QMenu::event(QEvent *e) | - | ||||||||||||||||||||||||
| 2069 | { | - | ||||||||||||||||||||||||
| 2070 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2071 | switch (e->type()) { | - | ||||||||||||||||||||||||
| 2072 | case never executed: QEvent::Polish:case QEvent::Polish:never executed: case QEvent::Polish: | 0 | ||||||||||||||||||||||||
| 2073 | d->updateLayoutDirection(); | - | ||||||||||||||||||||||||
| 2074 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2075 | case never executed: QEvent::ShortcutOverride:case QEvent::ShortcutOverride:never executed: {case QEvent::ShortcutOverride: | 0 | ||||||||||||||||||||||||
| 2076 | QKeyEvent *kev = static_cast<QKeyEvent*>(e); | - | ||||||||||||||||||||||||
| 2077 | if (kev->key() == Qt::Key_Up
| 0 | ||||||||||||||||||||||||
| 2078 | || kev->key() == Qt::Key_Left
| 0 | ||||||||||||||||||||||||
| 2079 | || kev->key() == Qt::Key_Enter
| 0 | ||||||||||||||||||||||||
| 2080 | || kev->matches(QKeySequence::Cancel)
| 0 | ||||||||||||||||||||||||
| 2081 | e->accept(); | - | ||||||||||||||||||||||||
| 2082 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 2083 | } | - | ||||||||||||||||||||||||
| 2084 | } | - | ||||||||||||||||||||||||
| 2085 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2086 | case never executed: QEvent::KeyPress:case QEvent::KeyPress:never executed: {case QEvent::KeyPress: | 0 | ||||||||||||||||||||||||
| 2087 | QKeyEvent *ke = (QKeyEvent*)e; | - | ||||||||||||||||||||||||
| 2088 | if (ke->key() == Qt::Key_Tab
| 0 | ||||||||||||||||||||||||
| 2089 | keyPressEvent(ke); | - | ||||||||||||||||||||||||
| 2090 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 2091 | } | - | ||||||||||||||||||||||||
| 2092 | } break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2093 | case never executed: QEvent::MouseButtonPress:case QEvent::MouseButtonPress:never executed: case QEvent::MouseButtonPress: | 0 | ||||||||||||||||||||||||
| 2094 | case never executed: QEvent::ContextMenu:case QEvent::ContextMenu:never executed: {case QEvent::ContextMenu: | 0 | ||||||||||||||||||||||||
| 2095 | bool canPopup = true; | - | ||||||||||||||||||||||||
| 2096 | if (e->type() == QEvent::MouseButtonPress
| 0 | ||||||||||||||||||||||||
| 2097 | canPopup = (static_cast<QMouseEvent*>(e)->button() == Qt::LeftButton); never executed: canPopup = (static_cast<QMouseEvent*>(e)->button() == Qt::LeftButton); | 0 | ||||||||||||||||||||||||
| 2098 | if (canPopup
| 0 | ||||||||||||||||||||||||
| 2099 | d->delayState.stop(); | - | ||||||||||||||||||||||||
| 2100 | internalDelayedPopup(); | - | ||||||||||||||||||||||||
| 2101 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2102 | } | - | ||||||||||||||||||||||||
| 2103 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2104 | case never executed: QEvent::Resize:case QEvent::Resize:never executed: {case QEvent::Resize: | 0 | ||||||||||||||||||||||||
| 2105 | QStyleHintReturnMask menuMask; | - | ||||||||||||||||||||||||
| 2106 | QStyleOption option; | - | ||||||||||||||||||||||||
| 2107 | option.initFrom(this); | - | ||||||||||||||||||||||||
| 2108 | if (style()->styleHint(QStyle::SH_Menu_Mask, &option, this, &menuMask)
| 0 | ||||||||||||||||||||||||
| 2109 | setMask(menuMask.region); | - | ||||||||||||||||||||||||
| 2110 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2111 | d->itemsDirty = 1; | - | ||||||||||||||||||||||||
| 2112 | d->updateActionRects(); | - | ||||||||||||||||||||||||
| 2113 | break; never executed: }break; | 0 | ||||||||||||||||||||||||
| 2114 | case never executed: QEvent::Show:case QEvent::Show:never executed: case QEvent::Show: | 0 | ||||||||||||||||||||||||
| 2115 | d->mouseDown = 0; | - | ||||||||||||||||||||||||
| 2116 | d->updateActionRects(); | - | ||||||||||||||||||||||||
| 2117 | d->sloppyState.reset(); | - | ||||||||||||||||||||||||
| 2118 | if (d->currentAction
| 0 | ||||||||||||||||||||||||
| 2119 | d->popupAction(d->currentAction, 0, false); never executed: d->popupAction(d->currentAction, 0, false); | 0 | ||||||||||||||||||||||||
| 2120 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2121 | - | |||||||||||||||||||||||||
| 2122 | case never executed: QEvent::ToolTip:case QEvent::ToolTip:never executed: case QEvent::ToolTip: | 0 | ||||||||||||||||||||||||
| 2123 | if (d->toolTipsVisible
| 0 | ||||||||||||||||||||||||
| 2124 | const QHelpEvent *ev = static_cast<const QHelpEvent*>(e); | - | ||||||||||||||||||||||||
| 2125 | if (const
| 0 | ||||||||||||||||||||||||
| 2126 | const QString toolTip = action->d_func()->tooltip; | - | ||||||||||||||||||||||||
| 2127 | if (!toolTip.isEmpty()
| 0 | ||||||||||||||||||||||||
| 2128 | QToolTip::showText(ev->globalPos(), toolTip, this); never executed: QToolTip::showText(ev->globalPos(), toolTip, this); | 0 | ||||||||||||||||||||||||
| 2129 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 2130 | } | - | ||||||||||||||||||||||||
| 2131 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2132 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2133 | - | |||||||||||||||||||||||||
| 2134 | - | |||||||||||||||||||||||||
| 2135 | case never executed: QEvent::QueryWhatsThis:case QEvent::QueryWhatsThis:never executed: case QEvent::QueryWhatsThis: | 0 | ||||||||||||||||||||||||
| 2136 | e->setAccepted(d->whatsThis.size()); | - | ||||||||||||||||||||||||
| 2137 | if (QAction *action = d->actionAt(static_cast<QHelpEvent*>(e)->pos())
| 0 | ||||||||||||||||||||||||
| 2138 | if (action->whatsThis().size()
| 0 | ||||||||||||||||||||||||
| 2139 | e->accept(); never executed: e->accept(); | 0 | ||||||||||||||||||||||||
| 2140 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2141 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 2142 | - | |||||||||||||||||||||||||
| 2143 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 2144 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2145 | } | - | ||||||||||||||||||||||||
| 2146 | return never executed: QWidget::event(e);return QWidget::event(e);never executed: return QWidget::event(e); | 0 | ||||||||||||||||||||||||
| 2147 | } | - | ||||||||||||||||||||||||
| 2148 | - | |||||||||||||||||||||||||
| 2149 | - | |||||||||||||||||||||||||
| 2150 | - | |||||||||||||||||||||||||
| 2151 | - | |||||||||||||||||||||||||
| 2152 | bool QMenu::focusNextPrevChild(bool next) | - | ||||||||||||||||||||||||
| 2153 | { | - | ||||||||||||||||||||||||
| 2154 | setFocus(); | - | ||||||||||||||||||||||||
| 2155 | QKeyEvent ev(QEvent::KeyPress, next ? Qt::Key_Tab : Qt::Key_Backtab, Qt::NoModifier); | - | ||||||||||||||||||||||||
| 2156 | keyPressEvent(&ev); | - | ||||||||||||||||||||||||
| 2157 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 2158 | } | - | ||||||||||||||||||||||||
| 2159 | - | |||||||||||||||||||||||||
| 2160 | - | |||||||||||||||||||||||||
| 2161 | - | |||||||||||||||||||||||||
| 2162 | - | |||||||||||||||||||||||||
| 2163 | void QMenu::keyPressEvent(QKeyEvent *e) | - | ||||||||||||||||||||||||
| 2164 | { | - | ||||||||||||||||||||||||
| 2165 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2166 | d->updateActionRects(); | - | ||||||||||||||||||||||||
| 2167 | int key = e->key(); | - | ||||||||||||||||||||||||
| 2168 | if (isRightToLeft()
| 0 | ||||||||||||||||||||||||
| 2169 | if (key == Qt::Key_Left
| 0 | ||||||||||||||||||||||||
| 2170 | key = Qt::Key_Right; never executed: key = Qt::Key_Right; | 0 | ||||||||||||||||||||||||
| 2171 | else if (key == Qt::Key_Right
| 0 | ||||||||||||||||||||||||
| 2172 | key = Qt::Key_Left; never executed: key = Qt::Key_Left; | 0 | ||||||||||||||||||||||||
| 2173 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2174 | - | |||||||||||||||||||||||||
| 2175 | if (key == Qt::Key_Tab
| 0 | ||||||||||||||||||||||||
| 2176 | key = Qt::Key_Down; never executed: key = Qt::Key_Down; | 0 | ||||||||||||||||||||||||
| 2177 | if (key == Qt::Key_Backtab
| 0 | ||||||||||||||||||||||||
| 2178 | key = Qt::Key_Up; never executed: key = Qt::Key_Up; | 0 | ||||||||||||||||||||||||
| 2179 | - | |||||||||||||||||||||||||
| 2180 | - | |||||||||||||||||||||||||
| 2181 | bool key_consumed = false; | - | ||||||||||||||||||||||||
| 2182 | switch(key) { | - | ||||||||||||||||||||||||
| 2183 | case never executed: Qt::Key_Home:case Qt::Key_Home:never executed: case Qt::Key_Home: | 0 | ||||||||||||||||||||||||
| 2184 | key_consumed = true; | - | ||||||||||||||||||||||||
| 2185 | if (d->scroll
| 0 | ||||||||||||||||||||||||
| 2186 | d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollTop, true); never executed: d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollTop, true); | 0 | ||||||||||||||||||||||||
| 2187 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2188 | case never executed: Qt::Key_End:case Qt::Key_End:never executed: case Qt::Key_End: | 0 | ||||||||||||||||||||||||
| 2189 | key_consumed = true; | - | ||||||||||||||||||||||||
| 2190 | if (d->scroll
| 0 | ||||||||||||||||||||||||
| 2191 | d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollBottom, true); never executed: d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollBottom, true); | 0 | ||||||||||||||||||||||||
| 2192 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2193 | case never executed: Qt::Key_PageUp:case Qt::Key_PageUp:never executed: case Qt::Key_PageUp: | 0 | ||||||||||||||||||||||||
| 2194 | key_consumed = true; | - | ||||||||||||||||||||||||
| 2195 | if (d->currentAction
| 0 | ||||||||||||||||||||||||
| 2196 | if(d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp
| 0 | ||||||||||||||||||||||||
| 2197 | d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollUp, true, true); never executed: d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollUp, true, true); | 0 | ||||||||||||||||||||||||
| 2198 | else | - | ||||||||||||||||||||||||
| 2199 | d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollTop, true); never executed: d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollTop, true); | 0 | ||||||||||||||||||||||||
| 2200 | } | - | ||||||||||||||||||||||||
| 2201 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2202 | case never executed: Qt::Key_PageDown:case Qt::Key_PageDown:never executed: case Qt::Key_PageDown: | 0 | ||||||||||||||||||||||||
| 2203 | key_consumed = true; | - | ||||||||||||||||||||||||
| 2204 | if (d->currentAction
| 0 | ||||||||||||||||||||||||
| 2205 | if(d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown
| 0 | ||||||||||||||||||||||||
| 2206 | d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollDown, true, true); never executed: d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollDown, true, true); | 0 | ||||||||||||||||||||||||
| 2207 | else | - | ||||||||||||||||||||||||
| 2208 | d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollBottom, true); never executed: d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollBottom, true); | 0 | ||||||||||||||||||||||||
| 2209 | } | - | ||||||||||||||||||||||||
| 2210 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2211 | case never executed: Qt::Key_Up:case Qt::Key_Up:never executed: case Qt::Key_Up: | 0 | ||||||||||||||||||||||||
| 2212 | case never executed: Qt::Key_Down:case Qt::Key_Down:never executed: {case Qt::Key_Down: | 0 | ||||||||||||||||||||||||
| 2213 | key_consumed = true; | - | ||||||||||||||||||||||||
| 2214 | QAction *nextAction = 0; | - | ||||||||||||||||||||||||
| 2215 | QMenuPrivate::QMenuScroller::ScrollLocation scroll_loc = QMenuPrivate::QMenuScroller::ScrollStay; | - | ||||||||||||||||||||||||
| 2216 | if (!d->currentAction
| 0 | ||||||||||||||||||||||||
| 2217 | if(key == Qt::Key_Down
| 0 | ||||||||||||||||||||||||
| 2218 | for(int i = 0; i < d->actions.count()
| 0 | ||||||||||||||||||||||||
| 2219 | QAction *act = d->actions.at(i); | - | ||||||||||||||||||||||||
| 2220 | if (d->actionRects.at(i).isNull()
| 0 | ||||||||||||||||||||||||
| 2221 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2222 | if (!act->isSeparator()
| 0 | ||||||||||||||||||||||||
| 2223 | (style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)
| 0 | ||||||||||||||||||||||||
| 2224 | || act->isEnabled()
| 0 | ||||||||||||||||||||||||
| 2225 | nextAction = act; | - | ||||||||||||||||||||||||
| 2226 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2227 | } | - | ||||||||||||||||||||||||
| 2228 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2229 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2230 | for(int i = d->actions.count()-1; i >= 0
| 0 | ||||||||||||||||||||||||
| 2231 | QAction *act = d->actions.at(i); | - | ||||||||||||||||||||||||
| 2232 | if (d->actionRects.at(i).isNull()
| 0 | ||||||||||||||||||||||||
| 2233 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2234 | if (!act->isSeparator()
| 0 | ||||||||||||||||||||||||
| 2235 | (style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)
| 0 | ||||||||||||||||||||||||
| 2236 | || act->isEnabled()
| 0 | ||||||||||||||||||||||||
| 2237 | nextAction = act; | - | ||||||||||||||||||||||||
| 2238 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2239 | } | - | ||||||||||||||||||||||||
| 2240 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2241 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2242 | } else { | - | ||||||||||||||||||||||||
| 2243 | for(int i = 0, y = 0; !nextAction
| 0 | ||||||||||||||||||||||||
| 2244 | QAction *act = d->actions.at(i); | - | ||||||||||||||||||||||||
| 2245 | if (act == d->currentAction
| 0 | ||||||||||||||||||||||||
| 2246 | if (key == Qt::Key_Up
| 0 | ||||||||||||||||||||||||
| 2247 | for(int next_i = i-1; true
| 0 | ||||||||||||||||||||||||
| 2248 | if (next_i == -1
| 0 | ||||||||||||||||||||||||
| 2249 | if(!style()->styleHint(QStyle::SH_Menu_SelectionWrap, 0, this)
| 0 | ||||||||||||||||||||||||
| 2250 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2251 | if (d->scroll
| 0 | ||||||||||||||||||||||||
| 2252 | scroll_loc = QMenuPrivate::QMenuScroller::ScrollBottom; never executed: scroll_loc = QMenuPrivate::QMenuScroller::ScrollBottom; | 0 | ||||||||||||||||||||||||
| 2253 | next_i = d->actionRects.count()-1; | - | ||||||||||||||||||||||||
| 2254 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2255 | QAction *next = d->actions.at(next_i); | - | ||||||||||||||||||||||||
| 2256 | if (next == d->currentAction
| 0 | ||||||||||||||||||||||||
| 2257 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2258 | if (d->actionRects.at(next_i).isNull()
| 0 | ||||||||||||||||||||||||
| 2259 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2260 | if (next->isSeparator()
| 0 | ||||||||||||||||||||||||
| 2261 | (!next->isEnabled()
| 0 | ||||||||||||||||||||||||
| 2262 | !style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)
| 0 | ||||||||||||||||||||||||
| 2263 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2264 | nextAction = next; | - | ||||||||||||||||||||||||
| 2265 | if (d->scroll
| 0 | ||||||||||||||||||||||||
| 2266 | int topVisible = d->scrollerHeight(); | - | ||||||||||||||||||||||||
| 2267 | if (d->tearoff
| 0 | ||||||||||||||||||||||||
| 2268 | topVisible += style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this); never executed: topVisible += style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this); | 0 | ||||||||||||||||||||||||
| 2269 | if (((
| 0 | ||||||||||||||||||||||||
| 2270 | scroll_loc = QMenuPrivate::QMenuScroller::ScrollTop; never executed: scroll_loc = QMenuPrivate::QMenuScroller::ScrollTop; | 0 | ||||||||||||||||||||||||
| 2271 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2272 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2273 | } | - | ||||||||||||||||||||||||
| 2274 | if (!nextAction
| 0 | ||||||||||||||||||||||||
| 2275 | d->tearoffHighlighted = 1; never executed: d->tearoffHighlighted = 1; | 0 | ||||||||||||||||||||||||
| 2276 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2277 | y += d->actionRects.at(i).height(); | - | ||||||||||||||||||||||||
| 2278 | for(int next_i = i+1; true
| 0 | ||||||||||||||||||||||||
| 2279 | if (next_i == d->actionRects.count()
| 0 | ||||||||||||||||||||||||
| 2280 | if(!style()->styleHint(QStyle::SH_Menu_SelectionWrap, 0, this)
| 0 | ||||||||||||||||||||||||
| 2281 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2282 | if (d->scroll
| 0 | ||||||||||||||||||||||||
| 2283 | scroll_loc = QMenuPrivate::QMenuScroller::ScrollTop; never executed: scroll_loc = QMenuPrivate::QMenuScroller::ScrollTop; | 0 | ||||||||||||||||||||||||
| 2284 | next_i = 0; | - | ||||||||||||||||||||||||
| 2285 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2286 | QAction *next = d->actions.at(next_i); | - | ||||||||||||||||||||||||
| 2287 | if (next == d->currentAction
| 0 | ||||||||||||||||||||||||
| 2288 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2289 | if (d->actionRects.at(next_i).isNull()
| 0 | ||||||||||||||||||||||||
| 2290 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2291 | if (next->isSeparator()
| 0 | ||||||||||||||||||||||||
| 2292 | (!next->isEnabled()
| 0 | ||||||||||||||||||||||||
| 2293 | !style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)
| 0 | ||||||||||||||||||||||||
| 2294 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2295 | nextAction = next; | - | ||||||||||||||||||||||||
| 2296 | if (d->scroll
| 0 | ||||||||||||||||||||||||
| 2297 | int bottomVisible = height() - d->scrollerHeight(); | - | ||||||||||||||||||||||||
| 2298 | if (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp
| 0 | ||||||||||||||||||||||||
| 2299 | bottomVisible -= d->scrollerHeight(); never executed: bottomVisible -= d->scrollerHeight(); | 0 | ||||||||||||||||||||||||
| 2300 | if (d->tearoff
| 0 | ||||||||||||||||||||||||
| 2301 | bottomVisible -= style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this); never executed: bottomVisible -= style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this); | 0 | ||||||||||||||||||||||||
| 2302 | if ((
| 0 | ||||||||||||||||||||||||
| 2303 | scroll_loc = QMenuPrivate::QMenuScroller::ScrollBottom; never executed: scroll_loc = QMenuPrivate::QMenuScroller::ScrollBottom; | 0 | ||||||||||||||||||||||||
| 2304 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2305 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2306 | } | - | ||||||||||||||||||||||||
| 2307 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2308 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2309 | } | - | ||||||||||||||||||||||||
| 2310 | y += d->actionRects.at(i).height(); | - | ||||||||||||||||||||||||
| 2311 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2312 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2313 | if (nextAction
| 0 | ||||||||||||||||||||||||
| 2314 | if (d->scroll
| 0 | ||||||||||||||||||||||||
| 2315 | d->scroll->scrollTimer.stop(); | - | ||||||||||||||||||||||||
| 2316 | d->scrollMenu(nextAction, scroll_loc); | - | ||||||||||||||||||||||||
| 2317 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2318 | d->setCurrentAction(nextAction, -1, QMenuPrivate::SelectedFromKeyboard); | - | ||||||||||||||||||||||||
| 2319 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2320 | break; never executed: }break; | 0 | ||||||||||||||||||||||||
| 2321 | - | |||||||||||||||||||||||||
| 2322 | case never executed: Qt::Key_Right:case Qt::Key_Right:never executed: case Qt::Key_Right: | 0 | ||||||||||||||||||||||||
| 2323 | if (d->currentAction
| 0 | ||||||||||||||||||||||||
| 2324 | d->popupAction(d->currentAction, 0, true); | - | ||||||||||||||||||||||||
| 2325 | key_consumed = true; | - | ||||||||||||||||||||||||
| 2326 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2327 | } | - | ||||||||||||||||||||||||
| 2328 | - | |||||||||||||||||||||||||
| 2329 | case never executed: Qt::Key_Left:case Qt::Key_Left:never executed: case Qt::Key_Left:code before this statement never executed: {case Qt::Key_Left: | 0 | ||||||||||||||||||||||||
| 2330 | if (d->currentAction
| 0 | ||||||||||||||||||||||||
| 2331 | QAction *nextAction = 0; | - | ||||||||||||||||||||||||
| 2332 | if (key == Qt::Key_Left
| 0 | ||||||||||||||||||||||||
| 2333 | QRect actionR = d->actionRect(d->currentAction); | - | ||||||||||||||||||||||||
| 2334 | for(int x = actionR.left()-1; !nextAction
| 0 | ||||||||||||||||||||||||
| 2335 | nextAction = d->actionAt(QPoint(x, actionR.center().y())); never executed: nextAction = d->actionAt(QPoint(x, actionR.center().y())); | 0 | ||||||||||||||||||||||||
| 2336 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2337 | QRect actionR = d->actionRect(d->currentAction); | - | ||||||||||||||||||||||||
| 2338 | for(int x = actionR.right()+1; !nextAction
| 0 | ||||||||||||||||||||||||
| 2339 | nextAction = d->actionAt(QPoint(x, actionR.center().y())); never executed: nextAction = d->actionAt(QPoint(x, actionR.center().y())); | 0 | ||||||||||||||||||||||||
| 2340 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2341 | if (nextAction
| 0 | ||||||||||||||||||||||||
| 2342 | d->setCurrentAction(nextAction, -1, QMenuPrivate::SelectedFromKeyboard); | - | ||||||||||||||||||||||||
| 2343 | key_consumed = true; | - | ||||||||||||||||||||||||
| 2344 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2345 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2346 | if (!key_consumed
| 0 | ||||||||||||||||||||||||
| 2347 | QPointer<QWidget> caused = d->causedPopup.widget; | - | ||||||||||||||||||||||||
| 2348 | d->hideMenu(this); | - | ||||||||||||||||||||||||
| 2349 | if (caused
| 0 | ||||||||||||||||||||||||
| 2350 | caused->setFocus(); never executed: caused->setFocus(); | 0 | ||||||||||||||||||||||||
| 2351 | key_consumed = true; | - | ||||||||||||||||||||||||
| 2352 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2353 | break; never executed: }break; | 0 | ||||||||||||||||||||||||
| 2354 | - | |||||||||||||||||||||||||
| 2355 | case never executed: Qt::Key_Alt:case Qt::Key_Alt:never executed: case Qt::Key_Alt: | 0 | ||||||||||||||||||||||||
| 2356 | if (d->tornoff
| 0 | ||||||||||||||||||||||||
| 2357 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2358 | - | |||||||||||||||||||||||||
| 2359 | key_consumed = true; | - | ||||||||||||||||||||||||
| 2360 | if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this)
| 0 | ||||||||||||||||||||||||
| 2361 | { | - | ||||||||||||||||||||||||
| 2362 | d->hideMenu(this); | - | ||||||||||||||||||||||||
| 2363 | - | |||||||||||||||||||||||||
| 2364 | if (QMenuBar *mb = qobject_cast<QMenuBar*>(QApplication::focusWidget())
| 0 | ||||||||||||||||||||||||
| 2365 | mb->d_func()->setKeyboardMode(false); | - | ||||||||||||||||||||||||
| 2366 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2367 | - | |||||||||||||||||||||||||
| 2368 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2369 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2370 | - | |||||||||||||||||||||||||
| 2371 | case never executed: Qt::Key_Space:case Qt::Key_Space:never executed: case Qt::Key_Space: | 0 | ||||||||||||||||||||||||
| 2372 | if (!style()->styleHint(QStyle::SH_Menu_SpaceActivatesItem, 0, this)
| 0 | ||||||||||||||||||||||||
| 2373 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2374 | - | |||||||||||||||||||||||||
| 2375 | - | |||||||||||||||||||||||||
| 2376 | - | |||||||||||||||||||||||||
| 2377 | - | |||||||||||||||||||||||||
| 2378 | case never executed: Qt::Key_Return:case Qt::Key_Return:never executed: case Qt::Key_Return:code before this statement never executed: case Qt::Key_Return: | 0 | ||||||||||||||||||||||||
| 2379 | case never executed: Qt::Key_Enter:case Qt::Key_Enter:never executed: {case Qt::Key_Enter: | 0 | ||||||||||||||||||||||||
| 2380 | if (!d->currentAction
| 0 | ||||||||||||||||||||||||
| 2381 | d->setFirstActionActive(); | - | ||||||||||||||||||||||||
| 2382 | key_consumed = true; | - | ||||||||||||||||||||||||
| 2383 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2384 | } | - | ||||||||||||||||||||||||
| 2385 | - | |||||||||||||||||||||||||
| 2386 | d->setSyncAction(); | - | ||||||||||||||||||||||||
| 2387 | - | |||||||||||||||||||||||||
| 2388 | if (d->currentAction->menu()
| 0 | ||||||||||||||||||||||||
| 2389 | d->popupAction(d->currentAction, 0, true); never executed: d->popupAction(d->currentAction, 0, true); | 0 | ||||||||||||||||||||||||
| 2390 | else | - | ||||||||||||||||||||||||
| 2391 | d->activateAction(d->currentAction, QAction::Trigger); never executed: d->activateAction(d->currentAction, QAction::Trigger); | 0 | ||||||||||||||||||||||||
| 2392 | key_consumed = true; | - | ||||||||||||||||||||||||
| 2393 | break; never executed: }break; | 0 | ||||||||||||||||||||||||
| 2394 | - | |||||||||||||||||||||||||
| 2395 | - | |||||||||||||||||||||||||
| 2396 | case never executed: Qt::Key_F1:case Qt::Key_F1:never executed: case Qt::Key_F1: | 0 | ||||||||||||||||||||||||
| 2397 | if (!d->currentAction
| 0 | ||||||||||||||||||||||||
| 2398 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2399 | QWhatsThis::enterWhatsThisMode(); | - | ||||||||||||||||||||||||
| 2400 | d->activateAction(d->currentAction, QAction::Trigger); | - | ||||||||||||||||||||||||
| 2401 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2402 | - | |||||||||||||||||||||||||
| 2403 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 2404 | key_consumed = false; | - | ||||||||||||||||||||||||
| 2405 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2406 | - | |||||||||||||||||||||||||
| 2407 | if (!key_consumed
| 0 | ||||||||||||||||||||||||
| 2408 | 0 | |||||||||||||||||||||||||
| 2409 | 0 | |||||||||||||||||||||||||
| 2410 | 0 | |||||||||||||||||||||||||
| 2411 | )
| 0 | ||||||||||||||||||||||||
| 2412 | key_consumed = true; | - | ||||||||||||||||||||||||
| 2413 | if (d->tornoff
| 0 | ||||||||||||||||||||||||
| 2414 | close(); | - | ||||||||||||||||||||||||
| 2415 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2416 | } | - | ||||||||||||||||||||||||
| 2417 | { | - | ||||||||||||||||||||||||
| 2418 | QPointer<QWidget> caused = d->causedPopup.widget; | - | ||||||||||||||||||||||||
| 2419 | d->hideMenu(this); | - | ||||||||||||||||||||||||
| 2420 | - | |||||||||||||||||||||||||
| 2421 | if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)
| 0 | ||||||||||||||||||||||||
| 2422 | mb->d_func()->setCurrentAction(d->menuAction); | - | ||||||||||||||||||||||||
| 2423 | mb->d_func()->setKeyboardMode(true); | - | ||||||||||||||||||||||||
| 2424 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2425 | - | |||||||||||||||||||||||||
| 2426 | } | - | ||||||||||||||||||||||||
| 2427 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2428 | - | |||||||||||||||||||||||||
| 2429 | if (!key_consumed
| 0 | ||||||||||||||||||||||||
| 2430 | if ((!e->modifiers()
| 0 | ||||||||||||||||||||||||
| 2431 | e->text().length()==1
| 0 | ||||||||||||||||||||||||
| 2432 | bool activateAction = false; | - | ||||||||||||||||||||||||
| 2433 | QAction *nextAction = 0; | - | ||||||||||||||||||||||||
| 2434 | if (style()->styleHint(QStyle::SH_Menu_KeyboardSearch, 0, this)
| 0 | ||||||||||||||||||||||||
| 2435 | int best_match_count = 0; | - | ||||||||||||||||||||||||
| 2436 | d->searchBufferTimer.start(2000, this); | - | ||||||||||||||||||||||||
| 2437 | d->searchBuffer += e->text(); | - | ||||||||||||||||||||||||
| 2438 | for(int i = 0; i < d->actions.size()
| 0 | ||||||||||||||||||||||||
| 2439 | int match_count = 0; | - | ||||||||||||||||||||||||
| 2440 | if (d->actionRects.at(i).isNull()
| 0 | ||||||||||||||||||||||||
| 2441 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2442 | QAction *act = d->actions.at(i); | - | ||||||||||||||||||||||||
| 2443 | const QString act_text = act->text(); | - | ||||||||||||||||||||||||
| 2444 | for(int c = 0; c < d->searchBuffer.size()
| 0 | ||||||||||||||||||||||||
| 2445 | if(act_text.indexOf(d->searchBuffer.at(c), 0, Qt::CaseInsensitive) != -1
| 0 | ||||||||||||||||||||||||
| 2446 | ++ never executed: match_count;++match_count;never executed: ++match_count; | 0 | ||||||||||||||||||||||||
| 2447 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2448 | if(match_count > best_match_count
| 0 | ||||||||||||||||||||||||
| 2449 | best_match_count = match_count; | - | ||||||||||||||||||||||||
| 2450 | nextAction = act; | - | ||||||||||||||||||||||||
| 2451 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2452 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2453 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2454 | - | |||||||||||||||||||||||||
| 2455 | else { | - | ||||||||||||||||||||||||
| 2456 | int clashCount = 0; | - | ||||||||||||||||||||||||
| 2457 | QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0; | - | ||||||||||||||||||||||||
| 2458 | QChar c = e->text().at(0).toUpper(); | - | ||||||||||||||||||||||||
| 2459 | for(int i = 0; i < d->actions.size()
| 0 | ||||||||||||||||||||||||
| 2460 | if (d->actionRects.at(i).isNull()
| 0 | ||||||||||||||||||||||||
| 2461 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2462 | QAction *act = d->actions.at(i); | - | ||||||||||||||||||||||||
| 2463 | QKeySequence sequence = QKeySequence::mnemonic(act->text()); | - | ||||||||||||||||||||||||
| 2464 | int key = sequence[0] & 0xffff; | - | ||||||||||||||||||||||||
| 2465 | if (key == c.unicode()
| 0 | ||||||||||||||||||||||||
| 2466 | clashCount++; | - | ||||||||||||||||||||||||
| 2467 | if (!first
| 0 | ||||||||||||||||||||||||
| 2468 | first = act; never executed: first = act; | 0 | ||||||||||||||||||||||||
| 2469 | if (act == d->currentAction
| 0 | ||||||||||||||||||||||||
| 2470 | currentSelected = act; never executed: currentSelected = act; | 0 | ||||||||||||||||||||||||
| 2471 | else if (!firstAfterCurrent
| 0 | ||||||||||||||||||||||||
| 2472 | firstAfterCurrent = act; never executed: firstAfterCurrent = act; | 0 | ||||||||||||||||||||||||
| 2473 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2474 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2475 | if (clashCount == 1
| 0 | ||||||||||||||||||||||||
| 2476 | activateAction = true; never executed: activateAction = true; | 0 | ||||||||||||||||||||||||
| 2477 | if (clashCount >= 1
| 0 | ||||||||||||||||||||||||
| 2478 | if (clashCount == 1
| 0 | ||||||||||||||||||||||||
| 2479 | nextAction = first; never executed: nextAction = first; | 0 | ||||||||||||||||||||||||
| 2480 | else | - | ||||||||||||||||||||||||
| 2481 | nextAction = firstAfterCurrent; never executed: nextAction = firstAfterCurrent; | 0 | ||||||||||||||||||||||||
| 2482 | } | - | ||||||||||||||||||||||||
| 2483 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2484 | - | |||||||||||||||||||||||||
| 2485 | if (nextAction
| 0 | ||||||||||||||||||||||||
| 2486 | key_consumed = true; | - | ||||||||||||||||||||||||
| 2487 | if(d->scroll
| 0 | ||||||||||||||||||||||||
| 2488 | d->scrollMenu(nextAction, QMenuPrivate::QMenuScroller::ScrollCenter, false); never executed: d->scrollMenu(nextAction, QMenuPrivate::QMenuScroller::ScrollCenter, false); | 0 | ||||||||||||||||||||||||
| 2489 | d->setCurrentAction(nextAction, 0, QMenuPrivate::SelectedFromElsewhere, true); | - | ||||||||||||||||||||||||
| 2490 | if (!nextAction->menu()
| 0 | ||||||||||||||||||||||||
| 2491 | d->setSyncAction(); | - | ||||||||||||||||||||||||
| 2492 | d->activateAction(nextAction, QAction::Trigger); | - | ||||||||||||||||||||||||
| 2493 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2494 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2495 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2496 | if (!key_consumed
| 0 | ||||||||||||||||||||||||
| 2497 | - | |||||||||||||||||||||||||
| 2498 | if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->topCausedWidget())
| 0 | ||||||||||||||||||||||||
| 2499 | QAction *oldAct = mb->d_func()->currentAction; | - | ||||||||||||||||||||||||
| 2500 | QApplication::sendEvent(mb, e); | - | ||||||||||||||||||||||||
| 2501 | if (mb->d_func()->currentAction != oldAct
| 0 | ||||||||||||||||||||||||
| 2502 | key_consumed = true; never executed: key_consumed = true; | 0 | ||||||||||||||||||||||||
| 2503 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2504 | - | |||||||||||||||||||||||||
| 2505 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2506 | - | |||||||||||||||||||||||||
| 2507 | - | |||||||||||||||||||||||||
| 2508 | - | |||||||||||||||||||||||||
| 2509 | - | |||||||||||||||||||||||||
| 2510 | - | |||||||||||||||||||||||||
| 2511 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2512 | if (key_consumed
| 0 | ||||||||||||||||||||||||
| 2513 | e->accept(); never executed: e->accept(); | 0 | ||||||||||||||||||||||||
| 2514 | else | - | ||||||||||||||||||||||||
| 2515 | e->ignore(); never executed: e->ignore(); | 0 | ||||||||||||||||||||||||
| 2516 | } | - | ||||||||||||||||||||||||
| 2517 | - | |||||||||||||||||||||||||
| 2518 | - | |||||||||||||||||||||||||
| 2519 | - | |||||||||||||||||||||||||
| 2520 | - | |||||||||||||||||||||||||
| 2521 | void QMenu::mouseMoveEvent(QMouseEvent *e) | - | ||||||||||||||||||||||||
| 2522 | { | - | ||||||||||||||||||||||||
| 2523 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2524 | if (!isVisible()
| 0 | ||||||||||||||||||||||||
| 2525 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2526 | - | |||||||||||||||||||||||||
| 2527 | d->motions++; | - | ||||||||||||||||||||||||
| 2528 | if (d->motions == 0
| 0 | ||||||||||||||||||||||||
| 2529 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2530 | - | |||||||||||||||||||||||||
| 2531 | d->hasHadMouse = d->hasHadMouse
| 0 | ||||||||||||||||||||||||
| 2532 | - | |||||||||||||||||||||||||
| 2533 | QAction *action = d->actionAt(e->pos()); | - | ||||||||||||||||||||||||
| 2534 | if ((!action
| 0 | ||||||||||||||||||||||||
| 2535 | if (d->hasHadMouse
| 0 | ||||||||||||||||||||||||
| 2536 | || (!d->currentAction
| 0 | ||||||||||||||||||||||||
| 2537 | d->setCurrentAction(action); | - | ||||||||||||||||||||||||
| 2538 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2539 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2540 | } | - | ||||||||||||||||||||||||
| 2541 | - | |||||||||||||||||||||||||
| 2542 | if (e->buttons()
| 0 | ||||||||||||||||||||||||
| 2543 | d->mouseDown = this; never executed: d->mouseDown = this; | 0 | ||||||||||||||||||||||||
| 2544 | - | |||||||||||||||||||||||||
| 2545 | if (d->activeMenu
| 0 | ||||||||||||||||||||||||
| 2546 | d->activeMenu->d_func()->setCurrentAction(0); never executed: d->activeMenu->d_func()->setCurrentAction(0); | 0 | ||||||||||||||||||||||||
| 2547 | - | |||||||||||||||||||||||||
| 2548 | QMenuSloppyState::MouseEventResult sloppyEventResult = d->sloppyState.processMouseEvent(e->localPos(), action, d->currentAction); | - | ||||||||||||||||||||||||
| 2549 | if (sloppyEventResult == QMenuSloppyState::EventShouldBePropagated
| 0 | ||||||||||||||||||||||||
| 2550 | d->setCurrentAction(action, d->mousePopupDelay); | - | ||||||||||||||||||||||||
| 2551 | } never executed: else if (sloppyEventResult == QMenuSloppyState::EventDiscardsSloppyStateend of block
| 0 | ||||||||||||||||||||||||
| 2552 | d->sloppyState.reset(); | - | ||||||||||||||||||||||||
| 2553 | d->hideMenu(d->activeMenu); | - | ||||||||||||||||||||||||
| 2554 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2555 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2556 | - | |||||||||||||||||||||||||
| 2557 | - | |||||||||||||||||||||||||
| 2558 | - | |||||||||||||||||||||||||
| 2559 | - | |||||||||||||||||||||||||
| 2560 | void QMenu::enterEvent(QEvent *) | - | ||||||||||||||||||||||||
| 2561 | { | - | ||||||||||||||||||||||||
| 2562 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2563 | d->hasReceievedEnter = true; | - | ||||||||||||||||||||||||
| 2564 | d->sloppyState.enter(); | - | ||||||||||||||||||||||||
| 2565 | d->motions = -1; | - | ||||||||||||||||||||||||
| 2566 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2567 | - | |||||||||||||||||||||||||
| 2568 | - | |||||||||||||||||||||||||
| 2569 | - | |||||||||||||||||||||||||
| 2570 | - | |||||||||||||||||||||||||
| 2571 | void QMenu::leaveEvent(QEvent *) | - | ||||||||||||||||||||||||
| 2572 | { | - | ||||||||||||||||||||||||
| 2573 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2574 | d->hasReceievedEnter = false; | - | ||||||||||||||||||||||||
| 2575 | if (!d->activeMenu
| 0 | ||||||||||||||||||||||||
| 2576 | setActiveAction(0); never executed: setActiveAction(0); | 0 | ||||||||||||||||||||||||
| 2577 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2578 | - | |||||||||||||||||||||||||
| 2579 | - | |||||||||||||||||||||||||
| 2580 | - | |||||||||||||||||||||||||
| 2581 | - | |||||||||||||||||||||||||
| 2582 | void | - | ||||||||||||||||||||||||
| 2583 | QMenu::timerEvent(QTimerEvent *e) | - | ||||||||||||||||||||||||
| 2584 | { | - | ||||||||||||||||||||||||
| 2585 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2586 | if (d->scroll
| 0 | ||||||||||||||||||||||||
| 2587 | d->scrollMenu((QMenuPrivate::QMenuScroller::ScrollDirection)d->scroll->scrollDirection); | - | ||||||||||||||||||||||||
| 2588 | if (d->scroll->scrollFlags == QMenuPrivate::QMenuScroller::ScrollNone
| 0 | ||||||||||||||||||||||||
| 2589 | d->scroll->scrollTimer.stop(); never executed: d->scroll->scrollTimer.stop(); | 0 | ||||||||||||||||||||||||
| 2590 | } never executed: else if (d->delayState.timer.timerId() == e->timerId()end of block
| 0 | ||||||||||||||||||||||||
| 2591 | if (d->currentAction
| 0 | ||||||||||||||||||||||||
| 2592 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2593 | d->delayState.stop(); | - | ||||||||||||||||||||||||
| 2594 | d->sloppyState.stopTimer(); | - | ||||||||||||||||||||||||
| 2595 | internalDelayedPopup(); | - | ||||||||||||||||||||||||
| 2596 | } never executed: else if (d->sloppyState.isTimerId(e->timerId())end of block
| 0 | ||||||||||||||||||||||||
| 2597 | d->sloppyState.timeout(); | - | ||||||||||||||||||||||||
| 2598 | } never executed: else if(d->searchBufferTimer.timerId() == e->timerId()end of block
| 0 | ||||||||||||||||||||||||
| 2599 | d->searchBuffer.clear(); | - | ||||||||||||||||||||||||
| 2600 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2601 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2602 | - | |||||||||||||||||||||||||
| 2603 | static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *item, QPlatformMenu *itemsMenu) | - | ||||||||||||||||||||||||
| 2604 | { | - | ||||||||||||||||||||||||
| 2605 | item->setText(action->text()); | - | ||||||||||||||||||||||||
| 2606 | item->setIsSeparator(action->isSeparator()); | - | ||||||||||||||||||||||||
| 2607 | if (action->isIconVisibleInMenu()
| 0 | ||||||||||||||||||||||||
| 2608 | item->setIcon(action->icon()); | - | ||||||||||||||||||||||||
| 2609 | if (QWidget *w = action->parentWidget()
| 0 | ||||||||||||||||||||||||
| 2610 | QStyleOption opt; | - | ||||||||||||||||||||||||
| 2611 | opt.init(w); | - | ||||||||||||||||||||||||
| 2612 | item->setIconSize(w->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, w)); | - | ||||||||||||||||||||||||
| 2613 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2614 | QStyleOption opt; | - | ||||||||||||||||||||||||
| 2615 | item->setIconSize((static_cast<QApplication *>(QCoreApplication::instance()))->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, 0)); | - | ||||||||||||||||||||||||
| 2616 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2617 | } else { | - | ||||||||||||||||||||||||
| 2618 | item->setIcon(QIcon()); | - | ||||||||||||||||||||||||
| 2619 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2620 | item->setVisible(action->isVisible()); | - | ||||||||||||||||||||||||
| 2621 | item->setShortcut(action->shortcut()); | - | ||||||||||||||||||||||||
| 2622 | item->setCheckable(action->isCheckable()); | - | ||||||||||||||||||||||||
| 2623 | item->setChecked(action->isChecked()); | - | ||||||||||||||||||||||||
| 2624 | item->setFont(action->font()); | - | ||||||||||||||||||||||||
| 2625 | item->setRole((QPlatformMenuItem::MenuRole) action->menuRole()); | - | ||||||||||||||||||||||||
| 2626 | item->setEnabled(action->isEnabled()); | - | ||||||||||||||||||||||||
| 2627 | - | |||||||||||||||||||||||||
| 2628 | if (action->menu()
| 0 | ||||||||||||||||||||||||
| 2629 | if (!action->menu()->platformMenu()
| 0 | ||||||||||||||||||||||||
| 2630 | action->menu()->setPlatformMenu(itemsMenu->createSubMenu()); never executed: action->menu()->setPlatformMenu(itemsMenu->createSubMenu()); | 0 | ||||||||||||||||||||||||
| 2631 | item->setMenu(action->menu()->platformMenu()); | - | ||||||||||||||||||||||||
| 2632 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2633 | item->setMenu(0); | - | ||||||||||||||||||||||||
| 2634 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2635 | } | - | ||||||||||||||||||||||||
| 2636 | - | |||||||||||||||||||||||||
| 2637 | - | |||||||||||||||||||||||||
| 2638 | - | |||||||||||||||||||||||||
| 2639 | - | |||||||||||||||||||||||||
| 2640 | void QMenu::actionEvent(QActionEvent *e) | - | ||||||||||||||||||||||||
| 2641 | { | - | ||||||||||||||||||||||||
| 2642 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2643 | d->itemsDirty = 1; | - | ||||||||||||||||||||||||
| 2644 | setAttribute(Qt::WA_Resized, false); | - | ||||||||||||||||||||||||
| 2645 | if (d->tornPopup
| 0 | ||||||||||||||||||||||||
| 2646 | d->tornPopup->syncWithMenu(this, e); never executed: d->tornPopup->syncWithMenu(this, e); | 0 | ||||||||||||||||||||||||
| 2647 | if (e->type() == QEvent::ActionAdded
| 0 | ||||||||||||||||||||||||
| 2648 | if(!d->tornoff
| 0 | ||||||||||||||||||||||||
| 2649 | connect(e->action(), qFlagLocation("2""triggered()" "\0" __FILE__ ":" "3260"), this, qFlagLocation("1""_q_actionTriggered()" "\0" __FILE__ ":" "3260")); | - | ||||||||||||||||||||||||
| 2650 | connect(e->action(), qFlagLocation("2""hovered()" "\0" __FILE__ ":" "3261"), this, qFlagLocation("1""_q_actionHovered()" "\0" __FILE__ ":" "3261")); | - | ||||||||||||||||||||||||
| 2651 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2652 | if (QWidgetAction *wa = qobject_cast<QWidgetAction *>(e->action())
| 0 | ||||||||||||||||||||||||
| 2653 | QWidget *widget = wa->requestWidget(this); | - | ||||||||||||||||||||||||
| 2654 | if (widget
| 0 | ||||||||||||||||||||||||
| 2655 | d->widgetItems.insert(wa, widget); never executed: d->widgetItems.insert(wa, widget); | 0 | ||||||||||||||||||||||||
| 2656 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2657 | } never executed: else if (e->type() == QEvent::ActionRemovedend of block
| 0 | ||||||||||||||||||||||||
| 2658 | e->action()->disconnect(this); | - | ||||||||||||||||||||||||
| 2659 | if (e->action() == d->currentAction
| 0 | ||||||||||||||||||||||||
| 2660 | d->currentAction = 0; never executed: d->currentAction = 0; | 0 | ||||||||||||||||||||||||
| 2661 | if (QWidgetAction *wa = qobject_cast<QWidgetAction *>(e->action())
| 0 | ||||||||||||||||||||||||
| 2662 | if (QWidget *widget = d->widgetItems.value(wa)
| 0 | ||||||||||||||||||||||||
| 2663 | wa->releaseWidget(widget); | - | ||||||||||||||||||||||||
| 2664 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2665 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2666 | d->widgetItems.remove(e->action()); | - | ||||||||||||||||||||||||
| 2667 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2668 | - | |||||||||||||||||||||||||
| 2669 | if (!d->platformMenu.isNull()
| 0 | ||||||||||||||||||||||||
| 2670 | if (e->type() == QEvent::ActionAdded
| 0 | ||||||||||||||||||||||||
| 2671 | QPlatformMenuItem *menuItem = d->platformMenu->createMenuItem(); | - | ||||||||||||||||||||||||
| 2672 | menuItem->setTag(reinterpret_cast<quintptr>(e->action())); | - | ||||||||||||||||||||||||
| 2673 | QObject::connect(menuItem, qFlagLocation("2""activated()" "\0" __FILE__ ":" "3294"), e->action(), qFlagLocation("1""trigger()" "\0" __FILE__ ":" "3294")); | - | ||||||||||||||||||||||||
| 2674 | QObject::connect(menuItem, qFlagLocation("2""hovered()" "\0" __FILE__ ":" "3295"), e->action(), qFlagLocation("2""hovered()" "\0" __FILE__ ":" "3295")); | - | ||||||||||||||||||||||||
| 2675 | copyActionToPlatformItem(e->action(), menuItem, d->platformMenu); | - | ||||||||||||||||||||||||
| 2676 | QPlatformMenuItem* beforeItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->before())); | - | ||||||||||||||||||||||||
| 2677 | d->platformMenu->insertMenuItem(menuItem, beforeItem); | - | ||||||||||||||||||||||||
| 2678 | } never executed: else if (e->type() == QEvent::ActionRemovedend of block
| 0 | ||||||||||||||||||||||||
| 2679 | QPlatformMenuItem *menuItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->action())); | - | ||||||||||||||||||||||||
| 2680 | d->platformMenu->removeMenuItem(menuItem); | - | ||||||||||||||||||||||||
| 2681 | delete menuItem; | - | ||||||||||||||||||||||||
| 2682 | } never executed: else if (e->type() == QEvent::ActionChangedend of block
| 0 | ||||||||||||||||||||||||
| 2683 | QPlatformMenuItem *menuItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->action())); | - | ||||||||||||||||||||||||
| 2684 | if (menuItem
| 0 | ||||||||||||||||||||||||
| 2685 | copyActionToPlatformItem(e->action(), menuItem, d->platformMenu); | - | ||||||||||||||||||||||||
| 2686 | d->platformMenu->syncMenuItem(menuItem); | - | ||||||||||||||||||||||||
| 2687 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2688 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2689 | - | |||||||||||||||||||||||||
| 2690 | d->platformMenu->syncSeparatorsCollapsible(d->collapsibleSeparators); | - | ||||||||||||||||||||||||
| 2691 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2692 | if (isVisible()
| 0 | ||||||||||||||||||||||||
| 2693 | d->updateActionRects(); | - | ||||||||||||||||||||||||
| 2694 | resize(sizeHint()); | - | ||||||||||||||||||||||||
| 2695 | update(); | - | ||||||||||||||||||||||||
| 2696 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2697 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2698 | - | |||||||||||||||||||||||||
| 2699 | - | |||||||||||||||||||||||||
| 2700 | - | |||||||||||||||||||||||||
| 2701 | - | |||||||||||||||||||||||||
| 2702 | void QMenu::internalDelayedPopup() | - | ||||||||||||||||||||||||
| 2703 | { | - | ||||||||||||||||||||||||
| 2704 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2705 | - | |||||||||||||||||||||||||
| 2706 | if (QMenu *menu = d->activeMenu
| 0 | ||||||||||||||||||||||||
| 2707 | if (d->activeMenu->menuAction() != d->currentAction
| 0 | ||||||||||||||||||||||||
| 2708 | d->hideMenu(menu); never executed: d->hideMenu(menu); | 0 | ||||||||||||||||||||||||
| 2709 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2710 | - | |||||||||||||||||||||||||
| 2711 | if (!d->currentAction
| 0 | ||||||||||||||||||||||||
| 2712 | !d->currentAction->menu()->isEnabled()
| 0 | ||||||||||||||||||||||||
| 2713 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2714 | - | |||||||||||||||||||||||||
| 2715 | - | |||||||||||||||||||||||||
| 2716 | d->activeMenu = d->currentAction->menu(); | - | ||||||||||||||||||||||||
| 2717 | d->activeMenu->d_func()->causedPopup.widget = this; | - | ||||||||||||||||||||||||
| 2718 | d->activeMenu->d_func()->causedPopup.action = d->currentAction; | - | ||||||||||||||||||||||||
| 2719 | - | |||||||||||||||||||||||||
| 2720 | int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this); | - | ||||||||||||||||||||||||
| 2721 | const QRect actionRect(d->actionRect(d->currentAction)); | - | ||||||||||||||||||||||||
| 2722 | const QPoint rightPos(mapToGlobal(QPoint(actionRect.right() + subMenuOffset + 1, actionRect.top()))); | - | ||||||||||||||||||||||||
| 2723 | - | |||||||||||||||||||||||||
| 2724 | d->activeMenu->popup(rightPos); | - | ||||||||||||||||||||||||
| 2725 | d->sloppyState.setSubMenuPopup(actionRect, d->currentAction, d->activeMenu); | - | ||||||||||||||||||||||||
| 2726 | - | |||||||||||||||||||||||||
| 2727 | - | |||||||||||||||||||||||||
| 2728 | - | |||||||||||||||||||||||||
| 2729 | - | |||||||||||||||||||||||||
| 2730 | - | |||||||||||||||||||||||||
| 2731 | if (underMouse()
| 0 | ||||||||||||||||||||||||
| 2732 | QEvent leaveEvent(QEvent::Leave); | - | ||||||||||||||||||||||||
| 2733 | QCoreApplication::sendEvent(this, &leaveEvent); | - | ||||||||||||||||||||||||
| 2734 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2735 | - | |||||||||||||||||||||||||
| 2736 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2737 | void QMenu::setNoReplayFor(QWidget *noReplayFor) | - | ||||||||||||||||||||||||
| 2738 | { | - | ||||||||||||||||||||||||
| 2739 | d_func()->noReplayFor = noReplayFor; | - | ||||||||||||||||||||||||
| 2740 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2741 | - | |||||||||||||||||||||||||
| 2742 | - | |||||||||||||||||||||||||
| 2743 | - | |||||||||||||||||||||||||
| 2744 | QPlatformMenu *QMenu::platformMenu() | - | ||||||||||||||||||||||||
| 2745 | { | - | ||||||||||||||||||||||||
| 2746 | - | |||||||||||||||||||||||||
| 2747 | return never executed: d_func()->platformMenu;return d_func()->platformMenu;never executed: return d_func()->platformMenu; | 0 | ||||||||||||||||||||||||
| 2748 | } | - | ||||||||||||||||||||||||
| 2749 | - | |||||||||||||||||||||||||
| 2750 | - | |||||||||||||||||||||||||
| 2751 | - | |||||||||||||||||||||||||
| 2752 | void QMenu::setPlatformMenu(QPlatformMenu *platformMenu) | - | ||||||||||||||||||||||||
| 2753 | { | - | ||||||||||||||||||||||||
| 2754 | d_func()->setPlatformMenu(platformMenu); | - | ||||||||||||||||||||||||
| 2755 | d_func()->syncPlatformMenu(); | - | ||||||||||||||||||||||||
| 2756 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2757 | bool QMenu::separatorsCollapsible() const | - | ||||||||||||||||||||||||
| 2758 | { | - | ||||||||||||||||||||||||
| 2759 | const QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2760 | return never executed: d->collapsibleSeparators;return d->collapsibleSeparators;never executed: return d->collapsibleSeparators; | 0 | ||||||||||||||||||||||||
| 2761 | } | - | ||||||||||||||||||||||||
| 2762 | - | |||||||||||||||||||||||||
| 2763 | void QMenu::setSeparatorsCollapsible(bool collapse) | - | ||||||||||||||||||||||||
| 2764 | { | - | ||||||||||||||||||||||||
| 2765 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2766 | if (d->collapsibleSeparators == collapse
| 0 | ||||||||||||||||||||||||
| 2767 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2768 | - | |||||||||||||||||||||||||
| 2769 | d->collapsibleSeparators = collapse; | - | ||||||||||||||||||||||||
| 2770 | d->itemsDirty = 1; | - | ||||||||||||||||||||||||
| 2771 | if (isVisible()
| 0 | ||||||||||||||||||||||||
| 2772 | d->updateActionRects(); | - | ||||||||||||||||||||||||
| 2773 | update(); | - | ||||||||||||||||||||||||
| 2774 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2775 | if (!d->platformMenu.isNull()
| 0 | ||||||||||||||||||||||||
| 2776 | d->platformMenu->syncSeparatorsCollapsible(collapse); never executed: d->platformMenu->syncSeparatorsCollapsible(collapse); | 0 | ||||||||||||||||||||||||
| 2777 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2778 | bool QMenu::toolTipsVisible() const | - | ||||||||||||||||||||||||
| 2779 | { | - | ||||||||||||||||||||||||
| 2780 | const QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2781 | return never executed: d->toolTipsVisible;return d->toolTipsVisible;never executed: return d->toolTipsVisible; | 0 | ||||||||||||||||||||||||
| 2782 | } | - | ||||||||||||||||||||||||
| 2783 | - | |||||||||||||||||||||||||
| 2784 | void QMenu::setToolTipsVisible(bool visible) | - | ||||||||||||||||||||||||
| 2785 | { | - | ||||||||||||||||||||||||
| 2786 | QMenuPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2787 | if (d->toolTipsVisible == visible
| 0 | ||||||||||||||||||||||||
| 2788 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2789 | - | |||||||||||||||||||||||||
| 2790 | d->toolTipsVisible = visible; | - | ||||||||||||||||||||||||
| 2791 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2792 | - | |||||||||||||||||||||||||
| 2793 | - | |||||||||||||||||||||||||
| 2794 | - | |||||||||||||||||||||||||
| 2795 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |