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

WebTab: Save parent tab index in session file

This commit is contained in:
David Rosca 2018-01-30 16:41:30 +01:00
parent 5b7653188b
commit 61299c89b6
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
3 changed files with 20 additions and 3 deletions

View File

@ -790,10 +790,19 @@ bool TabWidget::restoreState(const QVector<WebTab::SavedTab> &tabs, int currentT
return false;
}
QVector<QPair<WebTab*, int>> parentTabs;
for (int i = 0; i < tabs.size(); ++i) {
WebTab::SavedTab tab = tabs.at(i);
int index = addView(QUrl(), Qz::NT_CleanSelectedTab, false, tab.isPinned);
weTab(index)->restoreTab(tab);
WebTab *webTab = weTab(addView(QUrl(), Qz::NT_CleanSelectedTab, false, tab.isPinned));
webTab->restoreTab(tab);
if (tab.parentTab >= 0) {
parentTabs.append({webTab, tab.parentTab});
}
}
for (const auto p : qAsConst(parentTabs)) {
p.first->setParentTab(weTab(p.second));
}
setCurrentIndex(currentTab);

View File

@ -36,11 +36,12 @@
#include <QTimer>
#include <QSplitter>
static const int savedTabVersion = 3;
static const int savedTabVersion = 4;
WebTab::SavedTab::SavedTab()
: isPinned(false)
, zoomLevel(qzSettings->defaultZoomLevel)
, parentTab(-1)
{
}
@ -52,6 +53,7 @@ WebTab::SavedTab::SavedTab(WebTab* webTab)
history = webTab->historyData();
isPinned = webTab->isPinned();
zoomLevel = webTab->zoomLevel();
parentTab = webTab->parentTab() ? webTab->parentTab()->tabIndex() : -1;
}
bool WebTab::SavedTab::isValid() const
@ -67,6 +69,7 @@ void WebTab::SavedTab::clear()
history.clear();
isPinned = false;
zoomLevel = qzSettings->defaultZoomLevel;
parentTab = -1;
}
QDataStream &operator <<(QDataStream &stream, const WebTab::SavedTab &tab)
@ -78,6 +81,7 @@ QDataStream &operator <<(QDataStream &stream, const WebTab::SavedTab &tab)
stream << tab.history;
stream << tab.isPinned;
stream << tab.zoomLevel;
stream << tab.parentTab;
return stream;
}
@ -102,6 +106,9 @@ QDataStream &operator >>(QDataStream &stream, WebTab::SavedTab &tab)
if (version >= 3)
stream >> tab.zoomLevel;
if (version >= 4)
stream >> tab.parentTab;
tab.icon = QIcon(pixmap);
return stream;

View File

@ -46,6 +46,7 @@ public:
QByteArray history;
bool isPinned;
int zoomLevel;
int parentTab;
SavedTab();
SavedTab(WebTab* webTab);