[Kde-games-devel] How to overwrite a KCFG setting?
Ian Wadham
iandw.au at gmail.com
Fri Jan 4 07:33:40 UTC 2013
In a board-style game, the size of the board may be a config item. It certainly
is in KJumpingCube.
If the user changes the board size, it is necessary to clear the board and
start a new game. I would like to offer the user a chance to override that and
not automatically lose a game that is in progress if he/she accidentally clicked
a new board size in the settings dialog generated by KCFG and Qt Designer.
Here is some code that seems to work if I want to put the board size
back as it was and continue the current game:
((KConfigSkeleton::ItemInt *) (Prefs::self()->findItem ("CubeDim")))->
setValue (previousCubeDim);
Prefs::self()->writeConfig();
Is this OK? It seems a bit hairy to me, i.e. dependent on too many details
of kdelibs and internals of KCFG, any of which may change in future.
All the best, Ian W.
More information about the kde-games-devel
mailing list