--Boundary-00=_CJLs9kv3i0CIayo Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Description: clearsigned data Content-Disposition: inline -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hello... bug # notes what several others have observed: why is there both an image and a picture preview option? looking at the code, one does svg and the other one is more general. from the perspective of the user this doesn't make much sense at all. attached is a patch that merges the two thumbnail generators into one. a slightly different approach than that taken in the patch is to try and figure out the mimetype of the file with a call to KMimeType if the approach the patch takes is deemed too processor intensive and only run the qpicture load if it is an image/svg+xml ... i do wonder why the mimetype info isn't passed in to the ThumbCreator since it is known, though.. oh well =) - -- Aaron J. Seigo GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA EE75 D6B7 2EB1 A7F1 DB43 "Everything should be made as simple as possible, but not simpler" - Albert Einstein -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9sLJC1rcusafx20MRAm3+AKCuONAEYJo+pTJ4ZUDcqXPK+Hb+FwCgsGUc y/IfHtK4PXPCWNhxsf9SA4w= =QCP0 -----END PGP SIGNATURE----- --Boundary-00=_CJLs9kv3i0CIayo Content-Type: text/x-diff; charset="us-ascii"; name="thumbnail.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="thumbnail.diff" Index: Makefile.am =================================================================== RCS file: /home/kde/kdebase/kioslave/thumbnail/Makefile.am,v retrieving revision 1.9 diff -u -3 -d -p -r1.9 Makefile.am --- Makefile.am 2002/10/08 08:41:51 1.9 +++ Makefile.am 2002/10/18 23:23:20 @@ -6,7 +6,7 @@ LDFLAGS = $(all_libraries) $(KDE_RPATH) METASOURCES = AUTO kde_module_LTLIBRARIES = kio_thumbnail.la imagethumbnail.la \ - textthumbnail.la htmlthumbnail.la gsthumbnail.la picturethumbnail.la + textthumbnail.la htmlthumbnail.la gsthumbnail.la kio_thumbnail_la_SOURCES = thumbnail.cpp kio_thumbnail_la_LIBADD = $(LIB_KIO) @@ -28,12 +28,8 @@ gsthumbnail_la_SOURCES = gscreator.cpp gsthumbnail_la_LIBADD = $(LIB_KDECORE) gsthumbnail_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) -picturethumbnail_la_SOURCES = picturecreator.cpp -picturethumbnail_la_LIBADD = $(LIB_KDECORE) -picturethumbnail_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) - noinst_HEADERS = thumbnail.h imagecreator.h textcreator.h htmlcreator.h \ - gscreator.h picturecreator.h + gscreator.h kdelnk_DATA = thumbnail.protocol kdelnkdir = $(kde_servicesdir) @@ -42,6 +38,6 @@ servicetypes_DATA = thumbcreator.desktop servicetypesdir = $(kde_servicetypesdir) services_DATA = imagethumbnail.desktop textthumbnail.desktop \ - htmlthumbnail.desktop gsthumbnail.desktop picturethumbnail.desktop + htmlthumbnail.desktop gsthumbnail.desktop servicesdir = $(kde_servicesdir) Index: imagecreator.cpp =================================================================== RCS file: /home/kde/kdebase/kioslave/thumbnail/imagecreator.cpp,v retrieving revision 1.8 diff -u -3 -d -p -r1.8 imagecreator.cpp --- imagecreator.cpp 2001/10/01 20:47:41 1.8 +++ imagecreator.cpp 2002/10/18 23:23:20 @@ -23,6 +23,8 @@ #include #include +#include +#include #include @@ -37,10 +39,47 @@ extern "C" } }; -bool ImageCreator::create(const QString &path, int, int, QImage &img) +bool ImageCreator::create(const QString &path, int width, int height, QImage &img) { // create image preview - return img.load( path ); + QPicture pict; + if ( !pict.load(path,"svg") ) + return img.load( path ); + + // render the HTML page on a bigger pixmap and use smoothScale, + // looks better than directly scaling with the QPainter (malte) + + QRect rect = pict.boundingRect(); + double aspect = (double)rect.width() / (double)rect.height(); + + QPixmap pix; + if (width > 500 || height > 500 ) + { + if (height > width) + pix.resize(width, width / aspect); + else + pix.resize(height * aspect, height); + } + else + { + if (height > width) + pix.resize(500, 500 / aspect); + else + pix.resize(500 * aspect, 500); + } + // light-grey background, in case loadind the page failed + pix.fill( QColor( 245, 245, 245 ) ); + + int borderX = pix.width() / width, + borderY = pix.height() / height; + + QPainter p; + p.begin(&pix); + p.setWindow(pict.boundingRect()); + p.drawPicture(0,0,pict); + p.end(); + img = pix.convertToImage(); + return true; } ThumbCreator::Flags ImageCreator::flags() const --Boundary-00=_CJLs9kv3i0CIayo--