mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 08:52:15 -07:00
fix view zone close
This commit is contained in:
parent
3d18196710
commit
7a688fd7a9
4 changed files with 18 additions and 7 deletions
|
|
@ -2083,7 +2083,7 @@ void Player::eventShuffle(const Event_Shuffle &event)
|
||||||
int length = view->getCards().length();
|
int length = view->getCards().length();
|
||||||
// we want to close empty views as well
|
// we want to close empty views as well
|
||||||
if (length == 0 || length > absStart) { // note this assumes views always start at the top of the library
|
if (length == 0 || length > absStart) { // note this assumes views always start at the top of the library
|
||||||
view->deleteLater();
|
view->close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -42,11 +42,20 @@ ZoneViewZone::ZoneViewZone(Player *_p,
|
||||||
|
|
||||||
ZoneViewZone::~ZoneViewZone()
|
ZoneViewZone::~ZoneViewZone()
|
||||||
{
|
{
|
||||||
emit beingDeleted();
|
|
||||||
qDebug("ZoneViewZone destructor");
|
qDebug("ZoneViewZone destructor");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes this ZoneView and removes it from the origZone's views.
|
||||||
|
* You should normally call this method instead of deleteLater()
|
||||||
|
*/
|
||||||
|
void ZoneViewZone::close()
|
||||||
|
{
|
||||||
|
emit closed();
|
||||||
if (!(revealZone && !writeableRevealZone)) {
|
if (!(revealZone && !writeableRevealZone)) {
|
||||||
origZone->getViews().removeOne(this);
|
origZone->getViews().removeOne(this);
|
||||||
}
|
}
|
||||||
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF ZoneViewZone::boundingRect() const
|
QRectF ZoneViewZone::boundingRect() const
|
||||||
|
|
|
||||||
|
|
@ -94,13 +94,14 @@ public:
|
||||||
return isReversed;
|
return isReversed;
|
||||||
}
|
}
|
||||||
public slots:
|
public slots:
|
||||||
|
void close();
|
||||||
void setGroupBy(CardList::SortOption _groupBy);
|
void setGroupBy(CardList::SortOption _groupBy);
|
||||||
void setSortBy(CardList::SortOption _sortBy);
|
void setSortBy(CardList::SortOption _sortBy);
|
||||||
void setPileView(int _pileView);
|
void setPileView(int _pileView);
|
||||||
private slots:
|
private slots:
|
||||||
void zoneDumpReceived(const Response &r);
|
void zoneDumpReceived(const Response &r);
|
||||||
signals:
|
signals:
|
||||||
void beingDeleted();
|
void closed();
|
||||||
void optimumRectChanged();
|
void optimumRectChanged();
|
||||||
void wheelEventReceived(QGraphicsSceneWheelEvent *event);
|
void wheelEventReceived(QGraphicsSceneWheelEvent *event);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
|
||||||
setLayout(vbox);
|
setLayout(vbox);
|
||||||
|
|
||||||
connect(zone, &ZoneViewZone::optimumRectChanged, this, &ZoneViewWidget::resizeToZoneContents);
|
connect(zone, &ZoneViewZone::optimumRectChanged, this, &ZoneViewWidget::resizeToZoneContents);
|
||||||
connect(zone, &ZoneViewZone::beingDeleted, this, &ZoneViewWidget::zoneDeleted);
|
connect(zone, &ZoneViewZone::closed, this, &ZoneViewWidget::zoneDeleted);
|
||||||
zone->initializeCards(cardList);
|
zone->initializeCards(cardList);
|
||||||
|
|
||||||
// QLabel sizes aren't taken into account until the widget is rendered.
|
// QLabel sizes aren't taken into account until the widget is rendered.
|
||||||
|
|
@ -314,11 +314,12 @@ void ZoneViewWidget::handleScrollBarChange(int value)
|
||||||
|
|
||||||
void ZoneViewWidget::closeEvent(QCloseEvent *event)
|
void ZoneViewWidget::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
disconnect(zone, &ZoneViewZone::beingDeleted, this, 0);
|
disconnect(zone, &ZoneViewZone::closed, this, 0);
|
||||||
|
// manually call zone->close in order to remove it from the origZones views
|
||||||
|
zone->close();
|
||||||
if (shuffleCheckBox.isChecked())
|
if (shuffleCheckBox.isChecked())
|
||||||
player->sendGameCommand(Command_Shuffle());
|
player->sendGameCommand(Command_Shuffle());
|
||||||
emit closePressed(this);
|
zoneDeleted();
|
||||||
deleteLater();
|
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue