Buddy stars

Buddies will now be seen as stars in the chat
This commit is contained in:
Matt Lowe 2015-01-31 17:11:17 +01:00
parent 6d4716b38f
commit d57a6111aa
12 changed files with 409 additions and 12 deletions

View file

@ -134,12 +134,13 @@ QPixmap CountryPixmapGenerator::generatePixmap(int height, const QString &countr
QMap<QString, QPixmap> CountryPixmapGenerator::pmCache;
QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags userLevel)
QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags userLevel, bool isBuddy)
{
int key = height * 10000 + (int) userLevel;
int key = height * 10000 + (int) userLevel + (int) isBuddy;
if (pmCache.contains(key))
return pmCache.value(key);
QString levelString;
if (userLevel.testFlag(ServerInfo_User::IsAdmin))
levelString = "admin";
@ -149,13 +150,17 @@ QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags user
levelString = "registered";
else
levelString = "normal";
if (isBuddy)
levelString.append("_buddy");
QSvgRenderer svg(QString(":/resources/userlevels/" + levelString + ".svg"));
int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height());
QPixmap pixmap(width, height);
pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
svg.render(&painter, QRectF(0, 0, width, height));
pmCache.insert(key, pixmap);
return pixmap;
}