[bt-devel] Development status question
Joachim Ansorg
bt-devel@crosswire.org
Thu, 16 Aug 2001 17:10:43 +0200
Hi!
> I do understand what you are saying, but in CslotApply, there is a call
> made directly to kdialogbase::slotApply(). slotOk() is written in the same
> manner.
We have to call KDialogBase::slotApply() in COptionsDialog::slotApply()
because we reimplemented this virtual function. The original function
KDialogBase::slotApply() has to be called because we don't want to loose
functionality activated in KDialogBase::slotApply.
The complex things after you pressed OK are done in
BibleTime::slotSettingsOptions():
COptionsDialog *dlg = new COptionsDialog(m_important, this,
"COptionsDialog", m_keyAccel);
if ( dlg->exec() ) {
// find out changed settings and update the parts of the GUI using these
// settings
}
As you can see we call dlg->exec() which returns true if the dialog was
closed by the OK button. The code inside the brackets is executed if OK was
pressed, here we update the GUI using the changed settings.
For example:
const int changedSettings = dlg->getChangedSettings();
if (changedSettings & CSwordPresenter::language) { //the language changed
KConfigGroupSaver gs(m_config, "SWORD");
//apply new language
}
dlg->getChangedSettings() is implemented in COptionsDialog and returns an
integer containing the ORed together values which stand for the difrerent
types of settings.
These are the basic things done in slotSettingsOptions().
Now note, that pressing the Apply button does not clode the dialog so using
"if (dlg->exec()) { //code }" doesn't work (this works only if dlg->exec() is
finished(), i.e. the dialog was closed).
To apply the settings if the Apply button was pressed we have to find another
solution.
The best way to do this is to create a new SLOT in the BibleTime class and
connect to this SLOT a signal from COptionsDialog. You have to add an own
signal because we need the integer containing the changed settings.
This could look like:
connect( dlg, SIGNAL(apply(const int changedSettings)), this,
SLOT(slotSettingsApply(const int changed settings)));
Maybe we could use one block of code to apply the settings after OK or apply
were pressed.
If you decide to do so add a new function for this and call this function in
slotSettingsApply() and slotSettingsOptions().
> What puzzles me is why Ok works, and slotApply() does not. I was
> reading one of the tutorials on the KDE website and the slotApply function
> in that tutorial is much more complex than ours.
I'm not sure what solution is better to apply settings.
But we chose our solution because the BibleTime class has all the pointers
which have to be used to update the GUI.
As I already said above, the code to update the GUI after OK was pressed is
in BibleTime::slotSettingsOptions.
The code for apply has still to be written.
I hope I could solve your problems and help you with your programming
problem. If you still need some advide or help please ask me, I'd be glad to
help you (it's my task as project administrator).
God bless you!
Joachim