[Player] Stop reaching into graphics_item and emit signals instead for conceded and zoneId (#6912)

* [Player] Stop reaching into graphics_item and emit signals instead for conceded and zoneId

Took 7 minutes

Took 3 seconds

* Add sameValue check.

Took 3 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-05-19 12:22:40 +02:00 committed by GitHub
parent af2f888293
commit 9f1c225b7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 3 deletions

View file

@ -89,7 +89,6 @@ void Player::setConceded(bool _conceded)
if (conceded != _conceded) {
conceded = _conceded;
getGraphicsItem()->setVisible(!conceded);
if (conceded) {
clear();
}
@ -99,8 +98,10 @@ void Player::setConceded(bool _conceded)
void Player::setZoneId(int _zoneId)
{
zoneId = _zoneId;
graphicsItem->getPlayerArea()->setPlayerZoneId(zoneId);
if (zoneId != _zoneId) {
zoneId = _zoneId;
emit zoneIdChanged(zoneId);
}
}
void Player::processPlayerInfo(const ServerInfo_Player &info)

View file

@ -72,6 +72,7 @@ signals:
void newCardAdded(AbstractCardItem *card);
void rearrangeCounters();
void activeChanged(bool active);
void zoneIdChanged(int zoneId);
void concededChanged(int playerId, bool conceded);
void clearCustomZonesMenu();
void addViewCustomZoneActionToCustomZoneMenu(QString zoneName);

View file

@ -15,6 +15,8 @@ PlayerGraphicsItem::PlayerGraphicsItem(Player *_player) : player(_player)
connect(&SettingsCache::instance(), &SettingsCache::handJustificationChanged, this,
&PlayerGraphicsItem::rearrangeZones);
connect(player, &Player::rearrangeCounters, this, &PlayerGraphicsItem::rearrangeCounters);
connect(player, &Player::concededChanged, this, [this](int, bool c) { setVisible(!c); });
connect(player, &Player::zoneIdChanged, this, [this](int id) { playerArea->setPlayerZoneId(id); });
playerArea = new PlayerArea(this);