[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    scaled favicons
From:       Malte Starostik <malte () kde ! org>
Date:       2002-01-03 22:19:12
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello and Happy New Year,

the attached patch adds the favicon overlay as it was in minicli and 
KonqPixmapProvider to KIconLoader so it works again now that KMimeType 
handles favicons (btw, thanks to whoever did that).
Please review as I'm not at all sure if it's okay to do it this way.
If it's okay, I'll commit and remove the unused code from minicli and libkonq.
Thanks,
- -- 
Malte Starostik
PGP: 1024D/D2F3C787 [C138 2121 FAF3 410A 1C2A  27CD 5431 7745 D2F3 C787]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8NNjjVDF3RdLzx4cRAlmTAJwKdk+jYApySSE4jqAPIqVcngqowQCgqEqj
nHoLzqdZr3NbxX957RLK9yU=
=x2aH
-----END PGP SIGNATURE-----

["kiconloader.diff" (text/x-diff)]

Index: kiconloader.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kiconloader.cpp,v
retrieving revision 1.178
diff -u -3 -d -p -r1.178 kiconloader.cpp
--- kiconloader.cpp	2001/12/31 00:14:42	1.178
+++ kiconloader.cpp	2002/01/03 22:13:13
@@ -24,6 +24,7 @@
 #include <qdir.h>
 #include <qiconset.h>
 #include <qmovie.h>
+#include <qbitmap.h>
 
 #include <kdebug.h>
 #include <kstandarddirs.h>
@@ -399,7 +400,7 @@ QPixmap KIconLoader::loadIcon(const QStr
     QString name = _name;
     QPixmap pix;
     QString key;
-    bool absolutePath=false;
+    bool absolutePath=false, favIconOverlay=false;
 
     if (d->mpThemeRoot == 0L)
 	return pix;
@@ -407,6 +408,7 @@ QPixmap KIconLoader::loadIcon(const QStr
     // Special case for absolute path icons.
     if (name.startsWith("favicons/"))
     {
+       favIconOverlay = true;
        name = locateLocal("cache", name+".png");
     }
     if (name.at(0) == '/') absolutePath=true;
@@ -495,6 +497,7 @@ QPixmap KIconLoader::loadIcon(const QStr
     {
 	size = d->mpGroups[group].size;
     }
+    favIconOverlay = favIconOverlay && (size > 16);
 
     // Generate a unique cache key for the icon.
 
@@ -530,7 +533,7 @@ QPixmap KIconLoader::loadIcon(const QStr
     {
         // No? load it.
         KIcon icon;
-        if (absolutePath)
+        if (absolutePath && !favIconOverlay)
         {
             icon.context=KIcon::Any;
             icon.type=KIcon::Scalable;
@@ -538,7 +541,7 @@ QPixmap KIconLoader::loadIcon(const QStr
         }
         else
         {
-            icon = findMatchingIcon(name, size);
+            icon = findMatchingIcon(favIconOverlay ? "www" : name, size);
             if (!icon.isValid())
             {
                 // Try "User" icon too. Some apps expect this.
@@ -609,7 +612,7 @@ QPixmap KIconLoader::loadIcon(const QStr
     // Scale the icon and apply effects if necessary
     if ((iconType == KIcon::Scalable) && (size != img->width()))
     {
-	*img = img->smoothScale(size, size);
+        *img = img->smoothScale(size, size);
     }
     if ((iconType == KIcon::Threshold) && (size != img->width()))
     {
@@ -628,6 +631,23 @@ QPixmap KIconLoader::loadIcon(const QStr
     pix.convertFromImage(*img);
 
     delete img;
+
+    if (favIconOverlay)
+    {
+        QPixmap favIcon(name, "PNG");
+        int x = pix.width() - favIcon.width() - 1,
+            y = pix.height() - favIcon.height() - 1;
+        if (pix.mask())
+        {
+            QBitmap mask = *pix.mask();
+            bitBlt(&mask, x, y,
+                   favIcon.mask() ? const_cast<QBitmap *>(favIcon.mask()) : &favIcon,
+                   0, 0, favIcon.width(), favIcon.height(),
+                   favIcon.mask() ? Qt::OrROP : Qt::SetROP);
+            pix.setMask(mask);
+        }
+        bitBlt(&pix, x, y, &favIcon);
+    }
 
     QPixmapCache::insert(key, pix);
     return pix;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic