forked from qt-creator/qt-creator
QmakePM: Avoid multiple loads of the same standard icon
Loading a standard icon is expensive. Change-Id: Ic6bae20c9d0bdcb07fda48309bebcc3a959bc031 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
f900b4e1ba
commit
925492a1b3
@@ -149,17 +149,26 @@ QIcon icon(QFileIconProvider::IconType type)
|
||||
return instance()->icon(type);
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates a pixmap with baseicon and overlays overlayIcon over it.
|
||||
See platform note in class documentation about recommended usage.
|
||||
*/
|
||||
QPixmap overlayIcon(const QPixmap &baseIcon, const QIcon &overlayIcon)
|
||||
{
|
||||
QPixmap iconPixmap = baseIcon;
|
||||
QPainter painter(&iconPixmap);
|
||||
painter.drawPixmap(0, 0, overlayIcon.pixmap(baseIcon.size()));
|
||||
painter.end();
|
||||
return iconPixmap;
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates a pixmap with baseicon at size and overlays overlayIcon over it.
|
||||
See platform note in class documentation about recommended usage.
|
||||
*/
|
||||
QPixmap overlayIcon(QStyle::StandardPixmap baseIcon, const QIcon &overlayIcon, const QSize &size)
|
||||
QPixmap overlayIcon(QStyle::StandardPixmap baseIcon, const QIcon &overlay, const QSize &size)
|
||||
{
|
||||
QPixmap iconPixmap = qApp->style()->standardIcon(baseIcon).pixmap(size);
|
||||
QPainter painter(&iconPixmap);
|
||||
painter.drawPixmap(0, 0, overlayIcon.pixmap(size));
|
||||
painter.end();
|
||||
return iconPixmap;
|
||||
return overlayIcon(qApp->style()->standardIcon(baseIcon).pixmap(size), overlay);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -43,6 +43,7 @@ CORE_EXPORT QIcon icon(const QFileInfo &info);
|
||||
CORE_EXPORT QIcon icon(QFileIconProvider::IconType type);
|
||||
|
||||
// Register additional overlay icons
|
||||
CORE_EXPORT QPixmap overlayIcon(const QPixmap &baseIcon, const QIcon &overlayIcon);
|
||||
CORE_EXPORT QPixmap overlayIcon(QStyle::StandardPixmap baseIcon, const QIcon &overlayIcon, const QSize &size);
|
||||
CORE_EXPORT void registerIconOverlayForSuffix(const char *path, const char *suffix);
|
||||
CORE_EXPORT void registerIconOverlayForMimeType(const char *path, const char *mimeType);
|
||||
|
||||
Reference in New Issue
Block a user