summaryrefslogtreecommitdiff
path: root/src/websnap.cpp
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@nokia.com>2010-09-14 23:02:10 +0200
committerPierre Rossi <pierre.rossi@nokia.com>2010-09-15 18:40:33 +0200
commitaad3dfe4b42bd0f909755710d4fa2ac02ce59a0f (patch)
treeabbdaee0ca283e634f4f20c8f4c212b3885fba5b /src/websnap.cpp
parentUpgraded download i18n script to automagically grab translation strings (diff)
downloadrekonq-aad3dfe4b42bd0f909755710d4fa2ac02ce59a0f.tar.xz
Websnaps: change the image path to use base64.
This should solve the problems caused by special characters for good. A few other improvements: - do not call updateImage as many times as there are favorites. - removed an unused variable. - trade #defines for static const ints - take advantage of the already loaded page to refresh the snapshot.
Diffstat (limited to 'src/websnap.cpp')
-rw-r--r--src/websnap.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/websnap.cpp b/src/websnap.cpp
index afa08c64..54cf1053 100644
--- a/src/websnap.cpp
+++ b/src/websnap.cpp
@@ -38,7 +38,6 @@
// Qt Includes
#include <QtCore/QSize>
-#include <QtCore/QTimer>
#include <QtCore/QFile>
#include <QtGui/QPainter>
@@ -61,7 +60,7 @@ WebSnap::WebSnap(const KUrl& url, QObject *parent)
connect(&m_page, SIGNAL(loadFinished(bool)), this, SLOT(saveResult(bool)));
- QTimer::singleShot(0, this, SLOT(load()));
+ QMetaObject::invokeMethod(this, "load", Qt::QueuedConnection);
}
@@ -184,9 +183,9 @@ QPixmap WebSnap::renderPagePreview(const QWebPage &page, int w, int h)
QString WebSnap::imagePathFromUrl(const KUrl &url)
{
QUrl temp = QUrl(url.url());
- QString name = temp.toString(QUrl::RemoveScheme | QUrl::RemoveUserInfo | QUrl::StripTrailingSlash);
- name.remove(QRegExp(QL1S("[&+=_?./-]")));
- return KStandardDirs::locateLocal("cache", QString("thumbs/") + name + ".png", true);
+ QByteArray name = temp.toEncoded(QUrl::RemoveScheme | QUrl::RemoveUserInfo | QUrl::StripTrailingSlash);
+
+ return KStandardDirs::locateLocal("cache", QString("thumbs/") + name.toBase64() + ".png", true);
}
@@ -194,7 +193,7 @@ void WebSnap::saveResult(bool ok)
{
if (ok)
{
- QPixmap image = renderPagePreview(m_page, WIDTH, HEIGHT);
+ QPixmap image = renderPagePreview(m_page, defaultWidth, defaultHeight);
QString path = imagePathFromUrl(m_url);
QFile::remove(path);
image.save(path);