Qt 4.8
Public Functions | Public Variables | List of all members
PixmapEntry Struct Reference

#include <qiconloader_p.h>

Inheritance diagram for PixmapEntry:
QIconLoaderEngineEntry

Public Functions

QPixmap pixmap (const QSize &size, QIcon::Mode mode, QIcon::State state)
 
- Public Functions inherited from QIconLoaderEngineEntry
virtual ~QIconLoaderEngineEntry ()
 

Public Variables

QPixmap basePixmap
 
- Public Variables inherited from QIconLoaderEngineEntry
QIconDirInfo dir
 
QString filename
 

Additional Inherited Members

- Static Public Variables inherited from QIconLoaderEngineEntry
static int count
 

Detailed Description

Definition at line 104 of file qiconloader_p.h.

Functions

◆ pixmap()

QPixmap PixmapEntry::pixmap ( const QSize size,
QIcon::Mode  mode,
QIcon::State  state 
)
virtual

Implements QIconLoaderEngineEntry.

Definition at line 483 of file qiconloader.cpp.

484 {
485  Q_UNUSED(state);
486 
487  // Ensure that basePixmap is lazily initialized before generating the
488  // key, otherwise the cache key is not unique
489  if (basePixmap.isNull())
491 
492  int actualSize = qMin(size.width(), size.height());
493 
494  QString key = QLatin1Literal("$qt_theme_")
496  % HexString<int>(mode)
497  % HexString<qint64>(qApp->palette().cacheKey())
498  % HexString<int>(actualSize);
499 
500  QPixmap cachedPixmap;
501  if (QPixmapCache::find(key, &cachedPixmap)) {
502  return cachedPixmap;
503  } else {
504  QStyleOption opt(0);
505  opt.palette = qApp->palette();
506  cachedPixmap = qApp->style()->generatedIconPixmap(mode, basePixmap, &opt);
507  QPixmapCache::insert(key, cachedPixmap);
508  }
509  return cachedPixmap;
510 }
The QLatin1Literal class provides a thin wrapper around string literals used in source code...
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
bool load(const QString &fileName, const char *format=0, Qt::ImageConversionFlags flags=Qt::AutoColor)
Loads a pixmap from the file with the given fileName.
Definition: qpixmap.cpp:930
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QPixmap * find(const QString &key)
int width() const
Returns the width.
Definition: qsize.h:126
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
#define qApp
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
int key
int height() const
Returns the height.
Definition: qsize.h:129
qint64 cacheKey() const
Returns a number that identifies this QPixmap.
Definition: qpixmap.cpp:1136
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QPixmap basePixmap

Properties

◆ basePixmap

QPixmap PixmapEntry::basePixmap

Definition at line 107 of file qiconloader_p.h.


The documentation for this struct was generated from the following files: