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

WebTab: Save/Restore zoom level on restart

This commit is contained in:
innermous 2015-12-13 21:48:38 +02:00 committed by David Rosca
parent 278299fe2a
commit 5801ff0725
5 changed files with 20 additions and 0 deletions

View File

@ -661,6 +661,7 @@ void TabWidget::restoreClosedTab(QObject* obj)
int index = addView(QUrl(), tab.title, Qz::NT_CleanSelectedTab, false, tab.position);
WebTab* webTab = weTab(index);
webTab->setZoomLevel(tab.zoomLevel);
webTab->p_restoreTab(tab.url, tab.history);
updateClosedTabsButton();

View File

@ -44,6 +44,7 @@ void ClosedTabsManager::saveTab(WebTab* tab, int position)
closedTab.icon = tab->icon();
closedTab.position = position;
closedTab.history = tab->historyData();
closedTab.zoomLevel = tab->zoomLevel();
m_closedTabs.prepend(closedTab);
}

View File

@ -35,6 +35,7 @@ public:
QIcon icon;
QByteArray history;
int position;
int zoomLevel;
bool operator==(const Tab &a) const {
return (a.url == url &&

View File

@ -47,6 +47,7 @@ WebTab::SavedTab::SavedTab(WebTab* webTab)
title = webTab->title();
url = webTab->url();
icon = webTab->icon();
zoomLevel = webTab->zoomLevel();
history = webTab->historyData();
isPinned = webTab->isPinned();
}
@ -72,6 +73,7 @@ QDataStream &operator <<(QDataStream &stream, const WebTab::SavedTab &tab)
stream << tab.url;
stream << tab.icon.pixmap(16);
stream << tab.history;
stream << tab.zoomLevel;
stream << tab.isPinned;
return stream;
@ -90,6 +92,7 @@ QDataStream &operator >>(QDataStream &stream, WebTab::SavedTab &tab)
stream >> tab.url;
stream >> pixmap;
stream >> tab.history;
stream >> tab.zoomLevel;
if (version >= 2)
stream >> tab.isPinned;
@ -203,6 +206,16 @@ QWebEngineHistory* WebTab::history() const
return m_webView->history();
}
int WebTab::zoomLevel() const
{
return m_webView->zoomLevel();
}
void WebTab::setZoomLevel(int level)
{
m_webView->setZoomLevel(level);
}
void WebTab::detach()
{
Q_ASSERT(m_tabBar);
@ -302,6 +315,7 @@ void WebTab::restoreTab(const WebTab::SavedTab &tab)
m_tabBar->setTabText(index, tab.title);
m_locationBar->showUrl(tab.url);
m_webView->setZoomLevel(tab.zoomLevel);
m_tabIcon->setIcon(tab.icon);
if (!tab.url.isEmpty()) {

View File

@ -45,6 +45,7 @@ public:
QIcon icon;
QByteArray history;
bool isPinned;
int zoomLevel;
SavedTab();
SavedTab(WebTab* webTab);
@ -66,6 +67,8 @@ public:
QString title() const;
QIcon icon() const;
QWebEngineHistory* history() const;
int zoomLevel() const;
void setZoomLevel(int level);
void detach();
void attach(BrowserWindow* window);