QSettings problem with .desktop file
-
Hello,
I'm trying to edit a .desktop file on MeeGo using QSettings and when I modified an entry (in a group) then the group, that is [Desktop Entry] becomes [Desktop Entry].
What I can do to have it wrote correctly without the ?
Thanks. -
[quote author="b0unc3" date="1330002682"]Hello,
I'm trying to edit a .desktop file on MeeGo using QSettings and when I modified an entry (in a group) then the group, that is [Desktop Entry] becomes [Desktop Entry].
What I can do to have it wrote correctly without the ?
Thanks.[/quote][Desktop Entry] becomes [Desktop Entry] What do you mean? Please give more details and your source code.
-
Oh sorry, I didn't notice that the character was substituted in the thread text.
I mean that the whitespace in [Desktop Entry] becomes [Desktop% 20Entry]. -
[quote author="b0unc3" date="1330011772"]Oh sorry, I didn't notice that the character was substituted in the thread text.
I mean that the whitespace in [Desktop Entry] becomes [Desktop% 20Entry].
[/quote]Hm... the space has been replaced with just like as it is using URL encoding. It is strange what is causing it. It would be nice if you post the source code that you are using to process the config file. But anyway as a work around you can use "QUrl":http://developer.qt.nokia.com/doc/qt-4.8/qurl.html to detect encoded url characters and decode them.
-
[quote author="leon.anavi" date="1330012229"]
Hm... the space has been replaced with just like as it is using URL encoding. It is strange what is causing it. It would be nice if you post the source code that you are using to process the config file. But anyway as a work around you can use "QUrl":http://developer.qt.nokia.com/doc/qt-4.8/qurl.html to detect encoded url characters and decode them.
[/quote]Yes exactly.
A base code like this, will give you this behavior:
@
QSettings settings("file.desktop", QSettings::IniFormat);
settings.beginGroup("Desktop Entry");
settings.setValue("Name", "test");
settings.endGroup();
settings.sync();
@I don't know if I can use QUrl as a workaround, I don't see how.
-
OK... so it appears that in the original definition of INI files used at Microsoft Windows sections and key names should not contain any spaces. Therefore QSettings automatically replaces the spaces with % 20.
A macros "QT_NO_URL_CAST_FROM_STRING":http://developer.qt.nokia.com/doc/qt-4.8/qurl.html#QT_NO_URL_CAST_FROM_STRING is described at Qt documentation for QSettings Try to fix your issue using it. According to this description it will disables automatic conversions from QString (or char *) to QUrl.
-
[quote author="leon.anavi" date="1330015036"]OK... so it appears that in the original definition of INI files used at Microsoft Windows sections and key names should not contain any spaces. Therefore QSettings automatically replaces the spaces with % 20.
A macros "QT_NO_URL_CAST_FROM_STRING":http://developer.qt.nokia.com/doc/qt-4.8/qurl.html#QT_NO_URL_CAST_FROM_STRING is described at Qt documentation for QSettings Try to fix your issue using it. According to this description it will disables automatic conversions from QString (or char *) to QUrl.[/quote]
I've just tried it, but it doesn't resolve my issue.
-
Have you tried to use the native format for MeeGo? I mean something like this:
@QSettings settings("file.desktop", QSettings::NativeFormat);@
-
[quote author="leon.anavi" date="1330017302"]Have you tried to use the native format for MeeGo? I mean something like this:
@QSettings settings("file.desktop", QSettings::NativeFormat);@[/quote]
Yes, nothing changes.
I think I'll go with sed after the edit.