From 729bbd292f28bc7fc8d504fcea58815cb712cc7d Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 30 Jul 2010 22:23:47 +0000 Subject: [PATCH] (trunk qt) 1. fix icon sizing issue. 2. add a mechanism to get the favicon from the hostname as an alternative to passing in the full announce UR.L --- qt/favicon.cc | 16 ++++++++++++++-- qt/favicon.h | 3 +++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/qt/favicon.cc b/qt/favicon.cc index 4650d82bb..bb490a9a3 100644 --- a/qt/favicon.cc +++ b/qt/favicon.cc @@ -81,10 +81,22 @@ Favicons :: getHost( const QUrl& url ) QPixmap Favicons :: find( const QUrl& url ) +{ + return findFromHost( getHost( url ) ); +} + +namespace +{ + const QSize rightSize( 16, 16 ); +}; + +QPixmap +Favicons :: findFromHost( const QString& host ) { ensureCacheDirHasBeenScanned( ); - return myPixmaps[ getHost(url) ]; + const QPixmap pixmap = myPixmaps[ host ]; + return pixmap.size()==rightSize ? pixmap : pixmap.scaled(rightSize); } void @@ -97,7 +109,7 @@ Favicons :: add( const QUrl& url ) if( !myPixmaps.contains( host ) ) { // add a placholder s.t. we only ping the server once per session - QPixmap tmp( 16, 16 ); + QPixmap tmp( rightSize ); tmp.fill( Qt::transparent ); myPixmaps.insert( host, tmp ); diff --git a/qt/favicon.h b/qt/favicon.h index 2341cfc43..bc06cdeff 100644 --- a/qt/favicon.h +++ b/qt/favicon.h @@ -38,6 +38,9 @@ class Favicons: public QObject /* returns a cached pixmap, or a NULL pixmap if there's no match in the cache */ QPixmap find( const QUrl& url ); + /* returns a cached pixmap, or a NULL pixmap if there's no match in the cache */ + QPixmap findFromHost( const QString& host ); + /* this will emit a signal when (if) the icon becomes ready */ void add( const QUrl& url );