Programmatic color scheme change in QKdeTheme

Axel Spoerl axel.spoerl at qt.io
Tue Mar 11 09:10:58 GMT 2025


Hi David,
thanks for the insight!
The program would be ideal. However, it depends on KDE libraries. If an application links to KDE anyway, it can simply use the KDE platform theme.
Users of QKdeTheme are e.g. applications that don't link to KDE, because they need to run on Gnome environments as well.
If we wanted to propagate palettes to QKdeTheme, we would have to read them directly from settings without having to link to KDE.
Cheers
Axel
________________________________
From: David Redondo <david at david-redondo.de>
Sent: Tuesday, 11 March 2025 09:39
To: kde-devel at kde.org <kde-devel at kde.org>
Cc: Axel Spoerl <axel.spoerl at qt.io>
Subject: Re: Re: Programmatic color scheme change in QKdeTheme

[You don't often get email from david at david-redondo.de. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Am Montag, 10. März 2025, 19:24 schrieb Axel Spoerl:
> Hi David,
>
> I just did some debugging to find out, how KDE Palettes are promoted to the QKdeTheme.
> The blunt answer is: They don't, and they have never been.
>
> They were probably meant to be promoted at some point, because QKdeTheme implements an array of QPalette pointers (size == NPalettes == 17).
> So for each palette type, a new QPalette could be constructed from a KDE Palette. But that's not happening. The first record of the array is populated with default constructed QPalette, which is a fusion palette.
> All other records are initialized with nullptr and they remain like that throughout the life time of the QGuiApplication.
>
> QKdeTheme just implements font handling. Color wise, QGuiApplications won't blend in with KDE palettes. They just stick with a default fusion palette.
>
> That said: I think there's nothing needed right now. But we may want to pimp up QKdeTheme.
> The patch I mentioned factors it out from qgenericunixthemes.cpp. So enhancing the class will become a little easier.
>

Maybe a reason that it doesn't do that much was that Plasma has its own QPT,
so there was never enough pressure to make it better since in the most cases an
application would not use QKDETheme except if it shipped its own Qt or
something similar.

I've written  very small program that prints the resulting QPalette from color
schemes. The output for BreezeLight and BreezeDark is as follows:

/usr/share/color-schemes/BreezeLight.colors
QPalette(resolve=0x7ffdffffefffff7f,"WindowText:[Active:#ff232629,Disabled:#ffa0a1a3,Inactive:#ff232629],Button:[Active:#fffcfcfc,Disabled:#fff0f0f0,Inactive:#fffcfcfc],Light:[Active:#ffffffff,Disabled:#ffffffff,Inactive:#ffffffff],Midlight:[Active:#fff6f7f7,Disabled:#ffebedee,Inactive:#fff6f7f7],Dark:[Active:#ff888e93,Disabled:#ff82878c,Inactive:#ff888e93],Mid:[Active:#ffc4c8cc,Disabled:#ffbbc0c5,Inactive:#ffc4c8cc],Text:[Active:#ff232629,Disabled:#ffaaabac,Inactive:#ff232629],ButtonText:[Active:#ff232629,Disabled:#ffa8a9aa,Inactive:#ff232629],Base:[Active:#ffffffff,Disabled:#fff3f3f3,Inactive:#ffffffff],Window:[Active:#ffeff0f1,Disabled:#ffe3e5e7,Inactive:#ffeff0f1],Shadow:[Active:#ff474a4c,Disabled:#ff474a4c,Inactive:#ff474a4c],Highlight:[Active:#ff3daee9,Disabled:#ffe3e5e7,Inactive:#ffc2e0f5],HighlightedText:[Active:#ffffffff,Disabled:#ffa0a1a3,Inactive:#ff232629],Link:[Active:#ff2980b9,Disabled:#ffa3cae2,Inactive:#ff2980b9],LinkVisited:[Active:#ff9b59b6,Disabled:#ffd6bae1,Inactive:#ff9b59b6],AlternateBase:[Active:#fff7f7f7,Disabled:#ffebebeb,Inactive:#fff7f7f7],ToolTipBase:[Active:#fff7f7f7,Disabled:#fff7f7f7,Inactive:#fff7f7f7],ToolTipText:[Active:#ff232629,Disabled:#ff232629,Inactive:#ff232629],PlaceholderText:[Active:#ff707d8a,Disabled:#ffc2c8ce,Inactive:#ff707d8a],Accent:[Active:#ff3daee9,Disabled:#ffe3e5e7,Inactive:#ffc2e0f5]")

/usr/share/color-schemes/BreezeDark.colors
QPalette(resolve=0x7ffdffffefffff7f,"WindowText:[Active:#fffcfcfc,Disabled:#ff686a6c,Inactive:#fffcfcfc],Button:[Active:#ff292c30,Disabled:#ff272a2e,Inactive:#ff292c30],Light:[Active:#ff393e43,Disabled:#ff383d42,Inactive:#ff393e43],Midlight:[Active:#ff2e3337,Disabled:#ff2d3136,Inactive:#ff2e3337],Dark:[Active:#ff131516,Disabled:#ff121415,Inactive:#ff131516],Mid:[Active:#ff1c1f21,Disabled:#ff1b1d20,Inactive:#ff1c1f21],Text:[Active:#fffcfcfc,Disabled:#ff606263,Inactive:#fffcfcfc],ButtonText:[Active:#fffcfcfc,Disabled:#ff6d6f72,Inactive:#fffcfcfc],Base:[Active:#ff141618,Disabled:#ff131517,Inactive:#ff141618],Window:[Active:#ff202326,Disabled:#ff1f2124,Inactive:#ff202326],Shadow:[Active:#ff0e0f10,Disabled:#ff0d0e0f,Inactive:#ff0e0f10],Highlight:[Active:#ff3daee9,Disabled:#ff1f2124,Inactive:#ff1b4155],HighlightedText:[Active:#fffcfcfc,Disabled:#ff686a6c,Inactive:#fffcfcfc],Link:[Active:#ff1d99f3,Disabled:#ff164160,Inactive:#ff1d99f3],LinkVisited:[Active:#ff9b59b6,Disabled:#ff402b4c,Inactive:#ff9b59b6],AlternateBase:[Active:#ff1d1f22,Disabled:#ff1c1e20,Inactive:#ff1d1f22],ToolTipBase:[Active:#ff292c30,Disabled:#ff292c30,Inactive:#ff292c30],ToolTipText:[Active:#fffcfcfc,Disabled:#fffcfcfc,Inactive:#fffcfcfc],PlaceholderText:[Active:#ffa1a9b1,Disabled:#ff42464a,Inactive:#ffa1a9b1],Accent:[Active:#ff3daee9,Disabled:#ff1f2124,Inactive:#ff1b4155]")

The code that turns those color schemes into QPalettes is here: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Finvent.kde.org%2Fframeworks%2Fkcolorscheme%2F-%2Fblob%2Fmaster%2Fsrc%2Fkcolorscheme.cpp%23L580&data=05%7C02%7Caxel.spoerl%40qt.io%7C1fde212a5ffc42b896ec08dd607830bf%7C20d0b167794d448a9d01aaeccc1124ac%7C0%7C0%7C638772791535030807%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=7QRCRNTOir7zNA0SxXNOx937hndZeT0dC8Dhu3AMS%2B4%3D&reserved=0<https://invent.kde.org/frameworks/kcolorscheme/-/blob/master/src/kcolorscheme.cpp#L580>

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-devel/attachments/20250311/f496b1e1/attachment-0001.htm>


More information about the kde-devel mailing list