KConfigDialog
Martin Heni
martin at heni-online.de
Tue Mar 20 20:26:00 GMT 2007
KConfigDialog allows easy connection of the dialog with the data from a
KConfigSkeleton. Changes in the dialog reflect in the config data. However,
the other way round does not work as good: Data from the KConfig group is
only loaded into the dialog upon dialog creation. Then the widget/button/...
status is set according to the KConfig data. However, it can happen that the
main program needs to change the KConfig data and this should then reflect in
the dialog's buttons (either when it next time is shown or especially if it
is still open - depending whether its modal or not).
Unfortunately, the dialog checks quite thouroughly whether it is already open
etc and prevents any further updates to the dialog. At least none which I
could find. The only way to influence the widget's status seems to set the
GUI elements directly somewhere else, which I think is not so neat.
It would be useful if the KConfigDialog would allow access to its
KConfigDialogManager's updateWidget() etc procedures [which set the dialog
GUI according to the KConfig data]. Ideally by using a SLOT which could be
connected to the KConfigSkeleton configChanged() signal. I'd imaging
something like
connect(Prefs::self(), SIGNAL(configChanged()),
dialog, SLOT(updateWidgets()));
would be quite handy.
To allow this the KConfigManager needs to allow access to its updateWidget
stuff. One possibilty would be to use the updateWidget() function of
KConfigDialog which is already available as SLOT but not used directly. A
possible patch is attached. If this slot should not be reused one could
introduce a similar one with the same functionality. In both cases the update
widget stuff needs to be made accessible in the slot as indicated by the
patch.
I am not very familiar with the dialog and thus do not know whether this
change is sufficient to cover all situation or wether it could have
sideeffects somewhere else. So maybe someone with more in depth knowledge
could look into this and when agreeing on the problem implement the change.
Thanks a lot,
Martin
Index: kconfigdialog.cpp
===================================================================
--- kconfigdialog.cpp (revision 642359)
+++ kconfigdialog.cpp (working copy)
@@ -217,9 +217,6 @@
QMap<QWidget *, KConfigDialogManager *>::iterator it;
updateWidgets();
- d->manager->updateWidgets();
- for (it = d->managerForPage.begin(); it != d->managerForPage.end(); ++it)
- (*it)->updateWidgets();
bool has_changed = d->manager->hasChanged() || hasChanged();
for (it = d->managerForPage.begin();
@@ -251,6 +248,10 @@
void KConfigDialog::updateWidgets()
{
+ QMap<QWidget *, KConfigDialogManager *>::iterator it;
+ d->manager->updateWidgets();
+ for (it = d->managerForPage.begin(); it != d->managerForPage.end(); ++it)
+ (*it)->updateWidgets();
}
More information about the kde-core-devel
mailing list