| 132 | } |
| 133 | |
| 134 | void ElaMenu::showEvent(QShowEvent* event) |
| 135 | { |
| 136 | Q_EMIT menuShow(); |
| 137 | Q_D(ElaMenu); |
| 138 | //消除阴影偏移 |
| 139 | move(this->pos().x() - 6, this->pos().y()); |
| 140 | updateGeometry(); |
| 141 | if (!d->_animationPix.isNull()) |
| 142 | { |
| 143 | d->_animationPix = QPixmap(); |
| 144 | } |
| 145 | d->_animationPix = this->grab(this->rect()); |
| 146 | QPropertyAnimation* posAnimation = new QPropertyAnimation(d, "pAnimationImagePosY"); |
| 147 | connect(posAnimation, &QPropertyAnimation::finished, this, [=]() { |
| 148 | d->_animationPix = QPixmap(); |
| 149 | update(); |
| 150 | }); |
| 151 | connect(posAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant& value) { |
| 152 | update(); |
| 153 | }); |
| 154 | posAnimation->setEasingCurve(QEasingCurve::OutCubic); |
| 155 | posAnimation->setDuration(400); |
| 156 | int targetPosY = height(); |
| 157 | if (targetPosY > 160) |
| 158 | { |
| 159 | if (targetPosY < 320) |
| 160 | { |
| 161 | targetPosY = 160; |
| 162 | } |
| 163 | else |
| 164 | { |
| 165 | targetPosY /= 2; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | if (pos().y() + d->_menuStyle->getMenuItemHeight() + 9 >= QCursor::pos().y()) |
| 170 | { |
| 171 | posAnimation->setStartValue(-targetPosY); |
| 172 | } |
| 173 | else |
| 174 | { |
| 175 | posAnimation->setStartValue(targetPosY); |
| 176 | } |
| 177 | |
| 178 | posAnimation->setEndValue(0); |
| 179 | posAnimation->start(QAbstractAnimation::DeleteWhenStopped); |
| 180 | QMenu::showEvent(event); |
| 181 | } |
| 182 | |
| 183 | void ElaMenu::paintEvent(QPaintEvent* event) |
| 184 | { |
nothing calls this directly
no test coverage detected