| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qpushbutton.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | QPushButton::QPushButton(QWidget *parent) | - | ||||||||||||||||||
| 12 | : QAbstractButton(*new QPushButtonPrivate, parent) | - | ||||||||||||||||||
| 13 | { | - | ||||||||||||||||||
| 14 | QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 15 | d->init(); | - | ||||||||||||||||||
| 16 | } never executed: end of block | 0 | ||||||||||||||||||
| 17 | - | |||||||||||||||||||
| 18 | - | |||||||||||||||||||
| 19 | - | |||||||||||||||||||
| 20 | - | |||||||||||||||||||
| 21 | - | |||||||||||||||||||
| 22 | - | |||||||||||||||||||
| 23 | QPushButton::QPushButton(const QString &text, QWidget *parent) | - | ||||||||||||||||||
| 24 | : QAbstractButton(*new QPushButtonPrivate, parent) | - | ||||||||||||||||||
| 25 | { | - | ||||||||||||||||||
| 26 | QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 27 | setText(text); | - | ||||||||||||||||||
| 28 | d->init(); | - | ||||||||||||||||||
| 29 | } never executed: end of block | 0 | ||||||||||||||||||
| 30 | QPushButton::QPushButton(const QIcon& icon, const QString &text, QWidget *parent) | - | ||||||||||||||||||
| 31 | : QAbstractButton(*new QPushButtonPrivate, parent) | - | ||||||||||||||||||
| 32 | { | - | ||||||||||||||||||
| 33 | QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 34 | setText(text); | - | ||||||||||||||||||
| 35 | setIcon(icon); | - | ||||||||||||||||||
| 36 | d->init(); | - | ||||||||||||||||||
| 37 | } never executed: end of block | 0 | ||||||||||||||||||
| 38 | - | |||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | - | |||||||||||||||||||
| 41 | QPushButton::QPushButton(QPushButtonPrivate &dd, QWidget *parent) | - | ||||||||||||||||||
| 42 | : QAbstractButton(dd, parent) | - | ||||||||||||||||||
| 43 | { | - | ||||||||||||||||||
| 44 | QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 45 | d->init(); | - | ||||||||||||||||||
| 46 | } never executed: end of block | 0 | ||||||||||||||||||
| 47 | - | |||||||||||||||||||
| 48 | - | |||||||||||||||||||
| 49 | - | |||||||||||||||||||
| 50 | - | |||||||||||||||||||
| 51 | QPushButton::~QPushButton() | - | ||||||||||||||||||
| 52 | { | - | ||||||||||||||||||
| 53 | } | - | ||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | QDialog *QPushButtonPrivate::dialogParent() const | - | ||||||||||||||||||
| 56 | { | - | ||||||||||||||||||
| 57 | const QPushButton * const q = q_func(); | - | ||||||||||||||||||
| 58 | const QWidget *p = q; | - | ||||||||||||||||||
| 59 | while (p
| 0 | ||||||||||||||||||
| 60 | p = p->parentWidget(); | - | ||||||||||||||||||
| 61 | if (const
| 0 | ||||||||||||||||||
| 62 | return never executed: const_cast<QDialog *>(dialog);return const_cast<QDialog *>(dialog);never executed: return const_cast<QDialog *>(dialog); | 0 | ||||||||||||||||||
| 63 | } never executed: end of block | 0 | ||||||||||||||||||
| 64 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 65 | } | - | ||||||||||||||||||
| 66 | void QPushButton::initStyleOption(QStyleOptionButton *option) const | - | ||||||||||||||||||
| 67 | { | - | ||||||||||||||||||
| 68 | if (!option
| 0 | ||||||||||||||||||
| 69 | return; never executed: return; | 0 | ||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | const QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 72 | option->initFrom(this); | - | ||||||||||||||||||
| 73 | option->features = QStyleOptionButton::None; | - | ||||||||||||||||||
| 74 | if (d->flat
| 0 | ||||||||||||||||||
| 75 | option->features |= QStyleOptionButton::Flat; never executed: option->features |= QStyleOptionButton::Flat; | 0 | ||||||||||||||||||
| 76 | - | |||||||||||||||||||
| 77 | if (d->menu
| 0 | ||||||||||||||||||
| 78 | option->features |= QStyleOptionButton::HasMenu; never executed: option->features |= QStyleOptionButton::HasMenu; | 0 | ||||||||||||||||||
| 79 | - | |||||||||||||||||||
| 80 | if (autoDefault()
| 0 | ||||||||||||||||||
| 81 | option->features |= QStyleOptionButton::AutoDefaultButton; never executed: option->features |= QStyleOptionButton::AutoDefaultButton; | 0 | ||||||||||||||||||
| 82 | if (d->defaultButton
| 0 | ||||||||||||||||||
| 83 | option->features |= QStyleOptionButton::DefaultButton; never executed: option->features |= QStyleOptionButton::DefaultButton; | 0 | ||||||||||||||||||
| 84 | if (d->down
| 0 | ||||||||||||||||||
| 85 | option->state |= QStyle::State_Sunken; never executed: option->state |= QStyle::State_Sunken; | 0 | ||||||||||||||||||
| 86 | if (d->checked
| 0 | ||||||||||||||||||
| 87 | option->state |= QStyle::State_On; never executed: option->state |= QStyle::State_On; | 0 | ||||||||||||||||||
| 88 | if (!d->flat
| 0 | ||||||||||||||||||
| 89 | option->state |= QStyle::State_Raised; never executed: option->state |= QStyle::State_Raised; | 0 | ||||||||||||||||||
| 90 | option->text = d->text; | - | ||||||||||||||||||
| 91 | option->icon = d->icon; | - | ||||||||||||||||||
| 92 | option->iconSize = iconSize(); | - | ||||||||||||||||||
| 93 | } never executed: end of block | 0 | ||||||||||||||||||
| 94 | - | |||||||||||||||||||
| 95 | void QPushButton::setAutoDefault(bool enable) | - | ||||||||||||||||||
| 96 | { | - | ||||||||||||||||||
| 97 | QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 98 | uint state = enable
| 0 | ||||||||||||||||||
| 99 | if (d->autoDefault != QPushButtonPrivate::Auto
| 0 | ||||||||||||||||||
| 100 | return; never executed: return; | 0 | ||||||||||||||||||
| 101 | d->autoDefault = state; | - | ||||||||||||||||||
| 102 | d->sizeHint = QSize(); | - | ||||||||||||||||||
| 103 | update(); | - | ||||||||||||||||||
| 104 | updateGeometry(); | - | ||||||||||||||||||
| 105 | } never executed: end of block | 0 | ||||||||||||||||||
| 106 | - | |||||||||||||||||||
| 107 | bool QPushButton::autoDefault() const | - | ||||||||||||||||||
| 108 | { | - | ||||||||||||||||||
| 109 | const QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 110 | if(d->autoDefault == QPushButtonPrivate::Auto
| 0 | ||||||||||||||||||
| 111 | return never executed: ( d->dialogParent() != 0 );return ( d->dialogParent() != 0 );never executed: return ( d->dialogParent() != 0 ); | 0 | ||||||||||||||||||
| 112 | return never executed: d->autoDefault;return d->autoDefault;never executed: return d->autoDefault; | 0 | ||||||||||||||||||
| 113 | } | - | ||||||||||||||||||
| 114 | - | |||||||||||||||||||
| 115 | void QPushButton::setDefault(bool enable) | - | ||||||||||||||||||
| 116 | { | - | ||||||||||||||||||
| 117 | QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 118 | if (d->defaultButton == enable
| 0 | ||||||||||||||||||
| 119 | return; never executed: return; | 0 | ||||||||||||||||||
| 120 | d->defaultButton = enable; | - | ||||||||||||||||||
| 121 | if (d->defaultButton
| 0 | ||||||||||||||||||
| 122 | if (QDialog *dlg = d->dialogParent()
| 0 | ||||||||||||||||||
| 123 | dlg->d_func()->setMainDefault(this); never executed: dlg->d_func()->setMainDefault(this); | 0 | ||||||||||||||||||
| 124 | } never executed: end of block | 0 | ||||||||||||||||||
| 125 | update(); | - | ||||||||||||||||||
| 126 | - | |||||||||||||||||||
| 127 | QAccessible::State s; | - | ||||||||||||||||||
| 128 | s.defaultButton = true; | - | ||||||||||||||||||
| 129 | QAccessibleStateChangeEvent event(this, s); | - | ||||||||||||||||||
| 130 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||
| 131 | - | |||||||||||||||||||
| 132 | } never executed: end of block | 0 | ||||||||||||||||||
| 133 | - | |||||||||||||||||||
| 134 | bool QPushButton::isDefault() const | - | ||||||||||||||||||
| 135 | { | - | ||||||||||||||||||
| 136 | const QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 137 | return never executed: d->defaultButton;return d->defaultButton;never executed: return d->defaultButton; | 0 | ||||||||||||||||||
| 138 | } | - | ||||||||||||||||||
| 139 | - | |||||||||||||||||||
| 140 | - | |||||||||||||||||||
| 141 | - | |||||||||||||||||||
| 142 | - | |||||||||||||||||||
| 143 | QSize QPushButton::sizeHint() const | - | ||||||||||||||||||
| 144 | { | - | ||||||||||||||||||
| 145 | const QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 146 | if (d->sizeHint.isValid()
| 0 | ||||||||||||||||||
| 147 | return never executed: d->sizeHint;return d->sizeHint;never executed: return d->sizeHint; | 0 | ||||||||||||||||||
| 148 | d->lastAutoDefault = autoDefault(); | - | ||||||||||||||||||
| 149 | ensurePolished(); | - | ||||||||||||||||||
| 150 | - | |||||||||||||||||||
| 151 | int w = 0, h = 0; | - | ||||||||||||||||||
| 152 | - | |||||||||||||||||||
| 153 | QStyleOptionButton opt; | - | ||||||||||||||||||
| 154 | initStyleOption(&opt); | - | ||||||||||||||||||
| 155 | - | |||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | - | |||||||||||||||||||
| 158 | - | |||||||||||||||||||
| 159 | bool showButtonBoxIcons = qobject_cast<QDialogButtonBox*>(parentWidget())
| 0 | ||||||||||||||||||
| 160 | && style()->styleHint(QStyle::SH_DialogButtonBox_ButtonsHaveIcons)
| 0 | ||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | if (!icon().isNull()
| 0 | ||||||||||||||||||
| 163 | int ih = opt.iconSize.height(); | - | ||||||||||||||||||
| 164 | int iw = opt.iconSize.width() + 4; | - | ||||||||||||||||||
| 165 | w += iw; | - | ||||||||||||||||||
| 166 | h = qMax(h, ih); | - | ||||||||||||||||||
| 167 | } never executed: end of block | 0 | ||||||||||||||||||
| 168 | - | |||||||||||||||||||
| 169 | QString s(text()); | - | ||||||||||||||||||
| 170 | bool empty = s.isEmpty(); | - | ||||||||||||||||||
| 171 | if (empty
| 0 | ||||||||||||||||||
| 172 | s = QString::fromLatin1("XXXX"); never executed: s = QString::fromLatin1("XXXX"); | 0 | ||||||||||||||||||
| 173 | QFontMetrics fm = fontMetrics(); | - | ||||||||||||||||||
| 174 | QSize sz = fm.size(Qt::TextShowMnemonic, s); | - | ||||||||||||||||||
| 175 | if(!empty
| 0 | ||||||||||||||||||
| 176 | w += sz.width(); never executed: w += sz.width(); | 0 | ||||||||||||||||||
| 177 | if(!empty
| 0 | ||||||||||||||||||
| 178 | h = qMax(h, sz.height()); never executed: h = qMax(h, sz.height()); | 0 | ||||||||||||||||||
| 179 | opt.rect.setSize(QSize(w, h)); | - | ||||||||||||||||||
| 180 | - | |||||||||||||||||||
| 181 | if (menu()
| 0 | ||||||||||||||||||
| 182 | w += style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, this); never executed: w += style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, this); | 0 | ||||||||||||||||||
| 183 | - | |||||||||||||||||||
| 184 | d->sizeHint = (style()->sizeFromContents(QStyle::CT_PushButton, &opt, QSize(w, h), this). | - | ||||||||||||||||||
| 185 | expandedTo(QApplication::globalStrut())); | - | ||||||||||||||||||
| 186 | return never executed: d->sizeHint;return d->sizeHint;never executed: return d->sizeHint; | 0 | ||||||||||||||||||
| 187 | } | - | ||||||||||||||||||
| 188 | - | |||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | - | |||||||||||||||||||
| 191 | - | |||||||||||||||||||
| 192 | QSize QPushButton::minimumSizeHint() const | - | ||||||||||||||||||
| 193 | { | - | ||||||||||||||||||
| 194 | return never executed: sizeHint();return sizeHint();never executed: return sizeHint(); | 0 | ||||||||||||||||||
| 195 | } | - | ||||||||||||||||||
| 196 | - | |||||||||||||||||||
| 197 | - | |||||||||||||||||||
| 198 | - | |||||||||||||||||||
| 199 | - | |||||||||||||||||||
| 200 | void QPushButton::paintEvent(QPaintEvent *) | - | ||||||||||||||||||
| 201 | { | - | ||||||||||||||||||
| 202 | QStylePainter p(this); | - | ||||||||||||||||||
| 203 | QStyleOptionButton option; | - | ||||||||||||||||||
| 204 | initStyleOption(&option); | - | ||||||||||||||||||
| 205 | p.drawControl(QStyle::CE_PushButton, option); | - | ||||||||||||||||||
| 206 | } never executed: end of block | 0 | ||||||||||||||||||
| 207 | - | |||||||||||||||||||
| 208 | - | |||||||||||||||||||
| 209 | - | |||||||||||||||||||
| 210 | void QPushButton::keyPressEvent(QKeyEvent *e) | - | ||||||||||||||||||
| 211 | { | - | ||||||||||||||||||
| 212 | QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 213 | switch (e->key()) { | - | ||||||||||||||||||
| 214 | case never executed: Qt::Key_Enter:case Qt::Key_Enter:never executed: case Qt::Key_Enter: | 0 | ||||||||||||||||||
| 215 | case never executed: Qt::Key_Return:case Qt::Key_Return:never executed: case Qt::Key_Return: | 0 | ||||||||||||||||||
| 216 | if (autoDefault()
| 0 | ||||||||||||||||||
| 217 | click(); | - | ||||||||||||||||||
| 218 | break; never executed: break; | 0 | ||||||||||||||||||
| 219 | } | - | ||||||||||||||||||
| 220 | - | |||||||||||||||||||
| 221 | default never executed: :default:never executed: default:code before this statement never executed: default: | 0 | ||||||||||||||||||
| 222 | QAbstractButton::keyPressEvent(e); | - | ||||||||||||||||||
| 223 | } never executed: end of block | 0 | ||||||||||||||||||
| 224 | } | - | ||||||||||||||||||
| 225 | - | |||||||||||||||||||
| 226 | - | |||||||||||||||||||
| 227 | - | |||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | void QPushButton::focusInEvent(QFocusEvent *e) | - | ||||||||||||||||||
| 230 | { | - | ||||||||||||||||||
| 231 | QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 232 | if (e->reason() != Qt::PopupFocusReason
| 0 | ||||||||||||||||||
| 233 | d->defaultButton = true; | - | ||||||||||||||||||
| 234 | QDialog *dlg = qobject_cast<QDialog*>(window()); | - | ||||||||||||||||||
| 235 | if (dlg
| 0 | ||||||||||||||||||
| 236 | dlg->d_func()->setDefault(this); never executed: dlg->d_func()->setDefault(this); | 0 | ||||||||||||||||||
| 237 | } never executed: end of block | 0 | ||||||||||||||||||
| 238 | QAbstractButton::focusInEvent(e); | - | ||||||||||||||||||
| 239 | } never executed: end of block | 0 | ||||||||||||||||||
| 240 | - | |||||||||||||||||||
| 241 | - | |||||||||||||||||||
| 242 | - | |||||||||||||||||||
| 243 | - | |||||||||||||||||||
| 244 | void QPushButton::focusOutEvent(QFocusEvent *e) | - | ||||||||||||||||||
| 245 | { | - | ||||||||||||||||||
| 246 | QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 247 | if (e->reason() != Qt::PopupFocusReason
| 0 | ||||||||||||||||||
| 248 | QDialog *dlg = qobject_cast<QDialog*>(window()); | - | ||||||||||||||||||
| 249 | if (dlg
| 0 | ||||||||||||||||||
| 250 | dlg->d_func()->setDefault(0); never executed: dlg->d_func()->setDefault(0); | 0 | ||||||||||||||||||
| 251 | else | - | ||||||||||||||||||
| 252 | d->defaultButton = false; never executed: d->defaultButton = false; | 0 | ||||||||||||||||||
| 253 | } | - | ||||||||||||||||||
| 254 | - | |||||||||||||||||||
| 255 | QAbstractButton::focusOutEvent(e); | - | ||||||||||||||||||
| 256 | - | |||||||||||||||||||
| 257 | if (d->menu
| 0 | ||||||||||||||||||
| 258 | setDown(true); never executed: setDown(true); | 0 | ||||||||||||||||||
| 259 | - | |||||||||||||||||||
| 260 | } never executed: end of block | 0 | ||||||||||||||||||
| 261 | void QPushButton::setMenu(QMenu* menu) | - | ||||||||||||||||||
| 262 | { | - | ||||||||||||||||||
| 263 | QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 264 | if (menu == d->menu
| 0 | ||||||||||||||||||
| 265 | return; never executed: return; | 0 | ||||||||||||||||||
| 266 | - | |||||||||||||||||||
| 267 | if (menu
| 0 | ||||||||||||||||||
| 268 | connect(this, qFlagLocation("2""pressed()" "\0" __FILE__ ":" "526"), this, qFlagLocation("1""_q_popupPressed()" "\0" __FILE__ ":" "526"), Qt::UniqueConnection); | - | ||||||||||||||||||
| 269 | } never executed: end of block | 0 | ||||||||||||||||||
| 270 | if (d->menu
| 0 | ||||||||||||||||||
| 271 | removeAction(d->menu->menuAction()); never executed: removeAction(d->menu->menuAction()); | 0 | ||||||||||||||||||
| 272 | d->menu = menu; | - | ||||||||||||||||||
| 273 | if (d->menu
| 0 | ||||||||||||||||||
| 274 | addAction(d->menu->menuAction()); never executed: addAction(d->menu->menuAction()); | 0 | ||||||||||||||||||
| 275 | - | |||||||||||||||||||
| 276 | d->resetLayoutItemMargins(); | - | ||||||||||||||||||
| 277 | d->sizeHint = QSize(); | - | ||||||||||||||||||
| 278 | update(); | - | ||||||||||||||||||
| 279 | updateGeometry(); | - | ||||||||||||||||||
| 280 | } never executed: end of block | 0 | ||||||||||||||||||
| 281 | - | |||||||||||||||||||
| 282 | - | |||||||||||||||||||
| 283 | - | |||||||||||||||||||
| 284 | - | |||||||||||||||||||
| 285 | - | |||||||||||||||||||
| 286 | - | |||||||||||||||||||
| 287 | - | |||||||||||||||||||
| 288 | QMenu* QPushButton::menu() const | - | ||||||||||||||||||
| 289 | { | - | ||||||||||||||||||
| 290 | const QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 291 | return never executed: d->menu;return d->menu;never executed: return d->menu; | 0 | ||||||||||||||||||
| 292 | } | - | ||||||||||||||||||
| 293 | - | |||||||||||||||||||
| 294 | - | |||||||||||||||||||
| 295 | - | |||||||||||||||||||
| 296 | - | |||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | - | |||||||||||||||||||
| 299 | void QPushButton::showMenu() | - | ||||||||||||||||||
| 300 | { | - | ||||||||||||||||||
| 301 | QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 302 | if (!d
| 0 | ||||||||||||||||||
| 303 | return; never executed: return; | 0 | ||||||||||||||||||
| 304 | setDown(true); | - | ||||||||||||||||||
| 305 | d->_q_popupPressed(); | - | ||||||||||||||||||
| 306 | } never executed: end of block | 0 | ||||||||||||||||||
| 307 | - | |||||||||||||||||||
| 308 | void QPushButtonPrivate::_q_popupPressed() | - | ||||||||||||||||||
| 309 | { | - | ||||||||||||||||||
| 310 | QPushButton * const q = q_func(); | - | ||||||||||||||||||
| 311 | if (!down
| 0 | ||||||||||||||||||
| 312 | return; never executed: return; | 0 | ||||||||||||||||||
| 313 | - | |||||||||||||||||||
| 314 | menu->setNoReplayFor(q); | - | ||||||||||||||||||
| 315 | - | |||||||||||||||||||
| 316 | QPoint menuPos = adjustedMenuPosition(); | - | ||||||||||||||||||
| 317 | - | |||||||||||||||||||
| 318 | QPointer<QPushButton> guard(q); | - | ||||||||||||||||||
| 319 | QMenuPrivate::get(menu)->causedPopup.widget = guard; | - | ||||||||||||||||||
| 320 | - | |||||||||||||||||||
| 321 | - | |||||||||||||||||||
| 322 | - | |||||||||||||||||||
| 323 | menuOpen = true; | - | ||||||||||||||||||
| 324 | menu->exec(menuPos); | - | ||||||||||||||||||
| 325 | if (guard
| 0 | ||||||||||||||||||
| 326 | menuOpen = false; | - | ||||||||||||||||||
| 327 | q->setDown(false); | - | ||||||||||||||||||
| 328 | } never executed: end of block | 0 | ||||||||||||||||||
| 329 | } never executed: end of block | 0 | ||||||||||||||||||
| 330 | - | |||||||||||||||||||
| 331 | QPoint QPushButtonPrivate::adjustedMenuPosition() | - | ||||||||||||||||||
| 332 | { | - | ||||||||||||||||||
| 333 | QPushButton * const q = q_func(); | - | ||||||||||||||||||
| 334 | - | |||||||||||||||||||
| 335 | bool horizontal = true; | - | ||||||||||||||||||
| 336 | - | |||||||||||||||||||
| 337 | QToolBar *tb = qobject_cast<QToolBar*>(parent); | - | ||||||||||||||||||
| 338 | if (tb
| 0 | ||||||||||||||||||
| 339 | horizontal = false; never executed: horizontal = false; | 0 | ||||||||||||||||||
| 340 | - | |||||||||||||||||||
| 341 | - | |||||||||||||||||||
| 342 | QWidgetItem item(q); | - | ||||||||||||||||||
| 343 | QRect rect = item.geometry(); | - | ||||||||||||||||||
| 344 | rect.setRect(rect.x() - q->x(), rect.y() - q->y(), rect.width(), rect.height()); | - | ||||||||||||||||||
| 345 | - | |||||||||||||||||||
| 346 | QSize menuSize = menu->sizeHint(); | - | ||||||||||||||||||
| 347 | QPoint globalPos = q->mapToGlobal(rect.topLeft()); | - | ||||||||||||||||||
| 348 | int x = globalPos.x(); | - | ||||||||||||||||||
| 349 | int y = globalPos.y(); | - | ||||||||||||||||||
| 350 | if (horizontal
| 0 | ||||||||||||||||||
| 351 | if (globalPos.y() + rect.height() + menuSize.height() <= QApplication::desktop()->availableGeometry(q).height()
| 0 | ||||||||||||||||||
| 352 | y += rect.height(); | - | ||||||||||||||||||
| 353 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 354 | y -= menuSize.height(); | - | ||||||||||||||||||
| 355 | } never executed: end of block | 0 | ||||||||||||||||||
| 356 | if (q->layoutDirection() == Qt::RightToLeft
| 0 | ||||||||||||||||||
| 357 | x += rect.width() - menuSize.width(); never executed: x += rect.width() - menuSize.width(); | 0 | ||||||||||||||||||
| 358 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 359 | if (globalPos.x() + rect.width() + menu->sizeHint().width() <= QApplication::desktop()->availableGeometry(q).width()
| 0 | ||||||||||||||||||
| 360 | x += rect.width(); never executed: x += rect.width(); | 0 | ||||||||||||||||||
| 361 | else | - | ||||||||||||||||||
| 362 | x -= menuSize.width(); never executed: x -= menuSize.width(); | 0 | ||||||||||||||||||
| 363 | } | - | ||||||||||||||||||
| 364 | - | |||||||||||||||||||
| 365 | return never executed: QPoint(x,y);return QPoint(x,y);never executed: return QPoint(x,y); | 0 | ||||||||||||||||||
| 366 | } | - | ||||||||||||||||||
| 367 | - | |||||||||||||||||||
| 368 | - | |||||||||||||||||||
| 369 | - | |||||||||||||||||||
| 370 | void QPushButtonPrivate::resetLayoutItemMargins() | - | ||||||||||||||||||
| 371 | { | - | ||||||||||||||||||
| 372 | QPushButton * const q = q_func(); | - | ||||||||||||||||||
| 373 | QStyleOptionButton opt; | - | ||||||||||||||||||
| 374 | q->initStyleOption(&opt); | - | ||||||||||||||||||
| 375 | setLayoutItemMargins(QStyle::SE_PushButtonLayoutItem, &opt); | - | ||||||||||||||||||
| 376 | } never executed: end of block | 0 | ||||||||||||||||||
| 377 | - | |||||||||||||||||||
| 378 | void QPushButton::setFlat(bool flat) | - | ||||||||||||||||||
| 379 | { | - | ||||||||||||||||||
| 380 | QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 381 | if (d->flat == flat
| 0 | ||||||||||||||||||
| 382 | return; never executed: return; | 0 | ||||||||||||||||||
| 383 | d->flat = flat; | - | ||||||||||||||||||
| 384 | d->resetLayoutItemMargins(); | - | ||||||||||||||||||
| 385 | d->sizeHint = QSize(); | - | ||||||||||||||||||
| 386 | update(); | - | ||||||||||||||||||
| 387 | updateGeometry(); | - | ||||||||||||||||||
| 388 | } never executed: end of block | 0 | ||||||||||||||||||
| 389 | - | |||||||||||||||||||
| 390 | bool QPushButton::isFlat() const | - | ||||||||||||||||||
| 391 | { | - | ||||||||||||||||||
| 392 | const QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 393 | return never executed: d->flat;return d->flat;never executed: return d->flat; | 0 | ||||||||||||||||||
| 394 | } | - | ||||||||||||||||||
| 395 | - | |||||||||||||||||||
| 396 | - | |||||||||||||||||||
| 397 | bool QPushButton::event(QEvent *e) | - | ||||||||||||||||||
| 398 | { | - | ||||||||||||||||||
| 399 | QPushButtonPrivate * const d = d_func(); | - | ||||||||||||||||||
| 400 | if (e->type() == QEvent::ParentChange
| 0 | ||||||||||||||||||
| 401 | if (QDialog *dialog = d->dialogParent()
| 0 | ||||||||||||||||||
| 402 | if (d->defaultButton
| 0 | ||||||||||||||||||
| 403 | dialog->d_func()->setMainDefault(this); never executed: dialog->d_func()->setMainDefault(this); | 0 | ||||||||||||||||||
| 404 | } never executed: end of block | 0 | ||||||||||||||||||
| 405 | } never executed: else if (e->type() == QEvent::StyleChangeend of block
| 0 | ||||||||||||||||||
| 406 | - | |||||||||||||||||||
| 407 | - | |||||||||||||||||||
| 408 | - | |||||||||||||||||||
| 409 | ) { | - | ||||||||||||||||||
| 410 | d->resetLayoutItemMargins(); | - | ||||||||||||||||||
| 411 | updateGeometry(); | - | ||||||||||||||||||
| 412 | } never executed: else if (e->type() == QEvent::PolishRequestend of block
| 0 | ||||||||||||||||||
| 413 | updateGeometry(); | - | ||||||||||||||||||
| 414 | } never executed: end of block | 0 | ||||||||||||||||||
| 415 | return never executed: QAbstractButton::event(e);return QAbstractButton::event(e);never executed: return QAbstractButton::event(e); | 0 | ||||||||||||||||||
| 416 | } | - | ||||||||||||||||||
| 417 | - | |||||||||||||||||||
| 418 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |