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

Method showPopup

ElaWidgetTools/ElaMultiSelectComboBox.cpp:208–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208void ElaMultiSelectComboBox::showPopup()
209{
210 Q_D(ElaMultiSelectComboBox);
211 bool oldAnimationEffects = qApp->isEffectEnabled(Qt::UI_AnimateCombo);
212 qApp->setEffectEnabled(Qt::UI_AnimateCombo, false);
213 QComboBox::showPopup();
214 qApp->setEffectEnabled(Qt::UI_AnimateCombo, oldAnimationEffects);
215
216 if (count() > 0)
217 {
218 QWidget* container = this->findChild<QFrame*>();
219 if (container)
220 {
221 int containerHeight = 0;
222 if (count() >= maxVisibleItems())
223 {
224 containerHeight = maxVisibleItems() * 35 + 8;
225 }
226 else
227 {
228 containerHeight = count() * 35 + 8;
229 }
230 view()->resize(view()->width(), containerHeight - 8);
231 container->move(container->x(), container->y() + 3);
232 QLayout* layout = container->layout();
233 while (layout->count())
234 {
235 layout->takeAt(0);
236 }
237 QPropertyAnimation* fixedSizeAnimation = new QPropertyAnimation(container, "maximumHeight");
238 connect(fixedSizeAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant& value) {
239 container->setFixedHeight(value.toUInt());
240 });
241 fixedSizeAnimation->setStartValue(1);
242 fixedSizeAnimation->setEndValue(containerHeight);
243 fixedSizeAnimation->setEasingCurve(QEasingCurve::OutCubic);
244 fixedSizeAnimation->setDuration(400);
245 fixedSizeAnimation->start(QAbstractAnimation::DeleteWhenStopped);
246
247 QPropertyAnimation* viewPosAnimation = new QPropertyAnimation(view(), "pos");
248 connect(viewPosAnimation, &QPropertyAnimation::finished, this, [=]() {
249 d->_isAllowHidePopup = true;
250 layout->addWidget(view());
251 });
252 QPoint viewPos = view()->pos();
253 viewPosAnimation->setStartValue(QPoint(viewPos.x(), viewPos.y() - view()->height()));
254 viewPosAnimation->setEndValue(viewPos);
255 viewPosAnimation->setEasingCurve(QEasingCurve::OutCubic);
256 viewPosAnimation->setDuration(400);
257 viewPosAnimation->start(QAbstractAnimation::DeleteWhenStopped);
258 }
259 //指示器动画
260 QPropertyAnimation* rotateAnimation = new QPropertyAnimation(d, "pExpandIconRotate");
261 connect(rotateAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant& value) {
262 update();
263 });
264 rotateAnimation->setDuration(300);
265 rotateAnimation->setEasingCurve(QEasingCurve::InOutSine);

Callers

nothing calls this directly

Calls 5

countMethod · 0.80
takeAtMethod · 0.80
setFixedHeightMethod · 0.80
addWidgetMethod · 0.80
_refreshCurrentIndexsMethod · 0.80

Tested by

no test coverage detected