1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

Properly returning page to its original state after rendering preview.

See #663
This commit is contained in:
nowrep 2013-02-06 23:45:43 +01:00
parent 24957fd537
commit 2bb002b62d
2 changed files with 14 additions and 1 deletions

View File

@ -620,6 +620,10 @@ void WebPage::cleanBlockedObjects()
QWebElement bodyElement = docElement.findFirst("body");
bodyElement.appendInside("<style type=\"text/css\">\n/* AdBlock for QupZilla */\n" + elementHiding);
if (!view()->isVisible() && !url().fragment().isEmpty()) {
mainFrame()->scrollToAnchor(url().fragment());
}
}
QString WebPage::userAgentForUrl(const QUrl &url) const

View File

@ -255,8 +255,14 @@ void WebTab::p_restoreTab(const WebTab::SavedTab &tab)
QPixmap WebTab::renderTabPreview()
{
TabbedWebView* currentWebView = p_QupZilla->weView();
WebPage* page = m_view->page();
QSize oldSize = page->viewportSize();
const QSize oldSize = currentWebView ? currentWebView->page()->viewportSize() : page->viewportSize();
const QPoint originalScrollPosition = page->mainFrame()->scrollPosition();
// Hack to ensure rendering the same preview before and after the page was shown for the first tie
// This can occur eg. with opening background tabs
page->setViewportSize(oldSize);
const int previewWidth = 230;
const int previewHeight = 150;
@ -276,6 +282,9 @@ QPixmap WebTab::renderTabPreview()
p.end();
page->setViewportSize(oldSize);
// Restore also scrollbar positions, to prevent messing scrolling to anchor links
page->mainFrame()->setScrollBarValue(Qt::Vertical, originalScrollPosition.y());
page->mainFrame()->setScrollBarValue(Qt::Horizontal, originalScrollPosition.x());
return pageImage.scaled(previewWidth, previewHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}