1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 09:42:10 +02:00

ProfileManager: Implement profile migration from QupZilla

This commit is contained in:
David Rosca 2018-03-31 15:42:55 +02:00
parent 3dae3edff5
commit 7c078ad70e
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
3 changed files with 32 additions and 6 deletions

View File

@ -59,8 +59,7 @@ void DataPaths::setPortableVersion()
d->m_paths[Plugins].clear();
d->initAssetsIn(appDir);
// Make sure the Config and Temp paths exists
QDir().mkpath(d->m_paths[Config].at(0));
// Make sure Temp path exists
QDir().mkpath(d->m_paths[Temp].at(0));
}
@ -134,9 +133,6 @@ void DataPaths::init()
}
m_paths[Cache].append(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
// Make sure Config path exists
QDir().mkpath(m_paths[Config].at(0));
}
void DataPaths::initCurrentProfile(const QString &profilePath)

View File

@ -28,6 +28,8 @@
#include <QSqlDatabase>
#include <QMessageBox>
#include <QSettings>
#include <QStandardPaths>
#include <iostream>
ProfileManager::ProfileManager()
@ -38,7 +40,11 @@ void ProfileManager::initConfigDir()
{
QDir dir(DataPaths::path(DataPaths::Config));
if (dir.exists() && QFile(dir.filePath(QLatin1String("profiles/profiles.ini"))).exists()) {
if (!dir.exists()) {
migrateFromQupZilla();
}
if (QFileInfo::exists(dir.filePath(QLatin1String("profiles/profiles.ini")))) {
return;
}
@ -240,6 +246,29 @@ void ProfileManager::copyDataToProfile()
}
}
void ProfileManager::migrateFromQupZilla()
{
if (mApp->isPortable()) {
return;
}
#if defined(Q_OS_WIN)
const QString qzConfig = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QL1S("/qupzilla");
#elif defined(Q_OS_MACOS)
const QString qzConfig = QDir::homePath() + QLatin1String("/Library/Application Support/QupZilla");
#else // Unix
const QString qzConfig = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QL1S("/qupzilla");
#endif
if (!QFileInfo::exists(qzConfig)) {
return;
}
std::cout << "Falkon: Migrating config from QupZilla..." << std::endl;
QzTools::copyRecursively(qzConfig, DataPaths::path(DataPaths::Config));
}
void ProfileManager::connectDatabase()
{
QSqlDatabase db = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"));

View File

@ -51,6 +51,7 @@ private:
void updateCurrentProfile();
void updateProfile(const QString &current, const QString &profile);
void copyDataToProfile();
void migrateFromQupZilla();
void connectDatabase();
};