1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56: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; return false;
} }
QVector<QPair<WebTab*, int>> parentTabs;
for (int i = 0; i < tabs.size(); ++i) { for (int i = 0; i < tabs.size(); ++i) {
WebTab::SavedTab tab = tabs.at(i); WebTab::SavedTab tab = tabs.at(i);
int index = addView(QUrl(), Qz::NT_CleanSelectedTab, false, tab.isPinned); WebTab *webTab = weTab(addView(QUrl(), Qz::NT_CleanSelectedTab, false, tab.isPinned));
weTab(index)->restoreTab(tab); 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); setCurrentIndex(currentTab);

View File

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

View File

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