Albert
Loading...
Searching...
No Matches
albert::IconProvider Class Reference

#include <iconprovider.h>

Detailed Description

Generic pixmap provider.

Public Member Functions

 IconProvider ()
 
 ~IconProvider ()
 
QPixmap getPixmap (const QStringList &urls, QSize *size, const QSize &requestedSize) const
 Pixmap providing function. More...
 
QPixmap getPixmap (const QString &url, QSize *size, const QSize &requestedSize) const
 Pixmap providing function. More...
 
void clearCache ()
 Clears the internal icon cache. More...
 

Constructor & Destructor Documentation

◆ IconProvider()

albert::IconProvider::IconProvider ( )

◆ ~IconProvider()

albert::IconProvider::~IconProvider ( )

Member Function Documentation

◆ clearCache()

void albert::IconProvider::clearCache ( )

Clears the internal icon cache.

◆ getPixmap() [1/2]

QPixmap albert::IconProvider::getPixmap ( const QString &  url,
QSize *  size,
const QSize &  requestedSize 
) const

Pixmap providing function.

Parameters
sizeWill get assigned the actual size of the pixmap created
requestedSizeThe size the pixmap should have if possible.
urlThe URL of the pixmap to be created. Supported url schemes:
  • <path> or file:<path> Use the file at path as icon.
  • :<path> or qrc:<path> Use the file at path in the resource collection as icon.
  • qfip:<path> Use QFileIconProvider to get a generic icon for the file at <path>.
  • qsp:<pixmap enumerator> Get an icon from QStyle::StandardPixmap enum.
  • xdg:<icon name> Performs freedesktop icon theme specification lookup (on supported platforms only) to get an icon.
  • gen:<> Generate an icon on the fly. Supports drawing a background circle and renders text on it. All parameters are optional. Available parameters are:

    • background: The background color (default: none). See also QColor::fromString.
    • foreground: (default: window text color from system palette)
    • text: (default: none) The text to display
    • fontscalar: (default: 1) Scalar for the default font size which is the pixmap height.

    Examples

    /absolute/path/to/a/local/image/file.png
    file:/absolute/path/to/a/local/image/file.png
    :path-to-a-qresource-file
    qrc:path-to-a-qresource-file
    qfip:/path/to/any/file/for/example/a.pdf
    qsp:SP_TrashIcon
    xdg:some-themed-icon-name
    gen:?background=blue&foreground=red&text=Hi&fontscalar=0.5
    
Returns
The pixmap, if available, null pixmap otherwise.

◆ getPixmap() [2/2]

QPixmap albert::IconProvider::getPixmap ( const QStringList &  urls,
QSize *  size,
const QSize &  requestedSize 
) const

Pixmap providing function.

See getPixmap(const QString &url, QSize *size, const QSize &requestedSize) const for supported urls.

Parameters
urlsThe URLs of the pixmap to be created.
sizeWill get assigned the actual size of the pixmap created
requestedSizeThe size the pixmap should have if possible.
Returns
The first pixmap available in the urls list. Null pixmap otherwise.

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