This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How can my app get informed that the colorscheme changed?

Tags: None
(comma "," separated)
Petross404 (petross)
Registered Member
Posts
16
Karma
0
I want to connect a lamda function to a signal that gets emmited when the colorscheme (either global or app-specific) is changed.

Now I am using
Code: Select all
...
        auto c = client().data();
...
        connect(c, static_cast<void (KDecoration2::DecoratedClient::*)(const QPalette&)>(&KDecoration2::DecoratedClient::paletteChanged), this,
                [this]
        {
            this->paintTitleBar(&painter, repaintRegion);
        });

but it's qt breeze-specific and it isn't using the Frameworks API. I would like it to be able to support gtk applications too. I found ColorScope, is this right?
kde-cfeck
Registered Member
Posts
93
Karma
0
You want http://doc.qt.io/qt-5/qguiapplication.h ... tteChanged

KDecorations2 is just for window decorations.
Petross404 (petross)
Registered Member
Posts
16
Karma
0
kde-cfeck wrote:You want http://doc.qt.io/qt-5/qguiapplication.h ... tteChanged

KDecorations2 is just for window decorations.


So there isn't a way to handle this in a more generic way? Like read gtk palette too and force a repaint if this palette changes?
airdrik
Registered Member
Posts
1854
Karma
5
OS
I'm pretty sure gtk3 does something completely different, since their themes are derived more directly from (svg) images and css.

Regardless, I believe Qt should take care of translating whatever it is that gtk may be doing (when using the gtk theme for qt), so insofar as qt is able to recognize that the gtk color palette has changed then it will update its colors and fire off that event.


airdrik, proud to be a member of KDE forums since 2008-Dec.
Petross404 (petross)
Registered Member
Posts
16
Karma
0
airdrik wrote:I'm pretty sure gtk3 does something completely different, since their themes are derived more directly from (svg) images and css.

Regardless, I believe Qt should take care of translating whatever it is that gtk may be doing (when using the gtk theme for qt), so insofar as qt is able to recognize that the gtk color palette has changed then it will update its colors and fire off that event.


Thank you very much for your kind help. ;) I will look more into this.
jamesrenick
Registered Member
Posts
1
Karma
0
A similar code also uses sites like this one https://www.snapscoresofficiel.me/


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell