configuration dialogs for plugins

1 view
Skip to first unread message

doep

unread,
Dec 8, 2008, 5:38:31 PM12/8/08
to musikCube developers
A suggestion on how to make plugins be able to create configuration
dialogs.

First of all we need to make a call to the plugin like
"ShowConfiguration()"
In the call we send a interface to a IDialogParser like
"ShowConfiguration(IDialogParser *dialog)"
The IDialogParser should look something like this:
class IDialogParser{
bool SetDialog(utfchar *dialogXML);
bool SetOption(utfchar *controlName,utfchar *option,utfchar *value);
utfchar* Option(utfchar *controlName,utfchar *option);
}

The plugin will now be able to do something like this:

void ShowConfiguration(IDialogParser *dialog){
utfstring dialogXML(UTF(""
"<rows>"
" <row>"
" <columns>"
" <column size=\"100\">"
" <label>Option 1</label>"
" </column>"
" <column>"
" <control type=\"checkbox\" id=\"option1\" value=\"1\"/>"
" </column>"
" </columns>"
" </row>"
" <row>"
" <columns>"
" <column size=\"100\">"
" <label>Option 2</label>"
" </column>"
" <column>"
" <control type=\"radio\" id=\"option2\" value=\"opt1\" caption=
\"My first option\"/>"
" <control type=\"radio\" id=\"option2\" value=\"opt2\" caption=
\"My second option\"/>"
" <control type=\"radio\" id=\"option2\" value=\"opt3\" caption=
\"My third option\"/>"
" </column>"
" </columns>"
" </row>"
"</rows>"));

dialog->SetDialog(dialogXML.c_str());
}

Now we got 2 options on how to save the configuration.
The first option is to just save the settings by "id" and pass a
IPreferences down to the plugins whenever seem fit, or
we could have a method in the plugin like:

void SaveConfiguration(IDialogParser *dialog,IPreferences *preferences)
{

utfstring option1value = dialog->Option("option1","value");
utfstring option2value = dialog->Option("option2","value");

// And we can manipulate and save the options in the IPreferences

preferences->SetValue("myoption",option1value.c_str());
preferences->SetValue("myotheroption",option2value.c_str());

}


Not so sure about the xml format, it was just an example to get
started.


Best regards
Daniel
Reply all
Reply to author
Forward
0 new messages