summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tabpreviewpopup.cpp18
-rw-r--r--src/webtab.cpp30
-rw-r--r--src/webtab.h3
3 files changed, 37 insertions, 14 deletions
diff --git a/src/tabpreviewpopup.cpp b/src/tabpreviewpopup.cpp
index 4466868d..821c033c 100644
--- a/src/tabpreviewpopup.cpp
+++ b/src/tabpreviewpopup.cpp
@@ -31,7 +31,6 @@
// Rekonq Includes
#include "webtab.h"
#include "tabbar.h"
-#include "websnap.h"
#include "application.h"
#include "mainwindow.h"
@@ -99,21 +98,14 @@ TabPreviewPopup::~TabPreviewPopup()
void TabPreviewPopup::setWebTab(WebTab* tab)
{
- int w = (tab->parentWidget()->sizeHint().width() / TabBar::baseWidthDivisor);
- int h = w * rApp->mainWindow()->size().height() / rApp->mainWindow()->size().width();
+ const QPixmap preview = tab->tabPreview();
- if (!tab->part())
- setThumbnail(WebSnap::renderPagePreview(*tab->page(), w, h));
- else
+ if (!preview.isNull())
{
- QWidget *part = tab->part()->widget();
- QPixmap partThumb(part->size());
- part->render(&partThumb);
- setThumbnail(partThumb.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
+ setThumbnail(preview);
+ setUrl(tab->url().prettyUrl());
+ setFixedSize(preview.width(), preview.height() + m_url->heightForWidth(preview.width()));
}
- setUrl(tab->url().prettyUrl());
-
- setFixedSize(w, h + m_url->heightForWidth(w));
}
diff --git a/src/webtab.cpp b/src/webtab.cpp
index 724b5d0b..c91c3a20 100644
--- a/src/webtab.cpp
+++ b/src/webtab.cpp
@@ -36,15 +36,18 @@
#include "application.h"
#include "historymanager.h"
#include "messagebar.h"
+#include "mainwindow.h"
#include "opensearchmanager.h"
#include "previewselectorbar.h"
#include "rsswidget.h"
#include "searchenginebar.h"
#include "sessionmanager.h"
#include "syncmanager.h"
+#include "tabbar.h"
#include "urlbar.h"
#include "walletbar.h"
#include "webpage.h"
+#include "websnap.h"
#include "webshortcutwidget.h"
// KDE Includes
@@ -365,6 +368,33 @@ bool WebTab::hasAdBlockedElements()
}
+QPixmap WebTab::tabPreview()
+{
+ if (isPageLoading())
+ {
+ // no previews during load
+ return QPixmap();
+ }
+
+ int w = (parentWidget()->sizeHint().width() / TabBar::baseWidthDivisor);
+ int h = w * rApp->mainWindow()->size().height() / rApp->mainWindow()->size().width();
+
+ if (!part())
+ {
+ return WebSnap::renderPagePreview(*page(), w, h);
+ }
+ else
+ {
+ QWidget *partWidget = part()->widget();
+ QPixmap partThumb(partWidget->size());
+
+ partWidget->render(&partThumb);
+
+ return partThumb.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ }
+}
+
+
void WebTab::loadFinished()
{
// add page to history
diff --git a/src/webtab.h b/src/webtab.h
index 92ae2eb5..c318da10 100644
--- a/src/webtab.h
+++ b/src/webtab.h
@@ -90,9 +90,10 @@ public:
void setPart(KParts::ReadOnlyPart *p, const KUrl &u);
-
bool hasAdBlockedElements();
+ QPixmap tabPreview();
+
private Q_SLOTS:
void updateProgress(int progress);
void resetProgress();