qt6ct icon indicating copy to clipboard operation
qt6ct copied to clipboard

Configured theme not applying to all applications

Open Scraft161 opened this issue 1 year ago • 49 comments

I've used qt5ct and qt6ct to set custom styles for my qt apps, this works great for most apps and I've been using that. But there's a bit of snag, KDE Connect and Tokodon seem to ignore the configured style.

An image with "Ark" on the left with the style applied and "Tokodon" and "KDE Connect" on the right with their default styling
Ark left has the theme applied; whilst Tokodon and KDE Connect fall back to their default light theme.

I have noticed that Kde Connect and Tokodon are a bit different compared to other Qt apps with a header bar and more mobile-forward and responsive layout; but I don't see why they wouldn't be styled by the Qt theme.

I can however confirm that this shouldn't be a configuration issue as both Qt5 and Qt6 applications work fine and without any major issues.

Scraft161 avatar Jan 24 '24 22:01 Scraft161

little follow-up that provides more information:

I did some digging and apparently both KDE Connect and Tokodon are built with Kirigami, whatever may be the cause is probably in relation to that. What exactly is at play here, I don't know, but it does seem like a good place to start investigating.

In fact, I found this reddit thread talking about the exact issue at hand; but it doesn't seem to point to anything that could be of use.

Scraft161 avatar Jan 25 '24 01:01 Scraft161

KDE uses its own color scheme engine called KColorScheme (ignoring QPalette and Qt theme colors) and Kirigami applications are built on top of QML that qt5ct has no theme control for. The Qt's default for QML applications is the Fusion theme on Linux (just like for widgets) but KDE has its own theme called qqc2-desktop-style that allows applying widgets themes to QML applications. KDE applications are also made for their own icon engine called KIconEngine that applies KDE color schemes to svg icons so when the engine is not used you're likely to see things like black icons on black background.

I have a patch adding KColorScheme/KIconEngine/qqc2-desktop-style support to qt5ct, packages with it are available for NixOS and qt{5,6}ct-kde on AUR.

An important thing is to have a KDE color scheme for your Qt theme and apply it in the patched qt5ct or the result will be screwed as KDE applications use colors from both KDE color schemes and Qt themes. It enumerates such color schemes but doesn't show a difference in preview (as I'm too lazy to implement this, it's good for me as is).

In an ideal world, KDE applications should apply all the custom theming on their own like Qt applications with branded design do on Windows/macOS but it seems there's no people interested in doing such changes in the KDE coomunity.

ilya-fedin avatar Feb 02 '24 15:02 ilya-fedin

Kirigami is not the issue, as it also doesn't apply to KDE 6 apps like Dolphin and System Settings using qt6ct.

Vistaus avatar Sep 21 '24 11:09 Vistaus

System Settings do use Kirigami. Although you're right that it's not only Kirigami, it's KColorScheme framework which is used by both QML and Widgets KDE apps.

ilya-fedin avatar Sep 21 '24 15:09 ilya-fedin

But does Dolphin use Kirigami? And Haruna? And Amarok git, built with Qt 6? And Okular? Because it doesn't work in those apps either. And if System Settings only partly uses Kirigami, I'd expect the theme to at least partially apply.

Btw, I tried your patch on Arch Linux with qt6ct from git, but it doesn't solve the issue.

Vistaus avatar Sep 21 '24 15:09 Vistaus

As I said, it's not Kirigami but KColorScheme. And yes, all KDE applications use KColorScheme.

Btw, I tried your patch on Arch Linux with qt6ct from git, but it doesn't solve the issue.

Did you choose a color scheme with it that has a (KColorScheme) in its name?

ilya-fedin avatar Sep 21 '24 15:09 ilya-fedin

But then what changed with KDE 6? Because I never had issues like this with KDE 5 apps.

Yes, I chose Breeze Dark. That's one of the two default KDE themes, so it should be good. Except that it isn't.

Vistaus avatar Sep 21 '24 15:09 Vistaus

Yes, I chose Breeze Dark. That's one of the two default KDE themes, so it should be good. Except that it isn't.

Can you provide your Qt-related environment variables? env | grep QT

ilya-fedin avatar Sep 21 '24 15:09 ilya-fedin

❯ env | grep QT
QT_AUTO_SCREEN_SCALE_FACTOR=0
QT_WAYLAND_RECONNECT=1
QT_QPA_PLATFORMTHEME=qt6ct

Vistaus avatar Sep 21 '24 15:09 Vistaus

Can you reproduce if you run affected application in that terminal session?

ilya-fedin avatar Sep 21 '24 15:09 ilya-fedin

Can you reproduce if you run affected application in that terminal session?

Then it seems to work fine.

Vistaus avatar Sep 21 '24 15:09 Vistaus

Scratch that: it did apply the correct colors, but not the theming engine.

Vistaus avatar Sep 21 '24 15:09 Vistaus

Then it seems to work fine.

So the issue is that you have set QT_QPA_PLATFORMTHEME in a way it doesn't go through all your graphical session

ilya-fedin avatar Sep 21 '24 15:09 ilya-fedin

Then it seems to work fine.

So the issue is that you have set QT_QPA_PLATFORMTHEME in a way it doesn't go through all your graphical session

Please see my message after that one. 🙂

(And I have set that variable in /etc/environment, just like I used to do with qt5ct.)

Vistaus avatar Sep 21 '24 15:09 Vistaus

Scratch that: it did apply the correct colors, but not the theming engine.

Some KDE applications like Dolphin hardcode theme for non-KDE sessions now

ilya-fedin avatar Sep 21 '24 15:09 ilya-fedin

see https://invent.kde.org/frameworks/kiconthemes/-/issues/3

ilya-fedin avatar Sep 21 '24 15:09 ilya-fedin

Scratch that: it did apply the correct colors, but not the theming engine.

Some KDE applications like Dolphin hardcode theme for non-KDE sessions now

But I'm using KDE.

Vistaus avatar Sep 21 '24 15:09 Vistaus

But I'm using KDE.

Then you don't really need qt6ct? Setting qt6ct would make that logic to think you're using a non-KDE session.

ilya-fedin avatar Sep 21 '24 15:09 ilya-fedin

But I'm using KDE.

Then you don't really need qt6ct? Setting qt6ct would make that logic to think you're using a non-KDE session.

But using qt6ct I can disable cursor blinking, which is not supported by KDE itself. I was advised to use qt5ct for that on KDE 5, but I clean installed Arch Linux with KDE 6 last week, so now I need to use qt6ct to achieve that. And because of that, I also need to set the theming engine through qt6ct.

Vistaus avatar Sep 21 '24 15:09 Vistaus

That logic seem to force the Qt style from kdeglobals so setting it via both qt6ct and system settings should theoretically do the thing

ilya-fedin avatar Sep 21 '24 15:09 ilya-fedin

Could you explain that a bit more? Like I said: I did use this exact same setup with qt5ct without any issues.

Vistaus avatar Sep 21 '24 15:09 Vistaus

Could you explain that a bit more

You don't know how to set Qt style via system settings?

Like I said: I did use this exact same setup with qt5ct without any issues.

As you can see the linked issue in kiconthemes, it's done in KF6, not KF5

ilya-fedin avatar Sep 21 '24 22:09 ilya-fedin

I have set it in system settings, but it doesn’t make a difference for the majority of apps, including the ones I listed earlier.

Vistaus avatar Sep 21 '24 23:09 Vistaus

What those commands return?

grep widgetStyle ~/.config/kdeglobals 
grep style ~/.config/qt6ct/qt6ct.conf

ilya-fedin avatar Sep 21 '24 23:09 ilya-fedin

❯ grep widgetStyle ~/.config/kdeglobals 
widgetStyle=qt6ct-style

~
❯ grep style ~/.config/qt6ct/qt6ct.conf
style=kvantum
stylesheets=@Invalid()
toolbutton_style=2

~
❯ 

Vistaus avatar Sep 22 '24 09:09 Vistaus

Could it be that you have kvantum installed only for Qt 5?

ilya-fedin avatar Sep 22 '24 09:09 ilya-fedin

Nope, kvantum-qt6 is installed and qt6ct and FeatherNotes do use the Kvantum theme I set, so it's partly functioning.

Vistaus avatar Sep 22 '24 09:09 Vistaus

The only idea is maybe there's a miscommunication. Can you upload a screenshot of how it looks wrongly and (if possible) how it should look like?

ilya-fedin avatar Sep 22 '24 10:09 ilya-fedin

I have no idea what changed, but suddenly it's working now. Thanks for all of your help! 🙂

Vistaus avatar Sep 26 '24 16:09 Vistaus

Actually, scratch that: it works for a moment in for example Dolphin, but when I close Dolphin, it reverts to Breeze. Then I re-apply qt6ct as theme engine in System Settings and Dolphin looks fine again until I close it…

Vistaus avatar Sep 26 '24 16:09 Vistaus