mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Properly returning page to its original state after rendering preview.
See #663
This commit is contained in:
parent
24957fd537
commit
2bb002b62d
@ -620,6 +620,10 @@ void WebPage::cleanBlockedObjects()
|
|||||||
|
|
||||||
QWebElement bodyElement = docElement.findFirst("body");
|
QWebElement bodyElement = docElement.findFirst("body");
|
||||||
bodyElement.appendInside("<style type=\"text/css\">\n/* AdBlock for QupZilla */\n" + elementHiding);
|
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
|
QString WebPage::userAgentForUrl(const QUrl &url) const
|
||||||
|
@ -255,8 +255,14 @@ void WebTab::p_restoreTab(const WebTab::SavedTab &tab)
|
|||||||
|
|
||||||
QPixmap WebTab::renderTabPreview()
|
QPixmap WebTab::renderTabPreview()
|
||||||
{
|
{
|
||||||
|
TabbedWebView* currentWebView = p_QupZilla->weView();
|
||||||
WebPage* page = m_view->page();
|
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 previewWidth = 230;
|
||||||
const int previewHeight = 150;
|
const int previewHeight = 150;
|
||||||
@ -276,6 +282,9 @@ QPixmap WebTab::renderTabPreview()
|
|||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
page->setViewportSize(oldSize);
|
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);
|
return pageImage.scaled(previewWidth, previewHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user