diff options
-rw-r--r-- | src/tabbar.cpp | 5 | ||||
-rw-r--r-- | src/urlbar/listitem.cpp | 24 | ||||
-rw-r--r-- | src/urlbar/listitem.h | 3 | ||||
-rw-r--r-- | src/websnap.cpp | 8 | ||||
-rw-r--r-- | src/websnap.h | 1 |
5 files changed, 12 insertions, 29 deletions
diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 518b1a96..f8da57b1 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -164,13 +164,16 @@ void TabBar::showTabPreview(int tab) delete m_previewPopup.data(); m_previewPopup.clear(); + if (indexedTab->progress() != 0) + return; + m_previewPopup = new KPassivePopup(this); m_previewPopup.data()->setFrameShape(QFrame::StyledPanel); m_previewPopup.data()->setFrameShadow(QFrame::Plain); m_previewPopup.data()->setFixedSize(w, h); QLabel *l = new QLabel(); - l->setPixmap( WebSnap::renderPreview( *indexedTab->page(), w, h, false) ); + l->setPixmap( WebSnap::renderPreview( *indexedTab->page(), w, h, true) ); m_previewPopup.data()->setView(l); m_previewPopup.data()->layout()->setAlignment(Qt::AlignTop); diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp index 6f91aabd..229b43e9 100644 --- a/src/urlbar/listitem.cpp +++ b/src/urlbar/listitem.cpp @@ -31,6 +31,7 @@ // Local Includes #include "urlresolver.h" #include "application.h" +#include "websnap.h" // KDE Includes #include <KIcon> @@ -238,7 +239,8 @@ ItemPreview::ItemPreview(const QString &url, int width, int height, QWidget *par setFixedSize(width, height); setFrameStyle(QFrame::StyledPanel | QFrame::Raised); - QString path = KStandardDirs::locateLocal("cache", QString("thumbs/") + guessNameFromUrl( QUrl(url) ) + ".png", true); + KUrl u = WebSnap::fileForUrl( QUrl(url) ); + QString path = u.pathOrUrl(); if(QFile::exists(path)) { QPixmap preview; @@ -248,26 +250,6 @@ ItemPreview::ItemPreview(const QString &url, int width, int height, QWidget *par } -//TODO: REMOVE DUPLICATE CODE WITH PREVIEWIMAGE -QString ItemPreview::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; -} - - // --------------------------------------------------------------- diff --git a/src/urlbar/listitem.h b/src/urlbar/listitem.h index 2f6f898a..8a6f520f 100644 --- a/src/urlbar/listitem.h +++ b/src/urlbar/listitem.h @@ -193,9 +193,6 @@ class ItemPreview : public QLabel public: ItemPreview(const QString &url, int width, int height, QWidget *parent = 0); - -private: - static QString guessNameFromUrl(QUrl url); }; diff --git a/src/websnap.cpp b/src/websnap.cpp index 906bbc1e..612fdf4e 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -146,20 +146,22 @@ QString WebSnap::guessNameFromUrl(QUrl url) void WebSnap::saveResult(bool ok) { + QPixmap image = QPixmap(); + // crude error-checking if (!ok) { kDebug() << "Error loading site.."; m_snapTitle = "Error..."; - m_image = QPixmap(); + } else { - m_image = renderPreview(m_page, WIDTH, HEIGHT); + image = renderPreview(m_page, WIDTH, HEIGHT); m_snapTitle = m_page.mainFrame()->title(); } QFile::remove(fileForUrl(m_url).toLocalFile()); - m_image.save(fileForUrl(m_url).toLocalFile()); + image.save(fileForUrl(m_url).toLocalFile()); NewTabPage p( m_frame ); p.snapFinished(m_previewIndex, m_url, m_snapTitle); diff --git a/src/websnap.h b/src/websnap.h index e7c9e593..9773b4cc 100644 --- a/src/websnap.h +++ b/src/websnap.h @@ -78,7 +78,6 @@ private slots: private: QWebPage m_page; - QPixmap m_image; QUrl m_url; QString m_snapTitle; |