mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 08:14:47 -07:00
Themes: remove all hardcoded extensions
This commit is contained in:
parent
226a8cc017
commit
00e3e63f41
27 changed files with 348 additions and 419 deletions
|
|
@ -1,7 +1,6 @@
|
|||
#include "pixmapgenerator.h"
|
||||
#include "pb/serverinfo_user.pb.h"
|
||||
#include <QPainter>
|
||||
#include <QSvgRenderer>
|
||||
#include <cmath>
|
||||
#ifdef _WIN32
|
||||
#include "round.h"
|
||||
|
|
@ -16,12 +15,8 @@ QPixmap PhasePixmapGenerator::generatePixmap(int height, QString name)
|
|||
if (pmCache.contains(key))
|
||||
return pmCache.value(key);
|
||||
|
||||
QSvgRenderer svg(QString("theme:phases/" + name + ".svg"));
|
||||
|
||||
QPixmap pixmap(height, height);
|
||||
pixmap.fill(Qt::transparent);
|
||||
QPainter painter(&pixmap);
|
||||
svg.render(&painter, QRectF(0, 0, height, height));
|
||||
QPixmap pixmap = QPixmap("theme:phases/" + name).scaled(height, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
pmCache.insert(key, pixmap);
|
||||
return pixmap;
|
||||
}
|
||||
|
|
@ -36,20 +31,16 @@ QPixmap CounterPixmapGenerator::generatePixmap(int height, QString name, bool hi
|
|||
if (pmCache.contains(key))
|
||||
return pmCache.value(key);
|
||||
|
||||
QSvgRenderer svg(QString("theme:counters/" + name + ".svg"));
|
||||
|
||||
if (!svg.isValid()) {
|
||||
QPixmap pixmap = QPixmap("theme:counters/" + name).scaled(height, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
if(pixmap.isNull())
|
||||
{
|
||||
name = "general";
|
||||
if (highlight)
|
||||
name.append("_highlight");
|
||||
svg.load(QString("theme:counters/" + name + ".svg"));
|
||||
pixmap = QPixmap("theme:counters/" + name).scaled(height, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
@ -97,14 +88,8 @@ QPixmap GenderPixmapGenerator::generatePixmap(int height, int _gender)
|
|||
case ServerInfo_User::Female: genderStr = "female"; break;
|
||||
default: genderStr = "unknown";
|
||||
};
|
||||
|
||||
QSvgRenderer svg(QString("theme:genders/" + genderStr + ".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));
|
||||
|
||||
|
||||
QPixmap pixmap = QPixmap("theme:genders/" + genderStr).scaled(height, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
pmCache.insert(key, pixmap);
|
||||
return pixmap;
|
||||
}
|
||||
|
|
@ -119,14 +104,11 @@ QPixmap CountryPixmapGenerator::generatePixmap(int height, const QString &countr
|
|||
if (pmCache.contains(key))
|
||||
return pmCache.value(key);
|
||||
|
||||
QSvgRenderer svg(QString("theme:countries/" + countryCode.toLower() + ".svg"));
|
||||
int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height());
|
||||
QPixmap pixmap(width, height);
|
||||
pixmap.fill(Qt::transparent);
|
||||
QPixmap pixmap = QPixmap("theme:countries/" + countryCode.toLower()).scaled(height, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
QPainter painter(&pixmap);
|
||||
svg.render(&painter, QRectF(0, 0, width, height));
|
||||
painter.setPen(Qt::black);
|
||||
painter.drawRect(0, 0, width - 1, height - 1);
|
||||
painter.drawRect(0, 0, height - 1, height - 1);
|
||||
|
||||
pmCache.insert(key, pixmap);
|
||||
return pixmap;
|
||||
|
|
@ -154,13 +136,7 @@ QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags user
|
|||
if (isBuddy)
|
||||
levelString.append("_buddy");
|
||||
|
||||
QSvgRenderer svg(QString("theme: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));
|
||||
|
||||
QPixmap pixmap = QPixmap("theme:userlevels/" + levelString).scaled(height, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
pmCache.insert(key, pixmap);
|
||||
return pixmap;
|
||||
}
|
||||
|
|
@ -175,13 +151,7 @@ QPixmap LockPixmapGenerator::generatePixmap(int height)
|
|||
if (pmCache.contains(key))
|
||||
return pmCache.value(key);
|
||||
|
||||
QSvgRenderer svg(QString("theme:icons/lock.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));
|
||||
|
||||
QPixmap pixmap = QPixmap("theme:icons/lock").scaled(height, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
pmCache.insert(key, pixmap);
|
||||
return pixmap;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue