Porting to Qt5

Boudewijn Rempt boud at valdyas.org
Mon Apr 8 11:03:30 BST 2013


Hi,

No doubt you've seen my qt5 porting branch. I was surprised at how far I 
came, even though I was tempted to bang my head against my desk a couple 
of times (especially over the Q_PRIVATE_SLOT thing -- while all I had to 
do was change the moc includes in the cpp files from #include <bla.moc> to 
#include <moc_bla.cpp>...) But it seems very doable indeed.

Here's my notes on how I want to proceed, after I get back from the Libre 
Graphics Meeting:

Past week, I've been looking into the most promising approach to port 
Calligra to Qt5, and the effort needed to complete the task. Short 
summary: it should be very doable.

Approach

The goal is to create a base Qt5-only port of Calligra (minus Kexi and 
Plan for now) that can then optionally use KF5 libraries (like i18n). My 
initial test used Qt 5.0.1, but I want to switch to Qt 5.1 as soon as 
possible, so we can port to QSaveFile and other classes David Faure added 
to Qt for 5.1

Steps

* CMake: use extra-cmake-modules and a copy of relevant CMake modules for 
KF5 plus some compatibility definitions to make it as easy as possible to 
build Calligra with a minimum of changes. This is mostly done.

* kdelibs: add a shim "kofake" library that has enough of the KDE headers 
and implementation to build. This mostly is ready, but there is some stuff 
missing and currently libs/flake fails to build because of missing stuff.

After everything builds we need some more steps to do a proper port:

* Replace KPluginLoader with Qt5 plugin loading

** write a script to change all .desktop files to json
** write a script to change all plugins to add the json
** write a script to change all plugins from KDE plugins to Qt plugins
** change KoPluginLoader to build a database of the json of all available 
plugins and support the minimal query set that we need for calligra to 
load the right plugins at the right times

I already have the calligra-kopluginloader-rempt where almost all plugin 
loading is hidden behind the KoPluginLoader class.

* Refactor calligra to no longer use kparts to load documents
** remove kparts and kxmlgui
** introduce the document, view, mainwindow base classes I started on in 
the calligra-kopluginloader-rempt branch.

* Refactor the use of KActions -- we have a problem with losing shortcuts,
and this seems the moment to fix it.

* replace KUrl with QUrl
* replace KMimeType with QMimeType handling
* replace KSaveFile with QSaveFile
* replace KStandardDirs and KComponentData with QStandardPaths
* replace kconfig with qsettings
* replace KSaveFile with QSaveFile
* replace KTemporaryFile with QTemporaryFile
* replace KTempDir with QTemporaryDir
* replace KFileWidget/KFileDialog with QFileDialog (initial patch on 
reviewboard)
* port all tests from qtest_kde.h to QtTest or QtTestWidgets
* KApplication to QApplication
* ....

(all the things recommended in the KF5 porting file -- much of it can be 
done with simple scripts).

* Get rid of kofake completely by either using the Qt equivalent of 
classes (most cases), or add optional dependencies on KF5 tier1 libraries.

* Start hacking on graphics tablet support in Qt5... I guess.



More information about the calligra-devel mailing list