Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QAbstractFileIconEngine Class Referenceabstract

Helper base class for retrieving icons for files for usage by QFileIconProvider and related. More...

#include <qabstractfileiconengine_p.h>

+ Inheritance diagram for QAbstractFileIconEngine:
+ Collaboration diagram for QAbstractFileIconEngine:

Public Member Functions

 QAbstractFileIconEngine (const QFileInfo &info, QPlatformTheme::IconOptions opts)
 
QPixmap pixmap (const QSize &size, QIcon::Mode mode, QIcon::State) override
 Returns the icon as a pixmap with the required size, mode, and state.
 
QPixmap scaledPixmap (const QSize &size, QIcon::Mode mode, QIcon::State, qreal scale) override
 
QSize actualSize (const QSize &size, QIcon::Mode mode, QIcon::State state) override
 Returns the actual size of the icon the engine provides for the requested size, mode and state.
 
bool isNull () override
 
QFileInfo fileInfo () const
 
QPlatformTheme::IconOptions options () const
 
- Public Member Functions inherited from QPixmapIconEngine
 QPixmapIconEngine ()
 
 QPixmapIconEngine (const QPixmapIconEngine &)
 
 ~QPixmapIconEngine ()
 
void paint (QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override
 Uses the given painter to paint the icon with the required mode and state into the rectangle rect.
 
QPixmap pixmap (const QSize &size, QIcon::Mode mode, QIcon::State state) override
 Returns the icon as a pixmap with the required size, mode, and state.
 
QPixmap scaledPixmap (const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override
 
QPixmapIconEngineEntrybestMatch (const QSize &size, qreal scale, QIcon::Mode mode, QIcon::State state, bool sizeOnly)
 
QSize actualSize (const QSize &size, QIcon::Mode mode, QIcon::State state) override
 Returns the actual size of the icon the engine provides for the requested size, mode and state.
 
QList< QSizeavailableSizes (QIcon::Mode mode, QIcon::State state) override
 
void addPixmap (const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state) override
 Called by QIcon::addPixmap().
 
void addFile (const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state) override
 Called by QIcon::addFile().
 
bool isNull () override
 
QString key () const override
 \variable QIconEngine::ScaledPixmapArgument::size
 
QIconEngineclone () const override
 Reimplement this method to return a clone of this icon engine.
 
bool read (QDataStream &in) override
 Reads icon engine contents from the QDataStream in.
 
bool write (QDataStream &out) const override
 Writes the contents of this engine to the QDataStream out.
 
- Public Member Functions inherited from QIconEngine
 QIconEngine ()
 
virtual ~QIconEngine ()
 Destroys the icon engine.
 
virtual QString iconName ()
 
virtual void virtual_hook (int id, void *data)
 

Static Public Member Functions

template<class It >
static QList< QSizetoSizeList (It i1, It i2)
 

Protected Member Functions

virtual QPixmap filePixmap (const QSize &size, QIcon::Mode mode, QIcon::State)=0
 
virtual QString cacheKey () const
 
- Protected Member Functions inherited from QIconEngine
 QIconEngine (const QIconEngine &other)
 

Additional Inherited Members

- Public Types inherited from QIconEngine
enum  IconEngineHook { IsNullHook = 3 , ScaledPixmapHook }
 

Detailed Description

Helper base class for retrieving icons for files for usage by QFileIconProvider and related.

Reimplement availableSizes() and new virtual filePixmap() and return icons created with this engine from QPlatformTheme::fileIcon().

Note: The class internally caches pixmaps for files by suffix (with the exception of some files on Windows), but not for directories (since directory icons may have overlay icons on Windows). You might want to cache pixmaps for directories in your implementation.

Since
5.8
See also
QFileIconProvider::DontUseCustomDirectoryIcons, QPlatformTheme

Definition at line 24 of file qabstractfileiconengine_p.h.

Constructor & Destructor Documentation

◆ QAbstractFileIconEngine()

QAbstractFileIconEngine::QAbstractFileIconEngine ( const QFileInfo & info,
QPlatformTheme::IconOptions opts )
inlineexplicit

Definition at line 27 of file qabstractfileiconengine_p.h.

Member Function Documentation

◆ actualSize()

QSize QAbstractFileIconEngine::actualSize ( const QSize & size,
QIcon::Mode mode,
QIcon::State state )
overridevirtual

Returns the actual size of the icon the engine provides for the requested size, mode and state.

The default implementation returns the given size.

Reimplemented from QIconEngine.

Definition at line 60 of file qabstractfileiconengine.cpp.

References actualSize(), QPixmapIconEngine::availableSizes(), QSize::height(), i, QSize::isNull(), Qt::KeepAspectRatio, QSize::scale(), state, and QSize::width().

Referenced by actualSize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cacheKey()

QString QAbstractFileIconEngine::cacheKey ( ) const
protectedvirtual

Reimplemented in QWindowsFileIconEngine.

Definition at line 91 of file qabstractfileiconengine.cpp.

References QFileInfo::fileName(), QString::isEmpty(), QFileInfo::isExecutable(), QFileInfo::isFile(), QFileInfo::isSymLink(), and QFileInfo::suffix().

Referenced by pixmap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fileInfo()

QFileInfo QAbstractFileIconEngine::fileInfo ( ) const
inline

Definition at line 35 of file qabstractfileiconengine_p.h.

Referenced by QWindowsFileIconEngine::cacheKey(), QWindowsFileIconEngine::filePixmap(), and QCocoaFileIconEngine::filePixmap().

+ Here is the caller graph for this function:

◆ filePixmap()

virtual QPixmap QAbstractFileIconEngine::filePixmap ( const QSize & size,
QIcon::Mode mode,
QIcon::State  )
protectedpure virtual

Implemented in QWindowsFileIconEngine, and QCocoaFileIconEngine.

Referenced by pixmap().

+ Here is the caller graph for this function:

◆ isNull()

bool QAbstractFileIconEngine::isNull ( )
inlineoverridevirtual
Since
5.7

Returns true if this icon engine represent a null QIcon.

Reimplemented from QIconEngine.

Definition at line 33 of file qabstractfileiconengine_p.h.

◆ options()

QPlatformTheme::IconOptions QAbstractFileIconEngine::options ( ) const
inline

Definition at line 36 of file qabstractfileiconengine_p.h.

References m_options.

Referenced by QWindowsFileIconEngine::cacheKey(), and QWindowsFileIconEngine::filePixmap().

+ Here is the caller graph for this function:

◆ pixmap()

QPixmap QAbstractFileIconEngine::pixmap ( const QSize & size,
QIcon::Mode mode,
QIcon::State state )
overridevirtual

Returns the icon as a pixmap with the required size, mode, and state.

The default implementation creates a new pixmap and calls paint() to fill it.

Reimplemented from QIconEngine.

Definition at line 29 of file qabstractfileiconengine.cpp.

References cacheKey(), filePixmap(), QPixmapCache::find(), QPixmapCache::insert(), QString::number(), Q_UNUSED, and state.

+ Here is the call graph for this function:

◆ scaledPixmap()

QPixmap QAbstractFileIconEngine::scaledPixmap ( const QSize & size,
QIcon::Mode mode,
QIcon::State state,
qreal scale )
overridevirtual
Since
5.9

Returns a pixmap for the given size, mode, state and scale.

The scale argument is typically equal to the \l {High DPI} {device pixel ratio} of the display.

Note
Some engines may cast scale to an integer.
See also
ScaledPixmapArgument

Reimplemented from QIconEngine.

Definition at line 54 of file qabstractfileiconengine.cpp.

References pixmap, Q_UNUSED, and state.

◆ toSizeList()

template<class It >
QList< QSize > QAbstractFileIconEngine::toSizeList ( It i1,
It i2 )
inlinestatic

Definition at line 51 of file qabstractfileiconengine_p.h.


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