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

List:       kfm-devel
Subject:    Re: [PATCH] Don't scale favicon
From:       Aurélien Gâteau <aurelien.gateau () free ! fr>
Date:       2007-12-27 0:36:43
Message-ID: fkus2q$9cb$1 () ger ! gmane ! org
[Download RAW message or body]

David Faure wrote:

>> This sounds a bit more complicated to do. Would you agree to get the
>> patch applied as is for 4.0?
> 
> OK with me (although I wonder what changed the behavior of this code,
> kdebase/libkonq/konq_pixmapprovider.cc also says QPixmap small =
> SmallIcon( icon, size ) and y =0).

Hum... I don't have any kdebase/libkonq/konq_pixmapprovider.cc file... or is
it the KDE3 version?

Anyway, I have a better fix for the bug.

I looked a bit further in KIconLoader::loadIcon(), and found out it contains
some special code to handle favicons. It even knows how to blend the
favicon over the Web icon. This favicon code got broken because there is
no "www" icon anymore. I replaced it with "text-html" and it works again.
See kiconloader_favicon.diff.

Since KIconLoader::loadIcon() already blends the favicon, there is no need
for KonqPixmapProvider::loadIcon() to do it again. It simplifies the code
quite a lot. See konqueror_dont_scale_favicon2.diff.

Before testing, be sure to remove your icon cache
(/var/tmp/kdecache-$USER/kpc on my machine), or you might still get some
scaled favicons.

Is it ok to apply?

Aurélien

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

Index: kdeui/icons/kiconloader.cpp
===================================================================
--- kdeui/icons/kiconloader.cpp	(révision 752806)
+++ kdeui/icons/kiconloader.cpp	(copie de travail)
@@ -1007,7 +1007,7 @@
         else
         {
             if (!name.isEmpty())
-                icon = d->findMatchingIcon(favIconOverlay ? QString("www") : name, size);
+                icon = d->findMatchingIcon(favIconOverlay ? QString("text-html") : name, size);
 
             if (!icon.isValid())
             {


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

Index: src/konqpixmapprovider.cpp
===================================================================
--- src/konqpixmapprovider.cpp	(révision 752807)
+++ src/konqpixmapprovider.cpp	(copie de travail)
@@ -88,7 +88,7 @@
 
 QPixmap KonqPixmapProvider::pixmapFor( const QString& url, int size )
 {
-    return loadIcon( url, iconNameFor( KUrl( url ) ), size );
+    return loadIcon( iconNameFor( KUrl( url ) ), size );
 }
 
 void KonqPixmapProvider::load( KConfigGroup& kc, const QString& key )
@@ -157,60 +157,12 @@
     iconMap.clear();
 }
 
-QPixmap KonqPixmapProvider::loadIcon( const QString& url, const QString& icon,
-				      int size )
+QPixmap KonqPixmapProvider::loadIcon( const QString& icon, int size )
 {
     if ( size <= KIconLoader::SizeSmall )
 	return SmallIcon( icon, size );
 
-    KUrl u;
-    if ( url.at(0) == '/' )
-	u.setPath( url );
-    else
-	u = url;
-
-    QPixmap big;
-
-    // favicon? => blend the favicon in the large
-    if ( url.startsWith( "http:/" ) && icon.startsWith("favicons/") ) {
-	QPixmap small = SmallIcon( icon, size );
-	big = KIconLoader::global()->loadIcon( KProtocolInfo::icon("http"),
-					       KIconLoader::Panel, size );
-
-	int x = big.width()  - small.width();
-	int y = 0;
-#ifdef __GNUC__
-#warning This mask merge is probably wrong.  I couldnt find a way to get the old \
                behavior of Qt::OrROP
-#endif
-/* Old code that did the bitmask merge
-       if ( big.mask() ) {
-           QBitmap mask = *big.mask();
-           bitBlt( &mask, x, y,
-            small.mask() ? const_cast<QBitmap *>(small.mask()) : &small, 0, 0,
-                   small.width(), small.height(),
-                   small.mask() ? OrROP : SetROP );
-           big.setMask( mask );
-       }
-*/
-	QBitmap mask( big.mask() );
-	if( !mask.isNull() ) {
-            QBitmap sm( small.mask() );
-            QPainter pt(&mask);
-#ifdef __GNUC__
-		#warning
-#endif
-            pt.setCompositionMode( QPainter::CompositionMode_Source );
-            pt.drawPixmap(QPoint(x,y), sm.isNull() ? small : QPixmap(sm), \
                QRect(0,0,small.width(), small.height()));
-	    big.setMask( mask );
-	}
-        QPainter painterOnBig( &big );
-        painterOnBig.drawPixmap( x, y, small );
-    }
-
-    else // not a favicon..
-	big = KIconLoader::global()->loadIcon( icon, KIconLoader::Panel, size );
-
-    return big;
+    return KIconLoader::global()->loadIcon( icon, KIconLoader::Panel, size );
 }
 
 #include "konqpixmapprovider.moc"
Index: src/konqpixmapprovider.h
===================================================================
--- src/konqpixmapprovider.h	(révision 752807)
+++ src/konqpixmapprovider.h	(copie de travail)
@@ -79,7 +79,7 @@
     void notifyChange( bool isHost, const QString& hostOrURL, const QString& \
iconName );  
 private:
-    QPixmap loadIcon( const QString& url, const QString& icon, int size );
+    QPixmap loadIcon( const QString& icon, int size );
 
     KonqPixmapProvider();
     friend class KonqPixmapProviderSingleton;



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

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