Albert
Loading...
Searching...
No Matches
albert::Icon Class Referenceabstract

#include <albert/icon.h>

Description

Abstract icon engine.

Public Member Functions

virtual ~Icon ()
 Destructs the icon.
 
virtual std::unique_ptr< Iconclone () const =0
 Returns a clone of this icon.
 
virtual QSize actualSize (const QSize &device_independent_size, double device_pixel_ratio)
 Returns the device independent size of the available icon for the given device_independent_size and device_pixel_ratio.
 
virtual QPixmap pixmap (const QSize &device_independent_size, double device_pixel_ratio)
 Returns a pixmap for the requested device_independent_size and device_pixel_ratio.
 
virtual void paint (QPainter *painter, const QRect &rect)=0
 Uses the given painter to paint the icon into the rectangle rect.
 
virtual bool isNull ()
 Returns true if the icon is valid; otherwise returns false.
 
virtual QString toUrl () const =0
 Returns a URL representation of the icon.
 
virtual QString cacheKey ()
 Returns the cache key of the icon.
 

Static Public Member Functions

static QIcon qIcon (std::unique_ptr< albert::Icon > icon)
 Returns a QIcon using icon as icon engine.
 
static std::unique_ptr< IconiconFromUrl (const QString &url)
 Returns a built-in icon for the given url.
 
static std::unique_ptr< IconiconFromUrls (const QStringList &urls)
 Returns a built-in icon for the given urls.
 
Image icon
static std::unique_ptr< Iconimage (const QString &path)
 Returns an icon from an image file at path.
 
static std::unique_ptr< Iconimage (const std::filesystem::path &path)
 Returns an icon from an image file at path.
 
File type icon
static std::unique_ptr< IconfileType (const QString &path)
 Returns an icon representing the file type of the file at path.
 
static std::unique_ptr< IconfileType (const std::filesystem::path &path)
 Returns an icon representing the file type of the file at path.
 
Theme icon (<a href="https://specifications.freedesktop.org/icon-theme/latest/" >XDG icon lookup</a>)
static std::unique_ptr< Icontheme (const QString &icon_name)
 Returns an icon from the current icon theme with the given icon_name.
 
Grapheme icon
static QBrush graphemeDefaultBrush ()
 Returns the window text color of the current application palette.
 
static std::unique_ptr< Icongrapheme (const QString &grapheme, double scalar=1.0)
 Returns an icon rendering the given grapheme with graphemeDefaultBrush, scaled by scalar.
 
static std::unique_ptr< Icongrapheme (const QString &grapheme, double scalar, const QBrush &brush)
 Returns an icon rendering the given grapheme, scaled by scalar and colored with brush.
 
Iconified icon
static const QBrush & iconifiedDefaultBackgroundBrush ()
 Returns the default background brush (a top down gradient from white to some darker white).
 
static const QBrush & iconifiedDefaultBorderBrush ()
 Returns the default border color (a gradient slightly darker than the default background).
 
static std::unique_ptr< Iconiconified (std::unique_ptr< Icon > icon, const QBrush &background_brush=iconifiedDefaultBackgroundBrush(), double border_radius=1.0, int border_width=1, const QBrush &border_color=iconifiedDefaultBorderBrush())
 Returns iconified icon.
 
Composed icon
static std::unique_ptr< Iconcomposed (std::unique_ptr< Icon > icon1, std::unique_ptr< Icon > icon2, double size1=0.7, double size2=0.7, double x1=0.0, double y1=0.0, double x2=1.0, double y2=1.0)
 Returns a composed icon from icon1 and icon2.
 

Standard icon (QStyle standard pixmap)

This enum describes the available standard icons.

See Qt documentation for more details.

enum  StandardIconType
 
static std::unique_ptr< Iconstandard (StandardIconType type)
 Returns a standard icon for the given type.
 

Member Enumeration Documentation

◆ StandardIconType

Enumerator
TitleBarMinButton 

Menu button on a title bar.

TitleBarMenuButton 

Minimize button on title bars (e.g., in QMdiSubWindow).

TitleBarMaxButton 

Maximize button on title bars.

TitleBarCloseButton 

Close button on title bars.

TitleBarNormalButton 

Normal (restore) button on title bars.

TitleBarShadeButton 

Shade button on title bars.

TitleBarUnshadeButton 

Unshade button on title bars.

TitleBarContextHelpButton 

The Context help button on title bars.

MessageBoxInformation 

The "information" icon.

MessageBoxWarning 

The "warning" icon.

MessageBoxCritical 

The "critical" icon.

MessageBoxQuestion 

The "question" icon.

DesktopIcon 

The "desktop" icon.

TrashIcon 

The "trash" icon.

ComputerIcon 

The "My computer" icon.

DriveFDIcon 

The floppy icon.

DriveHDIcon 

The harddrive icon.

DriveCDIcon 

The CD icon.

DriveDVDIcon 

The DVD icon.

DriveNetIcon 

The network icon.

DirHomeIcon 

The home directory icon.

DirOpenIcon 

The open directory icon.

DirClosedIcon 

The closed directory icon.

DirIcon 

The directory icon.

DirLinkIcon 

The link to directory icon.

DirLinkOpenIcon 

The link to open directory icon.

FileIcon 

The file icon.

FileLinkIcon 

The link to file icon.

FileDialogStart 

The "start" icon in a file dialog.

FileDialogEnd 

The "end" icon in a file dialog.

FileDialogToParent 

The "parent directory" icon in a file dialog.

FileDialogNewFolder 

The "create new folder" icon in a file dialog.

FileDialogDetailedView 

The detailed view icon in a file dialog.

FileDialogInfoView 

The file info icon in a file dialog.

FileDialogContentsView 

The contents view icon in a file dialog.

FileDialogListView 

The list view icon in a file dialog.

FileDialogBack 

The back arrow in a file dialog.

DockWidgetCloseButton 

Close button on dock windows (see also QDockWidget).

ToolBarHorizontalExtensionButton 

Extension button for horizontal toolbars.

ToolBarVerticalExtensionButton 

Extension button for vertical toolbars.

DialogOkButton 

Icon for a standard OK button in a QDialogButtonBox.

DialogCancelButton 

Icon for a standard Cancel button in a QDialogButtonBox.

DialogHelpButton 

Icon for a standard Help button in a QDialogButtonBox.

DialogOpenButton 

Icon for a standard Open button in a QDialogButtonBox.

DialogSaveButton 

Icon for a standard Save button in a QDialogButtonBox.

DialogCloseButton 

Icon for a standard Close button in a QDialogButtonBox.

DialogApplyButton 

Icon for a standard Apply button in a QDialogButtonBox.

DialogResetButton 

Icon for a standard Reset button in a QDialogButtonBox.

DialogDiscardButton 

Icon for a standard Discard button in a QDialogButtonBox.

DialogYesButton 

Icon for a standard Yes button in a QDialogButtonBox.

DialogNoButton 

Icon for a standard No button in a QDialogButtonBox.

ArrowUp 

Icon arrow pointing up.

ArrowDown 

Icon arrow pointing down.

ArrowLeft 

Icon arrow pointing left.

ArrowRight 

Icon arrow pointing right.

ArrowBack 

Equivalent to SP_ArrowLeft when the current layout direction is Qt::LeftToRight, otherwise SP_ArrowRight.

ArrowForward 

Equivalent to SP_ArrowRight when the current layout direction is Qt::LeftToRight, otherwise SP_ArrowLeft.

CommandLink 

Icon used to indicate a Vista style command link glyph.

VistaShield 

Icon used to indicate UAC prompts on Windows Vista. This will return a null pixmap or icon on all other platforms.

BrowserReload 

Icon indicating that the current page should be reloaded.

BrowserStop 

Icon indicating that the page loading should stop.

MediaPlay 

Icon indicating that media should begin playback.

MediaStop 

Icon indicating that media should stop playback.

MediaPause 

Icon indicating that media should pause playback.

MediaSkipForward 

Icon indicating that media should skip forward.

MediaSkipBackward 

Icon indicating that media should skip backward.

MediaSeekForward 

Icon indicating that media should seek forward.

MediaSeekBackward 

Icon indicating that media should seek backward.

MediaVolume 

Icon indicating a volume control.

MediaVolumeMuted 

Icon indicating a muted volume control.

LineEditClearButton 

Icon for a standard clear button in a QLineEdit.

DialogYesToAllButton 

Icon for a standard YesToAll button in a QDialogButtonBox.

DialogNoToAllButton 

Icon for a standard NoToAll button in a QDialogButtonBox.

DialogSaveAllButton 

Icon for a standard SaveAll button in a QDialogButtonBox.

DialogAbortButton 

Icon for a standard Abort button in a QDialogButtonBox.

DialogRetryButton 

Icon for a standard Retry button in a QDialogButtonBox.

DialogIgnoreButton 

Icon for a standard Ignore button in a QDialogButtonBox.

RestoreDefaultsButton 

Icon for a standard RestoreDefaults button in a QDialogButtonBox.

TabCloseButton 

Icon for the close button in the tab of a QTabBar.

Member Function Documentation

◆ actualSize()

virtual QSize albert::Icon::actualSize ( const QSize &  device_independent_size,
double  device_pixel_ratio 
)
virtual

Returns the device independent size of the available icon for the given device_independent_size and device_pixel_ratio.

The base implementations returns device_independent_size.

◆ cacheKey()

virtual QString albert::Icon::cacheKey ( )
virtual

Returns the cache key of the icon.

The base implementation calls toUrl. Reimplement to get faster lookups.

◆ composed()

static std::unique_ptr< Icon > albert::Icon::composed ( std::unique_ptr< Icon icon1,
std::unique_ptr< Icon icon2,
double  size1 = 0.7,
double  size2 = 0.7,
double  x1 = 0.0,
double  y1 = 0.0,
double  x2 = 1.0,
double  y2 = 1.0 
)
static

Returns a composed icon from icon1 and icon2.

size1 and size2 specify the relative sizes (0.0 - 1.0) of the icons. x1, y1, x2, and y2 specify the relative positions (0.0 - 1.0, 0.5 is centered) of the icons.

◆ fileType()

static std::unique_ptr< Icon > albert::Icon::fileType ( const std::filesystem::path &  path)
static

Returns an icon representing the file type of the file at path.

◆ iconified()

static std::unique_ptr< Icon > albert::Icon::iconified ( std::unique_ptr< Icon icon,
const QBrush &  background_brush = iconifiedDefaultBackgroundBrush(),
double  border_radius = 1.0,
int  border_width = 1,
const QBrush &  border_color = iconifiedDefaultBorderBrush() 
)
static

Returns iconified icon.

i.e. drawn in a colored rounded rectangle with a border.

color specifies the background color, border_width the border width in device independent pixels, border_radius the relative border radius (0.0 - 1.0), and border_color the border color.

◆ image()

static std::unique_ptr< Icon > albert::Icon::image ( const std::filesystem::path &  path)
static

Returns an icon from an image file at path.

◆ isNull()

virtual bool albert::Icon::isNull ( )
virtual

Returns true if the icon is valid; otherwise returns false.

The base implementation returns false.

◆ pixmap()

virtual QPixmap albert::Icon::pixmap ( const QSize &  device_independent_size,
double  device_pixel_ratio 
)
virtual

Returns a pixmap for the requested device_independent_size and device_pixel_ratio.

The base implementation creates a transparent pixmap of actualSize and calls paint on it.


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