Alvaro
Soliverez
asoliverez@gmail.com
Settings
How to create a settings page
Create the view using designer, name it XxxDecl and store it in kmymoney2/dialogs/settings/xxxdecl.ui. See more information about naming the items further down
Create the class that contains the logic for the settings page, name it Xxx and store it in kmymoney2/dialogs/settings/xxx.[cpp|h].
Don't forget the Q_OBJECT macro at the beginning of the class declaration in the .h file and make the class a public derivative of XxxDecl
Add the xxxdecl.ui and xxx.cpp filename to the libsettings_a_SOURCES label in kmymoney2/dialogs/settings/Makefile.am
Add the xxxdecl.ui filename to the EXTRA_DIST label in kmymoney2/dialogs/settings/Makefile.am
Add the xxxdecl.cpp and xxxdecl.h filename to the DISTCLEANFILES label in kmymoney2/dialogs/settings/Makefile.am
Add the xxx.h filename to the noinst_HEADERS label in kmymoney2/dialogs/settings/Makefile.am
Add the construction code to KMyMoney2App::slotSettings() as
Xxx* xxxPage = new Xxx();
dlg->addPage(xxxPage, i18n("text"), "icon-name");
where you replace "text" with a short text that shows up under the icon in the settings view and "icon-name" with the name of the icon for that settings page
Make sure to include xxx.h in kmymoney/kmymoney2.cpp
How to add the setting items
For auto-generation of setter/getter code of your options, you have to follow certain rules. For each setting item you need an entry in kmymoney2/kmymoney2.kcfg. This is an XML formatted file. The contents of the 'name' attribute will be used as method for the C++-code, eg. a name of "AutoSavePeriod" for an integer parameter results in a setter and getter named
void KMyMoneySettings::setAutoSavePeriod(int)
int KMyMoneySettings::autoSavePeriod(void)
You should not access those functions directly from within your code but rather use the KMyMoneyGlobalSettings class which contains the same interface as KMyMoneySettings with some additional functionality.
When you name the GUI widget that controls the setting for this parameter make sure to name it "kcfg_AutoSavePeriod", that is "kcfg_" prepended with the name used in kmymoney2/kmymoney2.kcfg.
That should be it.
References
A more complete - but generic version - can be found on http://techbase.kde.org/Development/Tutorials/Using_KConfig_XT . Currently, &app; does not use the CMakeLists.txt file but the above mentioned Makefile.am approach. You can safely skip the section about CMakeLists.txt.
Hints
If you run a make 'too early' it could be, that certain entries for the Makefile are not setup correctly and the compiler will complain. In this case, try to run a 'make -f Makefile.dist' followed by './configure' and see if the problem goes away.