Benjamin Meyer ben at meyerhome.net
Sun Feb 23 04:24:07 GMT 2003

Based on all of the feedback from last week I have done a bit of work on the 
KAutoConfig class.

-KAutoConfig is now in kdeui and not kdecore (I removed it last Saturday) due 
to the obvious dependency problem.

-KAutoConfig is now modular.  Developers can easily add new widgets for 
KAutoConfig to manage.

-That horrible ugly 16 line macro (and those hard coded case statements) were 
completely removed from the class in the process of making it modular.

-The two apps that use KAutoConfig is KTron and KAudioCreator.  (Sorry, didn't 
know about this unwritten rule last week).  If anyone wants me to help them 
convert an existing app I am able and willing.

I wrote a helper for KURLRequester, but I am not sure where this should be 
stored in cvs.  Because KURLRequester is not in kdeui, KAutoConfig doesn't 
know about it by default.  Should I add this small class to the 
KURLRequester[h,cpp] files?  or are there other widgets in kfile that I 
should write wrappers for and store them all in 1 file together? (An example 
of how to use KURLRequester and other additional widgets is showed in the 
KTron settings code below.)

KTron was converted (and quite a bit was cleaned up) to show the power of this 
class.  Below is _all_ of the code that is needed in KTron to bring up the 
settings dialog.  As you can see it is only 2 functions :)  KAutoConfig takes 
care of the rest.  A nice side effect beyond added an entire settings dialog 
was the binary size of KTron was actually reduced.  For a lot of applications 
this is an excellent way to reduce code and simplify things.  Letting the 
developer work on the application and not have to worry about the settings 
dialog code.

One annoying thing was that KDialogBase constructor didn't let me specify the 
widget options (wflags) forcing me to add another function to close(true) the 
widget.  Looking through the KDialogBase code it looks simply as an oversite 
and if that is the case can I add a new constructor (which I believe doesn't 
break binary compatibility) with the extra argument (defaulted to what 
KDialogBase has now) and make the old constructor depreciated?

-Benjamin Meyer

P.S. I did a fresh co of kdelibs this afternoon and in kdecore someone used a 
qlist.h (should have been qptrlist.h) and in khtml there was some other 
compiler error that I wasn't sure of how to fix.

P.P.S. KAudioCreator settings dialog code is a little messy due to an old 
design flaw and will be fixed at some time in the future thus the clean KTron 
code reference here:

 * Show Options dialog.
void KTron::showOptions(){
  options = new KDialogBase(KDialogBase::IconList, i18n("Settings"), 
KDialogBase::Default | KDialogBase::Ok | KDialogBase::Apply | 
KDialogBase::Cancel , KDialogBase::Ok, this, "OptionsDialog", false, 
WDestructiveClose ); 
  KAutoConfig *kautoconfig = new KAutoConfig(options, "KAutoConfig");
  KAutoConfig_KURLRequester *r = new KAutoConfig_KURLRequester();
  kautoconfig->addKAutoConfigWidget("KURLRequester", r);
  connect(options, SIGNAL(okClicked()), kautoconfig, SLOT(saveSettings()));
  connect(options, SIGNAL(okClicked()), this, SLOT(closeOptions()));
  connect(options, SIGNAL(applyClicked()), kautoconfig, SLOT(saveSettings()));
  connect(options, SIGNAL(defaultClicked()), kautoconfig, 

  QVBox *frame = options->addVBoxPage(i18n("General"),i18n("General"), 
SmallIcon("package_settings", 32));
  General *general = new General(frame, "General");
  kautoconfig->addWidget(general, "Game");

  frame = options->addVBoxPage(i18n("Ai"),i18n("Ai"), 
SmallIcon("package_system", 32));
  Ai *ai = new Ai(frame, "Ai");
  kautoconfig->addWidget(ai, "Game");

  frame = options->addVBoxPage(i18n("Appearance"),i18n("Appearance"), 
SmallIcon("style", 32));
  Appearance *appearance = new Appearance(frame, "Appearance");
  kautoconfig->addWidget(appearance, "Game");
  connect(kautoconfig, SIGNAL(settingsChanged()), tron, SLOT(loadSettings()));
  connect(kautoconfig, SIGNAL(settingsChanged()), this, SLOT(readSettings()));


void KTron::closeOptions(){

More information about the kde-core-devel mailing list