Commit 4b30935a authored by David Narváez's avatar David Narváez

Optional Migration Code for KF5

This is long overdue and the fact that it has not caused more trouble in
bugzilla means it is probably a non-issue, but just to be complete,
here's code that migrates the old configuration to the new directories.

BUG: 353729

Test Plan:
Delete the kigrc config file, and the kig/kig-types/macros.kigt files if you have them.
Run the application.
Run it with existing kig/kig-types/macros.kigt too to make sure it does not delete the files.

Reviewers: #kde_edu, apol

Reviewed By: apol

Subscribers: cfeck, apol

Tags: #kde_edu

Differential Revision:
parent a651dd9f
......@@ -16,6 +16,7 @@ find_package(KF5ConfigWidgets REQUIRED)
find_package(KF5Archive REQUIRED)
find_package(KF5XmlGui 5.1 REQUIRED)
find_package(KF5Crash 5.15 REQUIRED)
find_package(KF5CoreAddons REQUIRED)
......@@ -23,10 +23,15 @@
#include <QApplication>
#include <QCommandLineParser>
#include <QDebug>
#include <QFile>
#include <QDir>
#include <QStandardPaths>
#include <KPluginLoader>
#include <KAboutData>
#include <KCrash>
#include <Kdelibs4ConfigMigrator>
#include <Kdelibs4Migration>
#include "aboutdata.h"
#include <klocalizedstring.h>
......@@ -45,10 +50,40 @@ static int convertToNative( const QUrl &file, const QByteArray& outfile )
return (*converterfunction)( file, outfile );
int main(int argc, char **argv)
static bool configMigration()
Kdelibs4ConfigMigrator migrator( QStringLiteral( "kig" ) );
migrator.setConfigFiles( QStringList() << QStringLiteral( "test.txt" ) );
return migrator.migrate();
static void dataMigration()
Kdelibs4Migration datamigrator;
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" ) );
int main( int argc, char **argv )
QApplication app( argc, argv );
KLocalizedString::setApplicationDomain( "kig" );
KAboutData about = kigAboutData( "kig", I18N_NOOP( "Kig" ) );
QCommandLineParser parser;
......@@ -60,6 +95,7 @@ int main(int argc, char **argv)
QCoreApplication::setOrganizationDomain( i18n( "" ) );
KAboutData::setApplicationData( about );
dataMigration(); // This needs the about AboutData to be set up
about.setupCommandLine( &parser );
parser.addOption( convertToNativeOption );
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment