Nova Flow OS
KDE Developer Platform
KDE Developer Platform
  • KDE Developer Platform
    • Getting started
      • Building KDE software
        • KDE software
        • Where to find the development team
        • Learning more
        • Choose what to work on
        • Source code cross-referencing
        • Installing build dependencies
        • Set up a development environment
        • Building KDE software with kdesrc-build
        • Basic troubleshooting
        • Tips and tricks
        • IDE Configuration
          • Setting up an IDE for KDE development
          • Visual Studio Code
          • Qt Creator
          • Kate
          • KDevelop
          • CLion
          • Sublime Text
        • Building KDE software manually
        • Building KDE software with distrobox and podman
      • Kirigami
        • KDE is ours
        • Setting up and getting started
        • Explaining pages
        • Layouts, ListViews, and Cards
        • Adding actions
        • Adding a dialog
        • Using separate files
        • Next steps
        • Colors and themes in Kirigami
        • Typography
        • Actions based components
        • Page rows and page stacks
        • Scrollable pages and list views
        • Cards
        • Drawers
        • Chips
        • Dialog types
        • Controls and interactive elements
        • Form layouts
        • Inline messages
        • Action toolbars
        • Progress bars and indicators
        • List views
        • Understanding CMakeLists
        • Figuring out main.cpp
        • Connect logic to your QML user interface
        • Connect models to your QML user interface
        • About page
        • Introduction to Kirigami Addons
        • FormCard About pages
        • Form delegates in your settings pages
      • KXmlGui
        • Getting started with KXmlGui
        • Hello World!
        • Creating the main window
        • Using actions
        • Saving and loading
        • Command line interface
      • Python with Kirigami
        • Apps with QML and Python
        • Your first Python + Kirigami application
        • Creating a Python package
        • Creating a Flatpak
      • Common programming mistakes
      • Adding a new KDE project
    • Features
      • Icons
      • Configuration
        • The KConfig Framework
        • Introduction to KConfig
        • Using KConfig XT
        • KDE Frameworks 6 porting guide
        • Settings module (KCM) development
        • KConfigDialog
      • D-Bus
        • What is D-Bus practically useful for?
        • Introduction to D-Bus
        • Accessing D-Bus interfaces
        • Intermediate D-Bus
        • Creating D-Bus interfaces
        • Using custom types with D-Bus
        • D-Bus autostart services
      • Create your own mouse cursor theme
      • Session management
      • Archives
      • Desktop file
      • KAuth
        • Privilege Escalation
        • Using actions in your applications
      • KIdleTime
      • Akonadi: personal information management
        • Debugging Akonadi Resources
        • Using Akonadi in applications
      • Concurrent programming
      • Solid
      • Sonnet
    • Plasma themes and plugins
      • Getting started
      • Plasma Widget tutorial
        • How to create a plasmoid
        • Setup
        • Porting Plasmoids to KF6
        • Testing
        • QML
        • Plasma's QML API
        • Widget Properties
        • Configuration
        • Translations / i18n
        • Examples
        • C++ API
      • KWin Effects
      • Plasma Desktop scripting
        • Javascript Interaction With Plasma Shells
        • Templates
        • Examples
        • API documentation
        • Configuration keys
      • Plasma Style tutorial
        • Creating a Plasma Style quickstart
        • Understanding Plasma Styles
        • SVG elements and Inkscape
        • Background SVG format
        • System and accent colors
        • Theme elements reference
        • Porting themes to Plasma 5
        • Porting themes to Plasma 6
      • Aurorae window decorations
      • KWin scripting tutorial
        • Quick start
        • KWin scripting API
      • Wallpapers
      • Plasma comic
        • Tutorial
        • Testing and debugging
        • Examples
      • Create a custom Window Switcher
      • KRunner C++ Plugin
        • Basic Anatomy of a Runner
        • KRunner metadata format
    • Applications
      • Creating sensor faces
      • Dolphin
        • Creating Dolphin service menus
      • Kate
        • Kate plugin tutorial
      • KMines
        • Making a KMines theme
      • Writing tests
        • Appium automation testing
    • Packaging
      • Android
        • KDE on Android
        • Building applications for Android
        • Packaging and publishing applications for Android
        • Publishing on Google Play
          • Introduction
          • Packaging your app
          • Adding your app to Google Play
          • Publishing your app
          • Releasing new versions of old apps
        • Porting applications to Android
          • Basic porting
          • Making applications run well on Android
          • Metadata
      • Windows
        • Packaging and publishing applications for Windows
        • Publish your app in the Microsoft Store
          • Packaging your app for the Microsoft Store
          • Submitting your app to the Microsoft Store
      • Plasma Mobile
        • KDE on mobile devices
        • Porting a new device to Plasma Mobile
        • KDE Telephony stack
          • General Overview
          • Kernel layer
          • System daemons
            • General overview
            • Developing Telephony functionality
            • ModemManager Telephony functions
          • Session daemons
          • QML declarative plugin layer
          • KDE application layer
        • Execute applications
      • Distributing KDE software as Flatpak
        • Your first Flatpak
        • Extending your package
        • Nightly Flatpaks and Flathub
        • Testing your Flatpak
    • System administration
      • Shell scripting with KDE dialogs
      • Kiosk: Simple configuration management for large deployment
        • Abstract
        • Introduction to Kiosk
        • Kiosk keys
    • Contribute to the documentation
    • About
      • Readme
      • License
        • Creative Commons Attribution-ShareAlike 4.0 International
        • GNU General Public License 3.0 or later
Powered by GitBook
On this page
  1. KDE Developer Platform
  2. Features
  3. Configuration

KDE Frameworks 6 porting guide

Porting guide for KDE Config Modules to Qt6/KF6

KDE Config Modules ("KCMs") underwent significant changes during the KF6 transition. This is a guide on how to port your KCMs to KF6! Note that KF6 is still a work in progress and will be subject to breaking changes. This guide will be updated accordingly, but can be expected to change before the initial release of KF6.

Build system and class name changes

In KF5, the code for QML KCMs was in KDeclarative, the code for QWidgets KCMs was in KConfigWidgets. In KF6, all relevant classes are in KCMUtils. The KCModule class is contained in the KF6::KCMUtils CMake library, and the ConfigModule/ManagedConfigModule classes for QML KCMs are in the KF6::KCMUtilsQuick library. KCModuleData is now part of KF6::KCMUtilsCore, but both the QWidgets and QML libraries publicly link against it.

Since the QML classes are no longer in KDeclarative, the KQuickAddons namespace is no longer suitable. Because of this, KDeclarative::ConfigModule has been renamed to KQuickConfigModule and KQuickAddons::ManagedConfigModule is now KQuickManagedConfigModule.

Class-hierarchy changes

In KF5, the APIs of the QML and QWidgets KCMs were very different. This causes mental burden when working with different UI technologies. In KF6, we have the KAbstractConfigModule class, which contains all the APIs that are not specific to a specific UI technology. Since the QML KCMs are more widely used in KDE nowadays and the API is cleaner, most API was copied from those classes.

Changes to ConfigModule and ManagedConfigModule

The QQmlComponent::Status getter was removed for lack of usage. showPassiveNotification/passiveNotificationRequested were also removed. The attached quickHelp property was also removed because it is not used when displaying KCMs. Setting a rootOnlyMessage was also removed due to it being unused.

We no longer use KPackage to install QML files and instead bundle them as QRC. This way all needed files are embedded in the plugin. This simplifies testing and installation. All QML files should be put in a folder called "ui". Using kcmutils_add_qml_kcm(my_kcm) a plugin target will be created and the files in the "ui" folder will be bundled. This macro also takes care of installing the plugin in the "plasma/kcms/systemsettings" namespace. You can override it using the INSTALL_NAMESPACE parameter. You can also specify source files using the optional SOURCES parameter. All arguments work just like the kcoreaddons_add_plugin macro. This macro also takes care of generating a desktop file for the KCM. This is for example needed if you want to pin a KCM to the taskmanager. If it isn't needed, it can be turned off using the DISABLE_DESKTOP_FILE_GENERATION option.

All parameters are used in the following example. But in most cases, providing only the first parameter (target name) is enough.

kcmutils_add_qml_kcm(my_kcm DISABLE_DESKTOP_FILE_GENERATION SOURCES kcm.coo INSTALL_NAMESPACE plasma/kcms/kinfocenter)
target_link_libraries(my_kcm ...)

Changes to QML modules

The org.kde.kcm QML module from KDeclarative has been moved to KCMUtils under the name org.kde.kcmutils. All versions of registered files are 1.0. For consistency, KPluginSelector and KPluginDelegate were renamed to PluginSelector and PluginDelegate. It is recommended to use a "namespaced" imports, e.g. import org.kde.kcmutils as KCMUtils.

The KCMShell class from org.kde.kquickcontrolsaddons has been moved to the mentioned KCMUtils QML module and is now called KCMLauncher. The open, openSystemSettings and openInfoCenter methods are identical. For checking whether a KCM is allowed to be displayed, use KAuthorized from the org.kde.config QML module.

import org.kde.config
if (KAuthorized.authorizeControlModule("kcm_clock")) {
    // Launch the KCM or do other logic
}
const allowedKCMs = KAuthorized.authorizeControlModules(["kcm_clock", "kcm_icons"])
// Do something with the allowed KCMs

Changes to KCModule class

The setAuthAction and authAction methods where removed, because you should take care of creating the KAuth::Action manually. In the relevant methods you should execute the action. To signal that the KCM requires administrative privileges when saving changes, use the setNeedsAuthorization method or set the setAuthActionName. The latter value can be retrieved using the authActionName getter, which internally calls setNeedsAuthorization.

Instead of Q_SIGNAL void changed(bool hasChanged), use setNeedsSave(bool needsSave). For connections, use void markAsChanged(). Instead of Q_SIGNAL void defaulted(bool state), use void setRepresentsDefault(bool defaults)

Compatibility API in KConfigWidgets 5.105

This release of KDE Frameworks introduced compatibility compatibility logic to ease the transition. This includes the methods QWidget *widget() and void setNeedsSave(bool needsSave), so you can port to them while still using KF5.. Also, the KCModule(QObject *parent, const KPluginMetaData & data = {}, const QVariantList &args = QVariantList()) constructor was added.

Changes to other KCMUtils API

The KCModuleProxy class has been removed. Instead, use KCModuleLoader to get a KCModule instance and embed the result of KCModule::widget in it. In case your app already has a QQmlEngine instance or needs one in other places, explicitly pass in the engine in for loading QML based KCMs. For loading KQuickConfigModule/KQuickManagedConfigModule instances, use KQuickModuleLoader. Use the QQmlEngine parameter as explained for the KCModuleLoader.

PreviousUsing KConfig XTNextSettings module (KCM) development

Last updated 8 months ago

Due to the class hierarchy changes, KCModule is no longer a subclass of QWidget. To get access to a KCModule's QWidget, call the widget() method. This should be used when you need the parent widget. Due to the class no longer being a QWidget subclass, passes in a QObject * instead of QWidget* for the parent. We internally cast this to a QWidget, but for the constructor it should be changed to QObject.

API using was removed, because metadata should be set using instead. In the constructor, take the const KPluginMetaData &data argument and pass it to the KCModule baseclass. For plugins embedded in e.g. a , this can be omitted.

KPluginFactory
KAboutData
KPluginMetaData
KPluginWidget