Index: digikam-5.2.0/core/utilities/assistants/firstrun/CMakeLists.txt
===================================================================
--- digikam-5.2.0.orig/core/utilities/assistants/firstrun/CMakeLists.txt
+++ digikam-5.2.0/core/utilities/assistants/firstrun/CMakeLists.txt
@@ -11,6 +11,7 @@ endif (POLICY CMP0063)
set(libfirstrun_SRCS
firstrundlg.cpp
+ migratefromdigikam4page.cpp
firstrundlgpage.cpp
welcomepage.cpp
collectionpage.cpp
@@ -26,6 +27,7 @@ set(libfirstrun_SRCS
include_directories($Migrate configuration and metadata from digiKam 4
You can choose here if you want to use the configuration and albums from digiKam 4 in digiKam 5 . " + "Please note the following warnings:
" + "Migration is done at your own risk. Digikam developers " + "don't recommend it and don't support it. On the other hand, Creating " + "a new configuration might result in loss of tags and other metadata that wasn't embedded inside " + "the pictures and was only available in digiKam 4's database.
" + "In either case you're recommended to backup " + "the configuration files and databases before proceeding.
" + "")); + + QWidget* const btns = new QWidget(vbox); + QVBoxLayout* const vlay = new QVBoxLayout(btns); + + m_migrateBehavior = new QButtonGroup(btns); + m_migrate = new QRadioButton(btns); + m_migrate->setText(i18n("Migrate configuration from digiKam 4")); + m_migrate->setChecked(true); + connect(m_migrate, SIGNAL(toggled(bool)), this, SLOT(migrationToggled(bool)) ); + m_migrateBehavior->addButton(m_migrate); + + m_createnew = new QRadioButton(btns); + m_createnew->setText(i18n("Create a new configuration")); + m_migrateBehavior->addButton(m_createnew); + + vlay->addWidget(m_migrate); + vlay->addWidget(m_createnew); + vlay->setContentsMargins(spacing, spacing, spacing, spacing); + vlay->setSpacing(spacing); + + connect(m_migrateBehavior, SIGNAL(buttonClicked(int)), this, SIGNAL(completeChanged())); + + setPageWidget(vbox); +} + +MigrateFromDigikam4Page::~MigrateFromDigikam4Page() +{ +} + +void MigrateFromDigikam4Page::doMigration() +{ + // Migrate digiKam config files from $KDEHOME/share/config/ + Kdelibs4ConfigMigrator migrator(QStringLiteral("digikam")); + QStringList configFiles; + configFiles << QStringLiteral("digikamrc") + << QStringLiteral("digikam_tagsmanagerrc") + << QStringLiteral("kipipluginsrc") + << QStringLiteral("kipirc") + << QStringLiteral("showfotorc"); + migrator.setConfigFiles( configFiles ); + migrator.migrate(); + + // Migrate digiKam config files from $KDEHOME/share/apps/digikam/ + Kdelibs4Migration migration; + QString oldappdatadir = migration.locateLocal("data", QStringLiteral("digikam")); + QStringList oldAppFiles = QDir(oldappdatadir).entryList( QDir::Files | QDir::Readable | QDir::NoDotAndDotDot ); + + Q_FOREACH( const QString &configFileName, oldAppFiles) + { + const QString newConfigLocation + = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + + QLatin1Char('/') + configFileName; + + if (QFile(newConfigLocation).exists()) { + qCDebug(DIGIKAM_GENERAL_LOG) << newConfigLocation << " already exists. Skipping"; + continue; + } + + QFileInfo fileInfo(newConfigLocation); + QDir().mkpath(fileInfo.absolutePath()); + + const QString oldConfigFile = oldappdatadir + QLatin1Char('/') + configFileName; + if (!oldConfigFile.isEmpty()) { + if (QFile(oldConfigFile).copy(newConfigLocation)) { + qCDebug(DIGIKAM_GENERAL_LOG) << "Config file" << oldConfigFile << "was migrated to" << newConfigLocation; + } + } + } + + // Migrate $KDEHOME/share/apps/kipi/geobookmarks.xml to ./.local/share/digikam/geobookmarks.xml + QString oldGeobookmarksFile = migration.locateLocal("data", QStringLiteral("kipi/geobookmarks.xml")); + const QString newGeobookmarksFile = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + + QStringLiteral("/geobookmarks.xml"); + + if (QFile(newGeobookmarksFile).exists()) { + qCDebug(DIGIKAM_GENERAL_LOG) << newGeobookmarksFile << " already exists. Skipping"; + } else { + QFileInfo fileInfo(newGeobookmarksFile); + QDir().mkpath(fileInfo.absolutePath()); + + if (!oldGeobookmarksFile.isEmpty()) { + if (QFile(oldGeobookmarksFile).copy(newGeobookmarksFile)) { + qCDebug(DIGIKAM_GENERAL_LOG) << "Config file" << oldGeobookmarksFile << "was migrated to" << newGeobookmarksFile; + } + } + } + + // Fix albumroot identifier since digiKam 5 doesn't interpret correctly + // values like volumeid:?path=%2Fhome%2Fantonio%2FPictures and it needs + // to be url-decoded. + DbEngineParameters parameters = DbEngineParameters::parametersFromConfig(KSharedConfig::openConfig()); + QSqlDatabase databaseHandler = QSqlDatabase::addDatabase(parameters.databaseType, QStringLiteral("digikam4migration")); + + databaseHandler.setHostName(parameters.hostName); + databaseHandler.setPort(parameters.port); + databaseHandler.setDatabaseName(parameters.databaseNameCore); + databaseHandler.setUserName(parameters.userName); + databaseHandler.setPassword(parameters.password); + databaseHandler.setConnectOptions(parameters.connectOptions); + if (!databaseHandler.open()) { + qCDebug(DIGIKAM_GENERAL_LOG) << "Cannot open database:" << databaseHandler.lastError().text(); + return; + } + + QSqlQuery query(QStringLiteral("SELECT id,identifier FROM albumroots"), databaseHandler); + while (query.next()) { + int id = query.value(0).toInt(); + QString identifier = query.value(1).toString(); + + if (identifier.startsWith(QStringLiteral("volumeid:?path=%2F"))) + { + QUrl url(identifier); + url.setQuery(url.query(QUrl::FullyDecoded), QUrl::DecodedMode); + qCDebug(DIGIKAM_GENERAL_LOG) << "Updating albumroot " << id << " from " << identifier << " to " << url.toString(); + QSqlQuery uquery(QStringLiteral("UPDATE albumroots SET identifier=? WHERE id=?"), databaseHandler); + uquery.bindValue(0, url.toString()); + uquery.bindValue(1, id); + uquery.exec(); + } + } + databaseHandler.close(); + + qCDebug(DIGIKAM_GENERAL_LOG) << "Migration finished"; +} + +bool MigrateFromDigikam4Page::isMigrationChecked() const +{ + return m_migrate->isChecked(); +} + +void MigrateFromDigikam4Page::migrationToggled(bool b) +{ + setFinalPage(b); +} + +int MigrateFromDigikam4Page::nextId() const +{ + if (m_migrate->isChecked()) + return -1; + else + return QWizardPage::nextId(); +} + +} // namespace Digikam Index: digikam-5.2.0/core/utilities/assistants/firstrun/migratefromdigikam4page.h =================================================================== --- /dev/null +++ digikam-5.2.0/core/utilities/assistants/firstrun/migratefromdigikam4page.h @@ -0,0 +1,63 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date : 2016-09-29 + * Description : migration page from digikam4 + * + * Copyright (C) 2016 by Antonio LarrosaThis assistant will help you to configure first " "run settings to be able to use digiKam quickly.
" +#if defined Q_OS_WIN || defined Q_OS_OSX "You can ignore the following if you use digiKam " "for the first time:
" @@ -75,10 +76,11 @@ WelcomePage::WelcomePage(FirstRunDlg* co #elif defined Q_OS_OSX // MacOS settings place. QLatin1String("~/Library/Preferences/"), QLatin1String("~/Library/Preferences/KDE/share/config/") -#else - // Linux settings place. - QLatin1String("~/.config/"), QLatin1String("~/.kde4/share/config") -#endif +#endif +#else // defined Q_OS_LINUX + "", + QLatin1String(digikam_version_short) +#endif )); setPageWidget(vbox); Index: digikam-5.2.0/po/es/digikam.po =================================================================== --- digikam-5.2.0.orig/po/es/digikam.po +++ digikam-5.2.0/po/es/digikam.po @@ -16820,6 +16820,41 @@ msgstr "" "podrá alterar las operaciones de gestión de las fotografías haciéndolas más " "lentas." +#: utilities/assistants/firstrun/migratefromdigikam4page.cpp:58 +msgid "Migration from digiKam 4" +msgstr "Migración desde Digikam4" + +#: utilities/assistants/firstrun/migratefromdigikam4page.cpp:66 +msgid "" +"You can choose here if you want to use the configuration and albums " +"from digiKam 4 in digiKam 5 . Please note the following warnings:" +"p>
Migration is done at your own risk. Digikam developers don't " +"recommend it and don't support it. On the other hand, Creating a new " +"configuration might result in loss of tags and other metadata that wasn't " +"embedded inside the pictures and was only available in digiKam 4's database." +"
In either case you're recommended to backup the configuration files " +"and databases before proceeding.
Puede elegir aquí si quieres usar la configuración y albums de " +"digiKam 4 en digiKam 5. Por favor, observe las siguientes advertencias:" +"p>
La migration se hace bajo su propia responsabilidad. Los " +"desarrolladores de Digikam no la recomiendan y no dan soporte. Por otra " +"parte, crear una configuración nueva puede resultar en pérdida de etiquetas " +"y otros metadatos que no estaban almacenados dentro de las imágenes y sólo " +"estaban en la base de datos de digiKam 4.
En cualquier caso, se " +"recomienda que hagas un backup de los ficheros de configuración y bases de " +"datos antes de continuar.