mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
improved card dragging
This commit is contained in:
parent
680d5ab84c
commit
0f272a2f51
9 changed files with 115 additions and 74 deletions
|
|
@ -88,19 +88,22 @@ QPixmap *CardInfo::loadPixmap()
|
|||
if (pixmap->load(QString("../pics/%1/%2%3.full.jpg").arg(editions.at(i)).arg(correctedName).arg(1)))
|
||||
return pixmap;
|
||||
}
|
||||
pixmap->load("../pics/none.jpg");
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
QPixmap *CardInfo::getPixmap(QSize size)
|
||||
{
|
||||
qDebug(QString("CardInfo::getPixmap(%1, %2) for %3").arg(size.width()).arg(size.height()).arg(getName()).toLatin1());
|
||||
if (QPixmap *result = scaledPixmapCache.value(size.width())) {
|
||||
QPixmap *cachedPixmap = scaledPixmapCache.value(size.width());
|
||||
if (cachedPixmap) {
|
||||
qDebug("cache HIT");
|
||||
return result;
|
||||
return cachedPixmap;
|
||||
}
|
||||
qDebug("cache MISS");
|
||||
QPixmap *result = new QPixmap(loadPixmap()->scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||
QPixmap *bigPixmap = loadPixmap();
|
||||
if (bigPixmap->isNull())
|
||||
return 0;
|
||||
QPixmap *result = new QPixmap(bigPixmap->scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||
scaledPixmapCache.insert(size.width(), result);
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue