Home · All Classes · Main Classes · Deprecated

Settings declarative language

Introduction

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.

Load declarative widgets from meegotouch application

Using a settings language user interface description xml file in an application needs the following steps:

  1. Use MSettingsLanguageParser to parse the xml file and use it to create the MSettingsLanguageBinary which represents the parsed information.

    See also:
    MSettingsLanguageParser::readFrom()
    MSettingsLanguageParser::createSettingsBinary()
  2. 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).

    See also:
    MDataStore
  3. Create the widgets through MSettingsLanguageWidgetFactory, by specifying the above two.

    See also:
    MSettingsLanguageWidgetFactory::createWidget()

Thats it, the widgets are ready, put them onto the page!

Example

    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);

Declarative settings language file format

The format of a settings declarative user interface description is the following:

For more details, see the schema of the language: Settings language reference

Example

<?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