MCPcopy Create free account
hub / github.com/Liniyous/ElaWidgetTools / hidePopup

Method hidePopup

ElaWidgetTools/ElaMultiSelectComboBox.cpp:280–350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280void ElaMultiSelectComboBox::hidePopup()
281{
282 Q_D(ElaMultiSelectComboBox);
283 if (d->_isFirstPopup && !this->view()->underMouse())
284 {
285 d->_isFirstPopup = false;
286 return;
287 }
288 if (eApp->containsCursorToItem(d->_comboView))
289 {
290 return;
291 }
292 else
293 {
294 if (d->_isAllowHidePopup)
295 {
296 QWidget* container = this->findChild<QFrame*>();
297 int containerHeight = container->height();
298 if (container)
299 {
300 QLayout* layout = container->layout();
301 while (layout->count())
302 {
303 layout->takeAt(0);
304 }
305 QPropertyAnimation* viewPosAnimation = new QPropertyAnimation(view(), "pos");
306 connect(viewPosAnimation, &QPropertyAnimation::finished, this, [=]() {
307 layout->addWidget(view());
308 QMouseEvent focusEvent(QEvent::MouseButtonPress, QPoint(-1, -1), QPoint(-1, -1), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
309 QApplication::sendEvent(parentWidget(), &focusEvent);
310 QComboBox::hidePopup();
311 container->setFixedHeight(containerHeight);
312 });
313 QPoint viewPos = view()->pos();
314 connect(viewPosAnimation, &QPropertyAnimation::finished, this, [=]() {
315 view()->move(viewPos);
316 });
317 viewPosAnimation->setStartValue(viewPos);
318 viewPosAnimation->setEndValue(QPoint(viewPos.x(), viewPos.y() - view()->height()));
319 viewPosAnimation->setEasingCurve(QEasingCurve::InCubic);
320 viewPosAnimation->start(QAbstractAnimation::DeleteWhenStopped);
321
322 QPropertyAnimation* fixedSizeAnimation = new QPropertyAnimation(container, "maximumHeight");
323 connect(fixedSizeAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant& value) {
324 container->setFixedHeight(value.toUInt());
325 });
326 fixedSizeAnimation->setStartValue(container->height());
327 fixedSizeAnimation->setEndValue(1);
328 fixedSizeAnimation->setEasingCurve(QEasingCurve::InCubic);
329 fixedSizeAnimation->start(QAbstractAnimation::DeleteWhenStopped);
330 d->_isAllowHidePopup = false;
331 }
332 //指示器动画
333 QPropertyAnimation* rotateAnimation = new QPropertyAnimation(d, "pExpandIconRotate");
334 connect(rotateAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant& value) {
335 update();
336 });
337 rotateAnimation->setDuration(300);

Callers

nothing calls this directly

Calls 5

containsCursorToItemMethod · 0.80
countMethod · 0.80
takeAtMethod · 0.80
addWidgetMethod · 0.80
setFixedHeightMethod · 0.80

Tested by

no test coverage detected