MCPcopy Create free account
hub / github.com/Linloir/GraphBuilder / AddWidget

Method AddWidget

customScrollContainer.cpp:234–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234void ScrollListContainer::AddWidget(QWidget *widget, bool setAnimation){
235 //Add animation for all widgets current
236 this->resize(this->width(), this->height() + widget->height() + spacing);
237 widgets.push_back(widget);
238 size++;
239 ys.push_back(0);
240 widget->resize(this->width(), widget->height());
241 widget->show();
242
243 if(setAnimation){
244 QGraphicsOpacityEffect* widgetOpac = new QGraphicsOpacityEffect(widget);
245 widgetOpac->setOpacity(0);
246 widget->setGraphicsEffect(widgetOpac);
247 QParallelAnimationGroup* dpGroup = new QParallelAnimationGroup;
248 QSequentialAnimationGroup* newWidgetFadeIn = new QSequentialAnimationGroup;
249 for(int i = 0; i < size - 1; i++){
250 ys[i] += widget->height() + spacing;
251 QPropertyAnimation* move = new QPropertyAnimation(widgets[i], "pos");
252 move->setDuration(750);
253 move->setStartValue(widgets[i]->pos());
254 move->setEndValue(QPoint(widgets[i]->x(), ys[i]));
255 move->setEasingCurve(QEasingCurve::InOutQuart);
256 dpGroup->addAnimation(move);
257 }
258 newWidgetFadeIn->addPause(300);
259 QPropertyAnimation* fade = new QPropertyAnimation(widgetOpac, "opacity", widget);
260 fade->setDuration(300);
261 fade->setStartValue(0);
262 fade->setEndValue(0.99);
263 newWidgetFadeIn->addAnimation(fade);
264 dpGroup->addAnimation(newWidgetFadeIn);
265 dpGroup->start();
266 connect(dpGroup, &QPropertyAnimation::stateChanged, [=](){
267 if(dpGroup->state() == QAbstractAnimation::Stopped){
268 if(widgetOpac->opacity() != 0.99){
269 fade->start(QAbstractAnimation::DeleteWhenStopped);
270 connect(fade,&QPropertyAnimation::finished,[=](){widgetOpac->deleteLater();});
271 }
272 else{
273 dpGroup->deleteLater();
274 widgetOpac->deleteLater();
275 }
276 }
277 });
278 }
279 else{
280 for(int i = 0; i < size - 1; i++){
281 ys[i] += widget->height() + spacing;
282 widgets[i]->move(QPoint(widgets[i]->pos().x(), ys[i]));
283 }
284 }
285}
286
287void ScrollListContainer::RemoveWidget(QWidget *widget){
288 int index;

Callers 1

addWidgetMethod · 0.80

Calls 2

addAnimationMethod · 0.80
moveMethod · 0.80

Tested by

no test coverage detected