mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +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:
parent
1b617068b2
commit
650f474113
@ -64,27 +64,25 @@ void RestoreManager::createFromFile(const QString &file)
|
||||
WindowData wd;
|
||||
wd.windowState = windowState;
|
||||
|
||||
{
|
||||
QDataStream tabStream(tabState);
|
||||
if (tabStream.atEnd()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QVector<WebTab::SavedTab> tabs;
|
||||
int tabListCount = 0;
|
||||
tabStream >> tabListCount;
|
||||
for (int i = 0; i < tabListCount; ++i) {
|
||||
WebTab::SavedTab tab;
|
||||
tabStream >> tab;
|
||||
tabs.append(tab);
|
||||
}
|
||||
wd.tabsState = tabs;
|
||||
|
||||
int currentTab;
|
||||
tabStream >> currentTab;
|
||||
wd.currentTab = currentTab;
|
||||
QDataStream tabStream(tabState);
|
||||
if (tabStream.atEnd()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QVector<WebTab::SavedTab> tabs;
|
||||
int tabListCount = 0;
|
||||
tabStream >> tabListCount;
|
||||
for (int i = 0; i < tabListCount; ++i) {
|
||||
WebTab::SavedTab tab;
|
||||
tabStream >> tab;
|
||||
tabs.append(tab);
|
||||
}
|
||||
wd.tabsState = tabs;
|
||||
|
||||
int currentTab;
|
||||
tabStream >> currentTab;
|
||||
wd.currentTab = currentTab;
|
||||
|
||||
m_data.append(wd);
|
||||
}
|
||||
}
|
||||
|
@ -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,11 +64,27 @@ 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 >> tab.icon;
|
||||
stream >> pixmap;
|
||||
stream >> tab.history;
|
||||
|
||||
tab.icon = QIcon(pixmap);
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user