#include "ththu.h"
#include "mylstfiles.h"
 
ththu::ththu()
{
	icon = icon.convertToFormat ( QImage::Format_RGB32, Qt::AutoColor );
	wgmask.load(":/new/prefix2/Interface/Theme/mask_thum.png");
	wgmask2.load(":/new/prefix2/Interface/Theme/forme_thum.png");
	wl_pixtmp2.load(":/new/prefix2/Interface/Theme/forme_thum.png");
}

void ththu::run()
{
	reader.setFileName(current_path + "/" + mywidget->toolTip());
	reader.setQuality ( 10 );
	if (reader.supportsOption(QImageIOHandler::Size))
	{
		mysize = reader.size();
		if ( mysize.width() > mysize.height() )
		{
			reader.setScaledSize ( QSize(114,114/((float)mysize.width() / (float)mysize.height())) );
		}
		else
		{
			reader.setScaledSize ( QSize(114*((float)mysize.width() / (float)mysize.height()),114));
		}
	}
	else
	{
		reader.setScaledSize ( QSize(114,114) );
	}

	//reader.setScaledSize ( QSize(114,114) );

	if (reader.read(&icon)) 
	{
		wl_pixtmp = QPixmap::fromImage(icon, Qt::AutoColor);
		p.begin(&wl_pixtmp2);
		p.drawPixmap ( 0,0,wgmask2);
		//p.drawPixmap ( 7,7,wl_pixtmp);
		p.drawPixmap ( (128-wl_pixtmp.width())/2,(128-wl_pixtmp.height())/2,wl_pixtmp);
		p.end();
		wl_pixtmp2.setMask(wgmask);
		wlico = QIcon(wl_pixtmp2);
		result = 1;
		emit myfin();
	}
	else
	{
		result = 0;
		emit myfin();
	}
	//exec();
}

