bool DiscardPile::_addCardItems(QList<CardItem*> &card_items, Player::Place place) { _m_mutex_pileCards.lock(); m_visibleCards.append(card_items); int numAdded = card_items.size(); int numRemoved = m_visibleCards.size() - qMax(m_numCardsVisible, numAdded + 1); for (int i = 0; i < numRemoved; i++) { CardItem* toRemove = m_visibleCards.first(); toRemove->setZValue(0.0); toRemove->setHomeOpacity(0.0); connect(toRemove, SIGNAL(movement_animation_finished()), this, SLOT(_destroyCard())); toRemove->goBack(true); m_visibleCards.removeFirst(); } foreach (CardItem* card_item, m_visibleCards) { card_item->setHomeOpacity(0.7); }
void TablePile::clear(bool playAnimation) { if (m_visibleCards.empty()) return; _m_mutex_pileCards.lock(); // check again since we just gain the lock. int shift = 1 * G_COMMON_LAYOUT.m_cardNormalWidth; QParallelAnimationGroup* group = new QParallelAnimationGroup; foreach (CardItem* toRemove, m_visibleCards) { toRemove->setZValue(0.0); toRemove->setHomeOpacity(0.0); toRemove->setHomePos(QPointF(toRemove->x() - shift, toRemove->y())); if (playAnimation) { connect(toRemove, SIGNAL(movement_animation_finished()), this, SLOT(_destroyCard())); group->addAnimation(toRemove->getGoBackAnimation(true)); } else delete toRemove; }