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

Method hidePopup

ElaWidgetTools/ElaComboBox.cpp:150–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150void ElaComboBox::hidePopup()
151{
152 Q_D(ElaComboBox);
153 if (d->_isAllowHidePopup)
154 {
155 QWidget* container = this->findChild<QFrame*>();
156 int containerHeight = container->height();
157 if (container)
158 {
159 QLayout* layout = container->layout();
160 while (layout->count())
161 {
162 layout->takeAt(0);
163 }
164 QPropertyAnimation* viewPosAnimation = new QPropertyAnimation(view(), "pos");
165 connect(viewPosAnimation, &QPropertyAnimation::finished, this, [=]() {
166 layout->addWidget(view());
167 QMouseEvent focusEvent(QEvent::MouseButtonPress, QPoint(-1, -1), QPoint(-1, -1), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
168 QApplication::sendEvent(parentWidget(), &focusEvent);
169 QComboBox::hidePopup();
170 container->setFixedHeight(containerHeight);
171 });
172 QPoint viewPos = view()->pos();
173 connect(viewPosAnimation, &QPropertyAnimation::finished, this, [=]() {
174 view()->move(viewPos);
175 });
176 viewPosAnimation->setStartValue(viewPos);
177 viewPosAnimation->setEndValue(QPoint(viewPos.x(), viewPos.y() - view()->height()));
178 viewPosAnimation->setEasingCurve(QEasingCurve::InCubic);
179 viewPosAnimation->start(QAbstractAnimation::DeleteWhenStopped);
180
181 QPropertyAnimation* fixedSizeAnimation = new QPropertyAnimation(container, "maximumHeight");
182 connect(fixedSizeAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant& value) {
183 container->setFixedHeight(value.toUInt());
184 });
185 fixedSizeAnimation->setStartValue(container->height());
186 fixedSizeAnimation->setEndValue(1);
187 fixedSizeAnimation->setEasingCurve(QEasingCurve::InCubic);
188 fixedSizeAnimation->start(QAbstractAnimation::DeleteWhenStopped);
189 d->_isAllowHidePopup = false;
190 }
191 //指示器动画
192 QPropertyAnimation* rotateAnimation = new QPropertyAnimation(d->_comboBoxStyle, "pExpandIconRotate");
193 connect(rotateAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant& value) {
194 update();
195 });
196 rotateAnimation->setDuration(300);
197 rotateAnimation->setEasingCurve(QEasingCurve::InOutSine);
198 rotateAnimation->setStartValue(d->_comboBoxStyle->getExpandIconRotate());
199 rotateAnimation->setEndValue(0);
200 rotateAnimation->start(QAbstractAnimation::DeleteWhenStopped);
201 QPropertyAnimation* markAnimation = new QPropertyAnimation(d->_comboBoxStyle, "pExpandMarkWidth");
202 markAnimation->setDuration(300);
203 markAnimation->setEasingCurve(QEasingCurve::InOutSine);
204 markAnimation->setStartValue(d->_comboBoxStyle->getExpandMarkWidth());
205 markAnimation->setEndValue(0);
206 markAnimation->start(QAbstractAnimation::DeleteWhenStopped);
207 }

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected