diff options
author | matgic78 <matgic78@gmail.com> | 2009-12-17 18:22:23 +0100 |
---|---|---|
committer | matgic78 <matgic78@gmail.com> | 2010-02-06 11:22:46 +0100 |
commit | 8343d45f3dfd631a3f5ac4213918f285930eb446 (patch) | |
tree | 8ec95f3f7b2c97ca6bf02ae70d8654011b72a99a /src/websnap.cpp | |
parent | QPointers --> QWeakPointers (diff) | |
download | rekonq-8343d45f3dfd631a3f5ac4213918f285930eb446.tar.xz |
Re-implemented previews in homepage without using plugins. Not finished yet :
Little things that change:
-nice buttons appearing on hover
-transitions on hover
TODO:
-when a preview is empty or when loading, it is very ugly
-for now there's no way to choose the page you want to preview
-port "closed Tabs" to this new architecture
-totally remove PreviewImage classes
-eventually, specific contextmenu for previews
Diffstat (limited to 'src/websnap.cpp')
-rw-r--r-- | src/websnap.cpp | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/src/websnap.cpp b/src/websnap.cpp index 7dcbb836..e5db7c4e 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -115,16 +115,62 @@ QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h) } +KUrl WebSnap::fileForUrl(KUrl url) +{ + QString filePath = + KStandardDirs::locateLocal("cache", QString("thumbs/") + WebSnap::guessNameFromUrl(url) + ".png", true); + return KUrl(filePath); +} + + +void WebSnap::SetData(QVariant data) +{ + m_data = data; +} + +QVariant& WebSnap::data() +{ + return m_data; +} + + + +QString WebSnap::guessNameFromUrl(QUrl url) +{ + QString name = url.toString( QUrl::RemoveScheme | QUrl::RemoveUserInfo | QUrl::StripTrailingSlash ); + + // TODO learn Regular Expressions :) + // and implement something better here.. + name.remove('/'); + name.remove('&'); + name.remove('.'); + name.remove('-'); + name.remove('_'); + name.remove('?'); + name.remove('='); + name.remove('+'); + + return name; +} + + void WebSnap::saveResult(bool ok) { // crude error-checking if (!ok) { kDebug() << "Error loading site.."; - return; + m_snapTitle = "Error..."; + m_image = QPixmap(); } - - m_image = renderPreview(m_page, WIDTH, HEIGHT); + else + { + m_image = renderPreview(m_page, WIDTH, HEIGHT); + } + + m_image.save(fileForUrl(m_url).toLocalFile()); + kDebug() << "finished"; + emit finished(); } |