Update PlayerList to work more akin to WebAO (#1039)
* Add Playerlist label formatter to account for missing args * Make it less of a visual atrocity
This commit is contained in:
parent
50204ec2e2
commit
552ccc38d6
@ -73,6 +73,10 @@ void PlayerListWidget::updatePlayer(const PlayerUpdate &update)
|
|||||||
void PlayerListWidget::setAuthenticated(bool f_state)
|
void PlayerListWidget::setAuthenticated(bool f_state)
|
||||||
{
|
{
|
||||||
m_is_authenticated = f_state;
|
m_is_authenticated = f_state;
|
||||||
|
for (const PlayerData &data : qAsConst(m_player_map))
|
||||||
|
{
|
||||||
|
updatePlayer(data.id, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerListWidget::onCustomContextMenuRequested(const QPoint &pos)
|
void PlayerListWidget::onCustomContextMenuRequested(const QPoint &pos)
|
||||||
@ -159,7 +163,7 @@ void PlayerListWidget::updatePlayer(int playerId, bool updateIcon)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
item->setText(data.name.isEmpty() ? QObject::tr("Unnamed Player") : data.name);
|
item->setText(formatLabel(data));
|
||||||
if (data.character.isEmpty())
|
if (data.character.isEmpty())
|
||||||
{
|
{
|
||||||
item->setToolTip(QString());
|
item->setToolTip(QString());
|
||||||
@ -179,3 +183,12 @@ void PlayerListWidget::updatePlayer(int playerId, bool updateIcon)
|
|||||||
item->setIcon(QIcon(ao_app->get_image_suffix(ao_app->get_character_path(data.character, "char_icon"), true)));
|
item->setIcon(QIcon(ao_app->get_image_suffix(ao_app->get_character_path(data.character, "char_icon"), true)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PlayerListWidget::formatLabel(const PlayerData &data)
|
||||||
|
{
|
||||||
|
if (m_is_authenticated)
|
||||||
|
{
|
||||||
|
return QString("%1 %2 %3").arg(data.character, data.character_name, data.name).simplified();
|
||||||
|
}
|
||||||
|
return QString("%1 %2").arg(data.character, data.character_name).simplified();
|
||||||
|
}
|
||||||
|
@ -29,6 +29,8 @@ private:
|
|||||||
void removePlayer(int playerId);
|
void removePlayer(int playerId);
|
||||||
void updatePlayer(int playerId, bool updateIcon);
|
void updatePlayer(int playerId, bool updateIcon);
|
||||||
|
|
||||||
|
QString formatLabel(const PlayerData &data);
|
||||||
|
|
||||||
void filterPlayerList();
|
void filterPlayerList();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
|
Loading…
Reference in New Issue
Block a user