summaryrefslogtreecommitdiff
path: root/src/webtab.cpp
diff options
context:
space:
mode:
authorDavid E. Narváez <david.narvaez@computer.org>2012-04-14 07:54:32 -0500
committerDavid E. Narváez <david.narvaez@computer.org>2012-04-14 07:54:32 -0500
commit9892d840c1d2219f3f86f55d9d35d4f79d56c8a1 (patch)
treedb77b6cea9c11fa60ce3c7feb2b679bb39c68891 /src/webtab.cpp
parentFix typo. (diff)
downloadrekonq-9892d840c1d2219f3f86f55d9d35d4f79d56c8a1.tar.xz
Move Tab Preview to WebTab
Let the WebTab class calculate its own preview, so that it can be used elsewhere in the code. REVIEW: 104517
Diffstat (limited to 'src/webtab.cpp')
-rw-r--r--src/webtab.cpp30
1 files changed, 30 insertions, 0 deletions
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