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

Drop support for pinned tabs without saving session

Pinned tabs are saved alongside normal tabs in a session file.
If user don't have session restore enabled, pinned tabs are saved
and restored from a special pinnedtabs.dat file which uses different
codepath.
It has also another problem that it only saves pinned tabs for last
browser window, which sometimes may be confusing and lead to losing
the pinned tabs.
This commit is contained in:
David Rosca 2016-12-27 18:40:16 +01:00
parent e15bcc9215
commit e9b226d477
4 changed files with 1 additions and 104 deletions

View File

@ -191,17 +191,10 @@ void BrowserWindow::postLaunch()
else if (mApp->afterLaunch() == MainApplication::RestoreSession && mApp->restoreManager()) {
addTab = !mApp->restoreSession(this, mApp->restoreManager()->restoreData());
}
else {
// Restore pinned tabs also when not restoring session
m_tabWidget->restorePinnedTabs();
}
break;
case Qz::BW_MacFirstWindow:
m_tabWidget->restorePinnedTabs();
// fallthrough
case Qz::BW_NewWindow:
case Qz::BW_MacFirstWindow:
addTab = true;
break;

View File

@ -702,14 +702,6 @@ void MainApplication::saveSession()
}
}
if (afterLaunch() != RestoreSession) {
// Pinned tabs are saved only for last window into pinnedtabs.dat
BrowserWindow* qupzilla_ = getWindow();
if (qupzilla_ && m_windows.count() == 1) {
qupzilla_->tabWidget()->savePinnedTabs();
}
}
QFile file(DataPaths::currentProfilePath() + QLatin1String("/session.dat"));
file.open(QIODevice::WriteOnly);
file.write(data);

View File

@ -773,91 +773,6 @@ QList<WebTab*> TabWidget::allTabs(bool withPinned)
return allTabs;
}
void TabWidget::savePinnedTabs()
{
if (mApp->isPrivate()) {
return;
}
QByteArray data;
QDataStream stream(&data, QIODevice::WriteOnly);
stream << Qz::sessionVersion;
QStringList tabs;
QList<QByteArray> tabsHistory;
for (int i = 0; i < count(); ++i) {
WebTab* tab = weTab(i);
if (!tab || !tab->isPinned()) {
continue;
}
tabs.append(tab->url().toEncoded());
tabsHistory.append(tab->historyData());
}
stream << tabs;
stream << tabsHistory;
QFile file(DataPaths::currentProfilePath() + "/pinnedtabs.dat");
file.open(QIODevice::WriteOnly);
file.write(data);
file.close();
}
void TabWidget::restorePinnedTabs()
{
if (mApp->isPrivate()) {
return;
}
QFile file(DataPaths::currentProfilePath() + "/pinnedtabs.dat");
if (!file.open(QIODevice::ReadOnly))
return;
QByteArray sd = file.readAll();
file.close();
QDataStream stream(&sd, QIODevice::ReadOnly);
if (stream.atEnd()) {
return;
}
int version;
stream >> version;
if (version != Qz::sessionVersion && version != Qz::sessionVersionQt5) {
return;
}
QStringList pinnedTabs;
stream >> pinnedTabs;
QList<QByteArray> tabHistory;
stream >> tabHistory;
for (int i = 0; i < pinnedTabs.count(); ++i) {
QUrl url = QUrl::fromEncoded(pinnedTabs.at(i).toUtf8());
QByteArray historyState = tabHistory.value(i);
int addedIndex;
if (!historyState.isEmpty()) {
addedIndex = addView(QUrl(), Qz::NT_CleanSelectedTab, false, true);
weTab(addedIndex)->p_restoreTab(url, historyState, 6);
}
else {
addedIndex = addView(url, tr("New tab"), Qz::NT_SelectedTab, false, -1, true);
}
WebTab* webTab = weTab(addedIndex);
if (webTab) {
webTab->setPinned(true);
}
m_tabBar->updatePinnedTabCloseButton(addedIndex);
}
}
QByteArray TabWidget::saveState()
{
QVector<WebTab::SavedTab> tabList;

View File

@ -75,9 +75,6 @@ public:
bool restoreState(const QVector<WebTab::SavedTab> &tabs, int currentTab);
void closeRecoveryTab();
void savePinnedTabs();
void restorePinnedTabs();
void setCurrentIndex(int index);
void nextTab();