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

[SessionRestore] Fixed saving some tab icons in session file.

Saving directly QPixmap instead of QIcon fixes issue when some
icons don't save correctly for some reason (eg. oxygen hdd icon).
This commit is contained in:
nowrep 2013-05-03 00:35:14 +02:00
parent 1b617068b2
commit 650f474113
2 changed files with 38 additions and 21 deletions

View File

@ -64,7 +64,6 @@ void RestoreManager::createFromFile(const QString &file)
WindowData wd;
wd.windowState = windowState;
{
QDataStream tabStream(tabState);
if (tabStream.atEnd()) {
continue;
@ -83,7 +82,6 @@ void RestoreManager::createFromFile(const QString &file)
int currentTab;
tabStream >> currentTab;
wd.currentTab = currentTab;
}
m_data.append(wd);
}

View File

@ -33,6 +33,8 @@
#include <QStyle>
#include <QTimer>
static const int savedTabVersion = 1;
WebTab::SavedTab::SavedTab(WebTab* webTab)
{
title = webTab->title();
@ -51,9 +53,10 @@ void WebTab::SavedTab::clear()
QDataStream &operator <<(QDataStream &stream, const WebTab::SavedTab &tab)
{
stream << savedTabVersion;
stream << tab.title;
stream << tab.url;
stream << tab.icon;
stream << tab.icon.pixmap(16);
stream << tab.history;
return stream;
@ -61,10 +64,26 @@ QDataStream &operator <<(QDataStream &stream, const WebTab::SavedTab &tab)
QDataStream &operator >>(QDataStream &stream, WebTab::SavedTab &tab)
{
int version;
stream >> version;
// FIXME: HACK to ensure backwards compatibility
if (version != savedTabVersion) {
stream.device()->seek(stream.device()->pos() - sizeof(int));
stream >> tab.title;
stream >> tab.url;
stream >> tab.icon;
stream >> tab.history;
return stream;
}
QPixmap pixmap;
stream >> tab.title;
stream >> tab.url;
stream >> pixmap;
stream >> tab.history;
tab.icon = QIcon(pixmap);
return stream;
}