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

apply changes after manual editing of kdeglobals

Tags: None
(comma "," separated)
pashazz
Registered Member
Posts
10
Karma
0
OS
how can I apply changes for kdeglobals config without restarting session?

I know there are reparseConfiguration method callable via d-bus, but to what app?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Please see KGlobalSettings.
You want to do something similar to this:
Code: Select all
QDBusMessage::createSignal("/KGlobalSettings", "org.kde.KGlobalSettings", "notifyChange" );


It will need two arguments - which are documented on api.kde.org.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
pashazz
Registered Member
Posts
10
Karma
0
OS
bcooksley wrote:Please see KGlobalSettings.
You want to do something similar to this:
Code: Select all
QDBusMessage::createSignal("/KGlobalSettings", "org.kde.KGlobalSettings", "notifyChange" );


It will need two arguments - which are documented on api.kde.org.

I haven't service org.kde.KGlobalSettings:
https://photos-1.dropbox.com/psi/tbd/zR ... e=1024x768

Is it available only from KDE apps? If so, can use it without writing a C++ app (possibly pykde4)
pashazz
Registered Member
Posts
10
Karma
0
OS
tried to use pykde4:

from PyKDE4.kdeui import KGlobalSettings
KGlobalSettings.emitChange(0,0)
(previously changed color scheme in [General] of kdeglobals)
out:
QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
and nothing changed....
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
The values you need to give to emitChange() need to set depending on the type of change you are making to kdeglobals.
The org.kde.KGlobalSettings interface is a signal only interface - meaning you will not see it on D-Bus. Applications send signals (like you did using your Python code) and all KDE applications recieve them and respond appropriately.

The first value should be a ChangeType, and the second value a SettingsCategory. Because they are Enums, assume they begin counting at 0, and count up from there.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
pashazz
Registered Member
Posts
10
Karma
0
OS
I changed the color scheme in kdeglobals.
then I tried to call
Code: Select all
KGlobalSettings.emitChange(KGlobalSettings.StyleChanged)

and
Code: Select all
KGlobalSettings.emitChange(KGlobalSettings.PaletteChanged)

and
Code: Select all
KGlobalSettings.emitChange(KGlobalSettings.SettingsChanged)

....still no effect. But I really changed the scheme:
Image
(as you can see apply button inactive ("Применить") and Systemsettings thinks that theme has changed but it hasn't!
Also IconChanged and StyleChanged worked for me when I changed icons and windows styles manually, but I can't change palette... what I should call?

p.s. I saw your name in sources of systemsettings, hope you can help me... systemsettings works good for me for changing color scheme...
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Unfortunately I did not develop most of the options you see within System Settings. They are plugins which have been written by others which System Settings loads in when you access them.

As for Palette/Colour changes, the following type is appropriate: KGlobalSettings::PaletteChanged.
Have you updated both the style file on disk as well as all the values in kdeglobals?


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
pashazz
Registered Member
Posts
10
Karma
0
OS
I found my mistake: there are not only info about name of scheme in kdeglobals, but color info too.

OK, then next question..... how to set color scheme using KDE API?

is the only way is to mix color scheme file and kdeglobals manually?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Unfortunately this is the part I never 100% understood in the colour management code. My guess would be that the details in kdeglobals are either the overridden colours, or a cache for applications to be able to conveniently access. In either case, updating both is recommended.

You should be able to use kwriteconfig as a command line tool, or KConfig / KConfigGroup in a actual application to update their values (you will have to do it all by hand however).


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
pashazz
Registered Member
Posts
10
Karma
0
OS

Python

Fri Jun 29, 2012 6:55 pm
solved by this function:
Code: Select all
#GPLv3 software
    @staticmethod
    def applyColorScheme(schemeFile):
        '''Applies the color scheme to KDE globals'''
        scheme = KConfig(schemeFile)
        kdeglobals = KConfig('kdeglobals')
        for groupName in scheme.groupList():
            group = scheme.group(groupName)
            global_group = kdeglobals.group(groupName)
            for (k, v) in group.entryMap().items():
                global_group.writeEntry(k, v)
               
        kdeglobals.sync()
        KGlobalSettings.emitChange(KGlobalSettings.PaletteChanged)


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], Google [Bot], lockheed, Sogou [Bot], Yahoo [Bot]