Home · All Classes · Main Classes · Deprecated |
Meegotouch settings language is a declarative way to define basic user interfaces. The user interface which can be built with it consists of basic input widgets: selections, text entries etc. Their sequence, title and other properties are described in an xml file which gets loaded at runtime.
Using a settings language user interface description xml file in an application needs the following steps:
Use MSettingsLanguageParser to parse the xml file and use it to create the MSettingsLanguageBinary which represents the parsed information.
Set up a datastore which will store the state of the widgets (eg. which element got selected from a selection, or what content does the text entry has).
Create the widgets through MSettingsLanguageWidgetFactory, by specifying the above two.
Thats it, the widgets are ready, put them onto the page!
QString filePath = "ui_description.xml"; QFile file (filePath); if (!file.open(QIODevice::ReadOnly)) { qCritical ("Unable to open the file."); return; } MSettingsLanguageParser parser; if (!parser.readFrom(file)) { qCritical ("Error parsing the ui description"); return; } MSettingsLanguageBinary* binary = parser.createSettingsBinary(); if (!binary) { qCritical ("Error parsing the ui description"); return; } MDataStore* datastore = new MyDataStore (); MSettingsLanguageWidget* widget = MSettingsLanguageWidgetFactory::createWidget(*binary, datastore ); page->setCentralWidget (widget);
The format of a settings declarative user interface description is the following:
The input items can be grouped into zero or more <group> and </group> tags. Each group has a title, and some input widgets in it. The "title" attribute of the group is mandatory.
Example:
<group title="Section 1">
some input widgets comes here
</group>
Common attributes for the input widgets are:
<selection>
Contains some options the user can choose from. Each option is represented by a button in an exclusive button group.
<selection key="Enum1" title="Please select one"> <option title="value1" >1</option> <option title="value2" >2</option> <option title="value3" >3</option> </selection>
<text>
A text entry with its title next to it.
<text key="Text1" title="Your name:" > </text>
<boolean>
A toggle button representing boolean user choice.
<boolean key="Bool1" title="I agree to the terms"></boolean>
<integer>
A slider through which the user can select a number between the specified min/max range.
<integer key="Integer1" title="Your age:" min="18" max="99"> </integer>
For more details, see the schema of the language: Settings language reference
<?xml version='1.0' encoding='UTF-8'?> <settings> <group title="declexample_group_title"> <text key="Text1" title="declexample_text_title" > </text> <text key="Text2" title="declexample_text_title2" > </text> <selection key="Enum1" title="declexample_value_title"> <option title="declexample_value1" >1</option> <option title="declexample_value2" >2</option> <option title="declexample_value3" >3</option> </selection> </group> <group title="declexample_group_title2"> <boolean key="Bool1" title="declexample_switch_title"> </boolean> <integer key="Integer1" title="declexample_select_title" min="30" max="60"> </integer> </group> </settings>
Copyright © 2010 Nokia Corporation | MeeGo Touch |