Making KDE apps that theme cross-desktop

I’m developing an app using Kirigami called Bazzite Updater, and it is very important for it to be themed properly across both KDE and Gnome. My solution ended up needing a dbus connection to directly monitor the freedesktop portal’s color-scheme, only used/created when the desktop isn’t KDE, to apply org.kde.breeze BreezeDark or BreezeLight.

This feels like a lot of setup required to ensure the app looks good for non-KDE desktops. Is there something I am missing that makes this easier? I feel like it would make sense for a “KApplication” class to exist that handles all of this in the background, but KirigamiAppDefaults::apply() seems to be the best I can find for simplifying the initial setup.

Hi, Kirigami developer here.

Indeed this is a thing that should be provided by a kde framework, as makes sense for most application to use this for behaving in a good way in Gnome by default. can you point me to your implementation? perhaps there is something that could be upstreamed or anyways gives a better idea on what is needed

My solution is lines 87-107 of main.cpp and the DbusListener class in utils.h, utils.cpp. This applies Breeze properly on Gnome and should work the same on any DE implementing the freedesktop color-scheme portal. I’ve just noticed it currently conflicts with (and mostly overrides) qt6ct, but that should be easily fixed by checking QT_QPA_PLATFORMTHEME.

Before making the DbusListener class I tried using KColorSchemeManager (lines 86-105) and I believe I tried QStyleHints::colorScheme(), but those attempts did not work. I would also like to try supporting the desktop’s accent color through the accent-color portal in the future, which should be very similar to this current solution, but that isn’t a high priority

initely not missing something obvious, but modern Qt 6 and KDE Frameworks 6 have actually streamlined a lot of this! Instead of writing manual D-Bus connections, you can leverage Qt’s built-in QStyleHints::colorScheme (available in Qt 6.5+) or use KColorSchemeManager, which automatically hooks into the system’s appearance settings across different desktops. Also, KQuickStyleManager helps manage styles gracefully on non-Plasma environments without requiring custom D-Bus listeners. Hope this helps clean up the boilerplate!