1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-14 19:12:11 +01:00

Qt5: Added info about Qt version into session files.

It will break restoring sessions from Qt4 into Qt5.
QupZilla can now run with Qt5.
(there are still some issues to be resolved)
This commit is contained in:
nowrep 2012-12-20 15:22:14 +01:00
parent 89e091f09c
commit 365c0d5efd
5 changed files with 18 additions and 9 deletions

View File

@ -891,9 +891,6 @@ void MainApplication::aboutToCloseWindow(QupZilla* window)
m_mainWindows.removeOne(window); m_mainWindows.removeOne(window);
} }
// Version of session.dat file
static const int sessionVersion = 0x0003;
bool MainApplication::saveStateSlot() bool MainApplication::saveStateSlot()
{ {
if (m_isPrivateSession || m_isRestoring || m_mainWindows.count() == 0 || m_restoreManager) { if (m_isPrivateSession || m_isRestoring || m_mainWindows.count() == 0 || m_restoreManager) {
@ -904,7 +901,7 @@ bool MainApplication::saveStateSlot()
file.open(QIODevice::WriteOnly); file.open(QIODevice::WriteOnly);
QDataStream stream(&file); QDataStream stream(&file);
stream << sessionVersion; stream << Qz::sessionVersion;
stream << m_mainWindows.count(); stream << m_mainWindows.count();
for (int i = 0; i < m_mainWindows.count(); i++) { for (int i = 0; i < m_mainWindows.count(); i++) {

View File

@ -28,6 +28,12 @@
namespace Qz namespace Qz
{ {
// Version of session.dat file
#if QT_VERSION >= 0x050000
static const int sessionVersion = 0x0003 & 0x050000;
#else
static const int sessionVersion = 0x0003 & 0x040000;
#endif
enum AppMessageType { enum AppMessageType {
AM_SetAdBlockIconEnabled, AM_SetAdBlockIconEnabled,

View File

@ -30,9 +30,6 @@ RestoreData RestoreManager::restoreData() const
return m_data; return m_data;
} }
// Version of session.dat file
static const int sessionVersion = 0x0003;
void RestoreManager::createFromFile(const QString &file) void RestoreManager::createFromFile(const QString &file)
{ {
if (!QFile::exists(file)) { if (!QFile::exists(file)) {
@ -45,7 +42,7 @@ void RestoreManager::createFromFile(const QString &file)
int version; int version;
stream >> version; stream >> version;
if (version != sessionVersion) { if (version != Qz::sessionVersion) {
return; return;
} }

View File

@ -20,8 +20,9 @@
#define RESTOREMANAGER_H #define RESTOREMANAGER_H
#include "webtab.h" #include "webtab.h"
#include "qz_namespace.h"
class RestoreManager class QT_QUPZILLA_EXPORT RestoreManager
{ {
public: public:
struct WindowData { struct WindowData {

View File

@ -723,6 +723,8 @@ void TabWidget::savePinnedTabs()
QByteArray data; QByteArray data;
QDataStream stream(&data, QIODevice::WriteOnly); QDataStream stream(&data, QIODevice::WriteOnly);
stream << Qz::sessionVersion;
QStringList tabs; QStringList tabs;
QList<QByteArray> tabsHistory; QList<QByteArray> tabsHistory;
for (int i = 0; i < count(); ++i) { for (int i = 0; i < count(); ++i) {
@ -760,6 +762,12 @@ void TabWidget::restorePinnedTabs()
return; return;
} }
int version;
stream >> version;
if (version != Qz::sessionVersion) {
return;
}
QStringList pinnedTabs; QStringList pinnedTabs;
stream >> pinnedTabs; stream >> pinnedTabs;
QList<QByteArray> tabHistory; QList<QByteArray> tabHistory;