Development/Tutorials/KDE4 Porting Guide: Difference between revisions

    From KDE TechBase
    (use templates for file and program)
    (use the module template)
    Line 10: Line 10:


    ==CMake==
    ==CMake==
    Unlike KDE3, KDE4 applications will be build with the help of [[Development/Tutorials/CMake | CMake]]. The easiest way to port your autotools system to CMake is with the help of the {{program|am2cmake} script which can be found in the {{path|cmake/scripts}} directory of the <tt>[http://websvn.kde.org/trunk/KDE/kdesdk/ kdesdk]</tt> module. This will create a series of {{file|CMakeLists.txt}} files alongside your old buildsystem files.
    Unlike KDE3, KDE4 applications will be build with the help of [[Development/Tutorials/CMake | CMake]]. The easiest way to port your autotools system to CMake is with the help of the {{program|am2cmake} script which can be found in the {{path|cmake/scripts}} directory of the [http://websvn.kde.org/trunk/KDE/kdesdk/ kdesdk] module. This will create a series of {{file|CMakeLists.txt}} files alongside your old buildsystem files.


    ==KDE4 API==
    ==KDE4 API==
    A portion porting your code to KDE4 is simply renaming of class names and header files. Since it would be rather tedious to change all these by hand, there is a handy script in the {{path|scripts/qt4}} directory of <tt>kdesdk</tt> called {{program|adapt-to-kde4-api.pl}}. This will scan all your files and create a {{program|diff}} output which can then be used to patch your code.
    A portion porting your code to KDE4 is simply renaming of class names and header files. Since it would be rather tedious to change all these by hand, there is a handy script in the {{path|scripts/qt4}} directory of {{module|kdesdk}} called {{program|adapt-to-kde4-api.pl}}. This will scan all your files and create a {{program|diff}} output which can then be used to patch your code.


    Once that simple code substitution has been done, you will still have to go through your code to port to, for example, the new <tt>KAction</tt> API. Documentation about all API changes is kept in the [http://websvn.kde.org/*checkout*/trunk/KDE/kdelibs/KDE4PORTING.html KDE4PORTING.html] file in the <tt>kdelibs</tt> module.
    Once that simple code substitution has been done, you will still have to go through your code to port to, for example, the new <tt>KAction</tt> API. Documentation about all API changes is kept in the [http://websvn.kde.org/*checkout*/trunk/KDE/kdelibs/KDE4PORTING.html KDE4PORTING.html] file in the {{module|kdelibs}} module.


    ==Qt Designer UI Files==
    ==Qt Designer UI Files==
    Line 32: Line 32:
    </code>
    </code>
    {{Warning|Beware, the conversion process loses any custom slots, table columns, etc.  So, you may need to put some stuff back by hand.}}
    {{Warning|Beware, the conversion process loses any custom slots, table columns, etc.  So, you may need to put some stuff back by hand.}}
    You should also run the {{program|fixuifiles}} program from the <tt>kdesdk</tt> package:
    You should also run the {{program|fixuifiles}} program from the {{module|kdesdk}} module:
    <code bash>
    <code bash>
    % $SVN/trunk/KDE/kdesdk/scripts/fixuifiles
    % $SVN/trunk/KDE/kdesdk/scripts/fixuifiles
    Line 40: Line 40:
    Instead of DCOP in KDE3, KDE4 now uses D-Bus for its interprocess communication.
    Instead of DCOP in KDE3, KDE4 now uses D-Bus for its interprocess communication.


    A guide on how to port the DCOP parts to D-Bus is available in the [http://websvn.kde.org/*checkout*/trunk/KDE/kdelibs/PORTING-TO-DBUS.txt PORTING-TO-DBUS.txt] file in the <tt>kdelibs</tt> module.
    A guide on how to port the DCOP parts to D-Bus is available in the [http://websvn.kde.org/*checkout*/trunk/KDE/kdelibs/PORTING-TO-DBUS.txt PORTING-TO-DBUS.txt] file in the {{module|kdelibs}} module.


    Several D-Bus tutorials are located in the [[Development/Tutorials#D-Bus|Tutorials]] section.
    Several D-Bus tutorials are located in the [[Development/Tutorials#D-Bus|Tutorials]] section.


    [[Category:KDE4]]
    [[Category:KDE4]]

    Revision as of 15:35, 24 February 2007

    Introduction

    A tutorial intended to help developers port their Qt3/KDE3 based applications to Qt4/KDE4. Porting a KDE3 based application needn't be a difficult process. Already, there are many scripts and sources of documentation which can help.

    Conventions

    For the instructions in this tutorial we use the following shorthand:

    • program refers to an executable program
    • path refers to a path
    • Template:File refers to a file
    • $SVN is the fullpath to the location of your KDE subversion checkout

    CMake

    Unlike KDE3, KDE4 applications will be build with the help of CMake. The easiest way to port your autotools system to CMake is with the help of the {{program|am2cmake} script which can be found in the cmake/scripts directory of the kdesdk module. This will create a series of Template:File files alongside your old buildsystem files.

    KDE4 API

    A portion porting your code to KDE4 is simply renaming of class names and header files. Since it would be rather tedious to change all these by hand, there is a handy script in the scripts/qt4 directory of kdesdk called adapt-to-kde4-api.pl. This will scan all your files and create a diff output which can then be used to patch your code.

    Once that simple code substitution has been done, you will still have to go through your code to port to, for example, the new KAction API. Documentation about all API changes is kept in the KDE4PORTING.html file in the kdelibs module.

    Qt Designer UI Files

    Qt designer ".ui" files created using Qt3 must be converted to the new Qt4 format. This can be done using the uic3 program available from your Qt4 installation.

    % $SVN/trunk/qt-copy/bin/uic3 -convert file.ui > foo.ui % mv foo.ui file.ui

    Or, if you prefer a graphical tool, you can use Qt4's designer program

    % $SVN/trunk/qt-copy/bin/designer file.ui (you can save file.ui over top itself, or save to a new file)

    Warning
    Beware, the conversion process loses any custom slots, table columns, etc. So, you may need to put some stuff back by hand.

    You should also run the fixuifiles program from the kdesdk module: % $SVN/trunk/KDE/kdesdk/scripts/fixuifiles

    D-Bus

    Instead of DCOP in KDE3, KDE4 now uses D-Bus for its interprocess communication.

    A guide on how to port the DCOP parts to D-Bus is available in the PORTING-TO-DBUS.txt file in the kdelibs module.

    Several D-Bus tutorials are located in the Tutorials section.