| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qtoolbutton.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | class QToolButtonPrivate : public QAbstractButtonPrivate | - | ||||||||||||||||||
| 7 | { | - | ||||||||||||||||||
| 8 | inline QToolButton* q_func() { return static_cast<QToolButton *>(q_ptr); } inline const QToolButton* q_func() const { return static_cast<const QToolButton *>(q_ptr); } friend class QToolButton; | - | ||||||||||||||||||
| 9 | public: | - | ||||||||||||||||||
| 10 | void init(); | - | ||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | void _q_buttonPressed(); | - | ||||||||||||||||||
| 13 | void _q_buttonReleased(); | - | ||||||||||||||||||
| 14 | void popupTimerDone(); | - | ||||||||||||||||||
| 15 | void _q_updateButtonDown(); | - | ||||||||||||||||||
| 16 | void _q_menuTriggered(QAction *); | - | ||||||||||||||||||
| 17 | - | |||||||||||||||||||
| 18 | bool updateHoverControl(const QPoint &pos); | - | ||||||||||||||||||
| 19 | void _q_actionTriggered(); | - | ||||||||||||||||||
| 20 | QStyle::SubControl newHoverControl(const QPoint &pos); | - | ||||||||||||||||||
| 21 | QStyle::SubControl hoverControl; | - | ||||||||||||||||||
| 22 | QRect hoverRect; | - | ||||||||||||||||||
| 23 | QPointer<QAction> menuAction; | - | ||||||||||||||||||
| 24 | QBasicTimer popupTimer; | - | ||||||||||||||||||
| 25 | int delay; | - | ||||||||||||||||||
| 26 | Qt::ArrowType arrowType; | - | ||||||||||||||||||
| 27 | Qt::ToolButtonStyle toolButtonStyle; | - | ||||||||||||||||||
| 28 | QToolButton::ToolButtonPopupMode popupMode; | - | ||||||||||||||||||
| 29 | enum { NoButtonPressed=0, MenuButtonPressed=1, ToolButtonPressed=2 }; | - | ||||||||||||||||||
| 30 | uint buttonPressed : 2; | - | ||||||||||||||||||
| 31 | uint menuButtonDown : 1; | - | ||||||||||||||||||
| 32 | uint autoRaise : 1; | - | ||||||||||||||||||
| 33 | uint repeat : 1; | - | ||||||||||||||||||
| 34 | QAction *defaultAction; | - | ||||||||||||||||||
| 35 | - | |||||||||||||||||||
| 36 | bool hasMenu() const; | - | ||||||||||||||||||
| 37 | - | |||||||||||||||||||
| 38 | QList<QAction *> actionsCopy; | - | ||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | }; | - | ||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 | - | |||||||||||||||||||
| 43 | bool QToolButtonPrivate::hasMenu() const | - | ||||||||||||||||||
| 44 | { | - | ||||||||||||||||||
| 45 | return never executed: ((defaultAction && defaultAction->menu())return ((defaultAction && defaultAction->menu()) || (menuAction && menuAction->menu()) || actions.size() > (defaultAction ? 1 : 0));never executed: return ((defaultAction && defaultAction->menu()) || (menuAction && menuAction->menu()) || actions.size() > (defaultAction ? 1 : 0)); | 0 | ||||||||||||||||||
| 46 | || (menuAction && menuAction->menu()) never executed: return ((defaultAction && defaultAction->menu()) || (menuAction && menuAction->menu()) || actions.size() > (defaultAction ? 1 : 0)); | 0 | ||||||||||||||||||
| 47 | || actions.size() > (defaultAction ? 1 : 0)); never executed: return ((defaultAction && defaultAction->menu()) || (menuAction && menuAction->menu()) || actions.size() > (defaultAction ? 1 : 0)); | 0 | ||||||||||||||||||
| 48 | } | - | ||||||||||||||||||
| 49 | QToolButton::QToolButton(QWidget * parent) | - | ||||||||||||||||||
| 50 | : QAbstractButton(*new QToolButtonPrivate, parent) | - | ||||||||||||||||||
| 51 | { | - | ||||||||||||||||||
| 52 | QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 53 | d->init(); | - | ||||||||||||||||||
| 54 | } never executed: end of block | 0 | ||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | - | |||||||||||||||||||
| 57 | - | |||||||||||||||||||
| 58 | - | |||||||||||||||||||
| 59 | - | |||||||||||||||||||
| 60 | void QToolButtonPrivate::init() | - | ||||||||||||||||||
| 61 | { | - | ||||||||||||||||||
| 62 | QToolButton * const q = q_func(); | - | ||||||||||||||||||
| 63 | defaultAction = 0; | - | ||||||||||||||||||
| 64 | - | |||||||||||||||||||
| 65 | if (qobject_cast<QToolBar*>(parent)
| 0 | ||||||||||||||||||
| 66 | autoRaise = true; never executed: autoRaise = true; | 0 | ||||||||||||||||||
| 67 | else | - | ||||||||||||||||||
| 68 | - | |||||||||||||||||||
| 69 | autoRaise = false; never executed: autoRaise = false; | 0 | ||||||||||||||||||
| 70 | arrowType = Qt::NoArrow; | - | ||||||||||||||||||
| 71 | menuButtonDown = false; | - | ||||||||||||||||||
| 72 | popupMode = QToolButton::DelayedPopup; | - | ||||||||||||||||||
| 73 | buttonPressed = QToolButtonPrivate::NoButtonPressed; | - | ||||||||||||||||||
| 74 | - | |||||||||||||||||||
| 75 | toolButtonStyle = Qt::ToolButtonIconOnly; | - | ||||||||||||||||||
| 76 | hoverControl = QStyle::SC_None; | - | ||||||||||||||||||
| 77 | - | |||||||||||||||||||
| 78 | q->setFocusPolicy(Qt::TabFocus); | - | ||||||||||||||||||
| 79 | q->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed, | - | ||||||||||||||||||
| 80 | QSizePolicy::ToolButton)); | - | ||||||||||||||||||
| 81 | - | |||||||||||||||||||
| 82 | - | |||||||||||||||||||
| 83 | QObject::connect(q, qFlagLocation("2""pressed()" "\0" __FILE__ ":" "219"), q, qFlagLocation("1""_q_buttonPressed()" "\0" __FILE__ ":" "219")); | - | ||||||||||||||||||
| 84 | QObject::connect(q, qFlagLocation("2""released()" "\0" __FILE__ ":" "220"), q, qFlagLocation("1""_q_buttonReleased()" "\0" __FILE__ ":" "220")); | - | ||||||||||||||||||
| 85 | - | |||||||||||||||||||
| 86 | - | |||||||||||||||||||
| 87 | setLayoutItemMargins(QStyle::SE_ToolButtonLayoutItem); | - | ||||||||||||||||||
| 88 | delay = q->style()->styleHint(QStyle::SH_ToolButton_PopupDelay, 0, q); | - | ||||||||||||||||||
| 89 | } never executed: end of block | 0 | ||||||||||||||||||
| 90 | void QToolButton::initStyleOption(QStyleOptionToolButton *option) const | - | ||||||||||||||||||
| 91 | { | - | ||||||||||||||||||
| 92 | if (!option
| 0 | ||||||||||||||||||
| 93 | return; never executed: return; | 0 | ||||||||||||||||||
| 94 | - | |||||||||||||||||||
| 95 | const QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 96 | option->initFrom(this); | - | ||||||||||||||||||
| 97 | bool forceNoText = false; | - | ||||||||||||||||||
| 98 | option->iconSize = iconSize(); | - | ||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | - | |||||||||||||||||||
| 101 | if (parentWidget()
| 0 | ||||||||||||||||||
| 102 | if (QToolBar *toolBar = qobject_cast<QToolBar *>(parentWidget())
| 0 | ||||||||||||||||||
| 103 | option->iconSize = toolBar->iconSize(); | - | ||||||||||||||||||
| 104 | } never executed: end of block | 0 | ||||||||||||||||||
| 105 | } never executed: end of block | 0 | ||||||||||||||||||
| 106 | - | |||||||||||||||||||
| 107 | - | |||||||||||||||||||
| 108 | if (!forceNoText
| 0 | ||||||||||||||||||
| 109 | option->text = d->text; never executed: option->text = d->text; | 0 | ||||||||||||||||||
| 110 | option->icon = d->icon; | - | ||||||||||||||||||
| 111 | option->arrowType = d->arrowType; | - | ||||||||||||||||||
| 112 | if (d->down
| 0 | ||||||||||||||||||
| 113 | option->state |= QStyle::State_Sunken; never executed: option->state |= QStyle::State_Sunken; | 0 | ||||||||||||||||||
| 114 | if (d->checked
| 0 | ||||||||||||||||||
| 115 | option->state |= QStyle::State_On; never executed: option->state |= QStyle::State_On; | 0 | ||||||||||||||||||
| 116 | if (d->autoRaise
| 0 | ||||||||||||||||||
| 117 | option->state |= QStyle::State_AutoRaise; never executed: option->state |= QStyle::State_AutoRaise; | 0 | ||||||||||||||||||
| 118 | if (!d->checked
| 0 | ||||||||||||||||||
| 119 | option->state |= QStyle::State_Raised; never executed: option->state |= QStyle::State_Raised; | 0 | ||||||||||||||||||
| 120 | - | |||||||||||||||||||
| 121 | option->subControls = QStyle::SC_ToolButton; | - | ||||||||||||||||||
| 122 | option->activeSubControls = QStyle::SC_None; | - | ||||||||||||||||||
| 123 | - | |||||||||||||||||||
| 124 | option->features = QStyleOptionToolButton::None; | - | ||||||||||||||||||
| 125 | if (d->popupMode == QToolButton::MenuButtonPopup
| 0 | ||||||||||||||||||
| 126 | option->subControls |= QStyle::SC_ToolButtonMenu; | - | ||||||||||||||||||
| 127 | option->features |= QStyleOptionToolButton::MenuButtonPopup; | - | ||||||||||||||||||
| 128 | } never executed: end of block | 0 | ||||||||||||||||||
| 129 | if (option->state & QStyle::State_MouseOver
| 0 | ||||||||||||||||||
| 130 | option->activeSubControls = d->hoverControl; | - | ||||||||||||||||||
| 131 | } never executed: end of block | 0 | ||||||||||||||||||
| 132 | if (d->menuButtonDown
| 0 | ||||||||||||||||||
| 133 | option->state |= QStyle::State_Sunken; | - | ||||||||||||||||||
| 134 | option->activeSubControls |= QStyle::SC_ToolButtonMenu; | - | ||||||||||||||||||
| 135 | } never executed: end of block | 0 | ||||||||||||||||||
| 136 | if (d->down
| 0 | ||||||||||||||||||
| 137 | option->state |= QStyle::State_Sunken; | - | ||||||||||||||||||
| 138 | option->activeSubControls |= QStyle::SC_ToolButton; | - | ||||||||||||||||||
| 139 | } never executed: end of block | 0 | ||||||||||||||||||
| 140 | - | |||||||||||||||||||
| 141 | - | |||||||||||||||||||
| 142 | if (d->arrowType != Qt::NoArrow
| 0 | ||||||||||||||||||
| 143 | option->features |= QStyleOptionToolButton::Arrow; never executed: option->features |= QStyleOptionToolButton::Arrow; | 0 | ||||||||||||||||||
| 144 | if (d->popupMode == QToolButton::DelayedPopup
| 0 | ||||||||||||||||||
| 145 | option->features |= QStyleOptionToolButton::PopupDelay; never executed: option->features |= QStyleOptionToolButton::PopupDelay; | 0 | ||||||||||||||||||
| 146 | - | |||||||||||||||||||
| 147 | if (d->hasMenu()
| 0 | ||||||||||||||||||
| 148 | option->features |= QStyleOptionToolButton::HasMenu; never executed: option->features |= QStyleOptionToolButton::HasMenu; | 0 | ||||||||||||||||||
| 149 | - | |||||||||||||||||||
| 150 | if (d->toolButtonStyle == Qt::ToolButtonFollowStyle
| 0 | ||||||||||||||||||
| 151 | option->toolButtonStyle = Qt::ToolButtonStyle(style()->styleHint(QStyle::SH_ToolButtonStyle, option, this)); | - | ||||||||||||||||||
| 152 | } never executed: elseend of block | 0 | ||||||||||||||||||
| 153 | option->toolButtonStyle = d->toolButtonStyle; never executed: option->toolButtonStyle = d->toolButtonStyle; | 0 | ||||||||||||||||||
| 154 | - | |||||||||||||||||||
| 155 | if (option->toolButtonStyle == Qt::ToolButtonTextBesideIcon
| 0 | ||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | if (d->defaultAction
| 0 | ||||||||||||||||||
| 158 | option->toolButtonStyle = Qt::ToolButtonIconOnly; never executed: option->toolButtonStyle = Qt::ToolButtonIconOnly; | 0 | ||||||||||||||||||
| 159 | } never executed: end of block | 0 | ||||||||||||||||||
| 160 | - | |||||||||||||||||||
| 161 | if (d->icon.isNull()
| 0 | ||||||||||||||||||
| 162 | if (!d->text.isEmpty()
| 0 | ||||||||||||||||||
| 163 | option->toolButtonStyle = Qt::ToolButtonTextOnly; never executed: option->toolButtonStyle = Qt::ToolButtonTextOnly; | 0 | ||||||||||||||||||
| 164 | else if (option->toolButtonStyle != Qt::ToolButtonTextOnly
| 0 | ||||||||||||||||||
| 165 | option->toolButtonStyle = Qt::ToolButtonIconOnly; never executed: option->toolButtonStyle = Qt::ToolButtonIconOnly; | 0 | ||||||||||||||||||
| 166 | } never executed: end of block | 0 | ||||||||||||||||||
| 167 | - | |||||||||||||||||||
| 168 | option->pos = pos(); | - | ||||||||||||||||||
| 169 | option->font = font(); | - | ||||||||||||||||||
| 170 | } never executed: end of block | 0 | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | - | |||||||||||||||||||
| 173 | - | |||||||||||||||||||
| 174 | - | |||||||||||||||||||
| 175 | - | |||||||||||||||||||
| 176 | QToolButton::~QToolButton() | - | ||||||||||||||||||
| 177 | { | - | ||||||||||||||||||
| 178 | } | - | ||||||||||||||||||
| 179 | - | |||||||||||||||||||
| 180 | - | |||||||||||||||||||
| 181 | - | |||||||||||||||||||
| 182 | - | |||||||||||||||||||
| 183 | QSize QToolButton::sizeHint() const | - | ||||||||||||||||||
| 184 | { | - | ||||||||||||||||||
| 185 | const QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 186 | if (d->sizeHint.isValid()
| 0 | ||||||||||||||||||
| 187 | return never executed: d->sizeHint;return d->sizeHint;never executed: return d->sizeHint; | 0 | ||||||||||||||||||
| 188 | ensurePolished(); | - | ||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | int w = 0, h = 0; | - | ||||||||||||||||||
| 191 | QStyleOptionToolButton opt; | - | ||||||||||||||||||
| 192 | initStyleOption(&opt); | - | ||||||||||||||||||
| 193 | - | |||||||||||||||||||
| 194 | QFontMetrics fm = fontMetrics(); | - | ||||||||||||||||||
| 195 | if (opt.toolButtonStyle != Qt::ToolButtonTextOnly
| 0 | ||||||||||||||||||
| 196 | QSize icon = opt.iconSize; | - | ||||||||||||||||||
| 197 | w = icon.width(); | - | ||||||||||||||||||
| 198 | h = icon.height(); | - | ||||||||||||||||||
| 199 | } never executed: end of block | 0 | ||||||||||||||||||
| 200 | - | |||||||||||||||||||
| 201 | if (opt.toolButtonStyle != Qt::ToolButtonIconOnly
| 0 | ||||||||||||||||||
| 202 | QSize textSize = fm.size(Qt::TextShowMnemonic, text()); | - | ||||||||||||||||||
| 203 | textSize.setWidth(textSize.width() + fm.width(QLatin1Char(' '))*2); | - | ||||||||||||||||||
| 204 | if (opt.toolButtonStyle == Qt::ToolButtonTextUnderIcon
| 0 | ||||||||||||||||||
| 205 | h += 4 + textSize.height(); | - | ||||||||||||||||||
| 206 | if (textSize.width() > w
| 0 | ||||||||||||||||||
| 207 | w = textSize.width(); never executed: w = textSize.width(); | 0 | ||||||||||||||||||
| 208 | } never executed: else if (opt.toolButtonStyle == Qt::ToolButtonTextBesideIconend of block
| 0 | ||||||||||||||||||
| 209 | w += 4 + textSize.width(); | - | ||||||||||||||||||
| 210 | if (textSize.height() > h
| 0 | ||||||||||||||||||
| 211 | h = textSize.height(); never executed: h = textSize.height(); | 0 | ||||||||||||||||||
| 212 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 213 | w = textSize.width(); | - | ||||||||||||||||||
| 214 | h = textSize.height(); | - | ||||||||||||||||||
| 215 | } never executed: end of block | 0 | ||||||||||||||||||
| 216 | } | - | ||||||||||||||||||
| 217 | - | |||||||||||||||||||
| 218 | opt.rect.setSize(QSize(w, h)); | - | ||||||||||||||||||
| 219 | if (d->popupMode == MenuButtonPopup
| 0 | ||||||||||||||||||
| 220 | w += style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, this); never executed: w += style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, this); | 0 | ||||||||||||||||||
| 221 | - | |||||||||||||||||||
| 222 | d->sizeHint = style()->sizeFromContents(QStyle::CT_ToolButton, &opt, QSize(w, h), this). | - | ||||||||||||||||||
| 223 | expandedTo(QApplication::globalStrut()); | - | ||||||||||||||||||
| 224 | return never executed: d->sizeHint;return d->sizeHint;never executed: return d->sizeHint; | 0 | ||||||||||||||||||
| 225 | } | - | ||||||||||||||||||
| 226 | - | |||||||||||||||||||
| 227 | - | |||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | - | |||||||||||||||||||
| 230 | QSize QToolButton::minimumSizeHint() const | - | ||||||||||||||||||
| 231 | { | - | ||||||||||||||||||
| 232 | return never executed: sizeHint();return sizeHint();never executed: return sizeHint(); | 0 | ||||||||||||||||||
| 233 | } | - | ||||||||||||||||||
| 234 | Qt::ToolButtonStyle QToolButton::toolButtonStyle() const | - | ||||||||||||||||||
| 235 | { | - | ||||||||||||||||||
| 236 | const QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 237 | return never executed: d->toolButtonStyle;return d->toolButtonStyle;never executed: return d->toolButtonStyle; | 0 | ||||||||||||||||||
| 238 | } | - | ||||||||||||||||||
| 239 | - | |||||||||||||||||||
| 240 | Qt::ArrowType QToolButton::arrowType() const | - | ||||||||||||||||||
| 241 | { | - | ||||||||||||||||||
| 242 | const QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 243 | return never executed: d->arrowType;return d->arrowType;never executed: return d->arrowType; | 0 | ||||||||||||||||||
| 244 | } | - | ||||||||||||||||||
| 245 | - | |||||||||||||||||||
| 246 | - | |||||||||||||||||||
| 247 | void QToolButton::setToolButtonStyle(Qt::ToolButtonStyle style) | - | ||||||||||||||||||
| 248 | { | - | ||||||||||||||||||
| 249 | QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 250 | if (d->toolButtonStyle == style
| 0 | ||||||||||||||||||
| 251 | return; never executed: return; | 0 | ||||||||||||||||||
| 252 | - | |||||||||||||||||||
| 253 | d->toolButtonStyle = style; | - | ||||||||||||||||||
| 254 | d->sizeHint = QSize(); | - | ||||||||||||||||||
| 255 | updateGeometry(); | - | ||||||||||||||||||
| 256 | if (isVisible()
| 0 | ||||||||||||||||||
| 257 | update(); | - | ||||||||||||||||||
| 258 | } never executed: end of block | 0 | ||||||||||||||||||
| 259 | } never executed: end of block | 0 | ||||||||||||||||||
| 260 | - | |||||||||||||||||||
| 261 | void QToolButton::setArrowType(Qt::ArrowType type) | - | ||||||||||||||||||
| 262 | { | - | ||||||||||||||||||
| 263 | QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 264 | if (d->arrowType == type
| 0 | ||||||||||||||||||
| 265 | return; never executed: return; | 0 | ||||||||||||||||||
| 266 | - | |||||||||||||||||||
| 267 | d->arrowType = type; | - | ||||||||||||||||||
| 268 | d->sizeHint = QSize(); | - | ||||||||||||||||||
| 269 | updateGeometry(); | - | ||||||||||||||||||
| 270 | if (isVisible()
| 0 | ||||||||||||||||||
| 271 | update(); | - | ||||||||||||||||||
| 272 | } never executed: end of block | 0 | ||||||||||||||||||
| 273 | } never executed: end of block | 0 | ||||||||||||||||||
| 274 | - | |||||||||||||||||||
| 275 | - | |||||||||||||||||||
| 276 | - | |||||||||||||||||||
| 277 | - | |||||||||||||||||||
| 278 | - | |||||||||||||||||||
| 279 | - | |||||||||||||||||||
| 280 | void QToolButton::paintEvent(QPaintEvent *) | - | ||||||||||||||||||
| 281 | { | - | ||||||||||||||||||
| 282 | QStylePainter p(this); | - | ||||||||||||||||||
| 283 | QStyleOptionToolButton opt; | - | ||||||||||||||||||
| 284 | initStyleOption(&opt); | - | ||||||||||||||||||
| 285 | p.drawComplexControl(QStyle::CC_ToolButton, opt); | - | ||||||||||||||||||
| 286 | } never executed: end of block | 0 | ||||||||||||||||||
| 287 | - | |||||||||||||||||||
| 288 | - | |||||||||||||||||||
| 289 | - | |||||||||||||||||||
| 290 | - | |||||||||||||||||||
| 291 | void QToolButton::actionEvent(QActionEvent *event) | - | ||||||||||||||||||
| 292 | { | - | ||||||||||||||||||
| 293 | QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 294 | QAction *action = event->action(); | - | ||||||||||||||||||
| 295 | switch (event->type()) { | - | ||||||||||||||||||
| 296 | case never executed: QEvent::ActionChanged:case QEvent::ActionChanged:never executed: case QEvent::ActionChanged: | 0 | ||||||||||||||||||
| 297 | if (action == d->defaultAction
| 0 | ||||||||||||||||||
| 298 | setDefaultAction(action); never executed: setDefaultAction(action); | 0 | ||||||||||||||||||
| 299 | break; never executed: break; | 0 | ||||||||||||||||||
| 300 | case never executed: QEvent::ActionAdded:case QEvent::ActionAdded:never executed: case QEvent::ActionAdded: | 0 | ||||||||||||||||||
| 301 | connect(action, qFlagLocation("2""triggered()" "\0" __FILE__ ":" "470"), this, qFlagLocation("1""_q_actionTriggered()" "\0" __FILE__ ":" "470")); | - | ||||||||||||||||||
| 302 | break; never executed: break; | 0 | ||||||||||||||||||
| 303 | case never executed: QEvent::ActionRemoved:case QEvent::ActionRemoved:never executed: case QEvent::ActionRemoved: | 0 | ||||||||||||||||||
| 304 | if (d->defaultAction == action
| 0 | ||||||||||||||||||
| 305 | d->defaultAction = 0; never executed: d->defaultAction = 0; | 0 | ||||||||||||||||||
| 306 | - | |||||||||||||||||||
| 307 | if (action == d->menuAction
| 0 | ||||||||||||||||||
| 308 | d->menuAction = 0; never executed: d->menuAction = 0; | 0 | ||||||||||||||||||
| 309 | - | |||||||||||||||||||
| 310 | action->disconnect(this); | - | ||||||||||||||||||
| 311 | break; never executed: break; | 0 | ||||||||||||||||||
| 312 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 313 | ; | - | ||||||||||||||||||
| 314 | } never executed: end of block | 0 | ||||||||||||||||||
| 315 | QAbstractButton::actionEvent(event); | - | ||||||||||||||||||
| 316 | } never executed: end of block | 0 | ||||||||||||||||||
| 317 | - | |||||||||||||||||||
| 318 | QStyle::SubControl QToolButtonPrivate::newHoverControl(const QPoint &pos) | - | ||||||||||||||||||
| 319 | { | - | ||||||||||||||||||
| 320 | QToolButton * const q = q_func(); | - | ||||||||||||||||||
| 321 | QStyleOptionToolButton opt; | - | ||||||||||||||||||
| 322 | q->initStyleOption(&opt); | - | ||||||||||||||||||
| 323 | opt.subControls = QStyle::SC_All; | - | ||||||||||||||||||
| 324 | hoverControl = q->style()->hitTestComplexControl(QStyle::CC_ToolButton, &opt, pos, q); | - | ||||||||||||||||||
| 325 | if (hoverControl == QStyle::SC_None
| 0 | ||||||||||||||||||
| 326 | hoverRect = QRect(); never executed: hoverRect = QRect(); | 0 | ||||||||||||||||||
| 327 | else | - | ||||||||||||||||||
| 328 | hoverRect = q->style()->subControlRect(QStyle::CC_ToolButton, &opt, hoverControl, q); never executed: hoverRect = q->style()->subControlRect(QStyle::CC_ToolButton, &opt, hoverControl, q); | 0 | ||||||||||||||||||
| 329 | return never executed: hoverControl;return hoverControl;never executed: return hoverControl; | 0 | ||||||||||||||||||
| 330 | } | - | ||||||||||||||||||
| 331 | - | |||||||||||||||||||
| 332 | bool QToolButtonPrivate::updateHoverControl(const QPoint &pos) | - | ||||||||||||||||||
| 333 | { | - | ||||||||||||||||||
| 334 | QToolButton * const q = q_func(); | - | ||||||||||||||||||
| 335 | QRect lastHoverRect = hoverRect; | - | ||||||||||||||||||
| 336 | QStyle::SubControl lastHoverControl = hoverControl; | - | ||||||||||||||||||
| 337 | bool doesHover = q->testAttribute(Qt::WA_Hover); | - | ||||||||||||||||||
| 338 | if (lastHoverControl != newHoverControl(pos)
| 0 | ||||||||||||||||||
| 339 | q->update(lastHoverRect); | - | ||||||||||||||||||
| 340 | q->update(hoverRect); | - | ||||||||||||||||||
| 341 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 342 | } | - | ||||||||||||||||||
| 343 | return never executed: !doesHover;return !doesHover;never executed: return !doesHover; | 0 | ||||||||||||||||||
| 344 | } | - | ||||||||||||||||||
| 345 | - | |||||||||||||||||||
| 346 | void QToolButtonPrivate::_q_actionTriggered() | - | ||||||||||||||||||
| 347 | { | - | ||||||||||||||||||
| 348 | QToolButton * const q = q_func(); | - | ||||||||||||||||||
| 349 | if (QAction *action = qobject_cast<QAction *>(q->sender())
| 0 | ||||||||||||||||||
| 350 | q->triggered(action); never executed: q->triggered(action); | 0 | ||||||||||||||||||
| 351 | } never executed: end of block | 0 | ||||||||||||||||||
| 352 | - | |||||||||||||||||||
| 353 | - | |||||||||||||||||||
| 354 | - | |||||||||||||||||||
| 355 | - | |||||||||||||||||||
| 356 | void QToolButton::enterEvent(QEvent * e) | - | ||||||||||||||||||
| 357 | { | - | ||||||||||||||||||
| 358 | QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 359 | if (d->autoRaise
| 0 | ||||||||||||||||||
| 360 | update(); never executed: update(); | 0 | ||||||||||||||||||
| 361 | if (d->defaultAction
| 0 | ||||||||||||||||||
| 362 | d->defaultAction->hover(); never executed: d->defaultAction->hover(); | 0 | ||||||||||||||||||
| 363 | QAbstractButton::enterEvent(e); | - | ||||||||||||||||||
| 364 | } never executed: end of block | 0 | ||||||||||||||||||
| 365 | - | |||||||||||||||||||
| 366 | - | |||||||||||||||||||
| 367 | - | |||||||||||||||||||
| 368 | - | |||||||||||||||||||
| 369 | - | |||||||||||||||||||
| 370 | void QToolButton::leaveEvent(QEvent * e) | - | ||||||||||||||||||
| 371 | { | - | ||||||||||||||||||
| 372 | QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 373 | if (d->autoRaise
| 0 | ||||||||||||||||||
| 374 | update(); never executed: update(); | 0 | ||||||||||||||||||
| 375 | - | |||||||||||||||||||
| 376 | QAbstractButton::leaveEvent(e); | - | ||||||||||||||||||
| 377 | } never executed: end of block | 0 | ||||||||||||||||||
| 378 | - | |||||||||||||||||||
| 379 | - | |||||||||||||||||||
| 380 | - | |||||||||||||||||||
| 381 | - | |||||||||||||||||||
| 382 | - | |||||||||||||||||||
| 383 | void QToolButton::timerEvent(QTimerEvent *e) | - | ||||||||||||||||||
| 384 | { | - | ||||||||||||||||||
| 385 | - | |||||||||||||||||||
| 386 | QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 387 | if (e->timerId() == d->popupTimer.timerId()
| 0 | ||||||||||||||||||
| 388 | d->popupTimerDone(); | - | ||||||||||||||||||
| 389 | return; never executed: return; | 0 | ||||||||||||||||||
| 390 | } | - | ||||||||||||||||||
| 391 | - | |||||||||||||||||||
| 392 | QAbstractButton::timerEvent(e); | - | ||||||||||||||||||
| 393 | } never executed: end of block | 0 | ||||||||||||||||||
| 394 | - | |||||||||||||||||||
| 395 | - | |||||||||||||||||||
| 396 | - | |||||||||||||||||||
| 397 | - | |||||||||||||||||||
| 398 | - | |||||||||||||||||||
| 399 | void QToolButton::changeEvent(QEvent *e) | - | ||||||||||||||||||
| 400 | { | - | ||||||||||||||||||
| 401 | - | |||||||||||||||||||
| 402 | QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 403 | if (e->type() == QEvent::ParentChange
| 0 | ||||||||||||||||||
| 404 | if (qobject_cast<QToolBar*>(parentWidget())
| 0 | ||||||||||||||||||
| 405 | d->autoRaise = true; never executed: d->autoRaise = true; | 0 | ||||||||||||||||||
| 406 | } never executed: else if (e->type() == QEvent::StyleChangeend of block
| 0 | ||||||||||||||||||
| 407 | - | |||||||||||||||||||
| 408 | - | |||||||||||||||||||
| 409 | - | |||||||||||||||||||
| 410 | ) { | - | ||||||||||||||||||
| 411 | d->delay = style()->styleHint(QStyle::SH_ToolButton_PopupDelay, 0, this); | - | ||||||||||||||||||
| 412 | d->setLayoutItemMargins(QStyle::SE_ToolButtonLayoutItem); | - | ||||||||||||||||||
| 413 | } never executed: end of block | 0 | ||||||||||||||||||
| 414 | - | |||||||||||||||||||
| 415 | QAbstractButton::changeEvent(e); | - | ||||||||||||||||||
| 416 | } never executed: end of block | 0 | ||||||||||||||||||
| 417 | - | |||||||||||||||||||
| 418 | - | |||||||||||||||||||
| 419 | - | |||||||||||||||||||
| 420 | - | |||||||||||||||||||
| 421 | void QToolButton::mousePressEvent(QMouseEvent *e) | - | ||||||||||||||||||
| 422 | { | - | ||||||||||||||||||
| 423 | QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 424 | - | |||||||||||||||||||
| 425 | QStyleOptionToolButton opt; | - | ||||||||||||||||||
| 426 | initStyleOption(&opt); | - | ||||||||||||||||||
| 427 | if (e->button() == Qt::LeftButton
| 0 | ||||||||||||||||||
| 428 | QRect popupr = style()->subControlRect(QStyle::CC_ToolButton, &opt, | - | ||||||||||||||||||
| 429 | QStyle::SC_ToolButtonMenu, this); | - | ||||||||||||||||||
| 430 | if (popupr.isValid()
| 0 | ||||||||||||||||||
| 431 | d->buttonPressed = QToolButtonPrivate::MenuButtonPressed; | - | ||||||||||||||||||
| 432 | showMenu(); | - | ||||||||||||||||||
| 433 | return; never executed: return; | 0 | ||||||||||||||||||
| 434 | } | - | ||||||||||||||||||
| 435 | } never executed: end of block | 0 | ||||||||||||||||||
| 436 | - | |||||||||||||||||||
| 437 | d->buttonPressed = QToolButtonPrivate::ToolButtonPressed; | - | ||||||||||||||||||
| 438 | QAbstractButton::mousePressEvent(e); | - | ||||||||||||||||||
| 439 | } never executed: end of block | 0 | ||||||||||||||||||
| 440 | - | |||||||||||||||||||
| 441 | - | |||||||||||||||||||
| 442 | - | |||||||||||||||||||
| 443 | - | |||||||||||||||||||
| 444 | void QToolButton::mouseReleaseEvent(QMouseEvent *e) | - | ||||||||||||||||||
| 445 | { | - | ||||||||||||||||||
| 446 | QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 447 | QAbstractButton::mouseReleaseEvent(e); | - | ||||||||||||||||||
| 448 | d->buttonPressed = QToolButtonPrivate::NoButtonPressed; | - | ||||||||||||||||||
| 449 | } never executed: end of block | 0 | ||||||||||||||||||
| 450 | - | |||||||||||||||||||
| 451 | - | |||||||||||||||||||
| 452 | - | |||||||||||||||||||
| 453 | - | |||||||||||||||||||
| 454 | bool QToolButton::hitButton(const QPoint &pos) const | - | ||||||||||||||||||
| 455 | { | - | ||||||||||||||||||
| 456 | const QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 457 | if(QAbstractButton::hitButton(pos)
| 0 | ||||||||||||||||||
| 458 | return never executed: (d->buttonPressed != QToolButtonPrivate::MenuButtonPressed);return (d->buttonPressed != QToolButtonPrivate::MenuButtonPressed);never executed: return (d->buttonPressed != QToolButtonPrivate::MenuButtonPressed); | 0 | ||||||||||||||||||
| 459 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 460 | } | - | ||||||||||||||||||
| 461 | void QToolButton::setMenu(QMenu* menu) | - | ||||||||||||||||||
| 462 | { | - | ||||||||||||||||||
| 463 | QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 464 | - | |||||||||||||||||||
| 465 | if (d->menuAction == (menu
| 0 | ||||||||||||||||||
| 466 | return; never executed: return; | 0 | ||||||||||||||||||
| 467 | - | |||||||||||||||||||
| 468 | if (d->menuAction
| 0 | ||||||||||||||||||
| 469 | removeAction(d->menuAction); never executed: removeAction(d->menuAction); | 0 | ||||||||||||||||||
| 470 | - | |||||||||||||||||||
| 471 | if (menu
| 0 | ||||||||||||||||||
| 472 | d->menuAction = menu->menuAction(); | - | ||||||||||||||||||
| 473 | addAction(d->menuAction); | - | ||||||||||||||||||
| 474 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 475 | d->menuAction = 0; | - | ||||||||||||||||||
| 476 | } never executed: end of block | 0 | ||||||||||||||||||
| 477 | - | |||||||||||||||||||
| 478 | - | |||||||||||||||||||
| 479 | d->sizeHint = QSize(); | - | ||||||||||||||||||
| 480 | updateGeometry(); | - | ||||||||||||||||||
| 481 | update(); | - | ||||||||||||||||||
| 482 | } never executed: end of block | 0 | ||||||||||||||||||
| 483 | - | |||||||||||||||||||
| 484 | - | |||||||||||||||||||
| 485 | - | |||||||||||||||||||
| 486 | - | |||||||||||||||||||
| 487 | - | |||||||||||||||||||
| 488 | - | |||||||||||||||||||
| 489 | QMenu* QToolButton::menu() const | - | ||||||||||||||||||
| 490 | { | - | ||||||||||||||||||
| 491 | const QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 492 | if (d->menuAction
| 0 | ||||||||||||||||||
| 493 | return never executed: d->menuAction->menu();return d->menuAction->menu();never executed: return d->menuAction->menu(); | 0 | ||||||||||||||||||
| 494 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 495 | } | - | ||||||||||||||||||
| 496 | - | |||||||||||||||||||
| 497 | - | |||||||||||||||||||
| 498 | - | |||||||||||||||||||
| 499 | - | |||||||||||||||||||
| 500 | - | |||||||||||||||||||
| 501 | - | |||||||||||||||||||
| 502 | void QToolButton::showMenu() | - | ||||||||||||||||||
| 503 | { | - | ||||||||||||||||||
| 504 | QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 505 | if (!d->hasMenu()
| 0 | ||||||||||||||||||
| 506 | d->menuButtonDown = false; | - | ||||||||||||||||||
| 507 | return; never executed: return; | 0 | ||||||||||||||||||
| 508 | } | - | ||||||||||||||||||
| 509 | - | |||||||||||||||||||
| 510 | if (d->menuButtonDown
| 0 | ||||||||||||||||||
| 511 | return; never executed: return; | 0 | ||||||||||||||||||
| 512 | - | |||||||||||||||||||
| 513 | - | |||||||||||||||||||
| 514 | d->menuButtonDown = true; | - | ||||||||||||||||||
| 515 | repaint(); | - | ||||||||||||||||||
| 516 | d->popupTimer.stop(); | - | ||||||||||||||||||
| 517 | d->popupTimerDone(); | - | ||||||||||||||||||
| 518 | } never executed: end of block | 0 | ||||||||||||||||||
| 519 | - | |||||||||||||||||||
| 520 | void QToolButtonPrivate::_q_buttonPressed() | - | ||||||||||||||||||
| 521 | { | - | ||||||||||||||||||
| 522 | QToolButton * const q = q_func(); | - | ||||||||||||||||||
| 523 | if (!hasMenu()
| 0 | ||||||||||||||||||
| 524 | return; never executed: return; | 0 | ||||||||||||||||||
| 525 | if (popupMode == QToolButton::MenuButtonPopup
| 0 | ||||||||||||||||||
| 526 | return; never executed: return; | 0 | ||||||||||||||||||
| 527 | else if (delay > 0
| 0 | ||||||||||||||||||
| 528 | popupTimer.start(delay, q); never executed: popupTimer.start(delay, q); | 0 | ||||||||||||||||||
| 529 | else if (delay == 0
| 0 | ||||||||||||||||||
| 530 | q->showMenu(); never executed: q->showMenu(); | 0 | ||||||||||||||||||
| 531 | } never executed: end of block | 0 | ||||||||||||||||||
| 532 | - | |||||||||||||||||||
| 533 | void QToolButtonPrivate::_q_buttonReleased() | - | ||||||||||||||||||
| 534 | { | - | ||||||||||||||||||
| 535 | popupTimer.stop(); | - | ||||||||||||||||||
| 536 | } never executed: end of block | 0 | ||||||||||||||||||
| 537 | - | |||||||||||||||||||
| 538 | void QToolButtonPrivate::popupTimerDone() | - | ||||||||||||||||||
| 539 | { | - | ||||||||||||||||||
| 540 | QToolButton * const q = q_func(); | - | ||||||||||||||||||
| 541 | popupTimer.stop(); | - | ||||||||||||||||||
| 542 | if (!menuButtonDown
| 0 | ||||||||||||||||||
| 543 | return; never executed: return; | 0 | ||||||||||||||||||
| 544 | - | |||||||||||||||||||
| 545 | menuButtonDown = true; | - | ||||||||||||||||||
| 546 | QPointer<QMenu> actualMenu; | - | ||||||||||||||||||
| 547 | bool mustDeleteActualMenu = false; | - | ||||||||||||||||||
| 548 | if(menuAction
| 0 | ||||||||||||||||||
| 549 | actualMenu = menuAction->menu(); | - | ||||||||||||||||||
| 550 | } never executed: else if (defaultActionend of block
| 0 | ||||||||||||||||||
| 551 | actualMenu = defaultAction->menu(); | - | ||||||||||||||||||
| 552 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 553 | actualMenu = new QMenu(q); | - | ||||||||||||||||||
| 554 | mustDeleteActualMenu = true; | - | ||||||||||||||||||
| 555 | for(int i = 0; i < actions.size()
| 0 | ||||||||||||||||||
| 556 | actualMenu->addAction(actions.at(i)); never executed: actualMenu->addAction(actions.at(i)); | 0 | ||||||||||||||||||
| 557 | } never executed: end of block | 0 | ||||||||||||||||||
| 558 | repeat = q->autoRepeat(); | - | ||||||||||||||||||
| 559 | q->setAutoRepeat(false); | - | ||||||||||||||||||
| 560 | bool horizontal = true; | - | ||||||||||||||||||
| 561 | - | |||||||||||||||||||
| 562 | QToolBar *tb = qobject_cast<QToolBar*>(parent); | - | ||||||||||||||||||
| 563 | if (tb
| 0 | ||||||||||||||||||
| 564 | horizontal = false; never executed: horizontal = false; | 0 | ||||||||||||||||||
| 565 | - | |||||||||||||||||||
| 566 | QPoint p; | - | ||||||||||||||||||
| 567 | const QRect rect = q->rect(); | - | ||||||||||||||||||
| 568 | QRect screen = QApplication::desktop()->availableGeometry(q->mapToGlobal(rect.center())); | - | ||||||||||||||||||
| 569 | QSize sh = ((
| 0 | ||||||||||||||||||
| 570 | if (horizontal
| 0 | ||||||||||||||||||
| 571 | if (q->isRightToLeft()
| 0 | ||||||||||||||||||
| 572 | if (q->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height()
| 0 | ||||||||||||||||||
| 573 | p = q->mapToGlobal(rect.bottomRight()); | - | ||||||||||||||||||
| 574 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 575 | p = q->mapToGlobal(rect.topRight() - QPoint(0, sh.height())); | - | ||||||||||||||||||
| 576 | } never executed: end of block | 0 | ||||||||||||||||||
| 577 | p.rx() -= sh.width(); | - | ||||||||||||||||||
| 578 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 579 | if (q->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height()
| 0 | ||||||||||||||||||
| 580 | p = q->mapToGlobal(rect.bottomLeft()); | - | ||||||||||||||||||
| 581 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 582 | p = q->mapToGlobal(rect.topLeft() - QPoint(0, sh.height())); | - | ||||||||||||||||||
| 583 | } never executed: end of block | 0 | ||||||||||||||||||
| 584 | } | - | ||||||||||||||||||
| 585 | } else { | - | ||||||||||||||||||
| 586 | if (q->isRightToLeft()
| 0 | ||||||||||||||||||
| 587 | if (q->mapToGlobal(QPoint(rect.left(), 0)).x() - sh.width() <= screen.x()
| 0 | ||||||||||||||||||
| 588 | p = q->mapToGlobal(rect.topRight()); | - | ||||||||||||||||||
| 589 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 590 | p = q->mapToGlobal(rect.topLeft()); | - | ||||||||||||||||||
| 591 | p.rx() -= sh.width(); | - | ||||||||||||||||||
| 592 | } never executed: end of block | 0 | ||||||||||||||||||
| 593 | } else { | - | ||||||||||||||||||
| 594 | if (q->mapToGlobal(QPoint(rect.right(), 0)).x() + sh.width() <= screen.right()
| 0 | ||||||||||||||||||
| 595 | p = q->mapToGlobal(rect.topRight()); | - | ||||||||||||||||||
| 596 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 597 | p = q->mapToGlobal(rect.topLeft() - QPoint(sh.width(), 0)); | - | ||||||||||||||||||
| 598 | } never executed: end of block | 0 | ||||||||||||||||||
| 599 | } | - | ||||||||||||||||||
| 600 | } | - | ||||||||||||||||||
| 601 | p.rx() = qMax(screen.left(), qMin(p.x(), screen.right() - sh.width())); | - | ||||||||||||||||||
| 602 | p.ry() += 1; | - | ||||||||||||||||||
| 603 | QPointer<QToolButton> that = q; | - | ||||||||||||||||||
| 604 | actualMenu->setNoReplayFor(q); | - | ||||||||||||||||||
| 605 | if (!mustDeleteActualMenu
| 0 | ||||||||||||||||||
| 606 | QObject::connect(actualMenu, qFlagLocation("2""triggered(QAction*)" "\0" __FILE__ ":" "787"), q, qFlagLocation("1""_q_menuTriggered(QAction*)" "\0" __FILE__ ":" "787")); never executed: QObject::connect(actualMenu, qFlagLocation("2""triggered(QAction*)" "\0" __FILE__ ":" "787"), q, qFlagLocation("1""_q_menuTriggered(QAction*)" "\0" __FILE__ ":" "787")); | 0 | ||||||||||||||||||
| 607 | QObject::connect(actualMenu, qFlagLocation("2""aboutToHide()" "\0" __FILE__ ":" "788"), q, qFlagLocation("1""_q_updateButtonDown()" "\0" __FILE__ ":" "788")); | - | ||||||||||||||||||
| 608 | actualMenu->d_func()->causedPopup.widget = q; | - | ||||||||||||||||||
| 609 | actualMenu->d_func()->causedPopup.action = defaultAction; | - | ||||||||||||||||||
| 610 | actionsCopy = q->actions(); | - | ||||||||||||||||||
| 611 | actualMenu->exec(p); | - | ||||||||||||||||||
| 612 | - | |||||||||||||||||||
| 613 | if (!that
| 0 | ||||||||||||||||||
| 614 | return; never executed: return; | 0 | ||||||||||||||||||
| 615 | - | |||||||||||||||||||
| 616 | QObject::disconnect(actualMenu, qFlagLocation("2""aboutToHide()" "\0" __FILE__ ":" "797"), q, qFlagLocation("1""_q_updateButtonDown()" "\0" __FILE__ ":" "797")); | - | ||||||||||||||||||
| 617 | if (mustDeleteActualMenu
| 0 | ||||||||||||||||||
| 618 | delete actualMenu; never executed: delete actualMenu; | 0 | ||||||||||||||||||
| 619 | else | - | ||||||||||||||||||
| 620 | QObject::disconnect(actualMenu, qFlagLocation("2""triggered(QAction*)" "\0" __FILE__ ":" "801"), q, qFlagLocation("1""_q_menuTriggered(QAction*)" "\0" __FILE__ ":" "801")); never executed: QObject::disconnect(actualMenu, qFlagLocation("2""triggered(QAction*)" "\0" __FILE__ ":" "801"), q, qFlagLocation("1""_q_menuTriggered(QAction*)" "\0" __FILE__ ":" "801")); | 0 | ||||||||||||||||||
| 621 | - | |||||||||||||||||||
| 622 | actionsCopy.clear(); | - | ||||||||||||||||||
| 623 | - | |||||||||||||||||||
| 624 | if (repeat
| 0 | ||||||||||||||||||
| 625 | q->setAutoRepeat(true); never executed: q->setAutoRepeat(true); | 0 | ||||||||||||||||||
| 626 | } never executed: end of block | 0 | ||||||||||||||||||
| 627 | - | |||||||||||||||||||
| 628 | void QToolButtonPrivate::_q_updateButtonDown() | - | ||||||||||||||||||
| 629 | { | - | ||||||||||||||||||
| 630 | QToolButton * const q = q_func(); | - | ||||||||||||||||||
| 631 | menuButtonDown = false; | - | ||||||||||||||||||
| 632 | if (q->isDown()
| 0 | ||||||||||||||||||
| 633 | q->setDown(false); never executed: q->setDown(false); | 0 | ||||||||||||||||||
| 634 | else | - | ||||||||||||||||||
| 635 | q->repaint(); never executed: q->repaint(); | 0 | ||||||||||||||||||
| 636 | } | - | ||||||||||||||||||
| 637 | - | |||||||||||||||||||
| 638 | void QToolButtonPrivate::_q_menuTriggered(QAction *action) | - | ||||||||||||||||||
| 639 | { | - | ||||||||||||||||||
| 640 | QToolButton * const q = q_func(); | - | ||||||||||||||||||
| 641 | if (action
| 0 | ||||||||||||||||||
| 642 | q->triggered(action); never executed: q->triggered(action); | 0 | ||||||||||||||||||
| 643 | } never executed: end of block | 0 | ||||||||||||||||||
| 644 | void QToolButton::setPopupMode(ToolButtonPopupMode mode) | - | ||||||||||||||||||
| 645 | { | - | ||||||||||||||||||
| 646 | QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 647 | d->popupMode = mode; | - | ||||||||||||||||||
| 648 | } never executed: end of block | 0 | ||||||||||||||||||
| 649 | - | |||||||||||||||||||
| 650 | QToolButton::ToolButtonPopupMode QToolButton::popupMode() const | - | ||||||||||||||||||
| 651 | { | - | ||||||||||||||||||
| 652 | const QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 653 | return never executed: d->popupMode;return d->popupMode;never executed: return d->popupMode; | 0 | ||||||||||||||||||
| 654 | } | - | ||||||||||||||||||
| 655 | void QToolButton::setAutoRaise(bool enable) | - | ||||||||||||||||||
| 656 | { | - | ||||||||||||||||||
| 657 | QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 658 | d->autoRaise = enable; | - | ||||||||||||||||||
| 659 | - | |||||||||||||||||||
| 660 | update(); | - | ||||||||||||||||||
| 661 | } never executed: end of block | 0 | ||||||||||||||||||
| 662 | - | |||||||||||||||||||
| 663 | bool QToolButton::autoRaise() const | - | ||||||||||||||||||
| 664 | { | - | ||||||||||||||||||
| 665 | const QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 666 | return never executed: d->autoRaise;return d->autoRaise;never executed: return d->autoRaise; | 0 | ||||||||||||||||||
| 667 | } | - | ||||||||||||||||||
| 668 | - | |||||||||||||||||||
| 669 | - | |||||||||||||||||||
| 670 | - | |||||||||||||||||||
| 671 | - | |||||||||||||||||||
| 672 | - | |||||||||||||||||||
| 673 | - | |||||||||||||||||||
| 674 | - | |||||||||||||||||||
| 675 | void QToolButton::setDefaultAction(QAction *action) | - | ||||||||||||||||||
| 676 | { | - | ||||||||||||||||||
| 677 | QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 678 | - | |||||||||||||||||||
| 679 | bool hadMenu = false; | - | ||||||||||||||||||
| 680 | hadMenu = d->hasMenu(); | - | ||||||||||||||||||
| 681 | - | |||||||||||||||||||
| 682 | d->defaultAction = action; | - | ||||||||||||||||||
| 683 | if (!action
| 0 | ||||||||||||||||||
| 684 | return; never executed: return; | 0 | ||||||||||||||||||
| 685 | if (!actions().contains(action)
| 0 | ||||||||||||||||||
| 686 | addAction(action); never executed: addAction(action); | 0 | ||||||||||||||||||
| 687 | QString buttonText = action->iconText(); | - | ||||||||||||||||||
| 688 | - | |||||||||||||||||||
| 689 | - | |||||||||||||||||||
| 690 | if (QActionPrivate::get(action)->iconText.isEmpty()
| 0 | ||||||||||||||||||
| 691 | buttonText.replace(QLatin1String("&"), QLatin1String("&&")); never executed: buttonText.replace(QLatin1String("&"), QLatin1String("&&")); | 0 | ||||||||||||||||||
| 692 | setText(buttonText); | - | ||||||||||||||||||
| 693 | setIcon(action->icon()); | - | ||||||||||||||||||
| 694 | - | |||||||||||||||||||
| 695 | setToolTip(action->toolTip()); | - | ||||||||||||||||||
| 696 | - | |||||||||||||||||||
| 697 | - | |||||||||||||||||||
| 698 | setStatusTip(action->statusTip()); | - | ||||||||||||||||||
| 699 | - | |||||||||||||||||||
| 700 | - | |||||||||||||||||||
| 701 | setWhatsThis(action->whatsThis()); | - | ||||||||||||||||||
| 702 | - | |||||||||||||||||||
| 703 | - | |||||||||||||||||||
| 704 | if (action->menu()
| 0 | ||||||||||||||||||
| 705 | - | |||||||||||||||||||
| 706 | - | |||||||||||||||||||
| 707 | - | |||||||||||||||||||
| 708 | setPopupMode(QToolButton::MenuButtonPopup); | - | ||||||||||||||||||
| 709 | } never executed: end of block | 0 | ||||||||||||||||||
| 710 | - | |||||||||||||||||||
| 711 | setCheckable(action->isCheckable()); | - | ||||||||||||||||||
| 712 | setChecked(action->isChecked()); | - | ||||||||||||||||||
| 713 | setEnabled(action->isEnabled()); | - | ||||||||||||||||||
| 714 | if (action->d_func()->fontSet
| 0 | ||||||||||||||||||
| 715 | setFont(action->font()); never executed: setFont(action->font()); | 0 | ||||||||||||||||||
| 716 | } never executed: end of block | 0 | ||||||||||||||||||
| 717 | - | |||||||||||||||||||
| 718 | - | |||||||||||||||||||
| 719 | - | |||||||||||||||||||
| 720 | - | |||||||||||||||||||
| 721 | - | |||||||||||||||||||
| 722 | - | |||||||||||||||||||
| 723 | - | |||||||||||||||||||
| 724 | QAction *QToolButton::defaultAction() const | - | ||||||||||||||||||
| 725 | { | - | ||||||||||||||||||
| 726 | const QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 727 | return never executed: d->defaultAction;return d->defaultAction;never executed: return d->defaultAction; | 0 | ||||||||||||||||||
| 728 | } | - | ||||||||||||||||||
| 729 | - | |||||||||||||||||||
| 730 | - | |||||||||||||||||||
| 731 | - | |||||||||||||||||||
| 732 | - | |||||||||||||||||||
| 733 | - | |||||||||||||||||||
| 734 | - | |||||||||||||||||||
| 735 | void QToolButton::nextCheckState() | - | ||||||||||||||||||
| 736 | { | - | ||||||||||||||||||
| 737 | QToolButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 738 | if (!d->defaultAction
| 0 | ||||||||||||||||||
| 739 | QAbstractButton::nextCheckState(); never executed: QAbstractButton::nextCheckState(); | 0 | ||||||||||||||||||
| 740 | else | - | ||||||||||||||||||
| 741 | d->defaultAction->trigger(); never executed: d->defaultAction->trigger(); | 0 | ||||||||||||||||||
| 742 | } | - | ||||||||||||||||||
| 743 | - | |||||||||||||||||||
| 744 | - | |||||||||||||||||||
| 745 | bool QToolButton::event(QEvent *event) | - | ||||||||||||||||||
| 746 | { | - | ||||||||||||||||||
| 747 | switch(event->type()) { | - | ||||||||||||||||||
| 748 | case never executed: QEvent::HoverEnter:case QEvent::HoverEnter:never executed: case QEvent::HoverEnter: | 0 | ||||||||||||||||||
| 749 | case never executed: QEvent::HoverLeave:case QEvent::HoverLeave:never executed: case QEvent::HoverLeave: | 0 | ||||||||||||||||||
| 750 | case never executed: QEvent::HoverMove:case QEvent::HoverMove:never executed: case QEvent::HoverMove: | 0 | ||||||||||||||||||
| 751 | if (const
| 0 | ||||||||||||||||||
| 752 | d_func()->updateHoverControl(he->pos()); never executed: d_func()->updateHoverControl(he->pos()); | 0 | ||||||||||||||||||
| 753 | break; never executed: break; | 0 | ||||||||||||||||||
| 754 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 755 | break; never executed: break; | 0 | ||||||||||||||||||
| 756 | } | - | ||||||||||||||||||
| 757 | return never executed: QAbstractButton::event(event);return QAbstractButton::event(event);never executed: return QAbstractButton::event(event); | 0 | ||||||||||||||||||
| 758 | } | - | ||||||||||||||||||
| 759 | - | |||||||||||||||||||
| 760 | - | |||||||||||||||||||
| 761 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |