MCPcopy Create free account
hub / github.com/MultiMC/Launcher / pixmap

Method pixmap

libraries/iconfix/internal/qiconloader.cpp:586–623  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

584}
585
586QPixmap PixmapEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
587{
588 Q_UNUSED(state);
589
590 // Ensure that basePixmap is lazily initialized before generating the
591 // key, otherwise the cache key is not unique
592 if (basePixmap.isNull())
593 basePixmap.load(filename);
594
595 QSize actualSize = basePixmap.size();
596 if (!actualSize.isNull() &&
597 (actualSize.width() > size.width() || actualSize.height() > size.height()))
598 actualSize.scale(size, Qt::KeepAspectRatio);
599
600 QString key = QLatin1String("$qt_theme_") % HexString<qint64>(basePixmap.cacheKey()) %
601 HexString<int>(mode) %
602 HexString<qint64>(QGuiApplication::palette().cacheKey()) %
603 HexString<int>(actualSize.width()) % HexString<int>(actualSize.height());
604
605 QPixmap cachedPixmap;
606 if (QPixmapCache::find(key, &cachedPixmap))
607 {
608 return cachedPixmap;
609 }
610 else
611 {
612 if (basePixmap.size() != actualSize)
613 {
614 cachedPixmap = basePixmap.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
615 }
616 else
617 {
618 cachedPixmap = basePixmap;
619 }
620 QPixmapCache::insert(key, cachedPixmap);
621 }
622 return cachedPixmap;
623}
624
625QPixmap ScalableEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
626{

Callers 5

dataMethod · 0.80
resetIconMethod · 0.80
AboutDialogMethod · 0.80
SaveIconFunction · 0.80
saveIconMethod · 0.80

Calls 2

loadMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected