Re: [kln2-devel] preferences & setHidden
Brought to you by:
wiecko
From: Marek W. <Mar...@fu...> - 2004-09-29 07:03:36
|
Carlo, First of all, thanks for your changes and fixes. :) On Fri, 17 Sep 2004, Carlo wrote: > * by updating the translations I got these errors OK. I updated kln2.pro and *notation.h files. lupdate should work now (I committed updated *.qm and *.ts to CVS). BTW: I'm planning to rename other files so that similar things would be ls-ed close to each other: scalenotation* => names_of_notes* solfeggionotation* => names_solfeggio* oneletternotation* => names_oneletter* KLNcanvasitem* => canvasitems* musicwidget* => widgets_piano* musicstaff* => widgets_staff* KLNfancywidge* => widgets_namebuttons* Also, I plan to move def. of ActionWithIconSwitch to globals.cpp and include contents of quickstartfile.h into kln2-defs.h (and delete qsf.h). If you have any changes that would affect these files - please commit now. ================================== > ## klearnnotes2.cpp: 1017 >> if (klnPrefs == NULL)return;//just to be sure...[or it might be >> created here] [...] > Well, it could also be created here, but it would contain nothing. OK, I'd leave this without any changes - if there were any problems in future we can sort this then. But I added a debug info (I'd rather not assert() here) to report when this if is activated - we shouldn't ever see it's output. ================================== > ## exercises preferences > I was thinking about writing Exercise::savePreferences > (/loadPreferences) wich would > - save exercise settings (like testLenthFactor) > - not set a group (doesn't call Preferences::setGroup) > - would be inherited by each exercise > (- could raise a signal caught by the exercise) > This function would be called by KLearnNotes2::saveOptions wich is > charged to setGroup and would solve the problem for the current > exercise. Sounds reasonable. But if you define a member in each exercise class: static const char* prefsGrpName = "exe: name-to-piano"; and a virtual (!) function in Exercise virtual setPrefsGroup() { klnPrefs->setGroup(prefsGrpName);}; you can set a different group name for each of the inherited classes by the classes 'virtual saveOptions()' itself. Maybe this way is clearer? When new kind of exe is added Kln2::saveOptions() will just have to loop through one more Exercise object, and the object itself would set group etc. If you need an example: in a similar way virtual rtti() and static const rttiNum are used for canvas objects (musicstaff.* musicwidget.* KLNcanvasitems.cpp). If you find some time - please, code it either this way or (if it would be easier for you) the way you suggested. :) > Alternatively each exercise could load his preferences in his > constructor and save them in the destructor creating his own group. Is > there anything wrong with this? It's less flexible: it might be desirable to save settings without destroying the object. ================================== BTW this reminds me about one more thing. Does anybody has any idea how to delete 'KLearnNotes2 *klearnnotes2'? I added debuginfo to the destructor to trace it: if there is no line delete klearnnotes2; in main() the object is not deleted [thus, for example klnPrefs is not deleted either and the prefs data is not saved :( ]; if there is above line ... it crashes instead of deleting kln2. I'm not sure what's wrong. I tried to trace this with gdb, but I can't do it either. :( Any ideas? Regards, Marek -- \/ /|\ Marek Wieckowski ##### | | | = . . = \|/ Institute of Theoretical Physics U | Warsaw University / ~ \___ | <| | | > . < | http://www.fuw.edu.pl/~wiecko <<___>> | http://klearnnotes2.sourceforge.net |