diff --git a/frame/item/appitem.cpp b/frame/item/appitem.cpp index 41e6efaf9..f8fae3764 100644 --- a/frame/item/appitem.cpp +++ b/frame/item/appitem.cpp @@ -132,13 +132,12 @@ void AppItem::paintEvent(QPaintEvent *e) } // icon - QPixmap pixmap = DockDisplayMode == Efficient ? m_smallIcon : m_largeIcon; - // ligher icon - if (m_hover) - pixmap = ImageFactory::lighter(pixmap); - + const QPixmap pixmap = DockDisplayMode == Efficient ? m_smallIcon : m_largeIcon; // draw icon painter.drawPixmap(itemRect.center() - pixmap.rect().center(), pixmap); + // draw ligher + if (m_hover) + painter.drawPixmap(itemRect.center() - pixmap.rect().center(), ImageFactory::lighterEffect(pixmap)); } void AppItem::mouseReleaseEvent(QMouseEvent *e) diff --git a/frame/item/launcheritem.cpp b/frame/item/launcheritem.cpp index 4b5cd79d0..da42d590c 100644 --- a/frame/item/launcheritem.cpp +++ b/frame/item/launcheritem.cpp @@ -20,10 +20,11 @@ void LauncherItem::paintEvent(QPaintEvent *e) QPainter painter(this); - QPixmap pixmap = DockDisplayMode == Fashion ? m_largeIcon : m_smallIcon; - if (m_hover) - pixmap = ImageFactory::lighter(pixmap); + const QPixmap pixmap = DockDisplayMode == Fashion ? m_largeIcon : m_smallIcon; painter.drawPixmap(rect().center() - pixmap.rect().center(), pixmap); + + if (m_hover) + painter.drawPixmap(rect().center() - pixmap.rect().center(), ImageFactory::lighterEffect(pixmap)); } void LauncherItem::resizeEvent(QResizeEvent *e) diff --git a/frame/item/pluginsitem.cpp b/frame/item/pluginsitem.cpp index f508d04d5..db3a42ee1 100644 --- a/frame/item/pluginsitem.cpp +++ b/frame/item/pluginsitem.cpp @@ -94,7 +94,10 @@ void PluginsItem::paintEvent(QPaintEvent *e) const QRect iconRect = perfectIconRect(); const QPixmap pixmap = icon.pixmap(iconRect.size()); - painter.drawPixmap(iconRect, m_hover ? ImageFactory::lighter(pixmap) : pixmap); + painter.drawPixmap(iconRect, pixmap); + + if (m_hover) + painter.drawPixmap(iconRect, ImageFactory::lighterEffect(pixmap)); } bool PluginsItem::eventFilter(QObject *o, QEvent *e) diff --git a/frame/util/imagefactory.cpp b/frame/util/imagefactory.cpp index eebbd58b8..084aeab67 100644 --- a/frame/util/imagefactory.cpp +++ b/frame/util/imagefactory.cpp @@ -1,6 +1,7 @@ #include "imagefactory.h" #include +#include ImageFactory::ImageFactory(QObject *parent) : QObject(parent) @@ -8,25 +9,12 @@ ImageFactory::ImageFactory(QObject *parent) } -QPixmap ImageFactory::lighter(const QPixmap pixmap, const int delta) +QPixmap ImageFactory::lighterEffect(const QPixmap pixmap, const int delta) { - QImage image = pixmap.toImage(); + QPixmap result(pixmap); + QPainter painter(&result); + painter.setCompositionMode(QPainter::CompositionMode_SourceIn); + painter.fillRect(result.rect(), QColor::fromRgb(255, 255, 255, delta)); - const int width = image.width(); - const int height = image.height(); - const int bytesPerPixel = image.bytesPerLine() / image.width(); - - for (int i(0); i != height; ++i) - { - uchar *scanLine = image.scanLine(i); - for (int j(0); j != width; ++j) - { - QRgb &rgba = *(QRgb*)scanLine; - if (qAlpha(rgba) && (qRed(rgba) || qGreen(rgba) || qBlue(rgba))) - rgba = QColor::fromRgba(rgba).lighter(delta).rgba(); - scanLine += bytesPerPixel; - } - } - - return QPixmap::fromImage(image); + return result; } diff --git a/frame/util/imagefactory.h b/frame/util/imagefactory.h index c5d4f549d..15eed884b 100644 --- a/frame/util/imagefactory.h +++ b/frame/util/imagefactory.h @@ -12,7 +12,7 @@ class ImageFactory : public QObject public: explicit ImageFactory(QObject *parent = 0); - static QPixmap lighter(const QPixmap pixmap, const int delta = 120); + static QPixmap lighterEffect(const QPixmap pixmap, const int delta = 50); }; #endif // IMAGEFACTORY_H