1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Ensuring tab previews are painted without scrollbars.

- it finally works now
This commit is contained in:
nowrep 2012-04-15 22:08:41 +02:00
parent 82bd695d3a
commit 8e76ba5a47
2 changed files with 5 additions and 6 deletions

View File

@ -267,8 +267,7 @@ void ClickToFlash::load()
"var qz_c2f_nextSibling=this.nextSibling;this.parentNode.removeChild(this);" "var qz_c2f_nextSibling=this.nextSibling;this.parentNode.removeChild(this);"
"setTimeout(function(){if(qz_c2f_nextSibling){" "setTimeout(function(){if(qz_c2f_nextSibling){"
"qz_c2f_parentNode.insertBefore(qz_c2f_clone,qz_c2f_nextSibling);}" "qz_c2f_parentNode.insertBefore(qz_c2f_clone,qz_c2f_nextSibling);}"
"else{qz_c2f_parentNode.appendChild(qz_c2f_clone);}" "else{qz_c2f_parentNode.appendChild(qz_c2f_clone);}},250);";
"}, 250);";
m_element.evaluateJavaScript(js); m_element.evaluateJavaScript(js);
} }

View File

@ -29,6 +29,7 @@
#include <QWebHistory> #include <QWebHistory>
#include <QWebFrame> #include <QWebFrame>
#include <QLabel> #include <QLabel>
#include <QStyle>
WebTab::SavedTab::SavedTab(WebTab* webTab) WebTab::SavedTab::SavedTab(WebTab* webTab)
{ {
@ -255,16 +256,15 @@ QPixmap WebTab::renderTabPreview()
const int previewWidth = 230; const int previewWidth = 230;
const int previewHeight = 150; const int previewHeight = 150;
const int verticalScrollBarWidth = page->mainFrame()->scrollBarGeometry(Qt::Vertical).width(); const int scrollBarExtent = style()->pixelMetric(QStyle::PM_ScrollBarExtent);
const int horizontalScrollBarWidth = page->mainFrame()->scrollBarGeometry(Qt::Horizontal).height();
const int pageWidth = qMin(page->mainFrame()->contentsSize().width(), 1280); const int pageWidth = qMin(page->mainFrame()->contentsSize().width(), 1280);
const int pageHeight = (pageWidth / 23 * 15); const int pageHeight = (pageWidth / 23 * 15);
const qreal scalingFactor = 2 * static_cast<qreal>(previewWidth) / pageWidth; const qreal scalingFactor = 2 * static_cast<qreal>(previewWidth) / pageWidth;
page->setViewportSize(QSize(pageWidth, pageHeight)); page->setViewportSize(QSize(pageWidth, pageHeight));
QPixmap pageImage((2 * previewWidth) - verticalScrollBarWidth, (2 * previewHeight) - horizontalScrollBarWidth); QPixmap pageImage((2 * previewWidth) - scrollBarExtent, (2 * previewHeight) - scrollBarExtent);
pageImage.fill(Qt::red); pageImage.fill(Qt::transparent);
QPainter p(&pageImage); QPainter p(&pageImage);
p.scale(scalingFactor, scalingFactor); p.scale(scalingFactor, scalingFactor);