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:
Fabio Bas 2015-05-17 23:30:14 +02:00
parent 48c3e64ef5
commit 6b8ebe54e9
64 changed files with 360 additions and 388 deletions

View file

@ -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 {
QSvgRenderer svg(QString(":/back.svg"));
if (getName().isEmpty()) {
QSvgRenderer svg(QString("theme:back.svg"));
bigPixmap = QPixmap(svg.defaultSize());
bigPixmap.fill(Qt::transparent);
QPainter painter(&bigPixmap);
svg.render(&painter);
} else {
pixmap = QPixmap(); // null
return;
}
}
@ -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()