diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ find_package(KF5Archive REQUIRED) find_package(KF5XmlGui 5.1 REQUIRED) find_package(KF5Crash 5.15 REQUIRED) +find_package(KF5CoreAddons REQUIRED) set(CMAKE_MODULE_PATH ${kig_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH}) @@ -56,6 +57,12 @@ add_definitions(-DKIG_ENABLE_PYTHON_SCRIPTING) endif(BoostPython_FOUND) +set_package_properties( + KF5CoreAddons PROPERTIES + TYPE OPTIONAL + PURPOSE "If linked to KF5CoreAddOns, Kig can automatically migrate files from installations with KDE4Libs" +) + set_package_properties( BoostPython PROPERTIES DESCRIPTION "Python scripting support in Boost" diff --git a/kig/CMakeLists.txt b/kig/CMakeLists.txt --- a/kig/CMakeLists.txt +++ b/kig/CMakeLists.txt @@ -1,6 +1,9 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ) +if(KF5CoreAddons_FOUND) + add_definitions(-DKIG_MIGRATION) +endif(KF5CoreAddons_FOUND) # kig diff --git a/kig/main.cpp b/kig/main.cpp --- a/kig/main.cpp +++ b/kig/main.cpp @@ -27,6 +27,14 @@ #include #include #include +#ifdef KIG_MIGRATION +#include +#include +#include + +#include +#include +#endif // KIG_MIGRATION #include "aboutdata.h" #include @@ -47,6 +55,14 @@ int main(int argc, char **argv) { +#ifdef KIG_MIGRATION + Kdelibs4ConfigMigrator migrator( QStringLiteral( "kig" ) ); + Kdelibs4Migration datamigrator; + + migrator.setConfigFiles( QStringList() << QStringLiteral( "test.txt" ) ); + migrator.migrate(); + +#endif // KIG_MIGRATION QApplication app( argc, argv ); KLocalizedString::setApplicationDomain("kig"); KAboutData about = kigAboutData( "kig", I18N_NOOP( "Kig" ) ); @@ -60,6 +76,24 @@ QCoreApplication::setOrganizationDomain( i18n( "kde.org" ) ); KAboutData::setApplicationData( about ); +#ifdef KIG_MIGRATION // This needs the about AboutData to be set up + QString file = datamigrator.locateLocal( "data", "kig/kig-types/macros.kigt" ); + + if ( !file.isEmpty() ) + { + QFile macros( file ); + const QDir writeableDataLocation ( QStandardPaths::writableLocation( QStandardPaths::DataLocation ) ); + const QDir typesDir( writeableDataLocation.absoluteFilePath( "kig-types" ) ); + + if ( !typesDir.exists() ) + { + writeableDataLocation.mkpath( "kig-types" ); + } + + + macros.copy( typesDir.absoluteFilePath( "macros.kigt" ) ); + } +#endif // KIG_MIGRATION about.setupCommandLine( &parser ); parser.addHelpOption(); parser.addOption( convertToNativeOption );