| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qmenubar.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 | class QMenuBarExtension : public QToolButton | - | ||||||||||||||||||||||||
| 16 | { | - | ||||||||||||||||||||||||
| 17 | public: | - | ||||||||||||||||||||||||
| 18 | explicit QMenuBarExtension(QWidget *parent); | - | ||||||||||||||||||||||||
| 19 | - | |||||||||||||||||||||||||
| 20 | QSize sizeHint() const override; | - | ||||||||||||||||||||||||
| 21 | void paintEvent(QPaintEvent *) override; | - | ||||||||||||||||||||||||
| 22 | }; | - | ||||||||||||||||||||||||
| 23 | - | |||||||||||||||||||||||||
| 24 | QMenuBarExtension::QMenuBarExtension(QWidget *parent) | - | ||||||||||||||||||||||||
| 25 | : QToolButton(parent) | - | ||||||||||||||||||||||||
| 26 | { | - | ||||||||||||||||||||||||
| 27 | setObjectName(QLatin1String("qt_menubar_ext_button")); | - | ||||||||||||||||||||||||
| 28 | setAutoRaise(true); | - | ||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||
| 30 | setPopupMode(QToolButton::InstantPopup); | - | ||||||||||||||||||||||||
| 31 | - | |||||||||||||||||||||||||
| 32 | setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton, 0, parentWidget())); | - | ||||||||||||||||||||||||
| 33 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 34 | - | |||||||||||||||||||||||||
| 35 | void QMenuBarExtension::paintEvent(QPaintEvent *) | - | ||||||||||||||||||||||||
| 36 | { | - | ||||||||||||||||||||||||
| 37 | QStylePainter p(this); | - | ||||||||||||||||||||||||
| 38 | QStyleOptionToolButton opt; | - | ||||||||||||||||||||||||
| 39 | initStyleOption(&opt); | - | ||||||||||||||||||||||||
| 40 | - | |||||||||||||||||||||||||
| 41 | opt.features &= ~QStyleOptionToolButton::HasMenu; | - | ||||||||||||||||||||||||
| 42 | p.drawComplexControl(QStyle::CC_ToolButton, opt); | - | ||||||||||||||||||||||||
| 43 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 44 | - | |||||||||||||||||||||||||
| 45 | - | |||||||||||||||||||||||||
| 46 | QSize QMenuBarExtension::sizeHint() const | - | ||||||||||||||||||||||||
| 47 | { | - | ||||||||||||||||||||||||
| 48 | int ext = style()->pixelMetric(QStyle::PM_ToolBarExtensionExtent, 0, parentWidget()); | - | ||||||||||||||||||||||||
| 49 | return never executed: QSize(ext, ext);return QSize(ext, ext);never executed: return QSize(ext, ext); | 0 | ||||||||||||||||||||||||
| 50 | } | - | ||||||||||||||||||||||||
| 51 | - | |||||||||||||||||||||||||
| 52 | - | |||||||||||||||||||||||||
| 53 | - | |||||||||||||||||||||||||
| 54 | - | |||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||
| 56 | QAction *QMenuBarPrivate::actionAt(QPoint p) const | - | ||||||||||||||||||||||||
| 57 | { | - | ||||||||||||||||||||||||
| 58 | for(int i = 0; i < actions.size()
| 0 | ||||||||||||||||||||||||
| 59 | if(actionRect(actions.at(i)).contains(p)
| 0 | ||||||||||||||||||||||||
| 60 | return never executed: actions.at(i);return actions.at(i);never executed: return actions.at(i); | 0 | ||||||||||||||||||||||||
| 61 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 62 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 63 | } | - | ||||||||||||||||||||||||
| 64 | - | |||||||||||||||||||||||||
| 65 | QRect QMenuBarPrivate::menuRect(bool extVisible) const | - | ||||||||||||||||||||||||
| 66 | { | - | ||||||||||||||||||||||||
| 67 | const QMenuBar * const q = q_func(); | - | ||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||
| 69 | int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q); | - | ||||||||||||||||||||||||
| 70 | QRect result = q->rect(); | - | ||||||||||||||||||||||||
| 71 | result.adjust(hmargin, 0, -hmargin, 0); | - | ||||||||||||||||||||||||
| 72 | - | |||||||||||||||||||||||||
| 73 | if (extVisible
| 0 | ||||||||||||||||||||||||
| 74 | if (q->isRightToLeft()
| 0 | ||||||||||||||||||||||||
| 75 | result.setLeft(result.left() + extension->sizeHint().width()); never executed: result.setLeft(result.left() + extension->sizeHint().width()); | 0 | ||||||||||||||||||||||||
| 76 | else | - | ||||||||||||||||||||||||
| 77 | result.setWidth(result.width() - extension->sizeHint().width()); never executed: result.setWidth(result.width() - extension->sizeHint().width()); | 0 | ||||||||||||||||||||||||
| 78 | } | - | ||||||||||||||||||||||||
| 79 | - | |||||||||||||||||||||||||
| 80 | if (leftWidget
| 0 | ||||||||||||||||||||||||
| 81 | QSize sz = leftWidget->sizeHint(); | - | ||||||||||||||||||||||||
| 82 | if (q->isRightToLeft()
| 0 | ||||||||||||||||||||||||
| 83 | result.setRight(result.right() - sz.width()); never executed: result.setRight(result.right() - sz.width()); | 0 | ||||||||||||||||||||||||
| 84 | else | - | ||||||||||||||||||||||||
| 85 | result.setLeft(result.left() + sz.width()); never executed: result.setLeft(result.left() + sz.width()); | 0 | ||||||||||||||||||||||||
| 86 | } | - | ||||||||||||||||||||||||
| 87 | - | |||||||||||||||||||||||||
| 88 | if (rightWidget
| 0 | ||||||||||||||||||||||||
| 89 | QSize sz = rightWidget->sizeHint(); | - | ||||||||||||||||||||||||
| 90 | if (q->isRightToLeft()
| 0 | ||||||||||||||||||||||||
| 91 | result.setLeft(result.left() + sz.width()); never executed: result.setLeft(result.left() + sz.width()); | 0 | ||||||||||||||||||||||||
| 92 | else | - | ||||||||||||||||||||||||
| 93 | result.setRight(result.right() - sz.width()); never executed: result.setRight(result.right() - sz.width()); | 0 | ||||||||||||||||||||||||
| 94 | } | - | ||||||||||||||||||||||||
| 95 | - | |||||||||||||||||||||||||
| 96 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 97 | } | - | ||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||
| 99 | bool QMenuBarPrivate::isVisible(QAction *action) | - | ||||||||||||||||||||||||
| 100 | { | - | ||||||||||||||||||||||||
| 101 | return never executed: !hiddenActions.contains(action);return !hiddenActions.contains(action);never executed: return !hiddenActions.contains(action); | 0 | ||||||||||||||||||||||||
| 102 | } | - | ||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||
| 104 | void QMenuBarPrivate::updateGeometries() | - | ||||||||||||||||||||||||
| 105 | { | - | ||||||||||||||||||||||||
| 106 | QMenuBar * const q = q_func(); | - | ||||||||||||||||||||||||
| 107 | if(!itemsDirty
| 0 | ||||||||||||||||||||||||
| 108 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 109 | int q_width = q->width()-(q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q)*2); | - | ||||||||||||||||||||||||
| 110 | int q_start = -1; | - | ||||||||||||||||||||||||
| 111 | if(leftWidget
| 0 | ||||||||||||||||||||||||
| 112 | int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q) | - | ||||||||||||||||||||||||
| 113 | + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q); | - | ||||||||||||||||||||||||
| 114 | int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q) | - | ||||||||||||||||||||||||
| 115 | + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q); | - | ||||||||||||||||||||||||
| 116 | if (leftWidget
| 0 | ||||||||||||||||||||||||
| 117 | QSize sz = leftWidget->sizeHint(); | - | ||||||||||||||||||||||||
| 118 | q_width -= sz.width(); | - | ||||||||||||||||||||||||
| 119 | q_start = sz.width(); | - | ||||||||||||||||||||||||
| 120 | QPoint pos(hmargin, (q->height() - leftWidget->height()) / 2); | - | ||||||||||||||||||||||||
| 121 | QRect vRect = QStyle::visualRect(q->layoutDirection(), q->rect(), QRect(pos, sz)); | - | ||||||||||||||||||||||||
| 122 | leftWidget->setGeometry(vRect); | - | ||||||||||||||||||||||||
| 123 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 124 | if (rightWidget
| 0 | ||||||||||||||||||||||||
| 125 | QSize sz = rightWidget->sizeHint(); | - | ||||||||||||||||||||||||
| 126 | q_width -= sz.width(); | - | ||||||||||||||||||||||||
| 127 | QPoint pos(q->width() - sz.width() - hmargin, vmargin); | - | ||||||||||||||||||||||||
| 128 | QRect vRect = QStyle::visualRect(q->layoutDirection(), q->rect(), QRect(pos, sz)); | - | ||||||||||||||||||||||||
| 129 | rightWidget->setGeometry(vRect); | - | ||||||||||||||||||||||||
| 130 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 131 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||
| 136 | - | |||||||||||||||||||||||||
| 137 | - | |||||||||||||||||||||||||
| 138 | - | |||||||||||||||||||||||||
| 139 | calcActionRects(q_width, q_start); | - | ||||||||||||||||||||||||
| 140 | currentAction = 0; | - | ||||||||||||||||||||||||
| 141 | - | |||||||||||||||||||||||||
| 142 | if(itemsDirty
| 0 | ||||||||||||||||||||||||
| 143 | for(int j = 0; j < shortcutIndexMap.size()
| 0 | ||||||||||||||||||||||||
| 144 | q->releaseShortcut(shortcutIndexMap.value(j)); never executed: q->releaseShortcut(shortcutIndexMap.value(j)); | 0 | ||||||||||||||||||||||||
| 145 | shortcutIndexMap.clear(); | - | ||||||||||||||||||||||||
| 146 | const int actionsCount = actions.count(); | - | ||||||||||||||||||||||||
| 147 | shortcutIndexMap.reserve(actionsCount); | - | ||||||||||||||||||||||||
| 148 | for (int i = 0; i < actionsCount
| 0 | ||||||||||||||||||||||||
| 149 | shortcutIndexMap.append(q->grabShortcut(QKeySequence::mnemonic(actions.at(i)->text()))); never executed: shortcutIndexMap.append(q->grabShortcut(QKeySequence::mnemonic(actions.at(i)->text()))); | 0 | ||||||||||||||||||||||||
| 150 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 151 | - | |||||||||||||||||||||||||
| 152 | itemsDirty = false; | - | ||||||||||||||||||||||||
| 153 | - | |||||||||||||||||||||||||
| 154 | hiddenActions.clear(); | - | ||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||
| 156 | QRect menuRect = this->menuRect(false); | - | ||||||||||||||||||||||||
| 157 | - | |||||||||||||||||||||||||
| 158 | - | |||||||||||||||||||||||||
| 159 | bool hasHiddenActions = false; | - | ||||||||||||||||||||||||
| 160 | for (int i = 0; i < actions.count()
| 0 | ||||||||||||||||||||||||
| 161 | const QRect &rect = actionRects.at(i); | - | ||||||||||||||||||||||||
| 162 | if (rect.isValid()
| 0 | ||||||||||||||||||||||||
| 163 | hasHiddenActions = true; | - | ||||||||||||||||||||||||
| 164 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 165 | } | - | ||||||||||||||||||||||||
| 166 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 167 | - | |||||||||||||||||||||||||
| 168 | - | |||||||||||||||||||||||||
| 169 | if (hasHiddenActions
| 0 | ||||||||||||||||||||||||
| 170 | menuRect = this->menuRect(true); | - | ||||||||||||||||||||||||
| 171 | for (int i = 0; i < actions.count()
| 0 | ||||||||||||||||||||||||
| 172 | const QRect &rect = actionRects.at(i); | - | ||||||||||||||||||||||||
| 173 | if (rect.isValid()
| 0 | ||||||||||||||||||||||||
| 174 | hiddenActions.append(actions.at(i)); | - | ||||||||||||||||||||||||
| 175 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 176 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 177 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 178 | - | |||||||||||||||||||||||||
| 179 | if (hiddenActions.count() > 0
| 0 | ||||||||||||||||||||||||
| 180 | QMenu *pop = extension->menu(); | - | ||||||||||||||||||||||||
| 181 | if (!pop
| 0 | ||||||||||||||||||||||||
| 182 | pop = new QMenu(q); | - | ||||||||||||||||||||||||
| 183 | extension->setMenu(pop); | - | ||||||||||||||||||||||||
| 184 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 185 | pop->clear(); | - | ||||||||||||||||||||||||
| 186 | pop->addActions(hiddenActions); | - | ||||||||||||||||||||||||
| 187 | - | |||||||||||||||||||||||||
| 188 | int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q); | - | ||||||||||||||||||||||||
| 189 | int x = q->isRightToLeft()
| 0 | ||||||||||||||||||||||||
| 190 | ? menuRect.left() - extension->sizeHint().width() + 1 | - | ||||||||||||||||||||||||
| 191 | : menuRect.right(); | - | ||||||||||||||||||||||||
| 192 | extension->setGeometry(x, vmargin, extension->sizeHint().width(), menuRect.height() - vmargin*2); | - | ||||||||||||||||||||||||
| 193 | extension->show(); | - | ||||||||||||||||||||||||
| 194 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 195 | extension->hide(); | - | ||||||||||||||||||||||||
| 196 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 197 | q->updateGeometry(); | - | ||||||||||||||||||||||||
| 198 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 199 | - | |||||||||||||||||||||||||
| 200 | QRect QMenuBarPrivate::actionRect(QAction *act) const | - | ||||||||||||||||||||||||
| 201 | { | - | ||||||||||||||||||||||||
| 202 | const int index = actions.indexOf(act); | - | ||||||||||||||||||||||||
| 203 | - | |||||||||||||||||||||||||
| 204 | - | |||||||||||||||||||||||||
| 205 | const_cast<QMenuBarPrivate*>(this)->updateGeometries(); | - | ||||||||||||||||||||||||
| 206 | - | |||||||||||||||||||||||||
| 207 | if (index < 0
| 0 | ||||||||||||||||||||||||
| 208 | return never executed: QRect();return QRect();never executed: return QRect(); | 0 | ||||||||||||||||||||||||
| 209 | - | |||||||||||||||||||||||||
| 210 | return never executed: actionRects.at(index);return actionRects.at(index);never executed: return actionRects.at(index); | 0 | ||||||||||||||||||||||||
| 211 | } | - | ||||||||||||||||||||||||
| 212 | - | |||||||||||||||||||||||||
| 213 | void QMenuBarPrivate::focusFirstAction() | - | ||||||||||||||||||||||||
| 214 | { | - | ||||||||||||||||||||||||
| 215 | if(!currentAction
| 0 | ||||||||||||||||||||||||
| 216 | updateGeometries(); | - | ||||||||||||||||||||||||
| 217 | int index = 0; | - | ||||||||||||||||||||||||
| 218 | while (index < actions.count()
never executed: index;++index;never executed: ++index; | 0 | ||||||||||||||||||||||||
| 219 | if (index < actions.count()
| 0 | ||||||||||||||||||||||||
| 220 | setCurrentAction(actions.at(index)); never executed: setCurrentAction(actions.at(index)); | 0 | ||||||||||||||||||||||||
| 221 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 222 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 223 | - | |||||||||||||||||||||||||
| 224 | void QMenuBarPrivate::setKeyboardMode(bool b) | - | ||||||||||||||||||||||||
| 225 | { | - | ||||||||||||||||||||||||
| 226 | QMenuBar * const q = q_func(); | - | ||||||||||||||||||||||||
| 227 | if (b
| 0 | ||||||||||||||||||||||||
| 228 | setCurrentAction(0); | - | ||||||||||||||||||||||||
| 229 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 230 | } | - | ||||||||||||||||||||||||
| 231 | keyboardState = b; | - | ||||||||||||||||||||||||
| 232 | if(b
| 0 | ||||||||||||||||||||||||
| 233 | QWidget *fw = QApplication::focusWidget(); | - | ||||||||||||||||||||||||
| 234 | if (fw != q
| 0 | ||||||||||||||||||||||||
| 235 | keyboardFocusWidget = fw; never executed: keyboardFocusWidget = fw; | 0 | ||||||||||||||||||||||||
| 236 | focusFirstAction(); | - | ||||||||||||||||||||||||
| 237 | q->setFocus(Qt::MenuBarFocusReason); | - | ||||||||||||||||||||||||
| 238 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 239 | if(!popupState
| 0 | ||||||||||||||||||||||||
| 240 | setCurrentAction(0); never executed: setCurrentAction(0); | 0 | ||||||||||||||||||||||||
| 241 | if(keyboardFocusWidget
| 0 | ||||||||||||||||||||||||
| 242 | if (QApplication::focusWidget() == q
| 0 | ||||||||||||||||||||||||
| 243 | keyboardFocusWidget->setFocus(Qt::MenuBarFocusReason); never executed: keyboardFocusWidget->setFocus(Qt::MenuBarFocusReason); | 0 | ||||||||||||||||||||||||
| 244 | keyboardFocusWidget = 0; | - | ||||||||||||||||||||||||
| 245 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 246 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 247 | q->update(); | - | ||||||||||||||||||||||||
| 248 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||
| 250 | void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst) | - | ||||||||||||||||||||||||
| 251 | { | - | ||||||||||||||||||||||||
| 252 | QMenuBar * const q = q_func(); | - | ||||||||||||||||||||||||
| 253 | if(!action
| 0 | ||||||||||||||||||||||||
| 254 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 255 | popupState = true; | - | ||||||||||||||||||||||||
| 256 | if (action->isEnabled()
| 0 | ||||||||||||||||||||||||
| 257 | closePopupMode = 0; | - | ||||||||||||||||||||||||
| 258 | activeMenu = action->menu(); | - | ||||||||||||||||||||||||
| 259 | activeMenu->d_func()->causedPopup.widget = q; | - | ||||||||||||||||||||||||
| 260 | activeMenu->d_func()->causedPopup.action = action; | - | ||||||||||||||||||||||||
| 261 | - | |||||||||||||||||||||||||
| 262 | QRect adjustedActionRect = actionRect(action); | - | ||||||||||||||||||||||||
| 263 | QPoint pos(q->mapToGlobal(QPoint(adjustedActionRect.left(), adjustedActionRect.bottom() + 1))); | - | ||||||||||||||||||||||||
| 264 | QSize popup_size = activeMenu->sizeHint(); | - | ||||||||||||||||||||||||
| 265 | - | |||||||||||||||||||||||||
| 266 | - | |||||||||||||||||||||||||
| 267 | QRect screenRect = QApplication::desktop()->screenGeometry(pos + QPoint(adjustedActionRect.width() / 2, 0)); | - | ||||||||||||||||||||||||
| 268 | pos = QPoint(qMax(pos.x(), screenRect.x()), qMax(pos.y(), screenRect.y())); | - | ||||||||||||||||||||||||
| 269 | - | |||||||||||||||||||||||||
| 270 | const bool fitUp = (q->mapToGlobal(adjustedActionRect.topLeft()).y() >= popup_size.height()); | - | ||||||||||||||||||||||||
| 271 | const bool fitDown = (pos.y() + popup_size.height() <= screenRect.bottom()); | - | ||||||||||||||||||||||||
| 272 | const bool rtl = q->isRightToLeft(); | - | ||||||||||||||||||||||||
| 273 | const int actionWidth = adjustedActionRect.width(); | - | ||||||||||||||||||||||||
| 274 | - | |||||||||||||||||||||||||
| 275 | if (!fitUp
| 0 | ||||||||||||||||||||||||
| 276 | bool shouldShiftToRight = !rtl; | - | ||||||||||||||||||||||||
| 277 | if (rtl
| 0 | ||||||||||||||||||||||||
| 278 | shouldShiftToRight = true; never executed: shouldShiftToRight = true; | 0 | ||||||||||||||||||||||||
| 279 | else if (actionWidth + popup_size.width() + pos.x() > screenRect.right()
| 0 | ||||||||||||||||||||||||
| 280 | shouldShiftToRight = false; never executed: shouldShiftToRight = false; | 0 | ||||||||||||||||||||||||
| 281 | - | |||||||||||||||||||||||||
| 282 | if (shouldShiftToRight
| 0 | ||||||||||||||||||||||||
| 283 | pos.rx() += actionWidth + (rtl
| 0 | ||||||||||||||||||||||||
| 284 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 285 | - | |||||||||||||||||||||||||
| 286 | if (!rtl
| 0 | ||||||||||||||||||||||||
| 287 | pos.rx() -= popup_size.width(); never executed: pos.rx() -= popup_size.width(); | 0 | ||||||||||||||||||||||||
| 288 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 289 | } else if (rtl
| 0 | ||||||||||||||||||||||||
| 290 | pos.rx() += actionWidth; | - | ||||||||||||||||||||||||
| 291 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 292 | - | |||||||||||||||||||||||||
| 293 | if(!defaultPopDown
| 0 | ||||||||||||||||||||||||
| 294 | pos.setY(qMax(screenRect.y(), q->mapToGlobal(QPoint(0, adjustedActionRect.top()-popup_size.height())).y())); never executed: pos.setY(qMax(screenRect.y(), q->mapToGlobal(QPoint(0, adjustedActionRect.top()-popup_size.height())).y())); | 0 | ||||||||||||||||||||||||
| 295 | activeMenu->popup(pos); | - | ||||||||||||||||||||||||
| 296 | if(activateFirst
| 0 | ||||||||||||||||||||||||
| 297 | activeMenu->d_func()->setFirstActionActive(); never executed: activeMenu->d_func()->setFirstActionActive(); | 0 | ||||||||||||||||||||||||
| 298 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 299 | q->update(actionRect(action)); | - | ||||||||||||||||||||||||
| 300 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 301 | - | |||||||||||||||||||||||||
| 302 | void QMenuBarPrivate::setCurrentAction(QAction *action, bool popup, bool activateFirst) | - | ||||||||||||||||||||||||
| 303 | { | - | ||||||||||||||||||||||||
| 304 | if(currentAction == action
| 0 | ||||||||||||||||||||||||
| 305 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 306 | - | |||||||||||||||||||||||||
| 307 | autoReleaseTimer.stop(); | - | ||||||||||||||||||||||||
| 308 | - | |||||||||||||||||||||||||
| 309 | doChildEffects = (popup
| 0 | ||||||||||||||||||||||||
| 310 | QMenuBar * const q = q_func(); | - | ||||||||||||||||||||||||
| 311 | QWidget *fw = 0; | - | ||||||||||||||||||||||||
| 312 | if(QMenu *menu = activeMenu
| 0 | ||||||||||||||||||||||||
| 313 | activeMenu = 0; | - | ||||||||||||||||||||||||
| 314 | if (popup
| 0 | ||||||||||||||||||||||||
| 315 | fw = q->window()->focusWidget(); | - | ||||||||||||||||||||||||
| 316 | q->setFocus(Qt::NoFocusReason); | - | ||||||||||||||||||||||||
| 317 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 318 | menu->hide(); | - | ||||||||||||||||||||||||
| 319 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 320 | - | |||||||||||||||||||||||||
| 321 | if(currentAction
| 0 | ||||||||||||||||||||||||
| 322 | q->update(actionRect(currentAction)); never executed: q->update(actionRect(currentAction)); | 0 | ||||||||||||||||||||||||
| 323 | - | |||||||||||||||||||||||||
| 324 | popupState = popup; | - | ||||||||||||||||||||||||
| 325 | - | |||||||||||||||||||||||||
| 326 | QAction *previousAction = currentAction; | - | ||||||||||||||||||||||||
| 327 | - | |||||||||||||||||||||||||
| 328 | currentAction = action; | - | ||||||||||||||||||||||||
| 329 | if (action
| 0 | ||||||||||||||||||||||||
| 330 | activateAction(action, QAction::Hover); | - | ||||||||||||||||||||||||
| 331 | if(popup
| 0 | ||||||||||||||||||||||||
| 332 | popupAction(action, activateFirst); never executed: popupAction(action, activateFirst); | 0 | ||||||||||||||||||||||||
| 333 | q->update(actionRect(action)); | - | ||||||||||||||||||||||||
| 334 | - | |||||||||||||||||||||||||
| 335 | } never executed: else if (previousActionend of block
| 0 | ||||||||||||||||||||||||
| 336 | QString empty; | - | ||||||||||||||||||||||||
| 337 | QStatusTipEvent tip(empty); | - | ||||||||||||||||||||||||
| 338 | QApplication::sendEvent(q, &tip); | - | ||||||||||||||||||||||||
| 339 | - | |||||||||||||||||||||||||
| 340 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 341 | if (fw
| 0 | ||||||||||||||||||||||||
| 342 | fw->setFocus(Qt::NoFocusReason); never executed: fw->setFocus(Qt::NoFocusReason); | 0 | ||||||||||||||||||||||||
| 343 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 344 | - | |||||||||||||||||||||||||
| 345 | void QMenuBarPrivate::calcActionRects(int max_width, int start) const | - | ||||||||||||||||||||||||
| 346 | { | - | ||||||||||||||||||||||||
| 347 | const QMenuBar * const q = q_func(); | - | ||||||||||||||||||||||||
| 348 | - | |||||||||||||||||||||||||
| 349 | if(!itemsDirty
| 0 | ||||||||||||||||||||||||
| 350 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||
| 352 | - | |||||||||||||||||||||||||
| 353 | actionRects.resize(actions.count()); | - | ||||||||||||||||||||||||
| 354 | actionRects.fill(QRect()); | - | ||||||||||||||||||||||||
| 355 | - | |||||||||||||||||||||||||
| 356 | const QStyle *style = q->style(); | - | ||||||||||||||||||||||||
| 357 | - | |||||||||||||||||||||||||
| 358 | const int itemSpacing = style->pixelMetric(QStyle::PM_MenuBarItemSpacing, 0, q); | - | ||||||||||||||||||||||||
| 359 | int max_item_height = 0, separator = -1, separator_start = 0, separator_len = 0; | - | ||||||||||||||||||||||||
| 360 | - | |||||||||||||||||||||||||
| 361 | - | |||||||||||||||||||||||||
| 362 | const QFontMetrics fm = q->fontMetrics(); | - | ||||||||||||||||||||||||
| 363 | const int hmargin = style->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q), | - | ||||||||||||||||||||||||
| 364 | vmargin = style->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q), | - | ||||||||||||||||||||||||
| 365 | icone = style->pixelMetric(QStyle::PM_SmallIconSize, 0, q); | - | ||||||||||||||||||||||||
| 366 | for(int i = 0; i < actions.count()
| 0 | ||||||||||||||||||||||||
| 367 | QAction *action = actions.at(i); | - | ||||||||||||||||||||||||
| 368 | if(!action->isVisible()
| 0 | ||||||||||||||||||||||||
| 369 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 370 | - | |||||||||||||||||||||||||
| 371 | QSize sz; | - | ||||||||||||||||||||||||
| 372 | - | |||||||||||||||||||||||||
| 373 | - | |||||||||||||||||||||||||
| 374 | if(action->isSeparator()
| 0 | ||||||||||||||||||||||||
| 375 | if (style->styleHint(QStyle::SH_DrawMenuBarSeparator, 0, q)
| 0 | ||||||||||||||||||||||||
| 376 | separator = i; never executed: separator = i; | 0 | ||||||||||||||||||||||||
| 377 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 378 | } else { | - | ||||||||||||||||||||||||
| 379 | const QString s = action->text(); | - | ||||||||||||||||||||||||
| 380 | QIcon is = action->icon(); | - | ||||||||||||||||||||||||
| 381 | - | |||||||||||||||||||||||||
| 382 | if (!is.isNull()
| 0 | ||||||||||||||||||||||||
| 383 | sz = sz.expandedTo(QSize(icone, icone)); never executed: sz = sz.expandedTo(QSize(icone, icone)); | 0 | ||||||||||||||||||||||||
| 384 | else if (!s.isEmpty()
| 0 | ||||||||||||||||||||||||
| 385 | sz = fm.size(Qt::TextShowMnemonic, s); never executed: sz = fm.size(Qt::TextShowMnemonic, s); | 0 | ||||||||||||||||||||||||
| 386 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 387 | - | |||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||
| 389 | QStyleOptionMenuItem opt; | - | ||||||||||||||||||||||||
| 390 | q->initStyleOption(&opt, action); | - | ||||||||||||||||||||||||
| 391 | sz = q->style()->sizeFromContents(QStyle::CT_MenuBarItem, &opt, sz, q); | - | ||||||||||||||||||||||||
| 392 | - | |||||||||||||||||||||||||
| 393 | if(!sz.isEmpty()
| 0 | ||||||||||||||||||||||||
| 394 | { | - | ||||||||||||||||||||||||
| 395 | int iWidth = sz.width() + itemSpacing; | - | ||||||||||||||||||||||||
| 396 | if(separator == -1
| 0 | ||||||||||||||||||||||||
| 397 | separator_start += iWidth; never executed: separator_start += iWidth; | 0 | ||||||||||||||||||||||||
| 398 | else | - | ||||||||||||||||||||||||
| 399 | separator_len += iWidth; never executed: separator_len += iWidth; | 0 | ||||||||||||||||||||||||
| 400 | } | - | ||||||||||||||||||||||||
| 401 | - | |||||||||||||||||||||||||
| 402 | max_item_height = qMax(max_item_height, sz.height()); | - | ||||||||||||||||||||||||
| 403 | - | |||||||||||||||||||||||||
| 404 | actionRects[i] = QRect(0, 0, sz.width(), sz.height()); | - | ||||||||||||||||||||||||
| 405 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 406 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 407 | - | |||||||||||||||||||||||||
| 408 | - | |||||||||||||||||||||||||
| 409 | const int fw = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q); | - | ||||||||||||||||||||||||
| 410 | int x = fw + ((
| 0 | ||||||||||||||||||||||||
| 411 | int y = fw + vmargin; | - | ||||||||||||||||||||||||
| 412 | for(int i = 0; i < actions.count()
| 0 | ||||||||||||||||||||||||
| 413 | QRect &rect = actionRects[i]; | - | ||||||||||||||||||||||||
| 414 | if (rect.isNull()
| 0 | ||||||||||||||||||||||||
| 415 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 416 | - | |||||||||||||||||||||||||
| 417 | - | |||||||||||||||||||||||||
| 418 | rect.setHeight(max_item_height); | - | ||||||||||||||||||||||||
| 419 | - | |||||||||||||||||||||||||
| 420 | - | |||||||||||||||||||||||||
| 421 | if(separator != -1
| 0 | ||||||||||||||||||||||||
| 422 | int left = (max_width - separator_len - hmargin - itemSpacing) + (x - separator_start - hmargin); | - | ||||||||||||||||||||||||
| 423 | if(left < separator_start
| 0 | ||||||||||||||||||||||||
| 424 | separator_start = x = hmargin; | - | ||||||||||||||||||||||||
| 425 | y += max_item_height; | - | ||||||||||||||||||||||||
| 426 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 427 | rect.moveLeft(left); | - | ||||||||||||||||||||||||
| 428 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 429 | rect.moveLeft(x); | - | ||||||||||||||||||||||||
| 430 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 431 | rect.moveTop(y); | - | ||||||||||||||||||||||||
| 432 | - | |||||||||||||||||||||||||
| 433 | - | |||||||||||||||||||||||||
| 434 | x += rect.width() + itemSpacing; | - | ||||||||||||||||||||||||
| 435 | - | |||||||||||||||||||||||||
| 436 | - | |||||||||||||||||||||||||
| 437 | rect = QStyle::visualRect(q->layoutDirection(), q->rect(), rect); | - | ||||||||||||||||||||||||
| 438 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 439 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 440 | - | |||||||||||||||||||||||||
| 441 | void QMenuBarPrivate::activateAction(QAction *action, QAction::ActionEvent action_e) | - | ||||||||||||||||||||||||
| 442 | { | - | ||||||||||||||||||||||||
| 443 | QMenuBar * const q = q_func(); | - | ||||||||||||||||||||||||
| 444 | if (!action
| 0 | ||||||||||||||||||||||||
| 445 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 446 | action->activate(action_e); | - | ||||||||||||||||||||||||
| 447 | if (action_e == QAction::Hover
| 0 | ||||||||||||||||||||||||
| 448 | action->showStatusText(q); never executed: action->showStatusText(q); | 0 | ||||||||||||||||||||||||
| 449 | - | |||||||||||||||||||||||||
| 450 | - | |||||||||||||||||||||||||
| 451 | - | |||||||||||||||||||||||||
| 452 | - | |||||||||||||||||||||||||
| 453 | - | |||||||||||||||||||||||||
| 454 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 455 | - | |||||||||||||||||||||||||
| 456 | - | |||||||||||||||||||||||||
| 457 | void QMenuBarPrivate::_q_actionTriggered() | - | ||||||||||||||||||||||||
| 458 | { | - | ||||||||||||||||||||||||
| 459 | QMenuBar * const q = q_func(); | - | ||||||||||||||||||||||||
| 460 | if (QAction *action = qobject_cast<QAction *>(q->sender())
| 0 | ||||||||||||||||||||||||
| 461 | q->triggered(action); | - | ||||||||||||||||||||||||
| 462 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 463 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 464 | - | |||||||||||||||||||||||||
| 465 | void QMenuBarPrivate::_q_actionHovered() | - | ||||||||||||||||||||||||
| 466 | { | - | ||||||||||||||||||||||||
| 467 | QMenuBar * const q = q_func(); | - | ||||||||||||||||||||||||
| 468 | if (QAction *action = qobject_cast<QAction *>(q->sender())
| 0 | ||||||||||||||||||||||||
| 469 | q->hovered(action); | - | ||||||||||||||||||||||||
| 470 | - | |||||||||||||||||||||||||
| 471 | if (QAccessible::isActive()
| 0 | ||||||||||||||||||||||||
| 472 | int actionIndex = actions.indexOf(action); | - | ||||||||||||||||||||||||
| 473 | QAccessibleEvent focusEvent(q, QAccessible::Focus); | - | ||||||||||||||||||||||||
| 474 | focusEvent.setChild(actionIndex); | - | ||||||||||||||||||||||||
| 475 | QAccessible::updateAccessibility(&focusEvent); | - | ||||||||||||||||||||||||
| 476 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 477 | - | |||||||||||||||||||||||||
| 478 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 479 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 480 | void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const | - | ||||||||||||||||||||||||
| 481 | { | - | ||||||||||||||||||||||||
| 482 | if (!option
| 0 | ||||||||||||||||||||||||
| 483 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 484 | const QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 485 | option->palette = palette(); | - | ||||||||||||||||||||||||
| 486 | option->state = QStyle::State_None; | - | ||||||||||||||||||||||||
| 487 | if (isEnabled()
| 0 | ||||||||||||||||||||||||
| 488 | option->state |= QStyle::State_Enabled; never executed: option->state |= QStyle::State_Enabled; | 0 | ||||||||||||||||||||||||
| 489 | else | - | ||||||||||||||||||||||||
| 490 | option->palette.setCurrentColorGroup(QPalette::Disabled); never executed: option->palette.setCurrentColorGroup(QPalette::Disabled); | 0 | ||||||||||||||||||||||||
| 491 | option->fontMetrics = fontMetrics(); | - | ||||||||||||||||||||||||
| 492 | if (d->currentAction
| 0 | ||||||||||||||||||||||||
| 493 | option->state |= QStyle::State_Selected; | - | ||||||||||||||||||||||||
| 494 | if (d->popupState
| 0 | ||||||||||||||||||||||||
| 495 | option->state |= QStyle::State_Sunken; never executed: option->state |= QStyle::State_Sunken; | 0 | ||||||||||||||||||||||||
| 496 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 497 | if (hasFocus()
| 0 | ||||||||||||||||||||||||
| 498 | option->state |= QStyle::State_HasFocus; never executed: option->state |= QStyle::State_HasFocus; | 0 | ||||||||||||||||||||||||
| 499 | option->menuRect = rect(); | - | ||||||||||||||||||||||||
| 500 | option->menuItemType = QStyleOptionMenuItem::Normal; | - | ||||||||||||||||||||||||
| 501 | option->checkType = QStyleOptionMenuItem::NotCheckable; | - | ||||||||||||||||||||||||
| 502 | option->text = action->text(); | - | ||||||||||||||||||||||||
| 503 | option->icon = action->icon(); | - | ||||||||||||||||||||||||
| 504 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 505 | void QMenuBarPrivate::init() | - | ||||||||||||||||||||||||
| 506 | { | - | ||||||||||||||||||||||||
| 507 | QMenuBar * const q = q_func(); | - | ||||||||||||||||||||||||
| 508 | q->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); | - | ||||||||||||||||||||||||
| 509 | q->setAttribute(Qt::WA_CustomWhatsThis); | - | ||||||||||||||||||||||||
| 510 | - | |||||||||||||||||||||||||
| 511 | if (!QApplication::instance()->testAttribute(Qt::AA_DontUseNativeMenuBar)
| 0 | ||||||||||||||||||||||||
| 512 | platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar(); never executed: platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar(); | 0 | ||||||||||||||||||||||||
| 513 | - | |||||||||||||||||||||||||
| 514 | if (platformMenuBar
| 0 | ||||||||||||||||||||||||
| 515 | q->hide(); never executed: q->hide(); | 0 | ||||||||||||||||||||||||
| 516 | q->setBackgroundRole(QPalette::Button); | - | ||||||||||||||||||||||||
| 517 | handleReparent(); | - | ||||||||||||||||||||||||
| 518 | q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, q)); | - | ||||||||||||||||||||||||
| 519 | - | |||||||||||||||||||||||||
| 520 | extension = new QMenuBarExtension(q); | - | ||||||||||||||||||||||||
| 521 | extension->setFocusPolicy(Qt::NoFocus); | - | ||||||||||||||||||||||||
| 522 | extension->hide(); | - | ||||||||||||||||||||||||
| 523 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 524 | - | |||||||||||||||||||||||||
| 525 | - | |||||||||||||||||||||||||
| 526 | QAction *QMenuBarPrivate::getNextAction(const int _start, const int increment) const | - | ||||||||||||||||||||||||
| 527 | { | - | ||||||||||||||||||||||||
| 528 | const QMenuBar * const q = q_func(); | - | ||||||||||||||||||||||||
| 529 | const_cast<QMenuBarPrivate*>(this)->updateGeometries(); | - | ||||||||||||||||||||||||
| 530 | bool allowActiveAndDisabled = q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q); | - | ||||||||||||||||||||||||
| 531 | const int start = (_start == -1
| 0 | ||||||||||||||||||||||||
| 532 | const int end = increment == -1
| 0 | ||||||||||||||||||||||||
| 533 | - | |||||||||||||||||||||||||
| 534 | for (int i = start; i != end
| 0 | ||||||||||||||||||||||||
| 535 | i += increment; | - | ||||||||||||||||||||||||
| 536 | QAction *current = actions.at(i); | - | ||||||||||||||||||||||||
| 537 | if (!actionRects.at(i).isNull()
| 0 | ||||||||||||||||||||||||
| 538 | return never executed: current;return current;never executed: return current; | 0 | ||||||||||||||||||||||||
| 539 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 540 | - | |||||||||||||||||||||||||
| 541 | if (_start != -1
| 0 | ||||||||||||||||||||||||
| 542 | return never executed: getNextAction(-1, increment);return getNextAction(-1, increment);never executed: return getNextAction(-1, increment); | 0 | ||||||||||||||||||||||||
| 543 | - | |||||||||||||||||||||||||
| 544 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 545 | } | - | ||||||||||||||||||||||||
| 546 | - | |||||||||||||||||||||||||
| 547 | - | |||||||||||||||||||||||||
| 548 | - | |||||||||||||||||||||||||
| 549 | - | |||||||||||||||||||||||||
| 550 | QMenuBar::QMenuBar(QWidget *parent) : QWidget(*new QMenuBarPrivate, parent, 0) | - | ||||||||||||||||||||||||
| 551 | { | - | ||||||||||||||||||||||||
| 552 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 553 | d->init(); | - | ||||||||||||||||||||||||
| 554 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 555 | - | |||||||||||||||||||||||||
| 556 | - | |||||||||||||||||||||||||
| 557 | - | |||||||||||||||||||||||||
| 558 | - | |||||||||||||||||||||||||
| 559 | - | |||||||||||||||||||||||||
| 560 | QMenuBar::~QMenuBar() | - | ||||||||||||||||||||||||
| 561 | { | - | ||||||||||||||||||||||||
| 562 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 563 | delete d->platformMenuBar; | - | ||||||||||||||||||||||||
| 564 | d->platformMenuBar = 0; | - | ||||||||||||||||||||||||
| 565 | - | |||||||||||||||||||||||||
| 566 | - | |||||||||||||||||||||||||
| 567 | - | |||||||||||||||||||||||||
| 568 | - | |||||||||||||||||||||||||
| 569 | - | |||||||||||||||||||||||||
| 570 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 571 | QAction *QMenuBar::addAction(const QString &text) | - | ||||||||||||||||||||||||
| 572 | { | - | ||||||||||||||||||||||||
| 573 | QAction *ret = new QAction(text, this); | - | ||||||||||||||||||||||||
| 574 | addAction(ret); | - | ||||||||||||||||||||||||
| 575 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||
| 576 | } | - | ||||||||||||||||||||||||
| 577 | QAction *QMenuBar::addAction(const QString &text, const QObject *receiver, const char* member) | - | ||||||||||||||||||||||||
| 578 | { | - | ||||||||||||||||||||||||
| 579 | QAction *ret = new QAction(text, this); | - | ||||||||||||||||||||||||
| 580 | QObject::connect(ret, qFlagLocation("2""triggered(bool)" "\0" __FILE__ ":" "793"), receiver, member); | - | ||||||||||||||||||||||||
| 581 | addAction(ret); | - | ||||||||||||||||||||||||
| 582 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||
| 583 | } | - | ||||||||||||||||||||||||
| 584 | - | |||||||||||||||||||||||||
| 585 | - | |||||||||||||||||||||||||
| 586 | - | |||||||||||||||||||||||||
| 587 | - | |||||||||||||||||||||||||
| 588 | - | |||||||||||||||||||||||||
| 589 | - | |||||||||||||||||||||||||
| 590 | - | |||||||||||||||||||||||||
| 591 | QMenu *QMenuBar::addMenu(const QString &title) | - | ||||||||||||||||||||||||
| 592 | { | - | ||||||||||||||||||||||||
| 593 | QMenu *menu = new QMenu(title, this); | - | ||||||||||||||||||||||||
| 594 | addAction(menu->menuAction()); | - | ||||||||||||||||||||||||
| 595 | return never executed: menu;return menu;never executed: return menu; | 0 | ||||||||||||||||||||||||
| 596 | } | - | ||||||||||||||||||||||||
| 597 | - | |||||||||||||||||||||||||
| 598 | - | |||||||||||||||||||||||||
| 599 | - | |||||||||||||||||||||||||
| 600 | - | |||||||||||||||||||||||||
| 601 | - | |||||||||||||||||||||||||
| 602 | - | |||||||||||||||||||||||||
| 603 | - | |||||||||||||||||||||||||
| 604 | QMenu *QMenuBar::addMenu(const QIcon &icon, const QString &title) | - | ||||||||||||||||||||||||
| 605 | { | - | ||||||||||||||||||||||||
| 606 | QMenu *menu = new QMenu(title, this); | - | ||||||||||||||||||||||||
| 607 | menu->setIcon(icon); | - | ||||||||||||||||||||||||
| 608 | addAction(menu->menuAction()); | - | ||||||||||||||||||||||||
| 609 | return never executed: menu;return menu;never executed: return menu; | 0 | ||||||||||||||||||||||||
| 610 | } | - | ||||||||||||||||||||||||
| 611 | QAction *QMenuBar::addMenu(QMenu *menu) | - | ||||||||||||||||||||||||
| 612 | { | - | ||||||||||||||||||||||||
| 613 | QAction *action = menu->menuAction(); | - | ||||||||||||||||||||||||
| 614 | addAction(action); | - | ||||||||||||||||||||||||
| 615 | return never executed: action;return action;never executed: return action; | 0 | ||||||||||||||||||||||||
| 616 | } | - | ||||||||||||||||||||||||
| 617 | - | |||||||||||||||||||||||||
| 618 | - | |||||||||||||||||||||||||
| 619 | - | |||||||||||||||||||||||||
| 620 | - | |||||||||||||||||||||||||
| 621 | QAction *QMenuBar::addSeparator() | - | ||||||||||||||||||||||||
| 622 | { | - | ||||||||||||||||||||||||
| 623 | QAction *ret = new QAction(this); | - | ||||||||||||||||||||||||
| 624 | ret->setSeparator(true); | - | ||||||||||||||||||||||||
| 625 | addAction(ret); | - | ||||||||||||||||||||||||
| 626 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||
| 627 | } | - | ||||||||||||||||||||||||
| 628 | QAction *QMenuBar::insertSeparator(QAction *before) | - | ||||||||||||||||||||||||
| 629 | { | - | ||||||||||||||||||||||||
| 630 | QAction *action = new QAction(this); | - | ||||||||||||||||||||||||
| 631 | action->setSeparator(true); | - | ||||||||||||||||||||||||
| 632 | insertAction(before, action); | - | ||||||||||||||||||||||||
| 633 | return never executed: action;return action;never executed: return action; | 0 | ||||||||||||||||||||||||
| 634 | } | - | ||||||||||||||||||||||||
| 635 | - | |||||||||||||||||||||||||
| 636 | - | |||||||||||||||||||||||||
| 637 | - | |||||||||||||||||||||||||
| 638 | - | |||||||||||||||||||||||||
| 639 | - | |||||||||||||||||||||||||
| 640 | - | |||||||||||||||||||||||||
| 641 | - | |||||||||||||||||||||||||
| 642 | QAction *QMenuBar::insertMenu(QAction *before, QMenu *menu) | - | ||||||||||||||||||||||||
| 643 | { | - | ||||||||||||||||||||||||
| 644 | QAction *action = menu->menuAction(); | - | ||||||||||||||||||||||||
| 645 | insertAction(before, action); | - | ||||||||||||||||||||||||
| 646 | return never executed: action;return action;never executed: return action; | 0 | ||||||||||||||||||||||||
| 647 | } | - | ||||||||||||||||||||||||
| 648 | - | |||||||||||||||||||||||||
| 649 | - | |||||||||||||||||||||||||
| 650 | - | |||||||||||||||||||||||||
| 651 | - | |||||||||||||||||||||||||
| 652 | - | |||||||||||||||||||||||||
| 653 | QAction *QMenuBar::activeAction() const | - | ||||||||||||||||||||||||
| 654 | { | - | ||||||||||||||||||||||||
| 655 | const QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 656 | return never executed: d->currentAction;return d->currentAction;never executed: return d->currentAction; | 0 | ||||||||||||||||||||||||
| 657 | } | - | ||||||||||||||||||||||||
| 658 | - | |||||||||||||||||||||||||
| 659 | - | |||||||||||||||||||||||||
| 660 | - | |||||||||||||||||||||||||
| 661 | - | |||||||||||||||||||||||||
| 662 | - | |||||||||||||||||||||||||
| 663 | - | |||||||||||||||||||||||||
| 664 | void QMenuBar::setActiveAction(QAction *act) | - | ||||||||||||||||||||||||
| 665 | { | - | ||||||||||||||||||||||||
| 666 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 667 | d->setCurrentAction(act, true, false); | - | ||||||||||||||||||||||||
| 668 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 669 | void QMenuBar::clear() | - | ||||||||||||||||||||||||
| 670 | { | - | ||||||||||||||||||||||||
| 671 | QList<QAction*> acts = actions(); | - | ||||||||||||||||||||||||
| 672 | for(int i = 0; i < acts.size()
| 0 | ||||||||||||||||||||||||
| 673 | removeAction(acts[i]); never executed: removeAction(acts[i]); | 0 | ||||||||||||||||||||||||
| 674 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 675 | void QMenuBar::setDefaultUp(bool b) | - | ||||||||||||||||||||||||
| 676 | { | - | ||||||||||||||||||||||||
| 677 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 678 | d->defaultPopDown = !b; | - | ||||||||||||||||||||||||
| 679 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 680 | - | |||||||||||||||||||||||||
| 681 | bool QMenuBar::isDefaultUp() const | - | ||||||||||||||||||||||||
| 682 | { | - | ||||||||||||||||||||||||
| 683 | const QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 684 | return never executed: !d->defaultPopDown;return !d->defaultPopDown;never executed: return !d->defaultPopDown; | 0 | ||||||||||||||||||||||||
| 685 | } | - | ||||||||||||||||||||||||
| 686 | - | |||||||||||||||||||||||||
| 687 | - | |||||||||||||||||||||||||
| 688 | - | |||||||||||||||||||||||||
| 689 | - | |||||||||||||||||||||||||
| 690 | void QMenuBar::resizeEvent(QResizeEvent *) | - | ||||||||||||||||||||||||
| 691 | { | - | ||||||||||||||||||||||||
| 692 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 693 | d->itemsDirty = true; | - | ||||||||||||||||||||||||
| 694 | d->updateGeometries(); | - | ||||||||||||||||||||||||
| 695 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 696 | - | |||||||||||||||||||||||||
| 697 | - | |||||||||||||||||||||||||
| 698 | - | |||||||||||||||||||||||||
| 699 | - | |||||||||||||||||||||||||
| 700 | void QMenuBar::paintEvent(QPaintEvent *e) | - | ||||||||||||||||||||||||
| 701 | { | - | ||||||||||||||||||||||||
| 702 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 703 | QPainter p(this); | - | ||||||||||||||||||||||||
| 704 | QRegion emptyArea(rect()); | - | ||||||||||||||||||||||||
| 705 | - | |||||||||||||||||||||||||
| 706 | - | |||||||||||||||||||||||||
| 707 | for (int i = 0; i < d->actions.count()
| 0 | ||||||||||||||||||||||||
| 708 | QAction *action = d->actions.at(i); | - | ||||||||||||||||||||||||
| 709 | QRect adjustedActionRect = d->actionRect(action); | - | ||||||||||||||||||||||||
| 710 | if (adjustedActionRect.isEmpty()
| 0 | ||||||||||||||||||||||||
| 711 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 712 | if(!e->rect().intersects(adjustedActionRect)
| 0 | ||||||||||||||||||||||||
| 713 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 714 | - | |||||||||||||||||||||||||
| 715 | emptyArea -= adjustedActionRect; | - | ||||||||||||||||||||||||
| 716 | QStyleOptionMenuItem opt; | - | ||||||||||||||||||||||||
| 717 | initStyleOption(&opt, action); | - | ||||||||||||||||||||||||
| 718 | opt.rect = adjustedActionRect; | - | ||||||||||||||||||||||||
| 719 | p.setClipRect(adjustedActionRect); | - | ||||||||||||||||||||||||
| 720 | style()->drawControl(QStyle::CE_MenuBarItem, &opt, &p, this); | - | ||||||||||||||||||||||||
| 721 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 722 | - | |||||||||||||||||||||||||
| 723 | if(int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this)
| 0 | ||||||||||||||||||||||||
| 724 | QRegion borderReg; | - | ||||||||||||||||||||||||
| 725 | borderReg += QRect(0, 0, fw, height()); | - | ||||||||||||||||||||||||
| 726 | borderReg += QRect(width()-fw, 0, fw, height()); | - | ||||||||||||||||||||||||
| 727 | borderReg += QRect(0, 0, width(), fw); | - | ||||||||||||||||||||||||
| 728 | borderReg += QRect(0, height()-fw, width(), fw); | - | ||||||||||||||||||||||||
| 729 | p.setClipRegion(borderReg); | - | ||||||||||||||||||||||||
| 730 | emptyArea -= borderReg; | - | ||||||||||||||||||||||||
| 731 | QStyleOptionFrame frame; | - | ||||||||||||||||||||||||
| 732 | frame.rect = rect(); | - | ||||||||||||||||||||||||
| 733 | frame.palette = palette(); | - | ||||||||||||||||||||||||
| 734 | frame.state = QStyle::State_None; | - | ||||||||||||||||||||||||
| 735 | frame.lineWidth = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth); | - | ||||||||||||||||||||||||
| 736 | frame.midLineWidth = 0; | - | ||||||||||||||||||||||||
| 737 | style()->drawPrimitive(QStyle::PE_PanelMenuBar, &frame, &p, this); | - | ||||||||||||||||||||||||
| 738 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 739 | p.setClipRegion(emptyArea); | - | ||||||||||||||||||||||||
| 740 | QStyleOptionMenuItem menuOpt; | - | ||||||||||||||||||||||||
| 741 | menuOpt.palette = palette(); | - | ||||||||||||||||||||||||
| 742 | menuOpt.state = QStyle::State_None; | - | ||||||||||||||||||||||||
| 743 | menuOpt.menuItemType = QStyleOptionMenuItem::EmptyArea; | - | ||||||||||||||||||||||||
| 744 | menuOpt.checkType = QStyleOptionMenuItem::NotCheckable; | - | ||||||||||||||||||||||||
| 745 | menuOpt.rect = rect(); | - | ||||||||||||||||||||||||
| 746 | menuOpt.menuRect = rect(); | - | ||||||||||||||||||||||||
| 747 | style()->drawControl(QStyle::CE_MenuBarEmptyArea, &menuOpt, &p, this); | - | ||||||||||||||||||||||||
| 748 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 749 | - | |||||||||||||||||||||||||
| 750 | - | |||||||||||||||||||||||||
| 751 | - | |||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||
| 753 | void QMenuBar::setVisible(bool visible) | - | ||||||||||||||||||||||||
| 754 | { | - | ||||||||||||||||||||||||
| 755 | if (isNativeMenuBar()
| 0 | ||||||||||||||||||||||||
| 756 | if (!visible
| 0 | ||||||||||||||||||||||||
| 757 | QWidget::setVisible(false); never executed: QWidget::setVisible(false); | 0 | ||||||||||||||||||||||||
| 758 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 759 | } | - | ||||||||||||||||||||||||
| 760 | QWidget::setVisible(visible); | - | ||||||||||||||||||||||||
| 761 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 762 | - | |||||||||||||||||||||||||
| 763 | - | |||||||||||||||||||||||||
| 764 | - | |||||||||||||||||||||||||
| 765 | - | |||||||||||||||||||||||||
| 766 | void QMenuBar::mousePressEvent(QMouseEvent *e) | - | ||||||||||||||||||||||||
| 767 | { | - | ||||||||||||||||||||||||
| 768 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 769 | if(e->button() != Qt::LeftButton
| 0 | ||||||||||||||||||||||||
| 770 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 771 | - | |||||||||||||||||||||||||
| 772 | d->mouseDown = true; | - | ||||||||||||||||||||||||
| 773 | - | |||||||||||||||||||||||||
| 774 | QAction *action = d->actionAt(e->pos()); | - | ||||||||||||||||||||||||
| 775 | if (!action
| 0 | ||||||||||||||||||||||||
| 776 | d->setCurrentAction(0); | - | ||||||||||||||||||||||||
| 777 | - | |||||||||||||||||||||||||
| 778 | if (QWhatsThis::inWhatsThisMode()
| 0 | ||||||||||||||||||||||||
| 779 | QWhatsThis::showText(e->globalPos(), d->whatsThis, this); never executed: QWhatsThis::showText(e->globalPos(), d->whatsThis, this); | 0 | ||||||||||||||||||||||||
| 780 | - | |||||||||||||||||||||||||
| 781 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 782 | } | - | ||||||||||||||||||||||||
| 783 | - | |||||||||||||||||||||||||
| 784 | if(d->currentAction == action
| 0 | ||||||||||||||||||||||||
| 785 | if(QMenu *menu = d->activeMenu
| 0 | ||||||||||||||||||||||||
| 786 | d->activeMenu = 0; | - | ||||||||||||||||||||||||
| 787 | menu->setAttribute(Qt::WA_NoMouseReplay); | - | ||||||||||||||||||||||||
| 788 | menu->hide(); | - | ||||||||||||||||||||||||
| 789 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 790 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 791 | d->setCurrentAction(action, true); | - | ||||||||||||||||||||||||
| 792 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 793 | } | - | ||||||||||||||||||||||||
| 794 | - | |||||||||||||||||||||||||
| 795 | - | |||||||||||||||||||||||||
| 796 | - | |||||||||||||||||||||||||
| 797 | - | |||||||||||||||||||||||||
| 798 | void QMenuBar::mouseReleaseEvent(QMouseEvent *e) | - | ||||||||||||||||||||||||
| 799 | { | - | ||||||||||||||||||||||||
| 800 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 801 | if(e->button() != Qt::LeftButton
| 0 | ||||||||||||||||||||||||
| 802 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 803 | - | |||||||||||||||||||||||||
| 804 | d->mouseDown = false; | - | ||||||||||||||||||||||||
| 805 | QAction *action = d->actionAt(e->pos()); | - | ||||||||||||||||||||||||
| 806 | if((d->closePopupMode
| 0 | ||||||||||||||||||||||||
| 807 | - | |||||||||||||||||||||||||
| 808 | - | |||||||||||||||||||||||||
| 809 | d->setCurrentAction(action, false); | - | ||||||||||||||||||||||||
| 810 | if(action
| 0 | ||||||||||||||||||||||||
| 811 | d->activateAction(action, QAction::Trigger); never executed: d->activateAction(action, QAction::Trigger); | 0 | ||||||||||||||||||||||||
| 812 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 813 | d->closePopupMode = 0; | - | ||||||||||||||||||||||||
| 814 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 815 | - | |||||||||||||||||||||||||
| 816 | - | |||||||||||||||||||||||||
| 817 | - | |||||||||||||||||||||||||
| 818 | - | |||||||||||||||||||||||||
| 819 | void QMenuBar::keyPressEvent(QKeyEvent *e) | - | ||||||||||||||||||||||||
| 820 | { | - | ||||||||||||||||||||||||
| 821 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 822 | d->updateGeometries(); | - | ||||||||||||||||||||||||
| 823 | int key = e->key(); | - | ||||||||||||||||||||||||
| 824 | if(isRightToLeft()
| 0 | ||||||||||||||||||||||||
| 825 | if(key == Qt::Key_Left
| 0 | ||||||||||||||||||||||||
| 826 | key = Qt::Key_Right; never executed: key = Qt::Key_Right; | 0 | ||||||||||||||||||||||||
| 827 | else if(key == Qt::Key_Right
| 0 | ||||||||||||||||||||||||
| 828 | key = Qt::Key_Left; never executed: key = Qt::Key_Left; | 0 | ||||||||||||||||||||||||
| 829 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 830 | if(key == Qt::Key_Tab
| 0 | ||||||||||||||||||||||||
| 831 | key = Qt::Key_Right; never executed: key = Qt::Key_Right; | 0 | ||||||||||||||||||||||||
| 832 | else if(key == Qt::Key_Backtab
| 0 | ||||||||||||||||||||||||
| 833 | key = Qt::Key_Left; never executed: key = Qt::Key_Left; | 0 | ||||||||||||||||||||||||
| 834 | - | |||||||||||||||||||||||||
| 835 | bool key_consumed = false; | - | ||||||||||||||||||||||||
| 836 | switch(key) { | - | ||||||||||||||||||||||||
| 837 | case never executed: Qt::Key_Up:case Qt::Key_Up:never executed: case Qt::Key_Up: | 0 | ||||||||||||||||||||||||
| 838 | case never executed: Qt::Key_Down:case Qt::Key_Down:never executed: case Qt::Key_Down: | 0 | ||||||||||||||||||||||||
| 839 | case never executed: Qt::Key_Enter:case Qt::Key_Enter:never executed: case Qt::Key_Enter: | 0 | ||||||||||||||||||||||||
| 840 | case never executed: Qt::Key_Space:case Qt::Key_Space:never executed: case Qt::Key_Space: | 0 | ||||||||||||||||||||||||
| 841 | case never executed: Qt::Key_Return:case Qt::Key_Return:never executed: {case Qt::Key_Return: | 0 | ||||||||||||||||||||||||
| 842 | if(!style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this)
| 0 | ||||||||||||||||||||||||
| 843 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 844 | if(d->currentAction->menu()
| 0 | ||||||||||||||||||||||||
| 845 | d->popupAction(d->currentAction, true); | - | ||||||||||||||||||||||||
| 846 | } never executed: else if(key == Qt::Key_Enterend of block
| 0 | ||||||||||||||||||||||||
| 847 | d->activateAction(d->currentAction, QAction::Trigger); | - | ||||||||||||||||||||||||
| 848 | d->setCurrentAction(d->currentAction, false); | - | ||||||||||||||||||||||||
| 849 | d->setKeyboardMode(false); | - | ||||||||||||||||||||||||
| 850 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 851 | key_consumed = true; | - | ||||||||||||||||||||||||
| 852 | break; never executed: }break; | 0 | ||||||||||||||||||||||||
| 853 | - | |||||||||||||||||||||||||
| 854 | case never executed: Qt::Key_Right:case Qt::Key_Right:never executed: case Qt::Key_Right: | 0 | ||||||||||||||||||||||||
| 855 | case never executed: Qt::Key_Left:case Qt::Key_Left:never executed: {case Qt::Key_Left: | 0 | ||||||||||||||||||||||||
| 856 | if(d->currentAction
| 0 | ||||||||||||||||||||||||
| 857 | int index = d->actions.indexOf(d->currentAction); | - | ||||||||||||||||||||||||
| 858 | if (QAction *nextAction = d->getNextAction(index, key == Qt::Key_Left ? -1 : +1)
| 0 | ||||||||||||||||||||||||
| 859 | d->setCurrentAction(nextAction, d->popupState, true); | - | ||||||||||||||||||||||||
| 860 | key_consumed = true; | - | ||||||||||||||||||||||||
| 861 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 862 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 863 | break; never executed: }break; | 0 | ||||||||||||||||||||||||
| 864 | - | |||||||||||||||||||||||||
| 865 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 866 | key_consumed = false; | - | ||||||||||||||||||||||||
| 867 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 868 | - | |||||||||||||||||||||||||
| 869 | if (!key_consumed
| 0 | ||||||||||||||||||||||||
| 870 | d->setCurrentAction(0); | - | ||||||||||||||||||||||||
| 871 | d->setKeyboardMode(false); | - | ||||||||||||||||||||||||
| 872 | key_consumed = true; | - | ||||||||||||||||||||||||
| 873 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 874 | - | |||||||||||||||||||||||||
| 875 | if(!key_consumed
| 0 | ||||||||||||||||||||||||
| 876 | (!e->modifiers()
| 0 | ||||||||||||||||||||||||
| 877 | (
| 0 | ||||||||||||||||||||||||
| 878 | int clashCount = 0; | - | ||||||||||||||||||||||||
| 879 | QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0; | - | ||||||||||||||||||||||||
| 880 | { | - | ||||||||||||||||||||||||
| 881 | QChar c = e->text()[0].toUpper(); | - | ||||||||||||||||||||||||
| 882 | for(int i = 0; i < d->actions.size()
| 0 | ||||||||||||||||||||||||
| 883 | if (d->actionRects.at(i).isNull()
| 0 | ||||||||||||||||||||||||
| 884 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 885 | QAction *act = d->actions.at(i); | - | ||||||||||||||||||||||||
| 886 | QString s = act->text(); | - | ||||||||||||||||||||||||
| 887 | if(!s.isEmpty()
| 0 | ||||||||||||||||||||||||
| 888 | int ampersand = s.indexOf(QLatin1Char('&')); | - | ||||||||||||||||||||||||
| 889 | if(ampersand >= 0
| 0 | ||||||||||||||||||||||||
| 890 | if(s[ampersand+1].toUpper() == c
| 0 | ||||||||||||||||||||||||
| 891 | clashCount++; | - | ||||||||||||||||||||||||
| 892 | if(!first
| 0 | ||||||||||||||||||||||||
| 893 | first = act; never executed: first = act; | 0 | ||||||||||||||||||||||||
| 894 | if(act == d->currentAction
| 0 | ||||||||||||||||||||||||
| 895 | currentSelected = act; never executed: currentSelected = act; | 0 | ||||||||||||||||||||||||
| 896 | else if (!firstAfterCurrent
| 0 | ||||||||||||||||||||||||
| 897 | firstAfterCurrent = act; never executed: firstAfterCurrent = act; | 0 | ||||||||||||||||||||||||
| 898 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 899 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 900 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 901 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 902 | } | - | ||||||||||||||||||||||||
| 903 | QAction *next_action = 0; | - | ||||||||||||||||||||||||
| 904 | if(clashCount >= 1
| 0 | ||||||||||||||||||||||||
| 905 | if(clashCount == 1
| 0 | ||||||||||||||||||||||||
| 906 | next_action = first; never executed: next_action = first; | 0 | ||||||||||||||||||||||||
| 907 | else | - | ||||||||||||||||||||||||
| 908 | next_action = firstAfterCurrent; never executed: next_action = firstAfterCurrent; | 0 | ||||||||||||||||||||||||
| 909 | } | - | ||||||||||||||||||||||||
| 910 | if(next_action
| 0 | ||||||||||||||||||||||||
| 911 | key_consumed = true; | - | ||||||||||||||||||||||||
| 912 | d->setCurrentAction(next_action, true, true); | - | ||||||||||||||||||||||||
| 913 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 914 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 915 | if(key_consumed
| 0 | ||||||||||||||||||||||||
| 916 | e->accept(); never executed: e->accept(); | 0 | ||||||||||||||||||||||||
| 917 | else | - | ||||||||||||||||||||||||
| 918 | e->ignore(); never executed: e->ignore(); | 0 | ||||||||||||||||||||||||
| 919 | } | - | ||||||||||||||||||||||||
| 920 | - | |||||||||||||||||||||||||
| 921 | - | |||||||||||||||||||||||||
| 922 | - | |||||||||||||||||||||||||
| 923 | - | |||||||||||||||||||||||||
| 924 | void QMenuBar::mouseMoveEvent(QMouseEvent *e) | - | ||||||||||||||||||||||||
| 925 | { | - | ||||||||||||||||||||||||
| 926 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 927 | if (!(e->buttons() & Qt::LeftButton)
| 0 | ||||||||||||||||||||||||
| 928 | d->mouseDown = false; never executed: d->mouseDown = false; | 0 | ||||||||||||||||||||||||
| 929 | bool popupState = d->popupState
| 0 | ||||||||||||||||||||||||
| 930 | QAction *action = d->actionAt(e->pos()); | - | ||||||||||||||||||||||||
| 931 | if ((action
| 0 | ||||||||||||||||||||||||
| 932 | d->setCurrentAction(action, popupState); never executed: d->setCurrentAction(action, popupState); | 0 | ||||||||||||||||||||||||
| 933 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 934 | - | |||||||||||||||||||||||||
| 935 | - | |||||||||||||||||||||||||
| 936 | - | |||||||||||||||||||||||||
| 937 | - | |||||||||||||||||||||||||
| 938 | void QMenuBar::leaveEvent(QEvent *) | - | ||||||||||||||||||||||||
| 939 | { | - | ||||||||||||||||||||||||
| 940 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 941 | if((!hasFocus()
| 0 | ||||||||||||||||||||||||
| 942 | (d->currentAction
| 0 | ||||||||||||||||||||||||
| 943 | d->setCurrentAction(0); never executed: d->setCurrentAction(0); | 0 | ||||||||||||||||||||||||
| 944 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 945 | - | |||||||||||||||||||||||||
| 946 | QPlatformMenu *QMenuBarPrivate::getPlatformMenu(QAction *action) | - | ||||||||||||||||||||||||
| 947 | { | - | ||||||||||||||||||||||||
| 948 | if (!action
| 0 | ||||||||||||||||||||||||
| 949 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 950 | - | |||||||||||||||||||||||||
| 951 | QPlatformMenu *platformMenu = action->menu()->platformMenu(); | - | ||||||||||||||||||||||||
| 952 | if (!platformMenu
| 0 | ||||||||||||||||||||||||
| 953 | platformMenu = platformMenuBar->createMenu(); | - | ||||||||||||||||||||||||
| 954 | if (platformMenu
| 0 | ||||||||||||||||||||||||
| 955 | action->menu()->setPlatformMenu(platformMenu); never executed: action->menu()->setPlatformMenu(platformMenu); | 0 | ||||||||||||||||||||||||
| 956 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 957 | - | |||||||||||||||||||||||||
| 958 | return never executed: platformMenu;return platformMenu;never executed: return platformMenu; | 0 | ||||||||||||||||||||||||
| 959 | } | - | ||||||||||||||||||||||||
| 960 | - | |||||||||||||||||||||||||
| 961 | - | |||||||||||||||||||||||||
| 962 | - | |||||||||||||||||||||||||
| 963 | - | |||||||||||||||||||||||||
| 964 | void QMenuBar::actionEvent(QActionEvent *e) | - | ||||||||||||||||||||||||
| 965 | { | - | ||||||||||||||||||||||||
| 966 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 967 | d->itemsDirty = true; | - | ||||||||||||||||||||||||
| 968 | - | |||||||||||||||||||||||||
| 969 | if (d->platformMenuBar
| 0 | ||||||||||||||||||||||||
| 970 | - | |||||||||||||||||||||||||
| 971 | QPlatformMenuBar *nativeMenuBar = d->platformMenuBar; | - | ||||||||||||||||||||||||
| 972 | - | |||||||||||||||||||||||||
| 973 | - | |||||||||||||||||||||||||
| 974 | - | |||||||||||||||||||||||||
| 975 | if (!nativeMenuBar
| 0 | ||||||||||||||||||||||||
| 976 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 977 | - | |||||||||||||||||||||||||
| 978 | if (e->type() == QEvent::ActionAdded
| 0 | ||||||||||||||||||||||||
| 979 | QPlatformMenu *menu = d->getPlatformMenu(e->action()); | - | ||||||||||||||||||||||||
| 980 | if (menu
| 0 | ||||||||||||||||||||||||
| 981 | QPlatformMenu* beforeMenu = __null; | - | ||||||||||||||||||||||||
| 982 | for (int beforeIndex = d->indexOf(e->action()) + 1; | - | ||||||||||||||||||||||||
| 983 | !beforeMenu
| 0 | ||||||||||||||||||||||||
| 984 | ++beforeIndex) | - | ||||||||||||||||||||||||
| 985 | { | - | ||||||||||||||||||||||||
| 986 | beforeMenu = d->getPlatformMenu(actions().at(beforeIndex)); | - | ||||||||||||||||||||||||
| 987 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 988 | - | |||||||||||||||||||||||||
| 989 | menu->setTag(reinterpret_cast<quintptr>(e->action())); | - | ||||||||||||||||||||||||
| 990 | menu->setText(e->action()->text()); | - | ||||||||||||||||||||||||
| 991 | d->platformMenuBar->insertMenu(menu, beforeMenu); | - | ||||||||||||||||||||||||
| 992 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 993 | } never executed: else if (e->type() == QEvent::ActionRemovedend of block
| 0 | ||||||||||||||||||||||||
| 994 | QPlatformMenu *menu = d->getPlatformMenu(e->action()); | - | ||||||||||||||||||||||||
| 995 | if (menu
| 0 | ||||||||||||||||||||||||
| 996 | d->platformMenuBar->removeMenu(menu); never executed: d->platformMenuBar->removeMenu(menu); | 0 | ||||||||||||||||||||||||
| 997 | } never executed: else if (e->type() == QEvent::ActionChangedend of block
| 0 | ||||||||||||||||||||||||
| 998 | QPlatformMenu* cur = d->platformMenuBar->menuForTag(reinterpret_cast<quintptr>(e->action())); | - | ||||||||||||||||||||||||
| 999 | QPlatformMenu *menu = d->getPlatformMenu(e->action()); | - | ||||||||||||||||||||||||
| 1000 | - | |||||||||||||||||||||||||
| 1001 | - | |||||||||||||||||||||||||
| 1002 | - | |||||||||||||||||||||||||
| 1003 | if (menu != cur
| 0 | ||||||||||||||||||||||||
| 1004 | if (cur
| 0 | ||||||||||||||||||||||||
| 1005 | d->platformMenuBar->removeMenu(cur); never executed: d->platformMenuBar->removeMenu(cur); | 0 | ||||||||||||||||||||||||
| 1006 | if (menu
| 0 | ||||||||||||||||||||||||
| 1007 | menu->setTag(reinterpret_cast<quintptr>(e->action())); | - | ||||||||||||||||||||||||
| 1008 | - | |||||||||||||||||||||||||
| 1009 | QPlatformMenu* beforeMenu = __null; | - | ||||||||||||||||||||||||
| 1010 | for (int beforeIndex = d->indexOf(e->action()) + 1; | - | ||||||||||||||||||||||||
| 1011 | !beforeMenu
| 0 | ||||||||||||||||||||||||
| 1012 | ++beforeIndex) | - | ||||||||||||||||||||||||
| 1013 | { | - | ||||||||||||||||||||||||
| 1014 | beforeMenu = d->getPlatformMenu(actions().at(beforeIndex)); | - | ||||||||||||||||||||||||
| 1015 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1016 | d->platformMenuBar->insertMenu(menu, beforeMenu); | - | ||||||||||||||||||||||||
| 1017 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1018 | } never executed: else if (menuend of block
| 0 | ||||||||||||||||||||||||
| 1019 | menu->setText(e->action()->text()); | - | ||||||||||||||||||||||||
| 1020 | menu->setVisible(e->action()->isVisible()); | - | ||||||||||||||||||||||||
| 1021 | menu->setEnabled(e->action()->isEnabled()); | - | ||||||||||||||||||||||||
| 1022 | d->platformMenuBar->syncMenu(menu); | - | ||||||||||||||||||||||||
| 1023 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1024 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1025 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1026 | - | |||||||||||||||||||||||||
| 1027 | if(e->type() == QEvent::ActionAdded
| 0 | ||||||||||||||||||||||||
| 1028 | connect(e->action(), qFlagLocation("2""triggered()" "\0" __FILE__ ":" "1286"), this, qFlagLocation("1""_q_actionTriggered()" "\0" __FILE__ ":" "1286")); | - | ||||||||||||||||||||||||
| 1029 | connect(e->action(), qFlagLocation("2""hovered()" "\0" __FILE__ ":" "1287"), this, qFlagLocation("1""_q_actionHovered()" "\0" __FILE__ ":" "1287")); | - | ||||||||||||||||||||||||
| 1030 | } never executed: else if(e->type() == QEvent::ActionRemovedend of block
| 0 | ||||||||||||||||||||||||
| 1031 | e->action()->disconnect(this); | - | ||||||||||||||||||||||||
| 1032 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1033 | if (isVisible()
| 0 | ||||||||||||||||||||||||
| 1034 | d->updateGeometries(); | - | ||||||||||||||||||||||||
| 1035 | update(); | - | ||||||||||||||||||||||||
| 1036 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1037 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1038 | - | |||||||||||||||||||||||||
| 1039 | - | |||||||||||||||||||||||||
| 1040 | - | |||||||||||||||||||||||||
| 1041 | - | |||||||||||||||||||||||||
| 1042 | void QMenuBar::focusInEvent(QFocusEvent *) | - | ||||||||||||||||||||||||
| 1043 | { | - | ||||||||||||||||||||||||
| 1044 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1045 | if(d->keyboardState
| 0 | ||||||||||||||||||||||||
| 1046 | d->focusFirstAction(); never executed: d->focusFirstAction(); | 0 | ||||||||||||||||||||||||
| 1047 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1048 | - | |||||||||||||||||||||||||
| 1049 | - | |||||||||||||||||||||||||
| 1050 | - | |||||||||||||||||||||||||
| 1051 | - | |||||||||||||||||||||||||
| 1052 | void QMenuBar::focusOutEvent(QFocusEvent *) | - | ||||||||||||||||||||||||
| 1053 | { | - | ||||||||||||||||||||||||
| 1054 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1055 | if(!d->popupState
| 0 | ||||||||||||||||||||||||
| 1056 | d->setCurrentAction(0); | - | ||||||||||||||||||||||||
| 1057 | d->setKeyboardMode(false); | - | ||||||||||||||||||||||||
| 1058 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1059 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1060 | - | |||||||||||||||||||||||||
| 1061 | - | |||||||||||||||||||||||||
| 1062 | - | |||||||||||||||||||||||||
| 1063 | - | |||||||||||||||||||||||||
| 1064 | void QMenuBar::timerEvent (QTimerEvent *e) | - | ||||||||||||||||||||||||
| 1065 | { | - | ||||||||||||||||||||||||
| 1066 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1067 | if (e->timerId() == d->autoReleaseTimer.timerId()
| 0 | ||||||||||||||||||||||||
| 1068 | d->autoReleaseTimer.stop(); | - | ||||||||||||||||||||||||
| 1069 | d->setCurrentAction(0); | - | ||||||||||||||||||||||||
| 1070 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1071 | QWidget::timerEvent(e); | - | ||||||||||||||||||||||||
| 1072 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1073 | - | |||||||||||||||||||||||||
| 1074 | - | |||||||||||||||||||||||||
| 1075 | void QMenuBarPrivate::handleReparent() | - | ||||||||||||||||||||||||
| 1076 | { | - | ||||||||||||||||||||||||
| 1077 | QMenuBar * const q = q_func(); | - | ||||||||||||||||||||||||
| 1078 | QWidget *newParent = q->parentWidget(); | - | ||||||||||||||||||||||||
| 1079 | - | |||||||||||||||||||||||||
| 1080 | - | |||||||||||||||||||||||||
| 1081 | - | |||||||||||||||||||||||||
| 1082 | - | |||||||||||||||||||||||||
| 1083 | QWidget *newWindow = newParent
| 0 | ||||||||||||||||||||||||
| 1084 | - | |||||||||||||||||||||||||
| 1085 | QVector<QPointer<QWidget> > newParents; | - | ||||||||||||||||||||||||
| 1086 | - | |||||||||||||||||||||||||
| 1087 | - | |||||||||||||||||||||||||
| 1088 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(oldParents)>::type> _container_((oldParents)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QPointer<QWidget> &w = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
| 1089 | if (w
| 0 | ||||||||||||||||||||||||
| 1090 | if (newParent == w
| 0 | ||||||||||||||||||||||||
| 1091 | newParents.append(w); | - | ||||||||||||||||||||||||
| 1092 | if (newParent != newWindow
| 0 | ||||||||||||||||||||||||
| 1093 | newParent = newParent->parentWidget(); never executed: newParent = newParent->parentWidget(); | 0 | ||||||||||||||||||||||||
| 1094 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1095 | w->removeEventFilter(q); | - | ||||||||||||||||||||||||
| 1096 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1097 | } | - | ||||||||||||||||||||||||
| 1098 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1099 | - | |||||||||||||||||||||||||
| 1100 | - | |||||||||||||||||||||||||
| 1101 | while (newParent
| 0 | ||||||||||||||||||||||||
| 1102 | - | |||||||||||||||||||||||||
| 1103 | newParents.append(newParent); | - | ||||||||||||||||||||||||
| 1104 | newParent->installEventFilter(q); | - | ||||||||||||||||||||||||
| 1105 | newParent = newParent->parentWidget(); | - | ||||||||||||||||||||||||
| 1106 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1107 | - | |||||||||||||||||||||||||
| 1108 | if (newParent
| 0 | ||||||||||||||||||||||||
| 1109 | - | |||||||||||||||||||||||||
| 1110 | newParents.append(newParent); | - | ||||||||||||||||||||||||
| 1111 | newParent->installEventFilter(q); | - | ||||||||||||||||||||||||
| 1112 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1113 | oldParents = newParents; | - | ||||||||||||||||||||||||
| 1114 | - | |||||||||||||||||||||||||
| 1115 | if (platformMenuBar
| 0 | ||||||||||||||||||||||||
| 1116 | if (newWindow
| 0 | ||||||||||||||||||||||||
| 1117 | - | |||||||||||||||||||||||||
| 1118 | - | |||||||||||||||||||||||||
| 1119 | - | |||||||||||||||||||||||||
| 1120 | newWindow->createWinId(); | - | ||||||||||||||||||||||||
| 1121 | platformMenuBar->handleReparent(newWindow->windowHandle()); | - | ||||||||||||||||||||||||
| 1122 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1123 | platformMenuBar->handleReparent(0); | - | ||||||||||||||||||||||||
| 1124 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1125 | } | - | ||||||||||||||||||||||||
| 1126 | - | |||||||||||||||||||||||||
| 1127 | - | |||||||||||||||||||||||||
| 1128 | - | |||||||||||||||||||||||||
| 1129 | - | |||||||||||||||||||||||||
| 1130 | - | |||||||||||||||||||||||||
| 1131 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1132 | - | |||||||||||||||||||||||||
| 1133 | - | |||||||||||||||||||||||||
| 1134 | - | |||||||||||||||||||||||||
| 1135 | - | |||||||||||||||||||||||||
| 1136 | void QMenuBar::changeEvent(QEvent *e) | - | ||||||||||||||||||||||||
| 1137 | { | - | ||||||||||||||||||||||||
| 1138 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1139 | if(e->type() == QEvent::StyleChange
| 0 | ||||||||||||||||||||||||
| 1140 | d->itemsDirty = true; | - | ||||||||||||||||||||||||
| 1141 | setMouseTracking(style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, this)); | - | ||||||||||||||||||||||||
| 1142 | if(parentWidget()
| 0 | ||||||||||||||||||||||||
| 1143 | resize(parentWidget()->width(), heightForWidth(parentWidget()->width())); never executed: resize(parentWidget()->width(), heightForWidth(parentWidget()->width())); | 0 | ||||||||||||||||||||||||
| 1144 | d->updateGeometries(); | - | ||||||||||||||||||||||||
| 1145 | } never executed: else if (e->type() == QEvent::ParentChangeend of block
| 0 | ||||||||||||||||||||||||
| 1146 | d->handleReparent(); | - | ||||||||||||||||||||||||
| 1147 | } never executed: else if (e->type() == QEvent::FontChangeend of block
| 0 | ||||||||||||||||||||||||
| 1148 | || e->type() == QEvent::ApplicationFontChange
| 0 | ||||||||||||||||||||||||
| 1149 | d->itemsDirty = true; | - | ||||||||||||||||||||||||
| 1150 | d->updateGeometries(); | - | ||||||||||||||||||||||||
| 1151 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1152 | - | |||||||||||||||||||||||||
| 1153 | QWidget::changeEvent(e); | - | ||||||||||||||||||||||||
| 1154 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1155 | - | |||||||||||||||||||||||||
| 1156 | - | |||||||||||||||||||||||||
| 1157 | - | |||||||||||||||||||||||||
| 1158 | - | |||||||||||||||||||||||||
| 1159 | bool QMenuBar::event(QEvent *e) | - | ||||||||||||||||||||||||
| 1160 | { | - | ||||||||||||||||||||||||
| 1161 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1162 | switch (e->type()) { | - | ||||||||||||||||||||||||
| 1163 | case never executed: QEvent::KeyPress:case QEvent::KeyPress:never executed: {case QEvent::KeyPress: | 0 | ||||||||||||||||||||||||
| 1164 | QKeyEvent *ke = (QKeyEvent*)e; | - | ||||||||||||||||||||||||
| 1165 | - | |||||||||||||||||||||||||
| 1166 | - | |||||||||||||||||||||||||
| 1167 | - | |||||||||||||||||||||||||
| 1168 | - | |||||||||||||||||||||||||
| 1169 | - | |||||||||||||||||||||||||
| 1170 | - | |||||||||||||||||||||||||
| 1171 | if(ke->key() == Qt::Key_Tab
| 0 | ||||||||||||||||||||||||
| 1172 | keyPressEvent(ke); | - | ||||||||||||||||||||||||
| 1173 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 1174 | } | - | ||||||||||||||||||||||||
| 1175 | - | |||||||||||||||||||||||||
| 1176 | } break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1177 | - | |||||||||||||||||||||||||
| 1178 | case never executed: QEvent::Shortcut:case QEvent::Shortcut:never executed: {case QEvent::Shortcut: | 0 | ||||||||||||||||||||||||
| 1179 | QShortcutEvent *se = static_cast<QShortcutEvent *>(e); | - | ||||||||||||||||||||||||
| 1180 | int shortcutId = se->shortcutId(); | - | ||||||||||||||||||||||||
| 1181 | for(int j = 0; j < d->shortcutIndexMap.size()
| 0 | ||||||||||||||||||||||||
| 1182 | if (shortcutId == d->shortcutIndexMap.value(j)
| 0 | ||||||||||||||||||||||||
| 1183 | d->_q_internalShortcutActivated(j); never executed: d->_q_internalShortcutActivated(j); | 0 | ||||||||||||||||||||||||
| 1184 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1185 | } break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1186 | - | |||||||||||||||||||||||||
| 1187 | case never executed: QEvent::Show:case QEvent::Show:never executed: case QEvent::Show: | 0 | ||||||||||||||||||||||||
| 1188 | d->_q_updateLayout(); | - | ||||||||||||||||||||||||
| 1189 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1190 | case never executed: QEvent::ShortcutOverride:case QEvent::ShortcutOverride:never executed: {case QEvent::ShortcutOverride: | 0 | ||||||||||||||||||||||||
| 1191 | QKeyEvent *kev = static_cast<QKeyEvent*>(e); | - | ||||||||||||||||||||||||
| 1192 | - | |||||||||||||||||||||||||
| 1193 | if (kev->matches(QKeySequence::Cancel)
| 0 | ||||||||||||||||||||||||
| 1194 | e->accept(); | - | ||||||||||||||||||||||||
| 1195 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 1196 | } | - | ||||||||||||||||||||||||
| 1197 | } | - | ||||||||||||||||||||||||
| 1198 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1199 | - | |||||||||||||||||||||||||
| 1200 | - | |||||||||||||||||||||||||
| 1201 | - | |||||||||||||||||||||||||
| 1202 | case never executed: QEvent::QueryWhatsThis:case QEvent::QueryWhatsThis:never executed: case QEvent::QueryWhatsThis: | 0 | ||||||||||||||||||||||||
| 1203 | e->setAccepted(d->whatsThis.size()); | - | ||||||||||||||||||||||||
| 1204 | if (QAction *action = d->actionAt(static_cast<QHelpEvent*>(e)->pos())
| 0 | ||||||||||||||||||||||||
| 1205 | if (action->whatsThis().size()
| 0 | ||||||||||||||||||||||||
| 1206 | e->accept(); never executed: e->accept(); | 0 | ||||||||||||||||||||||||
| 1207 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1208 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 1209 | - | |||||||||||||||||||||||||
| 1210 | case never executed: QEvent::LayoutDirectionChange:case QEvent::LayoutDirectionChange:never executed: case QEvent::LayoutDirectionChange: | 0 | ||||||||||||||||||||||||
| 1211 | d->_q_updateLayout(); | - | ||||||||||||||||||||||||
| 1212 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1213 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 1214 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1215 | } | - | ||||||||||||||||||||||||
| 1216 | return never executed: QWidget::event(e);return QWidget::event(e);never executed: return QWidget::event(e); | 0 | ||||||||||||||||||||||||
| 1217 | } | - | ||||||||||||||||||||||||
| 1218 | - | |||||||||||||||||||||||||
| 1219 | - | |||||||||||||||||||||||||
| 1220 | - | |||||||||||||||||||||||||
| 1221 | - | |||||||||||||||||||||||||
| 1222 | bool QMenuBar::eventFilter(QObject *object, QEvent *event) | - | ||||||||||||||||||||||||
| 1223 | { | - | ||||||||||||||||||||||||
| 1224 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1225 | if (object
| 0 | ||||||||||||||||||||||||
| 1226 | d->handleReparent(); never executed: d->handleReparent(); | 0 | ||||||||||||||||||||||||
| 1227 | - | |||||||||||||||||||||||||
| 1228 | if (object == d->leftWidget
| 0 | ||||||||||||||||||||||||
| 1229 | switch (event->type()) { | - | ||||||||||||||||||||||||
| 1230 | case never executed: QEvent::ShowToParent:case QEvent::ShowToParent:never executed: case QEvent::ShowToParent: | 0 | ||||||||||||||||||||||||
| 1231 | case never executed: QEvent::HideToParent:case QEvent::HideToParent:never executed: case QEvent::HideToParent: | 0 | ||||||||||||||||||||||||
| 1232 | d->_q_updateLayout(); | - | ||||||||||||||||||||||||
| 1233 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1234 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 1235 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1236 | } | - | ||||||||||||||||||||||||
| 1237 | } | - | ||||||||||||||||||||||||
| 1238 | - | |||||||||||||||||||||||||
| 1239 | if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this)
| 0 | ||||||||||||||||||||||||
| 1240 | if (d->altPressed
| 0 | ||||||||||||||||||||||||
| 1241 | switch (event->type()) { | - | ||||||||||||||||||||||||
| 1242 | case never executed: QEvent::KeyPress:case QEvent::KeyPress:never executed: case QEvent::KeyPress: | 0 | ||||||||||||||||||||||||
| 1243 | case never executed: QEvent::KeyRelease:case QEvent::KeyRelease:never executed: case QEvent::KeyRelease: | 0 | ||||||||||||||||||||||||
| 1244 | { | - | ||||||||||||||||||||||||
| 1245 | QKeyEvent *kev = static_cast<QKeyEvent*>(event); | - | ||||||||||||||||||||||||
| 1246 | if (kev->key() == Qt::Key_Alt
| 0 | ||||||||||||||||||||||||
| 1247 | if (event->type() == QEvent::KeyPress
| 0 | ||||||||||||||||||||||||
| 1248 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1249 | d->setKeyboardMode(!d->keyboardState); | - | ||||||||||||||||||||||||
| 1250 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1251 | } | - | ||||||||||||||||||||||||
| 1252 | - | |||||||||||||||||||||||||
| 1253 | case never executed: QEvent::MouseButtonPress:case QEvent::MouseButtonPress:never executed: case QEvent::MouseButtonPress:code before this statement never executed: case QEvent::MouseButtonPress: | 0 | ||||||||||||||||||||||||
| 1254 | case never executed: QEvent::MouseButtonRelease:case QEvent::MouseButtonRelease:never executed: case QEvent::MouseButtonRelease: | 0 | ||||||||||||||||||||||||
| 1255 | case never executed: QEvent::MouseMove:case QEvent::MouseMove:never executed: case QEvent::MouseMove: | 0 | ||||||||||||||||||||||||
| 1256 | case never executed: QEvent::FocusIn:case QEvent::FocusIn:never executed: case QEvent::FocusIn: | 0 | ||||||||||||||||||||||||
| 1257 | case never executed: QEvent::FocusOut:case QEvent::FocusOut:never executed: case QEvent::FocusOut: | 0 | ||||||||||||||||||||||||
| 1258 | case never executed: QEvent::ActivationChange:case QEvent::ActivationChange:never executed: case QEvent::ActivationChange: | 0 | ||||||||||||||||||||||||
| 1259 | d->altPressed = false; | - | ||||||||||||||||||||||||
| 1260 | (static_cast<QApplication *>(QCoreApplication::instance()))->removeEventFilter(this); | - | ||||||||||||||||||||||||
| 1261 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1262 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 1263 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1264 | } | - | ||||||||||||||||||||||||
| 1265 | } else if (isVisible()
| 0 | ||||||||||||||||||||||||
| 1266 | if (event->type() == QEvent::ShortcutOverride
| 0 | ||||||||||||||||||||||||
| 1267 | QKeyEvent *kev = static_cast<QKeyEvent*>(event); | - | ||||||||||||||||||||||||
| 1268 | if ((kev->key() == Qt::Key_Alt
| 0 | ||||||||||||||||||||||||
| 1269 | && kev->modifiers() == Qt::AltModifier
| 0 | ||||||||||||||||||||||||
| 1270 | d->altPressed = true; | - | ||||||||||||||||||||||||
| 1271 | (static_cast<QApplication *>(QCoreApplication::instance()))->installEventFilter(this); | - | ||||||||||||||||||||||||
| 1272 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1273 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1274 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1275 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1276 | - | |||||||||||||||||||||||||
| 1277 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1278 | } | - | ||||||||||||||||||||||||
| 1279 | - | |||||||||||||||||||||||||
| 1280 | - | |||||||||||||||||||||||||
| 1281 | - | |||||||||||||||||||||||||
| 1282 | - | |||||||||||||||||||||||||
| 1283 | - | |||||||||||||||||||||||||
| 1284 | - | |||||||||||||||||||||||||
| 1285 | - | |||||||||||||||||||||||||
| 1286 | QAction *QMenuBar::actionAt(const QPoint &pt) const | - | ||||||||||||||||||||||||
| 1287 | { | - | ||||||||||||||||||||||||
| 1288 | const QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1289 | return never executed: d->actionAt(pt);return d->actionAt(pt);never executed: return d->actionAt(pt); | 0 | ||||||||||||||||||||||||
| 1290 | } | - | ||||||||||||||||||||||||
| 1291 | - | |||||||||||||||||||||||||
| 1292 | - | |||||||||||||||||||||||||
| 1293 | - | |||||||||||||||||||||||||
| 1294 | - | |||||||||||||||||||||||||
| 1295 | - | |||||||||||||||||||||||||
| 1296 | - | |||||||||||||||||||||||||
| 1297 | QRect QMenuBar::actionGeometry(QAction *act) const | - | ||||||||||||||||||||||||
| 1298 | { | - | ||||||||||||||||||||||||
| 1299 | const QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1300 | return never executed: d->actionRect(act);return d->actionRect(act);never executed: return d->actionRect(act); | 0 | ||||||||||||||||||||||||
| 1301 | } | - | ||||||||||||||||||||||||
| 1302 | - | |||||||||||||||||||||||||
| 1303 | - | |||||||||||||||||||||||||
| 1304 | - | |||||||||||||||||||||||||
| 1305 | - | |||||||||||||||||||||||||
| 1306 | QSize QMenuBar::minimumSizeHint() const | - | ||||||||||||||||||||||||
| 1307 | { | - | ||||||||||||||||||||||||
| 1308 | const QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1309 | const bool as_gui_menubar = !isNativeMenuBar(); | - | ||||||||||||||||||||||||
| 1310 | - | |||||||||||||||||||||||||
| 1311 | ensurePolished(); | - | ||||||||||||||||||||||||
| 1312 | QSize ret(0, 0); | - | ||||||||||||||||||||||||
| 1313 | const_cast<QMenuBarPrivate*>(d)->updateGeometries(); | - | ||||||||||||||||||||||||
| 1314 | const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, this); | - | ||||||||||||||||||||||||
| 1315 | const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this); | - | ||||||||||||||||||||||||
| 1316 | int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this); | - | ||||||||||||||||||||||||
| 1317 | int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this); | - | ||||||||||||||||||||||||
| 1318 | if(as_gui_menubar
| 0 | ||||||||||||||||||||||||
| 1319 | int w = parentWidget()
| 0 | ||||||||||||||||||||||||
| 1320 | d->calcActionRects(w - (2 * fw), 0); | - | ||||||||||||||||||||||||
| 1321 | for (int i = 0; ret.isNull()
| 0 | ||||||||||||||||||||||||
| 1322 | ret = d->actionRects.at(i).size(); never executed: ret = d->actionRects.at(i).size(); | 0 | ||||||||||||||||||||||||
| 1323 | if (!d->extension->isHidden()
| 0 | ||||||||||||||||||||||||
| 1324 | ret += QSize(d->extension->sizeHint().width(), 0); never executed: ret += QSize(d->extension->sizeHint().width(), 0); | 0 | ||||||||||||||||||||||||
| 1325 | ret += QSize(2*fw + hmargin, 2*fw + vmargin); | - | ||||||||||||||||||||||||
| 1326 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1327 | int margin = 2*vmargin + 2*fw + spaceBelowMenuBar; | - | ||||||||||||||||||||||||
| 1328 | if(d->leftWidget
| 0 | ||||||||||||||||||||||||
| 1329 | QSize sz = d->leftWidget->minimumSizeHint(); | - | ||||||||||||||||||||||||
| 1330 | ret.setWidth(ret.width() + sz.width()); | - | ||||||||||||||||||||||||
| 1331 | if(sz.height() + margin > ret.height()
| 0 | ||||||||||||||||||||||||
| 1332 | ret.setHeight(sz.height() + margin); never executed: ret.setHeight(sz.height() + margin); | 0 | ||||||||||||||||||||||||
| 1333 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1334 | if(d->rightWidget
| 0 | ||||||||||||||||||||||||
| 1335 | QSize sz = d->rightWidget->minimumSizeHint(); | - | ||||||||||||||||||||||||
| 1336 | ret.setWidth(ret.width() + sz.width()); | - | ||||||||||||||||||||||||
| 1337 | if(sz.height() + margin > ret.height()
| 0 | ||||||||||||||||||||||||
| 1338 | ret.setHeight(sz.height() + margin); never executed: ret.setHeight(sz.height() + margin); | 0 | ||||||||||||||||||||||||
| 1339 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1340 | if(as_gui_menubar
| 0 | ||||||||||||||||||||||||
| 1341 | QStyleOptionMenuItem opt; | - | ||||||||||||||||||||||||
| 1342 | opt.rect = rect(); | - | ||||||||||||||||||||||||
| 1343 | opt.menuRect = rect(); | - | ||||||||||||||||||||||||
| 1344 | opt.state = QStyle::State_None; | - | ||||||||||||||||||||||||
| 1345 | opt.menuItemType = QStyleOptionMenuItem::Normal; | - | ||||||||||||||||||||||||
| 1346 | opt.checkType = QStyleOptionMenuItem::NotCheckable; | - | ||||||||||||||||||||||||
| 1347 | opt.palette = palette(); | - | ||||||||||||||||||||||||
| 1348 | return never executed: (style()->sizeFromContents(QStyle::CT_MenuBar, &opt,return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this));never executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this)); | 0 | ||||||||||||||||||||||||
| 1349 | ret.expandedTo(QApplication::globalStrut()), never executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this)); | 0 | ||||||||||||||||||||||||
| 1350 | this)); never executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this)); | 0 | ||||||||||||||||||||||||
| 1351 | } | - | ||||||||||||||||||||||||
| 1352 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||
| 1353 | } | - | ||||||||||||||||||||||||
| 1354 | - | |||||||||||||||||||||||||
| 1355 | - | |||||||||||||||||||||||||
| 1356 | - | |||||||||||||||||||||||||
| 1357 | - | |||||||||||||||||||||||||
| 1358 | QSize QMenuBar::sizeHint() const | - | ||||||||||||||||||||||||
| 1359 | { | - | ||||||||||||||||||||||||
| 1360 | const QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1361 | const bool as_gui_menubar = !isNativeMenuBar(); | - | ||||||||||||||||||||||||
| 1362 | - | |||||||||||||||||||||||||
| 1363 | ensurePolished(); | - | ||||||||||||||||||||||||
| 1364 | QSize ret(0, 0); | - | ||||||||||||||||||||||||
| 1365 | const_cast<QMenuBarPrivate*>(d)->updateGeometries(); | - | ||||||||||||||||||||||||
| 1366 | const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, this); | - | ||||||||||||||||||||||||
| 1367 | const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this); | - | ||||||||||||||||||||||||
| 1368 | int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this); | - | ||||||||||||||||||||||||
| 1369 | int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this); | - | ||||||||||||||||||||||||
| 1370 | if(as_gui_menubar
| 0 | ||||||||||||||||||||||||
| 1371 | const int w = parentWidget()
| 0 | ||||||||||||||||||||||||
| 1372 | d->calcActionRects(w - (2 * fw), 0); | - | ||||||||||||||||||||||||
| 1373 | for (int i = 0; i < d->actionRects.count()
| 0 | ||||||||||||||||||||||||
| 1374 | const QRect &actionRect = d->actionRects.at(i); | - | ||||||||||||||||||||||||
| 1375 | ret = ret.expandedTo(QSize(actionRect.x() + actionRect.width(), actionRect.y() + actionRect.height())); | - | ||||||||||||||||||||||||
| 1376 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1377 | - | |||||||||||||||||||||||||
| 1378 | - | |||||||||||||||||||||||||
| 1379 | ret += QSize(fw + hmargin, fw + vmargin); | - | ||||||||||||||||||||||||
| 1380 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1381 | int margin = 2*vmargin + 2*fw + spaceBelowMenuBar; | - | ||||||||||||||||||||||||
| 1382 | if(d->leftWidget
| 0 | ||||||||||||||||||||||||
| 1383 | QSize sz = d->leftWidget->sizeHint(); | - | ||||||||||||||||||||||||
| 1384 | sz.rheight() += margin; | - | ||||||||||||||||||||||||
| 1385 | ret = ret.expandedTo(sz); | - | ||||||||||||||||||||||||
| 1386 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1387 | if(d->rightWidget
| 0 | ||||||||||||||||||||||||
| 1388 | QSize sz = d->rightWidget->sizeHint(); | - | ||||||||||||||||||||||||
| 1389 | ret.setWidth(ret.width() + sz.width()); | - | ||||||||||||||||||||||||
| 1390 | if(sz.height() + margin > ret.height()
| 0 | ||||||||||||||||||||||||
| 1391 | ret.setHeight(sz.height() + margin); never executed: ret.setHeight(sz.height() + margin); | 0 | ||||||||||||||||||||||||
| 1392 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1393 | if(as_gui_menubar
| 0 | ||||||||||||||||||||||||
| 1394 | QStyleOptionMenuItem opt; | - | ||||||||||||||||||||||||
| 1395 | opt.rect = rect(); | - | ||||||||||||||||||||||||
| 1396 | opt.menuRect = rect(); | - | ||||||||||||||||||||||||
| 1397 | opt.state = QStyle::State_None; | - | ||||||||||||||||||||||||
| 1398 | opt.menuItemType = QStyleOptionMenuItem::Normal; | - | ||||||||||||||||||||||||
| 1399 | opt.checkType = QStyleOptionMenuItem::NotCheckable; | - | ||||||||||||||||||||||||
| 1400 | opt.palette = palette(); | - | ||||||||||||||||||||||||
| 1401 | return never executed: (style()->sizeFromContents(QStyle::CT_MenuBar, &opt,return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this));never executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this)); | 0 | ||||||||||||||||||||||||
| 1402 | ret.expandedTo(QApplication::globalStrut()), never executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this)); | 0 | ||||||||||||||||||||||||
| 1403 | this)); never executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this)); | 0 | ||||||||||||||||||||||||
| 1404 | } | - | ||||||||||||||||||||||||
| 1405 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||
| 1406 | } | - | ||||||||||||||||||||||||
| 1407 | - | |||||||||||||||||||||||||
| 1408 | - | |||||||||||||||||||||||||
| 1409 | - | |||||||||||||||||||||||||
| 1410 | - | |||||||||||||||||||||||||
| 1411 | int QMenuBar::heightForWidth(int) const | - | ||||||||||||||||||||||||
| 1412 | { | - | ||||||||||||||||||||||||
| 1413 | const QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1414 | const bool as_gui_menubar = !isNativeMenuBar(); | - | ||||||||||||||||||||||||
| 1415 | - | |||||||||||||||||||||||||
| 1416 | const_cast<QMenuBarPrivate*>(d)->updateGeometries(); | - | ||||||||||||||||||||||||
| 1417 | int height = 0; | - | ||||||||||||||||||||||||
| 1418 | const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this); | - | ||||||||||||||||||||||||
| 1419 | int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this); | - | ||||||||||||||||||||||||
| 1420 | int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this); | - | ||||||||||||||||||||||||
| 1421 | if(as_gui_menubar
| 0 | ||||||||||||||||||||||||
| 1422 | for (int i = 0; i < d->actionRects.count()
| 0 | ||||||||||||||||||||||||
| 1423 | height = qMax(height, d->actionRects.at(i).height()); never executed: height = qMax(height, d->actionRects.at(i).height()); | 0 | ||||||||||||||||||||||||
| 1424 | if (height
| 0 | ||||||||||||||||||||||||
| 1425 | height += spaceBelowMenuBar; never executed: height += spaceBelowMenuBar; | 0 | ||||||||||||||||||||||||
| 1426 | height += 2*fw; | - | ||||||||||||||||||||||||
| 1427 | height += 2*vmargin; | - | ||||||||||||||||||||||||
| 1428 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1429 | int margin = 2*vmargin + 2*fw + spaceBelowMenuBar; | - | ||||||||||||||||||||||||
| 1430 | if(d->leftWidget
| 0 | ||||||||||||||||||||||||
| 1431 | height = qMax(d->leftWidget->sizeHint().height() + margin, height); never executed: height = qMax(d->leftWidget->sizeHint().height() + margin, height); | 0 | ||||||||||||||||||||||||
| 1432 | if(d->rightWidget
| 0 | ||||||||||||||||||||||||
| 1433 | height = qMax(d->rightWidget->sizeHint().height() + margin, height); never executed: height = qMax(d->rightWidget->sizeHint().height() + margin, height); | 0 | ||||||||||||||||||||||||
| 1434 | if(as_gui_menubar
| 0 | ||||||||||||||||||||||||
| 1435 | QStyleOptionMenuItem opt; | - | ||||||||||||||||||||||||
| 1436 | opt.init(this); | - | ||||||||||||||||||||||||
| 1437 | opt.menuRect = rect(); | - | ||||||||||||||||||||||||
| 1438 | opt.state = QStyle::State_None; | - | ||||||||||||||||||||||||
| 1439 | opt.menuItemType = QStyleOptionMenuItem::Normal; | - | ||||||||||||||||||||||||
| 1440 | opt.checkType = QStyleOptionMenuItem::NotCheckable; | - | ||||||||||||||||||||||||
| 1441 | return never executed: style()->sizeFromContents(QStyle::CT_MenuBar, &opt, QSize(0, height), this).height();return style()->sizeFromContents(QStyle::CT_MenuBar, &opt, QSize(0, height), this).height();never executed: return style()->sizeFromContents(QStyle::CT_MenuBar, &opt, QSize(0, height), this).height(); | 0 | ||||||||||||||||||||||||
| 1442 | } | - | ||||||||||||||||||||||||
| 1443 | return never executed: height;return height;never executed: return height; | 0 | ||||||||||||||||||||||||
| 1444 | } | - | ||||||||||||||||||||||||
| 1445 | - | |||||||||||||||||||||||||
| 1446 | - | |||||||||||||||||||||||||
| 1447 | - | |||||||||||||||||||||||||
| 1448 | - | |||||||||||||||||||||||||
| 1449 | void QMenuBarPrivate::_q_internalShortcutActivated(int id) | - | ||||||||||||||||||||||||
| 1450 | { | - | ||||||||||||||||||||||||
| 1451 | QMenuBar * const q = q_func(); | - | ||||||||||||||||||||||||
| 1452 | QAction *act = actions.at(id); | - | ||||||||||||||||||||||||
| 1453 | setCurrentAction(act, true, true); | - | ||||||||||||||||||||||||
| 1454 | if (act
| 0 | ||||||||||||||||||||||||
| 1455 | activateAction(act, QAction::Trigger); | - | ||||||||||||||||||||||||
| 1456 | - | |||||||||||||||||||||||||
| 1457 | autoReleaseTimer.start(100, q); | - | ||||||||||||||||||||||||
| 1458 | } never executed: else if (actend of block
| 0 | ||||||||||||||||||||||||
| 1459 | - | |||||||||||||||||||||||||
| 1460 | setKeyboardMode(true); | - | ||||||||||||||||||||||||
| 1461 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1462 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1463 | - | |||||||||||||||||||||||||
| 1464 | void QMenuBarPrivate::_q_updateLayout() | - | ||||||||||||||||||||||||
| 1465 | { | - | ||||||||||||||||||||||||
| 1466 | QMenuBar * const q = q_func(); | - | ||||||||||||||||||||||||
| 1467 | itemsDirty = true; | - | ||||||||||||||||||||||||
| 1468 | if (q->isVisible()
| 0 | ||||||||||||||||||||||||
| 1469 | updateGeometries(); | - | ||||||||||||||||||||||||
| 1470 | q->update(); | - | ||||||||||||||||||||||||
| 1471 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1472 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1473 | void QMenuBar::setCornerWidget(QWidget *w, Qt::Corner corner) | - | ||||||||||||||||||||||||
| 1474 | { | - | ||||||||||||||||||||||||
| 1475 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1476 | switch (corner) { | - | ||||||||||||||||||||||||
| 1477 | case never executed: Qt::TopLeftCorner:case Qt::TopLeftCorner:never executed: case Qt::TopLeftCorner: | 0 | ||||||||||||||||||||||||
| 1478 | if (d->leftWidget
| 0 | ||||||||||||||||||||||||
| 1479 | d->leftWidget->removeEventFilter(this); never executed: d->leftWidget->removeEventFilter(this); | 0 | ||||||||||||||||||||||||
| 1480 | d->leftWidget = w; | - | ||||||||||||||||||||||||
| 1481 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1482 | case never executed: Qt::TopRightCorner:case Qt::TopRightCorner:never executed: case Qt::TopRightCorner: | 0 | ||||||||||||||||||||||||
| 1483 | if (d->rightWidget
| 0 | ||||||||||||||||||||||||
| 1484 | d->rightWidget->removeEventFilter(this); never executed: d->rightWidget->removeEventFilter(this); | 0 | ||||||||||||||||||||||||
| 1485 | d->rightWidget = w; | - | ||||||||||||||||||||||||
| 1486 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1487 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 1488 | QMessageLogger(__FILE__, 1760, __PRETTY_FUNCTION__).warning("QMenuBar::setCornerWidget: Only TopLeftCorner and TopRightCorner are supported"); | - | ||||||||||||||||||||||||
| 1489 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1490 | } | - | ||||||||||||||||||||||||
| 1491 | - | |||||||||||||||||||||||||
| 1492 | if (w
| 0 | ||||||||||||||||||||||||
| 1493 | w->setParent(this); | - | ||||||||||||||||||||||||
| 1494 | w->installEventFilter(this); | - | ||||||||||||||||||||||||
| 1495 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1496 | - | |||||||||||||||||||||||||
| 1497 | d->_q_updateLayout(); | - | ||||||||||||||||||||||||
| 1498 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1499 | QWidget *QMenuBar::cornerWidget(Qt::Corner corner) const | - | ||||||||||||||||||||||||
| 1500 | { | - | ||||||||||||||||||||||||
| 1501 | const QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1502 | QWidget *w = 0; | - | ||||||||||||||||||||||||
| 1503 | switch(corner) { | - | ||||||||||||||||||||||||
| 1504 | case never executed: Qt::TopLeftCorner:case Qt::TopLeftCorner:never executed: case Qt::TopLeftCorner: | 0 | ||||||||||||||||||||||||
| 1505 | w = d->leftWidget; | - | ||||||||||||||||||||||||
| 1506 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1507 | case never executed: Qt::TopRightCorner:case Qt::TopRightCorner:never executed: case Qt::TopRightCorner: | 0 | ||||||||||||||||||||||||
| 1508 | w = d->rightWidget; | - | ||||||||||||||||||||||||
| 1509 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1510 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 1511 | QMessageLogger(__FILE__, 1791, __PRETTY_FUNCTION__).warning("QMenuBar::cornerWidget: Only TopLeftCorner and TopRightCorner are supported"); | - | ||||||||||||||||||||||||
| 1512 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1513 | } | - | ||||||||||||||||||||||||
| 1514 | - | |||||||||||||||||||||||||
| 1515 | return never executed: w;return w;never executed: return w; | 0 | ||||||||||||||||||||||||
| 1516 | } | - | ||||||||||||||||||||||||
| 1517 | void QMenuBar::setNativeMenuBar(bool nativeMenuBar) | - | ||||||||||||||||||||||||
| 1518 | { | - | ||||||||||||||||||||||||
| 1519 | QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1520 | if (nativeMenuBar != bool(d->platformMenuBar)
| 0 | ||||||||||||||||||||||||
| 1521 | if (!nativeMenuBar
| 0 | ||||||||||||||||||||||||
| 1522 | delete d->platformMenuBar; | - | ||||||||||||||||||||||||
| 1523 | d->platformMenuBar = 0; | - | ||||||||||||||||||||||||
| 1524 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1525 | if (!d->platformMenuBar
| 0 | ||||||||||||||||||||||||
| 1526 | d->platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar(); never executed: d->platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar(); | 0 | ||||||||||||||||||||||||
| 1527 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1528 | - | |||||||||||||||||||||||||
| 1529 | updateGeometry(); | - | ||||||||||||||||||||||||
| 1530 | if (!nativeMenuBar
| 0 | ||||||||||||||||||||||||
| 1531 | setVisible(true); never executed: setVisible(true); | 0 | ||||||||||||||||||||||||
| 1532 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1533 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1534 | - | |||||||||||||||||||||||||
| 1535 | bool QMenuBar::isNativeMenuBar() const | - | ||||||||||||||||||||||||
| 1536 | { | - | ||||||||||||||||||||||||
| 1537 | const QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1538 | return never executed: bool(d->platformMenuBar);return bool(d->platformMenuBar);never executed: return bool(d->platformMenuBar); | 0 | ||||||||||||||||||||||||
| 1539 | } | - | ||||||||||||||||||||||||
| 1540 | - | |||||||||||||||||||||||||
| 1541 | - | |||||||||||||||||||||||||
| 1542 | - | |||||||||||||||||||||||||
| 1543 | - | |||||||||||||||||||||||||
| 1544 | QPlatformMenuBar *QMenuBar::platformMenuBar() | - | ||||||||||||||||||||||||
| 1545 | { | - | ||||||||||||||||||||||||
| 1546 | const QMenuBarPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1547 | return never executed: d->platformMenuBar;return d->platformMenuBar;never executed: return d->platformMenuBar; | 0 | ||||||||||||||||||||||||
| 1548 | } | - | ||||||||||||||||||||||||
| 1549 | - | |||||||||||||||||||||||||
| 1550 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |