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

Took 7 minutes

Took 3 seconds
This commit is contained in:
Lukas Brübach 2026-05-19 10:57:35 +02:00
parent 7a5b2e9f0e
commit abc25a1a68
3 changed files with 4 additions and 2 deletions

View file

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

View file

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

View file

@ -15,6 +15,8 @@ PlayerGraphicsItem::PlayerGraphicsItem(Player *_player) : player(_player)
connect(&SettingsCache::instance(), &SettingsCache::handJustificationChanged, this, connect(&SettingsCache::instance(), &SettingsCache::handJustificationChanged, this,
&PlayerGraphicsItem::rearrangeZones); &PlayerGraphicsItem::rearrangeZones);
connect(player, &Player::rearrangeCounters, this, &PlayerGraphicsItem::rearrangeCounters); 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); playerArea = new PlayerArea(this);