From b4516b0bacb68179eb6f7cbff9c6474ec03cc9ab Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 30 Sep 2009 10:21:58 +0200 Subject: BIG BIG commit removed: - last closed tabs feature - new tab page settings (unuseful, we need something better) implemented - new home page layout (needs love) - new about: protocol to load home page sections - preview images cache todo: - cleaning cache mechanism - bug fixing - add/remove to preferred actions --- src/previewimage.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/previewimage.cpp') diff --git a/src/previewimage.cpp b/src/previewimage.cpp index c10f8924..9cd1fdaa 100644 --- a/src/previewimage.cpp +++ b/src/previewimage.cpp @@ -35,21 +35,22 @@ #include #include -PreviewImage::PreviewImage(const QString &url, const QString &pos) + +PreviewImage::PreviewImage(const QString &url) : QLabel() , ws(0) , m_url(url) { - QString path = KStandardDirs::locateLocal("cache", QString("thumbs/rek") + pos + ".png", true); + m_savePath = KStandardDirs::locateLocal("cache", QString("thumbs/") + guessNameFromUrl(m_url) + ".png", true); - if(QFile::exists(path)) + if(QFile::exists(m_savePath)) { - m_pixmap.load(path); + m_pixmap.load(m_savePath); setPixmap( m_pixmap ); } else { - ws = new WebSnap( url, pos ); + ws = new WebSnap( url ); connect(ws, SIGNAL(finished()), this, SLOT(setSiteImage())); QString path = KStandardDirs::locate("appdata", "pics/busywidget.gif"); @@ -73,7 +74,10 @@ void PreviewImage::setSiteImage() delete m; setMovie(0); - setPixmap( ws->previewImage() ); + m_pixmap = ws->previewImage(); + setPixmap(m_pixmap); + + m_pixmap.save(m_savePath); } @@ -82,3 +86,9 @@ void PreviewImage::mousePressEvent(QMouseEvent *event) Q_UNUSED(event) Application::instance()->loadUrl(m_url); } + + +QString PreviewImage::guessNameFromUrl(QString url) +{ + return QUrl(url).toString( QUrl::RemoveScheme | QUrl::RemoveUserInfo | QUrl::StripTrailingSlash ); +} -- cgit v1.2.1