mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Theme manager
This is the first implementation of a theme manager. It’s a rebased and revisited version of #792.
This commit is contained in:
parent
5d08236cbe
commit
bdd55db549
64 changed files with 359 additions and 387 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "carddatabase.h"
|
||||
#include "settingscache.h"
|
||||
#include "thememanager.h"
|
||||
#include <QDir>
|
||||
#include <QDirIterator>
|
||||
#include <QFile>
|
||||
|
|
@ -570,7 +571,7 @@ void CardInfo::loadPixmap(QPixmap &pixmap)
|
|||
pixmap = QPixmap();
|
||||
|
||||
if (getName().isEmpty()) {
|
||||
pixmap.load(settingsCache->getCardBackPicturePath());
|
||||
pixmap = themeManager->getCardBackPixmap();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -594,15 +595,15 @@ void CardInfo::getPixmap(QSize size, QPixmap &pixmap)
|
|||
QPixmap bigPixmap;
|
||||
loadPixmap(bigPixmap);
|
||||
if (bigPixmap.isNull()) {
|
||||
if (!getName().isEmpty()) {
|
||||
pixmap = QPixmap(); // null
|
||||
return;
|
||||
} else {
|
||||
if (getName().isEmpty()) {
|
||||
pixmap = QPixmap(size);
|
||||
pixmap.fill(Qt::transparent);
|
||||
QSvgRenderer svg(QString(":/back.svg"));
|
||||
QSvgRenderer svg(QString("theme:back.svg"));
|
||||
QPainter painter(&pixmap);
|
||||
svg.render(&painter, QRectF(0, 0, size.width(), size.height()));
|
||||
} else {
|
||||
pixmap = QPixmap(); // null
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
pixmap = bigPixmap.scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
|
|
@ -724,7 +725,7 @@ CardDatabase::CardDatabase(QObject *parent)
|
|||
noCard = new CardInfo(this);
|
||||
QPixmap tmp;
|
||||
noCard->loadPixmap(tmp); // cache pixmap for card back
|
||||
connect(settingsCache, SIGNAL(cardBackPicturePathChanged()), noCard, SLOT(updatePixmapCache()));
|
||||
connect(themeManager, SIGNAL(themeChanged()), noCard, SLOT(updatePixmapCache()));
|
||||
}
|
||||
|
||||
CardDatabase::~CardDatabase()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue