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

Method showPopup

ElaWidgetTools/ElaComboBox.cpp:81–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81void ElaComboBox::showPopup()
82{
83 Q_D(ElaComboBox);
84 bool oldAnimationEffects = qApp->isEffectEnabled(Qt::UI_AnimateCombo);
85 qApp->setEffectEnabled(Qt::UI_AnimateCombo, false);
86 QComboBox::showPopup();
87 qApp->setEffectEnabled(Qt::UI_AnimateCombo, oldAnimationEffects);
88 if (count() > 0)
89 {
90 QWidget* container = this->findChild<QFrame*>();
91 if (container)
92 {
93 int containerHeight = 0;
94 if (count() >= maxVisibleItems())
95 {
96 containerHeight = maxVisibleItems() * 35 + 8;
97 }
98 else
99 {
100 containerHeight = count() * 35 + 8;
101 }
102 view()->resize(view()->width(), containerHeight - 8);
103 container->move(container->x(), container->y() + 3);
104 QLayout* layout = container->layout();
105 while (layout->count())
106 {
107 layout->takeAt(0);
108 }
109 QPropertyAnimation* fixedSizeAnimation = new QPropertyAnimation(container, "maximumHeight");
110 connect(fixedSizeAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant& value) {
111 container->setFixedHeight(value.toUInt());
112 });
113 fixedSizeAnimation->setStartValue(1);
114 fixedSizeAnimation->setEndValue(containerHeight);
115 fixedSizeAnimation->setEasingCurve(QEasingCurve::OutCubic);
116 fixedSizeAnimation->setDuration(400);
117 fixedSizeAnimation->start(QAbstractAnimation::DeleteWhenStopped);
118
119 QPropertyAnimation* viewPosAnimation = new QPropertyAnimation(view(), "pos");
120 connect(viewPosAnimation, &QPropertyAnimation::finished, this, [=]() {
121 d->_isAllowHidePopup = true;
122 layout->addWidget(view());
123 });
124 QPoint viewPos = view()->pos();
125 viewPosAnimation->setStartValue(QPoint(viewPos.x(), viewPos.y() - view()->height()));
126 viewPosAnimation->setEndValue(viewPos);
127 viewPosAnimation->setEasingCurve(QEasingCurve::OutCubic);
128 viewPosAnimation->setDuration(400);
129 viewPosAnimation->start(QAbstractAnimation::DeleteWhenStopped);
130 }
131 //指示器动画
132 QPropertyAnimation* rotateAnimation = new QPropertyAnimation(d->_comboBoxStyle, "pExpandIconRotate");
133 connect(rotateAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant& value) {
134 update();
135 });
136 rotateAnimation->setDuration(300);
137 rotateAnimation->setEasingCurve(QEasingCurve::InOutSine);
138 rotateAnimation->setStartValue(d->_comboBoxStyle->getExpandIconRotate());

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected