mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
WebTab: Preserve order of child tabs in session file
This commit is contained in:
parent
4bb75de25c
commit
85def54d3c
@ -790,19 +790,25 @@ bool TabWidget::restoreState(const QVector<WebTab::SavedTab> &tabs, int currentT
|
||||
return false;
|
||||
}
|
||||
|
||||
QVector<QPair<WebTab*, int>> parentTabs;
|
||||
QVector<QPair<WebTab*, QVector<int>>> childTabs;
|
||||
|
||||
for (int i = 0; i < tabs.size(); ++i) {
|
||||
WebTab::SavedTab tab = tabs.at(i);
|
||||
WebTab *webTab = weTab(addView(QUrl(), Qz::NT_CleanSelectedTab, false, tab.isPinned));
|
||||
webTab->restoreTab(tab);
|
||||
if (tab.parentTab >= 0) {
|
||||
parentTabs.append({webTab, tab.parentTab});
|
||||
if (!tab.childTabs.isEmpty()) {
|
||||
childTabs.append({webTab, tab.childTabs});
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto p : qAsConst(parentTabs)) {
|
||||
p.first->setParentTab(weTab(p.second));
|
||||
for (const auto p : qAsConst(childTabs)) {
|
||||
const auto indices = p.second;
|
||||
for (int index : indices) {
|
||||
WebTab *t = weTab(index);
|
||||
if (t) {
|
||||
p.first->addChildTab(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setCurrentIndex(currentTab);
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include <QTimer>
|
||||
#include <QSplitter>
|
||||
|
||||
static const int savedTabVersion = 4;
|
||||
static const int savedTabVersion = 5;
|
||||
|
||||
WebTab::SavedTab::SavedTab()
|
||||
: isPinned(false)
|
||||
@ -54,6 +54,12 @@ WebTab::SavedTab::SavedTab(WebTab* webTab)
|
||||
isPinned = webTab->isPinned();
|
||||
zoomLevel = webTab->zoomLevel();
|
||||
parentTab = webTab->parentTab() ? webTab->parentTab()->tabIndex() : -1;
|
||||
|
||||
const auto children = webTab->childTabs();
|
||||
childTabs.reserve(children.count());
|
||||
for (WebTab *child : children) {
|
||||
childTabs.append(child->tabIndex());
|
||||
}
|
||||
}
|
||||
|
||||
bool WebTab::SavedTab::isValid() const
|
||||
@ -70,6 +76,7 @@ void WebTab::SavedTab::clear()
|
||||
isPinned = false;
|
||||
zoomLevel = qzSettings->defaultZoomLevel;
|
||||
parentTab = -1;
|
||||
childTabs.clear();
|
||||
}
|
||||
|
||||
QDataStream &operator <<(QDataStream &stream, const WebTab::SavedTab &tab)
|
||||
@ -82,6 +89,7 @@ QDataStream &operator <<(QDataStream &stream, const WebTab::SavedTab &tab)
|
||||
stream << tab.isPinned;
|
||||
stream << tab.zoomLevel;
|
||||
stream << tab.parentTab;
|
||||
stream << tab.childTabs;
|
||||
|
||||
return stream;
|
||||
}
|
||||
@ -109,6 +117,9 @@ QDataStream &operator >>(QDataStream &stream, WebTab::SavedTab &tab)
|
||||
if (version >= 4)
|
||||
stream >> tab.parentTab;
|
||||
|
||||
if (version >= 5)
|
||||
stream >> tab.childTabs;
|
||||
|
||||
tab.icon = QIcon(pixmap);
|
||||
|
||||
return stream;
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
bool isPinned;
|
||||
int zoomLevel;
|
||||
int parentTab;
|
||||
QVector<int> childTabs;
|
||||
|
||||
SavedTab();
|
||||
SavedTab(WebTab* webTab);
|
||||
|
Loading…
Reference in New Issue
Block a user