From 84c17cd9f886b433e3fb619b8281fea5b57fa8c0 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Sun, 3 Mar 2013 14:58:16 +0000 Subject: [PATCH] UI Nits: Images embossed .. akin to the NSImage 'template' function we now pre-process the GcSplitter icons to get a shaded and embossed look. Its a bit clunky code, but its only run at startup. --- src/GcSideBarItem.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/GcSideBarItem.cpp b/src/GcSideBarItem.cpp index 476c50b61..14f5bcf0b 100644 --- a/src/GcSideBarItem.cpp +++ b/src/GcSideBarItem.cpp @@ -25,10 +25,22 @@ QIcon iconFromPNG(QString filename) pngImage.load(filename); // use muted dark gray color - QImage result = pngImage.convertToFormat(QImage::Format_Indexed8); - result.setColor(0, QColor(80,80,80, 255).rgb()); + QImage gray8 = pngImage.convertToFormat(QImage::Format_Indexed8); + QImage white8 = pngImage.convertToFormat(QImage::Format_Indexed8); + gray8.setColor(0, QColor(80,80,80, 255).rgb()); + white8.setColor(0, QColor(255,255,255, 100).rgb()); - QIcon icon(QPixmap::fromImage(result)); + // now convert to a format we can paint with! + QImage white = white8.convertToFormat(QImage::Format_ARGB32_Premultiplied); + QImage gray = gray8.convertToFormat(QImage::Format_ARGB32_Premultiplied); + + QPainter painter; + painter.begin(&white); + painter.setBackgroundMode(Qt::TransparentMode); + painter.drawImage(0,-1, gray); + painter.end(); + + QIcon icon(QPixmap::fromImage(white)); return icon; }