Qt ForkAwesome 0.3.0
Library that bundles ForkAwesome for use within Qt applications
Loading...
Searching...
No Matches
QtForkAwesome::Renderer Class Reference

Allows rendering a QtForkAwesome::Icon (or an arbitrary QChar using an arbitrary font file). More...

#include <renderer.h>

Public Member Functions

 Renderer (const QString &fontFileName=QString())
 Constructs a new renderer with the given fontFileName.
 
 Renderer (const QByteArray &fontData)
 Constructs a new renderer with the given fontData.
 
 ~Renderer ()
 Destructs the renderer.
 
const QString & fontFilePath () const
 Returns the path of the font file.
 
void warnIfInvalid () const
 Prints a warning using qWarning() if no font could be loaded.
 
 operator bool () const
 Returns whether the render could load the font file.
 
void render (QChar character, QPainter *painter, const QRect &rect, const QColor &color) const
 Renders the specified icon using the specified painter.
 
void render (Icon icon, QPainter *painter, const QRect &rect, const QColor &color) const
 Renders the specified icon using the specified painter.
 
QPixmap pixmap (QChar icon, const QSize &size, const QColor &color, qreal scaleFactor) const
 Renders the specified character as pixmap of the specified size.
 
QPixmap pixmap (Icon icon, const QSize &size, const QColor &color, qreal scaleFactor) const
 Renders the specified icon as pixmap of the specified size.
 
QPixmap pixmap (QChar icon, const QSize &size, const QColor &color) const
 Renders the specified character as pixmap of the specified size.
 
QPixmap pixmap (Icon icon, const QSize &size, const QColor &color) const
 Renders the specified icon as pixmap of the specified size.
 
void addThemeOverride (QChar character, const QString &iconNameInTheme)
 Uses the icon from the current icon theme obtained via QIcon::fromTheme() for character if it exists.
 
void addThemeOverride (Icon icon, const QString &iconNameInTheme)
 Uses the icon from the current icon theme obtained via QIcon::fromTheme() for icon if it exists.
 
void addOverride (QChar character, const QIcon &override)
 Uses the specified override icon for character if it is not null.
 
void addOverride (Icon icon, const QIcon &override)
 Uses the specified override icon for icon if it is not null.
 
void setAssociatedPaintDevice (QPaintDevice *paintDevice)
 Sets the associated paintDevice.
 
void clearOverrides ()
 Clears all overrides added via addThemeOverride() or addOverride().
 

Static Public Member Functions

static Rendererglobal ()
 Returns the global instance (which is so far only used by the icon engine plugin).
 

Detailed Description

Allows rendering a QtForkAwesome::Icon (or an arbitrary QChar using an arbitrary font file).

Definition at line 22 of file renderer.h.

Constructor & Destructor Documentation

◆ Renderer() [1/2]

QtForkAwesome::Renderer::Renderer ( const QString & fontFileName = QString())
explicit

Constructs a new renderer with the given fontFileName.

Remarks
If fontFileName is empty, the bundled font file will be used.

Definition at line 89 of file renderer.cpp.

◆ Renderer() [2/2]

QtForkAwesome::Renderer::Renderer ( const QByteArray & fontData)
explicit

Constructs a new renderer with the given fontData.

Definition at line 98 of file renderer.cpp.

◆ ~Renderer()

QtForkAwesome::Renderer::~Renderer ( )

Destructs the renderer.

Definition at line 106 of file renderer.cpp.

Member Function Documentation

◆ addOverride() [1/2]

void QtForkAwesome::Renderer::addOverride ( Icon icon,
const QIcon & override )
inline

Uses the specified override icon for icon if it is not null.

Definition at line 73 of file renderer.h.

◆ addOverride() [2/2]

void QtForkAwesome::Renderer::addOverride ( QChar character,
const QIcon & override )

Uses the specified override icon for character if it is not null.

Definition at line 249 of file renderer.cpp.

◆ addThemeOverride() [1/2]

void QtForkAwesome::Renderer::addThemeOverride ( Icon icon,
const QString & iconNameInTheme )
inline

Uses the icon from the current icon theme obtained via QIcon::fromTheme() for icon if it exists.

Definition at line 65 of file renderer.h.

◆ addThemeOverride() [2/2]

void QtForkAwesome::Renderer::addThemeOverride ( QChar character,
const QString & iconNameInTheme )

Uses the icon from the current icon theme obtained via QIcon::fromTheme() for character if it exists.

Definition at line 241 of file renderer.cpp.

◆ clearOverrides()

void QtForkAwesome::Renderer::clearOverrides ( )

Clears all overrides added via addThemeOverride() or addOverride().

Definition at line 257 of file renderer.cpp.

◆ fontFilePath()

const QString & QtForkAwesome::Renderer::fontFilePath ( ) const

Returns the path of the font file.

Remarks
Returns an empty string when the renderer was constructed from a QByteArray().

Definition at line 117 of file renderer.cpp.

◆ global()

Renderer & QtForkAwesome::Renderer::global ( )
static

Returns the global instance (which is so far only used by the icon engine plugin).

Definition at line 276 of file renderer.cpp.

◆ operator bool()

QtForkAwesome::Renderer::operator bool ( ) const

Returns whether the render could load the font file.

Definition at line 139 of file renderer.cpp.

◆ pixmap() [1/4]

QPixmap QtForkAwesome::Renderer::pixmap ( Icon icon,
const QSize & size,
const QColor & color ) const

Renders the specified icon as pixmap of the specified size.

Remarks
  • The pixmap will be scaled for the associated paint device or the global device-dixel-ratio if no paint device has been associated.
  • When rendering a QPixmap for a QIcon, better use the other overloads with the actual size (and a scale factor of one).

Definition at line 233 of file renderer.cpp.

◆ pixmap() [2/4]

QPixmap QtForkAwesome::Renderer::pixmap ( Icon icon,
const QSize & size,
const QColor & color,
qreal scaleFactor ) const

Renders the specified icon as pixmap of the specified size.

Definition at line 207 of file renderer.cpp.

◆ pixmap() [3/4]

QPixmap QtForkAwesome::Renderer::pixmap ( QChar icon,
const QSize & size,
const QColor & color ) const

Renders the specified character as pixmap of the specified size.

Remarks
  • The pixmap will be scaled for the associated paint device or the global device-dixel-ratio if no paint device has been associated.
  • When rendering a QPixmap for a QIcon, better use the other overloads with the actual size (and a scale factor of one).

Definition at line 220 of file renderer.cpp.

◆ pixmap() [4/4]

QPixmap QtForkAwesome::Renderer::pixmap ( QChar icon,
const QSize & size,
const QColor & color,
qreal scaleFactor ) const

Renders the specified character as pixmap of the specified size.

Definition at line 175 of file renderer.cpp.

◆ render() [1/2]

void QtForkAwesome::Renderer::render ( Icon icon,
QPainter * painter,
const QRect & rect,
const QColor & color ) const
inline

Renders the specified icon using the specified painter.

Definition at line 57 of file renderer.h.

◆ render() [2/2]

void QtForkAwesome::Renderer::render ( QChar character,
QPainter * painter,
const QRect & rect,
const QColor & color ) const

Renders the specified icon using the specified painter.

Definition at line 159 of file renderer.cpp.

◆ setAssociatedPaintDevice()

void QtForkAwesome::Renderer::setAssociatedPaintDevice ( QPaintDevice * paintDevice)

Sets the associated paintDevice.

Remarks
The device-pixel-ratio of the specified device will be used when rendering pixmaps using the overloads that do not take a scale factor.

Definition at line 268 of file renderer.cpp.

◆ warnIfInvalid()

void QtForkAwesome::Renderer::warnIfInvalid ( ) const

Prints a warning using qWarning() if no font could be loaded.

Definition at line 125 of file renderer.cpp.


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