parent
acb40bc738
commit
8ad448a23c
4 changed files with 24 additions and 25 deletions
|
@ -95,7 +95,7 @@ void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedS
|
|||
if(facedown)
|
||||
{
|
||||
// never reveal card color, always paint the card back
|
||||
PictureLoader::getPixmap(translatedPixmap, nullptr, translatedSize.toSize());
|
||||
PictureLoader::getCardBackPixmap(translatedPixmap, translatedSize.toSize());
|
||||
} else {
|
||||
// don't even spend time trying to load the picture if our size is too small
|
||||
if(translatedSize.width() > 10)
|
||||
|
|
|
@ -41,7 +41,10 @@ void CardInfoPicture::updatePixmap()
|
|||
|
||||
void CardInfoPicture::loadPixmap()
|
||||
{
|
||||
if(info)
|
||||
PictureLoader::getPixmap(resizedPixmap, info, size());
|
||||
else
|
||||
PictureLoader::getCardBackPixmap(resizedPixmap, size());
|
||||
}
|
||||
|
||||
void CardInfoPicture::paintEvent(QPaintEvent *)
|
||||
|
|
|
@ -422,7 +422,7 @@ PictureLoader::~PictureLoader()
|
|||
worker->deleteLater();
|
||||
}
|
||||
|
||||
void PictureLoader::internalGetCardBackPixmap(QPixmap &pixmap, QSize size)
|
||||
void PictureLoader::getCardBackPixmap(QPixmap &pixmap, QSize size)
|
||||
{
|
||||
QString backCacheKey = "_trice_card_back_" + QString::number(size.width()) + QString::number(size.height());
|
||||
if(!QPixmapCache::find(backCacheKey, &pixmap))
|
||||
|
@ -435,8 +435,9 @@ void PictureLoader::internalGetCardBackPixmap(QPixmap &pixmap, QSize size)
|
|||
|
||||
void PictureLoader::getPixmap(QPixmap &pixmap, CardInfo *card, QSize size)
|
||||
{
|
||||
if(card)
|
||||
{
|
||||
if(card == nullptr)
|
||||
return;
|
||||
|
||||
// search for an exact size copy of the picure in cache
|
||||
QString key = card->getPixmapCacheKey();
|
||||
QString sizekey = key + QLatin1Char('_') + QString::number(size.width()) + QString::number(size.height());
|
||||
|
@ -454,10 +455,6 @@ void PictureLoader::getPixmap(QPixmap &pixmap, CardInfo *card, QSize size)
|
|||
|
||||
// add the card to the load queue
|
||||
getInstance().worker->enqueueImageLoad(card);
|
||||
} else {
|
||||
// requesting the image for a null card is a shortcut to get the card background image
|
||||
internalGetCardBackPixmap(pixmap, size);
|
||||
}
|
||||
}
|
||||
|
||||
void PictureLoader::imageLoaded(CardInfo *card, const QImage &image)
|
||||
|
|
|
@ -82,11 +82,10 @@ private:
|
|||
PictureLoaderWorker * worker;
|
||||
public:
|
||||
static void getPixmap(QPixmap &pixmap, CardInfo *card, QSize size);
|
||||
static void getCardBackPixmap(QPixmap &pixmap, QSize size);
|
||||
static void clearPixmapCache(CardInfo *card);
|
||||
static void clearPixmapCache();
|
||||
static void cacheCardPixmaps(QList<CardInfo *> cards);
|
||||
protected:
|
||||
static void internalGetCardBackPixmap(QPixmap &pixmap, QSize size);
|
||||
private slots:
|
||||
void picDownloadChanged();
|
||||
void picsPathChanged();
|
||||
|
|
Loading…
Reference in a new issue