Porting Kig to Qt/KDE 6

Hello everyone. :slight_smile:

I have noticed nobody seems to be working on porting Kig towards KDE 6, so I am trying to achieve it myself, with little knowledge about how the framework works.

I am encountering a problem I don’t know how to solve:

This line creates the following error:

In file included from /usr/include/KF6/KCoreAddons/KPluginFactory:1,
                 from /home/rubis/kig/kig/kig_part.cpp:52:
/usr/include/KF6/KCoreAddons/kpluginfactory.h: In instantiation of ‘static QObject* KPluginFactory::createInstance(QWidget*, QObject*, const KPluginMetaData&, const QVariantList&) [with impl = KigPart; ParentType = QObject; QVariantList = QList<QVariant>]’:
/usr/include/KF6/KCoreAddons/kpluginfactory.h:495:20:   required from ‘QObject* (* KPluginFactory::InheritanceChecker<impl>::createInstanceFunction(...))(QWidget*, QObject*, const KPluginMetaData&, const QVariantList&) [with impl = KigPart; KPluginFactory::CreateInstanceWithMetaDataFunction = QObject* (*)(QWidget*, QObject*, const KPluginMetaData&, const QList<QVariant>&)]’
  495 |             return &createInstance<impl, QObject>;
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/KF6/KCoreAddons/kpluginfactory.h:524:109:   required from ‘void KPluginFactory::registerPlugin() [with T = KigPart; typename std::enable_if<InheritanceChecker<impl>::enabled, int>::type <anonymous> = 0]’
  524 | CreateInstanceWithMetaDataFunction instanceFunction = InheritanceChecker<T>().createInstanceFunction(static_cast<T *>(nullptr));
      |                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~

/home/rubis/kig/kig/kig_part.cpp:83:1:   required from here
   83 | K_PLUGIN_CLASS_WITH_JSON(KigPart, "kig_part.json")
      | ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/KF6/KCoreAddons/kpluginfactory.h:593:29: error: invalid conversion from ‘QObject*’ to ‘QWidget*’ [-fpermissive]
  593 |             return new impl(p);
      |                             ^
      |                             |
      |                             QObject*
/home/rubis/kig/kig/kig_part.cpp:168:27: note:   initializing argument 1 of ‘KigPart::KigPart(QWidget*, QObject*, const QVariantList&)’
  168 | KigPart::KigPart(QWidget *parentWidget, QObject *parent, const QVariantList &)
      |                  ~~~~~~~~~^~~~~~~~~~~~
make[2]: *** [CMakeFiles/kigpart.dir/build.make:1651: CMakeFiles/kigpart.dir/kig/kig_part.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1187: CMakeFiles/kigpart.dir/all] Error 2

For what I understand, the macro K_PLUGIN_CLASS_WITH_JSON is used here incorrectly and doesn’t work with KF6…

Would you like to help me?

Thank you very much in advance!

1 Like

Hi,

You need to update the signature of KigPart constructor. src/kmail_part.h ¡ master ¡ PIM / KMail ¡ GitLab

Basically add const KPluginMetaData &data` as third argument

2 Likes

Thank you @carl !
That was it. :slight_smile:

Should I mark the thread as solved, or is it preferable I wait before finishing the port, in case I get stuck on another thing?

Hello, I finished a draft of the port of Kig to Qt6.

Everything seem to work; the only feature I deemed not worth porting is the “Geogebra” file importer, because it relied on QXmlPatterns, which was removed on Qt6.

When you have time, please don’t hesitate to look into my merge request, and to give me feedbacks. :slight_smile:

I couldn’t figure out what’s the best way to make BUILD_WITH_QT6 defaults to ON, and I don’t know how to update the CI pipeline…

For the CI, you can look at other projects, for instance .gitlab-ci.yml ¡ master ¡ Education / GCompris ¡ GitLab For Linux and FreeBSD CI, add -qt6 (linux.yml becomes linux-qt6.yml) Also adjust the dependencies in .kde-ci.yml, change @stable to @stable-kf6.

1 Like

Alright, I’ve updated the CI accordingly.
The Linux job is successful, but the FreeBSD and Windows one aren’t. Is there some leeway?

Great work, thanks! :slight_smile:

1 Like

I’ve made progress, now all the build jobs pass. :slight_smile:

Now, it’s the “flatpak” job which fails for an odd reason (KParts not found?):

You missed my comments on the MR

Ah, indeed, I didn’t get the notification.

I applied the simple suggestions without problems, it’s for the KLazyLocalizedString I’m a bit more hesitant, because I don’t understand it, and the previous code used a lot of C-String, which I need to refactor.

Could you explain me what’s the use for KLazyLocalizedString? How is it different from a KLocalizedString or even QString?

Okay, I get it. But since Kig’s translation is supposed to be “finished”, I should use i18n() directly, no?

gettext are not getting extracted by the string extractors, so it won’t be translated

The codebase is indeed a bit old school with way too many char * strings :confused: but I managed to push a commit to your branch to use KLazyLocalizedString and fix some of these issues

1 Like

Thanks, I will resume the work tomorrow. :slight_smile:

But still, the translation of Kig for my language is finished. So why not refactor directly to QString instead of KLazyLocalizedString?

For those reading this later, the use of KLazyLocalizedString was further discussed in the MR

1 Like

Indeed. :slight_smile:

Now that the porting has been merged, I can safely mark the thread as solved.

Thank you very much to all of you, for your precious help and support.

2 Likes

Trying a build on Haiku with kde-builder failed, missing Qt6Core targets or something?

# kde-builder running: 'cmake' '-B' '.' '-S' '/Opslag/KDE/kde/src/kig' '-G' 'Ninja' '-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON' '-DCMAKE_BUILD_TYPE=RelWithDebInfo' '-DECM_DIR=/Opslag/KDE/kde/usr/share/ECM/cmake' '-DBINARY_ICONS_RESOURCE=ON' '-DDocBookXSL_DIR=/system/data/xml/docbook/xsl-stylesheets-1.79.2' '-DDocBookXML4_DTD_DIR=/boot/system/data/xml/docbook/xml-dtd-4.5' '-DCMAKE_AUTOGEN_PARALLEL=1' '-DHAVE_X11=OFF' '-DWITH_X11=OFF' '-DWITHOUT_X11=ON' '-DCMAKE_CXX_FLAGS:STRING=-pipe' '-DCMAKE_INSTALL_PREFIX=/Opslag/KDE/kde/usr'
# from directory:  /Opslag/KDE/kde/build/kig
# with environment:  /Opslag/KDE/kde/build/kig/kde-builder.env
-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is GNU 13.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Installing in /Opslag/KDE/kde/usr. Run /Opslag/KDE/kde/build/kig/prefix.sh to set the environment for kig.
-- Looking for __GLIBC__
-- Looking for __GLIBC__ - not found
-- Performing Test _OFFT_IS_64BIT
-- Performing Test _OFFT_IS_64BIT - Success
-- Performing Test HAVE_DATE_TIME
-- Performing Test HAVE_DATE_TIME - Success
-- Could not set up the appstream test. appstreamcli is missing.
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE
CMake Error at /boot/system/lib/cmake/Qt6Qml/Qt6QmlMacros.cmake:3651 (message):
  qt_generate_foreign_qml_types() is only available in Qt 6.
Call Stack (most recent call first):
  /boot/system/lib/cmake/Qt6Qml/Qt6QmlConfig.cmake:200 (include)
  /boot/system/data/cmake/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
  /Opslag/KDE/kde/usr/lib/cmake/KF6Config/KF6ConfigConfig.cmake:42 (find_dependency)
  /boot/system/data/cmake/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
  /Opslag/KDE/kde/usr/lib/cmake/KF6KIO/KF6KIOConfig.cmake:31 (find_dependency)
  /boot/system/data/cmake/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
  /Opslag/KDE/kde/usr/lib/cmake/KF6Parts/KF6PartsConfig.cmake:28 (find_dependency)
  CMakeLists.txt:34 (find_package)


-- Configuring incomplete, errors occurred!

# exit code was: 1

Seems I needed to add -DBUILD_WITH_QT6=ON in kde-builder.yaml to make it build. This shouldn’t be needed anymore?

EDIT: fix on the way and ready for merge, thanks to upstream for quick reply!

1 Like