diff --git a/src/core/stylehelper.cpp b/src/core/stylehelper.cpp index 88e489c9d..f7817d2bb 100644 --- a/src/core/stylehelper.cpp +++ b/src/core/stylehelper.cpp @@ -369,79 +369,6 @@ QPixmap StyleHelper::disabledSideBarIcon(const QPixmap &enabledicon) { } -// Draws a cached pixmap with shadow -void StyleHelper::drawIconWithShadow(const QIcon &icon, const QRect &rect, QPainter *p, QIcon::Mode iconMode, int dipRadius, const QColor &color, const QPoint &dipOffset) { - - QPixmap cache; - const int devicePixelRatio = p->device()->devicePixelRatio(); - QString pixmapName = QString::fromLatin1("icon %0 %1 %2 %3").arg(icon.cacheKey()).arg(iconMode).arg(rect.height()).arg(devicePixelRatio); - - if (!QPixmapCache::find(pixmapName, &cache)) { - // High-dpi support: The in parameters (rect, radius, offset) are in - // device-independent pixels. The call to QIcon::pixmap() below might - // return a high-dpi pixmap, which will in that case have a devicePixelRatio - // different than 1. The shadow drawing caluculations are done in device - // pixels. - QWindow *window = dynamic_cast(p->device())->window()->windowHandle(); - QPixmap px = icon.pixmap(window, rect.size(), iconMode); - int radius = dipRadius * devicePixelRatio; - QPoint offset = dipOffset * devicePixelRatio; - cache = QPixmap(px.size() + QSize(radius * 2, radius * 2)); - cache.fill(Qt::transparent); - - QPainter cachePainter(&cache); - if (iconMode == QIcon::Disabled) { - const bool hasDisabledState = icon.availableSizes().count() == icon.availableSizes(QIcon::Disabled).count(); - if (!hasDisabledState) - px = disabledSideBarIcon(icon.pixmap(window, rect.size())); - } - - // Draw shadow - QImage tmp(px.size() + QSize(radius * 2, radius * 2 + 1), QImage::Format_ARGB32_Premultiplied); - tmp.fill(Qt::transparent); - - QPainter tmpPainter(&tmp); - tmpPainter.setCompositionMode(QPainter::CompositionMode_Source); - tmpPainter.drawPixmap(QRect(radius, radius, px.width(), px.height()), px); - tmpPainter.end(); - - // blur the alpha channel - QImage blurred(tmp.size(), QImage::Format_ARGB32_Premultiplied); - blurred.fill(Qt::transparent); - QPainter blurPainter(&blurred); - qt_blurImage(&blurPainter, tmp, radius, false, true); - blurPainter.end(); - - tmp = blurred; - - // blacken the image... - tmpPainter.begin(&tmp); - tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn); - tmpPainter.fillRect(tmp.rect(), color); - tmpPainter.end(); - - tmpPainter.begin(&tmp); - tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn); - tmpPainter.fillRect(tmp.rect(), color); - tmpPainter.end(); - - // draw the blurred drop shadow... - cachePainter.drawImage(QRect(0, 0, cache.rect().width(), cache.rect().height()), tmp); - - // Draw the actual pixmap... - cachePainter.drawPixmap(QRect(QPoint(radius, radius) + offset, QSize(px.width(), px.height())), px); - cachePainter.end(); - cache.setDevicePixelRatio(devicePixelRatio); - QPixmapCache::insert(pixmapName, cache); - } - - QRect targetRect = cache.rect(); - targetRect.setSize(targetRect.size() / cache.devicePixelRatio()); - targetRect.moveCenter(rect.center() - dipOffset); - p->drawPixmap(targetRect, cache); - -} - // Draws a CSS-like border image where the defined borders are not stretched // Unit for rect, left, top, right and bottom is user pixels void StyleHelper::drawCornerImage(const QImage &img, QPainter *painter, const QRect &rect, int left, int top, int right, int bottom) { diff --git a/src/core/stylehelper.h b/src/core/stylehelper.h index 282cc1c38..c7ed596ca 100644 --- a/src/core/stylehelper.h +++ b/src/core/stylehelper.h @@ -84,7 +84,6 @@ public: static bool usePixmapCache() { return true; } static QPixmap disabledSideBarIcon(const QPixmap &enabledicon); - static void drawIconWithShadow(const QIcon &icon, const QRect &rect, QPainter *p, QIcon::Mode iconMode, int dipRadius = 3, const QColor &color = QColor(0, 0, 0, 130), const QPoint &dipOffset = QPoint(1, -2)); static void drawCornerImage(const QImage &img, QPainter *painter, const QRect &rect, int left = 0, int top = 0, int right = 0, int bottom = 0); static void tintImage(QImage &img, const QColor &tintColor);