diff --git a/src/lib/app/datapaths.cpp b/src/lib/app/datapaths.cpp index 6e4d5c01d..d2efb346d 100644 --- a/src/lib/app/datapaths.cpp +++ b/src/lib/app/datapaths.cpp @@ -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) diff --git a/src/lib/app/profilemanager.cpp b/src/lib/app/profilemanager.cpp index 11b1f95cc..49c15886d 100644 --- a/src/lib/app/profilemanager.cpp +++ b/src/lib/app/profilemanager.cpp @@ -28,6 +28,8 @@ #include #include #include +#include + #include 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")); diff --git a/src/lib/app/profilemanager.h b/src/lib/app/profilemanager.h index efd6f9734..74e266532 100644 --- a/src/lib/app/profilemanager.h +++ b/src/lib/app/profilemanager.h @@ -51,6 +51,7 @@ private: void updateCurrentProfile(); void updateProfile(const QString ¤t, const QString &profile); void copyDataToProfile(); + void migrateFromQupZilla(); void connectDatabase(); };