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

[SOLVED] KDesktopFile not working

Tags: None
(comma "," separated)
User avatar
giucam
KDE Developer
Posts
62
Karma
1
OS

[SOLVED] KDesktopFile not working

Fri May 29, 2009 8:52 pm
Hi, I'm experimenting a bit with the KDesktopFile class, but I'm not able to make it work:

Code: Select all
KDesktopFile desktopFile("/usr/share/apps/solid/actions/test-predicate-openinwindow.desktop");
kDebug()<<desktopFile.readName();


executing it I get a distressing "", even if the file, I checked, has the field "Name=Open with File Manager". I tried even with

Code: Select all
kDebug()<<desktopFile.desktopGroup().readEntry("Name");


with no result.

Does anyone know what I'm doing wrong?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

[SOLVED] KDesktopFile not working

Sat May 30, 2009 12:38 am
If you try the following does anything get output?
Code: Select all
kDebug() << "Test" << desktopFile.desktopGroup().name();


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
giucam
KDE Developer
Posts
62
Karma
1
OS

[SOLVED] KDesktopFile not working

Sat May 30, 2009 4:18 pm
yes, it works, but it is not the "Name" field, but the name of the KConfigGroup, so it says "Desktop Entry"
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

[SOLVED] KDesktopFile not working

Sat May 30, 2009 10:20 pm
It is possible that KConfigGroup is trying to read the internationalised entry, which language do you have specified for KDE global settings?


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
giucam
KDE Developer
Posts
62
Karma
1
OS

[SOLVED] KDesktopFile not working

Sun May 31, 2009 9:05 am
I've set US English, so it shouldn't be that, even because I can't read other fields, like Icon, that are not dependent on the language used.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

[SOLVED] KDesktopFile not working

Sun May 31, 2009 9:10 am
In the application, have you constructed a KApplication instance?


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
giucam
KDE Developer
Posts
62
Karma
1
OS

[SOLVED] KDesktopFile not working

Sun May 31, 2009 12:39 pm
it is not an application. I took the code of the device notifier plasmoid and I'm modifying it a bit.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

[SOLVED] KDesktopFile not working

Mon Jun 01, 2009 12:30 am
It should be fine then...
How are you testing your changes? By using plasmoidviewer? Or are you just loading it into Plasma itself?


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
giucam
KDE Developer
Posts
62
Karma
1
OS

[SOLVED] KDesktopFile not working

Mon Jun 01, 2009 12:18 pm
it doesn't matter, i tried both. maybe, since i'm using trunk, it is a bug.
now that i'm thinking about it i'll go and see the code of quicklaunch that reads the .desktop in order to set the icons, since it works here.
User avatar
giucam
KDE Developer
Posts
62
Karma
1
OS

[SOLVED] KDesktopFile not working

Mon Jun 01, 2009 12:52 pm
It seems like KDesktopFile has some problems with the files like the ones in /usr/share/apps/solid/actions/. i tried with /usr/share/applications/firefox.desktop and it works.
so i have to understand why it does this silly thing, since i need to read the solid ones.
User avatar
giucam
KDE Developer
Posts
62
Karma
1
OS

[SOLVED] KDesktopFile not working

Mon Jun 01, 2009 12:58 pm
ok, i solved.
obviously it was a stupid thing: these files have a group [Desktop Action open] and i have to get that KConfigGroup and read the entries from there.

Last edited by giucam on Mon Jun 01, 2009 2:50 pm, edited 1 time in total.
User avatar
giucam
KDE Developer
Posts
62
Karma
1
OS
so here is the result of all my efforts: Device Manager :-D:-D


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]