46 #include "private/qfactoryloader_p.h" 47 #include "private/qiconloader_p.h" 57 #include "private/qguiplatformplugin_p.h" 60 #include <private/qt_mac_p.h> 61 #include <private/qt_cocoa_helpers_mac_p.h> 65 #include "private/qt_x11_p.h" 66 #include "private/qkde_p.h" 69 #include "private/qstylehelper_p.h" 121 qtIconCache()->clear();
126 serialNum(serialNumCounter.fetchAndAddRelaxed(1)),
149 #if defined(Q_WS_MAC) 206 if ((pe =
tryMatch(size, mode, oppositeState)))
212 if ((pe =
tryMatch(size, oppositeMode, state)))
214 if ((pe =
tryMatch(size, oppositeMode, oppositeState)))
218 if ((pe =
tryMatch(size, oppositeMode, state)))
220 if ((pe =
tryMatch(size, mode, oppositeState)))
222 if ((pe =
tryMatch(size, oppositeMode, oppositeState)))
265 return pixmap(size, mode, state);
310 actualSize = pe->size;
324 if(pe && pe->
size == pixmap.
size()) {
346 if(size ==
QSize()) {
348 size = pixmap.
size();
354 if(pe->
size == size) {
387 for (
int i=0; i < num_entries; ++i) {
412 for (
int i=0; i < num_entries; ++i) {
448 #ifndef QT_NO_LIBRARY 778 return !
d ||
d->
ref == 1;
856 #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) 862 if (
QIconEngine *engine = factory->create(fileName)) {
870 if (
QIconEngine *engine = factory->create(fileName)) {
905 return engine->availableSizes(mode, state);
1043 if (qtIconCache()->contains(name)) {
1044 icon = *qtIconCache()->object(name);
1047 qtIconCache()->insert(name, cachedIcon);
1081 #if !defined(QT_NO_DATASTREAM) 1108 qWarning(
"QIcon: Cannot stream QIconEngine. Use QIconEngineV2 instead.");
1118 for (
int i=0; i < num_entries; ++i) {
1160 #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) 1179 for (
int i=0; i < num_entries; ++i) {
1198 #endif //QT_NO_DATASTREAM 1203 static int widths[2] = { 22, 32 };
1204 static int heights[2] = { 22, 32 };
1206 static QSize pixmapSizeHelper(QIcon::Size which)
1209 if (which == QIcon::Large)
1211 return QSize(widths[i], heights[i]);
1230 {
return pixmap(pixmapSizeHelper(size), mode, state); }
1253 void QIcon::setPixmapSize(Size which,
const QSize &size)
1258 widths[i] = size.
width();
1259 heights[i] = size.
height();
1267 QSize QIcon::pixmapSize(Size which)
1269 return pixmapSizeHelper(which);
1301 #endif // QT3_SUPPORT The QVariant class acts like a union for the most common Qt data types.
virtual QString key() const
Returns a key that identifies this icon engine.
virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const =0
Returns a copy of the given pixmap, styled to conform to the specified iconMode and taking into accou...
The QPainter class performs low-level painting on widgets and other paint devices.
static QRect alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rectangle)
Returns a new rectangle of the specified size that is aligned to the given rectangle according to the...
static void setThemeName(const QString &path)
Sets the current icon theme to name.
The QLatin1Literal class provides a thin wrapper around string literals used in source code...
void push_back(const T &t)
This function is provided for STL compatibility.
QList< QSize > availableSizes(Mode mode=Normal, State state=Off) const
Returns a list of available icon sizes for the specified mode and state.
int serialNumber() const
Returns a number that identifies the contents of this QIcon object.
QCache< QString, QIcon > IconCache
static mach_timebase_info_data_t info
void addPixmap(const QPixmap &pixmap, Mode mode=Normal, State state=Off)
Adds pixmap to the icon, as a specialization for mode and state.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
QVector< QPixmapIconEngineEntry > pixmaps
#define QT_END_NAMESPACE
This macro expands to.
QString iconName()
Returns the name used to create the engine, if available.
QPixmapIconEngineEntry * bestMatch(const QSize &size, QIcon::Mode mode, QIcon::State state, bool sizeOnly)
QSize size() const
Returns the size of the pixmap.
const QChar at(int i) const
Returns the character at the given index position in the string.
void remove(int i)
Removes the element at index position i.
The QAtomicInt class provides platform-independent atomic operations on integers. ...
friend Q_GUI_EXPORT QDataStream & operator<<(QDataStream &, const QIcon &)
Writes the given icon to the given stream as a PNG image.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
static void setThemeSearchPaths(const QStringList &searchpath)
Sets the search paths for icon themes to paths.
static QIcon fromTheme(const QString &name, const QIcon &fallback=QIcon())
Returns the QIcon corresponding to name in the current icon theme.
virtual QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state)
Returns the actual size of the icon the engine provides for the requested size, mode and state...
bool atEnd() const
Returns true if the I/O device has reached the end position (end of the stream or file) or if there i...
CGFloat qt_mac_get_scalefactor()
qint64 cacheKey() const
Returns a number that identifies the contents of this QPalette object.
virtual QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
Returns the icon as a pixmap with the required size, mode, and state.
void setThemeName(const QString &themeName)
State
This enum describes the state for which a pixmap is intended to be used.
void setThemeSearchPath(const QStringList &searchPaths)
QPixmap scaled(int w, int h, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const
QString absoluteFilePath() const
Returns an absolute path including the file name.
long ASN1_INTEGER_get ASN1_INTEGER * a
static QPalette palette()
Returns the application palette.
static QStyle * style()
Returns the application's style object.
bool ref()
Atomically increments the value of this QAtomicInt.
QString key() const
Returns a key that identifies this icon engine.
The QString class provides a Unicode character string.
~QIcon()
Destroys the icon.
#define Q_BASIC_ATOMIC_INITIALIZER(a)
void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state)
Uses the given painter to paint the icon with the required mode and state into the rectangle rect...
static QStringList themeSearchPaths()
Returns the search paths for icon themes.
QIcon::Mode mode
the requested mode of an image.
#define QIconEngineFactoryInterface_iid
QIconEngineV2 * clone() const
Returns a clone of this icon engine.
void virtual_hook(int id, void *data)
Additional method to allow extending QIconEngineV2 without adding new virtual methods (and without br...
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
static QPixmap * find(const QString &key)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
static QBasicAtomicInt serialNumCounter
int width() const
Returns the width.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QLatin1String("/iconengines")
This struct represents arguments to virtual_hook() function when id parameter is QIconEngineV2::Avail...
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
QIcon()
Constructs a null icon.
The QStyleOption class stores the parameters used by QStyle functions.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString name() const
Returns the name used to create the icon, if available.
QSize size() const
Returns the size of the rectangle.
Mode
This enum type describes the mode for which a pixmap is intended to be used.
virtual void virtual_hook(int id, void *data)
Additional method to allow extending QIconEngineV2 without adding new virtual methods (and without br...
bool deref()
Atomically decrements the value of this QAtomicInt.
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
The QStringList class provides a list of strings.
virtual void addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state)
Called by QIcon::addPixmap().
QList< QSize > sizes
image sizes that are available with specified mode and
Q_CORE_EXPORT void qWarning(const char *,...)
static QString themeName()
Returns the name of the current icon theme.
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
virtual bool read(QDataStream &in)
Reads icon engine contents from the QDataStream in.
friend Q_GUI_EXPORT QDataStream & operator>>(QDataStream &, QIcon &)
Reads an image, or a set of images, from the given stream into the given icon.
void clear()
Removes all items from the list.
The State element defines configurations of objects and properties.
virtual QIconEngineV2 * clone() const
Returns a clone of this icon engine.
The QIconEngineV2 class provides an abstract base class for QIcon renderers.
void addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state)
Called by QIcon::addPixmap().
static void qt_cleanup_icon_cache()
const T & at(int i) const
Returns the item at index position i in the vector.
QStringList themeSearchPaths() const
bool read(QDataStream &in)
Reads icon engine contents from the QDataStream in.
static QIconLoader * instance()
int version() const
Returns the version number of the data serialization format.
Qt::LayoutDirection layoutDirection() const
Returns the layout direction used by the painter when drawing text.
virtual bool write(QDataStream &out) const
Writes the contents of this engine to the QDataStream out.
QPalette palette
the palette that should be used when painting the control
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
Returns the icon as a pixmap with the required size, mode, and state.
QString themeName() const
qint64 cacheKey() const
Returns a number that identifies the contents of this QIcon object.
void clear()
Clears the contents of the string and makes it empty.
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,(QIconEngineFactoryInterface_iid, QLatin1String("/iconengines"), Qt::CaseInsensitive)) Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader
QSize actualSize(const QSize &size, Mode mode=Normal, State state=Off) const
Returns the actual size of the icon for the requested size, mode, and state.
QIcon & operator=(const QIcon &other)
Assigns the other icon to this icon and returns a reference to this icon.
#define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER)
QString suffix() const
Returns the suffix of the file.
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
The QIconEngine class provides an abstract base class for QIcon renderers.
int height() const
Returns the height.
The QRect class defines a rectangle in the plane using integer precision.
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
qint64 cacheKey() const
Returns a number that identifies this QPixmap.
static bool hasThemeIcon(const QString &name)
Returns true if there is an icon available for name in the current icon theme, otherwise returns fals...
The QPixmap class is an off-screen image representation that can be used as a paint device...
void scale(int w, int h, Qt::AspectRatioMode mode)
Scales the size to a rectangle with the given width and height, according to the specified mode: ...
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
bool isNull() const
Returns true if both the width and height is 0; otherwise returns false.
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
The QSize class defines the size of a two-dimensional object using integer point precision.
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
The QDataStream class provides serialization of binary data to a QIODevice.
QIconEngineFactoryInterfaceV2_iid
QIcon::State state
the requested state of an image.
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
virtual void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state)=0
Uses the given painter to paint the icon with the required mode and state into the rectangle rect...
The QFileInfo class provides system-independent file information.
void qAddPostRoutine(QtCleanUpFunction ptr)
Adds a global routine that will be called from the QApplication destructor.
static QString fileName(const QString &fileUrl)
int size() const
Returns the number of items in the vector.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
static QPixmapIconEngineEntry * bestSizeMatch(const QSize &size, QPixmapIconEngineEntry *pa, QPixmapIconEngineEntry *pb)
void addFile(const QString &fileName, const QSize &size=QSize(), Mode mode=Normal, State state=Off)
Adds an image from the file with the given fileName to the icon, as a specialization for size...
bool write(QDataStream &out) const
Writes the contents of this engine to the QDataStream out.
QPixmapIconEngineEntry * tryMatch(const QSize &size, QIcon::Mode mode, QIcon::State state)
void addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state)
Called by QIcon::addFile().
virtual void addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state)
Called by QIcon::addFile().
void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment=Qt::AlignCenter, Mode mode=Normal, State state=Off) const
Uses the painter to paint the icon with specified alignment, required mode, and state into the rectan...
static int area(const QSize &s)
QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state)
Returns the actual size of the icon the engine provides for the requested size, mode and state...
The QIcon class provides scalable icons in different modes and states.