Changeset View
Changeset View
Standalone View
Standalone View
src/decorationbutton.cpp
Show First 20 Lines • Show All 441 Lines • ▼ Show 20 Line(s) | |||||
442 | } | 442 | } | ||
443 | 443 | | |||
444 | DELEGATE(setGeometry, geometry, const QRectF &) | 444 | DELEGATE(setGeometry, geometry, const QRectF &) | ||
445 | 445 | | |||
446 | #undef DELEGATE | 446 | #undef DELEGATE | ||
447 | 447 | | |||
448 | bool DecorationButton::contains(const QPointF &pos) const | 448 | bool DecorationButton::contains(const QPointF &pos) const | ||
449 | { | 449 | { | ||
450 | return d->geometry.toRect().contains(pos.toPoint()); | 450 | if (!d->geometry.contains(pos)) { | ||
451 | return false; | ||||
452 | } | ||||
453 | | ||||
454 | // additional make sure pos is not on the right or bottom edge | ||||
455 | const bool horizontalInside = d->geometry.width() < 0 ? pos.x() < d->geometry.x() : | ||||
zzag: Can you please explain this part? Shouldn't it be `d->geometry.right() < pos.x()`? | |||||
If rect.width() is smaller 0, then arbitrary QRect rect is to the left of its "anchor point" rect.x(). The right border is therefore defined by value rect.x(). Looking at the Qt source in this case rect.right() defines the left border of the rectangle. I assume we always want to exclude the border to the right. I also hope that no on in practice defines a decoration button with negative width. ;) romangg: If `rect.width()` is smaller 0, then arbitrary QRect `rect` is to the left of its "anchor… | |||||
zzag: No short names. | |||||
456 | pos.x() < d->geometry.right(); | ||||
457 | const bool verticalInside = d->geometry.height() < 0 ? pos.y() < d->geometry.y() : | ||||
458 | pos.y() < d->geometry.bottom(); | ||||
459 | return horizontalInside && verticalInside; | ||||
451 | } | 460 | } | ||
452 | 461 | | |||
453 | bool DecorationButton::event(QEvent *event) | 462 | bool DecorationButton::event(QEvent *event) | ||
454 | { | 463 | { | ||
455 | switch (event->type()) { | 464 | switch (event->type()) { | ||
456 | case QEvent::HoverEnter: | 465 | case QEvent::HoverEnter: | ||
457 | hoverEnterEvent(static_cast<QHoverEvent*>(event)); | 466 | hoverEnterEvent(static_cast<QHoverEvent*>(event)); | ||
458 | return true; | 467 | return true; | ||
▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines |
Can you please explain this part? Shouldn't it be d->geometry.right() < pos.x()?