| 101 | Q_D(const ElaPromotionCard); |
| 102 | return d->_pVerticalCardPixmapRatio; |
| 103 | } |
| 104 | |
| 105 | bool ElaPromotionCard::event(QEvent* event) |
| 106 | { |
| 107 | Q_D(ElaPromotionCard); |
| 108 | switch (event->type()) |
| 109 | { |
| 110 | case QEvent::MouseButtonPress: |
| 111 | { |
| 112 | QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event); |
| 113 | QPropertyAnimation* opacityAnimation = new QPropertyAnimation(d, "pPressOpacity"); |
| 114 | connect(opacityAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant& value) { |
| 115 | update(); |
| 116 | }); |
| 117 | connect(opacityAnimation, &QPropertyAnimation::finished, this, [=]() { |
| 118 | d->_isPressAnimationFinished = true; |
| 119 | }); |
| 120 | opacityAnimation->setDuration(300); |
| 121 | opacityAnimation->setEasingCurve(QEasingCurve::InQuad); |
| 122 | opacityAnimation->setStartValue(1); |
| 123 | opacityAnimation->setEndValue(0); |
| 124 | opacityAnimation->start(QAbstractAnimation::DeleteWhenStopped); |
| 125 | |
| 126 | QPropertyAnimation* pressAnimation = new QPropertyAnimation(d, "pPressRadius"); |
| 127 | connect(pressAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant& value) { |
| 128 | d->_pressGradient->setRadius(value.toReal()); |
| 129 | }); |
| 130 | pressAnimation->setDuration(300); |
| 131 | pressAnimation->setEasingCurve(QEasingCurve::InQuad); |
| 132 | pressAnimation->setStartValue(30); |
| 133 | pressAnimation->setEndValue(d->_getLongestDistance(mouseEvent->pos()) * 1.8); |
| 134 | pressAnimation->start(QAbstractAnimation::DeleteWhenStopped); |
| 135 | d->_isPressAnimationFinished = false; |
| 136 | d->_pressGradient->setFocalPoint(mouseEvent->pos()); |
| 137 | d->_pressGradient->setCenter(mouseEvent->pos()); |
| 138 | //点击后隐藏Hover效果 |
| 139 | d->_startHoverOpacityAnimation(false); |
| 140 | break; |
| 141 | } |
| 142 | case QEvent::MouseButtonRelease: |
| 143 | { |
| 144 | Q_EMIT promotionCardClicked(); |
| 145 | break; |
| 146 | } |
| 147 | case QEvent::MouseMove: |
| 148 | { |
| 149 | QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event); |
| 150 | if (d->_pHoverOpacity < 1 && d->_isPressAnimationFinished) |
| 151 | { |
| 152 | d->_startHoverOpacityAnimation(true); |
| 153 | } |
| 154 | if (d->_isPressAnimationFinished) |
| 155 | { |
| 156 | d->_hoverGradient->setCenter(mouseEvent->pos()); |
| 157 | d->_hoverGradient->setFocalPoint(mouseEvent->pos()); |
| 158 | } |
| 159 | update(); |
| 160 | break; |
nothing calls this directly
no test coverage detected