<liclass="level1"><ahref="#settings_xml_types">Attribute and Value types</a><ul><liclass="level2"><ahref="#settings_xml_types_basic">Basic Types</a></li>
<liclass="level1"><ahref="#settings_xml_sample">Sample settings XML file</a></li>
</ul>
</div>
<divclass="textblock"><p>Documentation of the XML format used to create settings uis</p>
<p>This format is used to create settings.xml files to be read by the default XML <aclass="el"href="class_qt_mvvm_1_1_i_settings_setup_loader.html"title="An interface for a generic settings setup loader. ">QtMvvm::ISettingsSetupLoader</a>. The files are read via that service and mapped to <aclass="el"href="namespace_qt_mvvm_1_1_settings_elements.html#struct_qt_mvvm_1_1_settings_elements_1_1_setup"title="The whole settings setup. ">QtMvvm::SettingsElements::Setup</a>.</p>
<p>All the settings files you have can be easily translated via a standard ts/qm file. The following explains how exactly.</p>
<p>The mvvm core module comes with a special make taget, called <code>lupdate</code> that will automatically run lupdate when your sources change to update the TRANSLATIONS files. To not run this automatically, call qmake with <code>qmake CONFIG+=no_auto_lupdate ...</code>. In both cases, you can always run <code>make lupdate</code> to explicitly update the dependencies.</p>
<p>With this step enabled, the only thing left to do is to add the settings xml file to the translation targets so it gets included as a source when running the lupdate target. To do so, simply add it to the <code>SETTINGS_TRANSLATIONS</code> qmake variable:</p>
<divclass="fragment"><divclass="line">SETTINGS_TRANSLATIONS += settings.xml</div></div><!-- fragment --><p>This will internally generate a cpp file that is parsed and included in lupdate when running it via the builtin lupdate target.</p>
<p>The <code><SettingsConfig></code> element must be the root Element of the XML document and is mapped to the <aclass="el"href="namespace_qt_mvvm_1_1_settings_elements.html#struct_qt_mvvm_1_1_settings_elements_1_1_setup"title="The whole settings setup. ">QtMvvm::SettingsElements::Setup</a>.</p>
<tdclass="markdownTableBodyNone">allowSearch </td><tdclass="markdownTableBodyNone">bool </td><tdclass="markdownTableBodyNone"><code>true</code></td><tdclass="markdownTableBodyNone">no </td><tdclass="markdownTableBodyNone">Specifies if the user is allowed to search in the settings. </td></tr>
<tdclass="markdownTableBodyNone">allowRestore </td><tdclass="markdownTableBodyNone">bool </td><tdclass="markdownTableBodyNone"><code>true</code></td><tdclass="markdownTableBodyNone">no </td><tdclass="markdownTableBodyNone">Specifies if the user is allowed to restore the factory defaults. </td></tr>
<p>Can be an arbitrary number of Elements from the following list. However, only one type of element is allowed. If you for example use <code><Entry></code> as first child, all other children must be of the same type as well:</p>
<p>A top level category to organize sections in.</p>
<p>The <code><Category></code> element is mapped to the <aclass="el"href="namespace_qt_mvvm_1_1_settings_elements.html#struct_qt_mvvm_1_1_settings_elements_1_1_category"title="A top level category to organize sections in. ">QtMvvm::SettingsElements::Category</a>.</p>
<tdclass="markdownTableBodyNone">icon </td><tdclass="markdownTableBodyNone">url </td><tdclass="markdownTableBodyNone"><code>"qrc:/de/skycoder42/qtmvvm/icons/settings.svg"</code></td><tdclass="markdownTableBodyNone">no </td><tdclass="markdownTableBodyNone">An icon for the category. </td></tr>
<tdclass="markdownTableBodyNone">tooltip </td><tdclass="markdownTableBodyNone">string </td><tdclass="markdownTableBodyNone"><em>Empty</em></td><tdclass="markdownTableBodyNone">yes </td><tdclass="markdownTableBodyNone">A tooltip to describe what the category is about. </td></tr>
<p>Can be an arbitrary number of Elements from the following list. However, only one type of element is allowed. If you for example use <code><Entry></code> as first child, all other children must be of the same type as well:</p>
<p>A bigger section for different entries and groups.</p>
<p>The <code><Section></code> element is mapped to the <aclass="el"href="namespace_qt_mvvm_1_1_settings_elements.html#struct_qt_mvvm_1_1_settings_elements_1_1_section"title="A bigger section for different entries and groups. ">QtMvvm::SettingsElements::Section</a>.</p>
<tdclass="markdownTableBodyNone">icon </td><tdclass="markdownTableBodyNone">url </td><tdclass="markdownTableBodyNone"><em>Empty</em></td><tdclass="markdownTableBodyNone">no </td><tdclass="markdownTableBodyNone">An icon for the section. </td></tr>
<tdclass="markdownTableBodyNone">tooltip </td><tdclass="markdownTableBodyNone">string </td><tdclass="markdownTableBodyNone"><em>Empty</em></td><tdclass="markdownTableBodyNone">yes </td><tdclass="markdownTableBodyNone">A tooltip to describe what the section is about. </td></tr>
<p>Can be an arbitrary number of Elements from the following list. However, only one type of element is allowed. If you for example use <code><Entry></code> as first child, all other children must be of the same type as well:</p>
<p>The <code><Group></code> element is mapped to the <aclass="el"href="namespace_qt_mvvm_1_1_settings_elements.html#struct_qt_mvvm_1_1_settings_elements_1_1_group"title="A logical group of settings entries. ">QtMvvm::SettingsElements::Group</a>. A special property of the group is, that when the <code>title</code> is not set, the group becomes hidden and instead all entries that are part of the group are simply shown as normal elements in the section, instead of organizing them into subgroups. If the title is empty, the tooltip is ignored, even if set. The descriptors however still apply.</p>
<tdclass="markdownTableBodyNone">tooltip </td><tdclass="markdownTableBodyNone">string </td><tdclass="markdownTableBodyNone"><em>Empty</em></td><tdclass="markdownTableBodyNone">yes </td><tdclass="markdownTableBodyNone">A tooltip to describe what the group is about. </td></tr>
<p>Can be an arbitrary number of Elements from the following list. However, only one type of element is allowed. If you for example use <code><Entry></code> as first child, all other children must be of the same type as well:</p>
<p>An entry in the settings to display and edit a value.</p>
<p>The <code><Entry></code> element is mapped to the <aclass="el"href="namespace_qt_mvvm_1_1_settings_elements.html#struct_qt_mvvm_1_1_settings_elements_1_1_entry"title="An entry in the settings to display and edit a value. ">QtMvvm::SettingsElements::Entry</a>.</p>
<tdclass="markdownTableBodyNone">type </td><tdclass="markdownTableBodyNone"><aclass="el"href="settings_xml.html#settings_xml_types_type">type</a></td><tdclass="markdownTableBodyNone"><code>"QString"</code></td><tdclass="markdownTableBodyNone">no </td><tdclass="markdownTableBodyNone">The input view type (typically the actual data type) to show. </td></tr>
<tdclass="markdownTableBodyNone">title </td><tdclass="markdownTableBodyNone">string </td><tdclass="markdownTableBodyNone"><em>Empty</em></td><tdclass="markdownTableBodyNone">yes </td><tdclass="markdownTableBodyNone">A short title/label of the entry to give it a name. </td></tr>
<tdclass="markdownTableBodyNone">tooltip </td><tdclass="markdownTableBodyNone">string </td><tdclass="markdownTableBodyNone"><em>Empty</em></td><tdclass="markdownTableBodyNone">yes </td><tdclass="markdownTableBodyNone">A tooltip with more detailed information about the entry. </td></tr>
<tdclass="markdownTableBodyNone">default </td><tdclass="markdownTableBodyNone">variant </td><tdclass="markdownTableBodyNone"><em>Invalid</em></td><tdclass="markdownTableBodyNone"><code>trdefault</code></td><tdclass="markdownTableBodyNone">A default value to display in case no value is in the settings yet. </td></tr>
<tdclass="markdownTableBodyNone">trdefault </td><tdclass="markdownTableBodyNone">bool </td><tdclass="markdownTableBodyNone"><code>false</code></td><tdclass="markdownTableBodyNone">no </td><tdclass="markdownTableBodyNone">If set to true, <code>default</code> will be translated. If not set or set to false, it will not be </td></tr>
<p>The <code><SearchKey></code> Element is converted to a string added to the <aclass="el"href="namespace_qt_mvvm_1_1_settings_elements.html#ae02581cca1a57472c9d7303617410377"title="A list of keys to find this entry by when searching. ">QtMvvm::SettingsElements::Entry::searchKeys</a> property. A searchkey can only be a child of an Entry, and all the keys are merged to a list. It's a leaf element and must contain the string that becomes the search key. The contens of the search key will be translated.</p>
<p>The <code><Property></code> Element is an XML description of a generic <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/qvariant.html">QVariant</a> property. Each property gets converted to a <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/qstring.html">QString</a> key and a <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/qvariant.html">QVariant</a> value that then becomes a property of the parent element. Properties can be children of entries, as well as properties and elements, as long as for the last two their type is <code>object</code></p>
<tdclass="markdownTableBodyNone">key </td><tdclass="markdownTableBodyNone">string </td><tdclass="markdownTableBodyNone"><em>Required</em></td><tdclass="markdownTableBodyNone">no </td><tdclass="markdownTableBodyNone">The key of the property </td></tr>
<tdclass="markdownTableBodyNone">type </td><tdclass="markdownTableBodyNone"><aclass="el"href="settings_xml.html#settings_xml_types_type">type</a></td><tdclass="markdownTableBodyNone"><em>Required</em></td><tdclass="markdownTableBodyNone">no </td><tdclass="markdownTableBodyNone">The type of the properties value </td></tr>
<tdclass="markdownTableBodyNone">tr </td><tdclass="markdownTableBodyNone">bool </td><tdclass="markdownTableBodyNone"><code>false</code></td><tdclass="markdownTableBodyNone">no </td><tdclass="markdownTableBodyNone">Specify whether the properties value (content) should be translated. Does not apply to <code>list</code> or <code>object</code> types </td></tr>
<tdclass="markdownTableBodyNone">ztr </td><tdclass="markdownTableBodyNone">bool </td><tdclass="markdownTableBodyNone"><code>false</code></td><tdclass="markdownTableBodyNone">no </td><tdclass="markdownTableBodyNone">Like tr, but does not translate the text, only generate the translation in the ts file </td></tr>
<tdclass="markdownTableBodyNone">list </td><tdclass="markdownTableBodyNone">An arbitrary number of <aclass="el"href="settings_xml.html#settings_xml_elements_element">Element</a> elements </td></tr>
<tdclass="markdownTableBodyNone">object </td><tdclass="markdownTableBodyNone">An arbitrary number of <aclass="el"href="settings_xml.html#settings_xml_elements_property">Property</a> elements </td></tr>
<tdclass="markdownTableBodyNone"><em>Others</em></td><tdclass="markdownTableBodyNone">Has text content. The text content is interpreted as a value of the given type </td></tr>
<p>The <code><Element></code> Element is an XML description of a generic <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/qvariant.html">QVariant</a> list value. A property of type <code>list</code> will have a number of elements as children that are converted to a list of <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/qvariant.html">QVariant</a> values. Each element can be of a different type, but typically they all are of the same.</p>
<tdclass="markdownTableBodyNone">type </td><tdclass="markdownTableBodyNone"><aclass="el"href="settings_xml.html#settings_xml_types_type">type</a></td><tdclass="markdownTableBodyNone"><em>Required</em></td><tdclass="markdownTableBodyNone">no </td><tdclass="markdownTableBodyNone">The type of the list element </td></tr>
<tdclass="markdownTableBodyNone">tr </td><tdclass="markdownTableBodyNone">bool </td><tdclass="markdownTableBodyNone"><code>false</code></td><tdclass="markdownTableBodyNone">no </td><tdclass="markdownTableBodyNone">Specify whether the element value (content) should be translated. Does not apply to <code>list</code> or <code>object</code> types </td></tr>
<tdclass="markdownTableBodyNone">ztr </td><tdclass="markdownTableBodyNone">bool </td><tdclass="markdownTableBodyNone"><code>false</code></td><tdclass="markdownTableBodyNone">no </td><tdclass="markdownTableBodyNone">Like tr, but does not translate the text, only generate the translation in the ts file </td></tr>
<tdclass="markdownTableBodyNone">list </td><tdclass="markdownTableBodyNone">An arbitrary number of <aclass="el"href="settings_xml.html#settings_xml_elements_element">Element</a> elements </td></tr>
<tdclass="markdownTableBodyNone">object </td><tdclass="markdownTableBodyNone">An arbitrary number of <aclass="el"href="settings_xml.html#settings_xml_elements_property">Property</a> elements </td></tr>
<tdclass="markdownTableBodyNone"><em>Others</em></td><tdclass="markdownTableBodyNone">Has text content. The text content is interpreted as a value of the given type </td></tr>
<p>An <code><Include></code> element is a reference to a different file to be included at that point. When the parser reaches an include, it continues to read the included file as if it was a part of the original XML document. Because of that the root element of an included settings file must not be <code><SettingsConfig></code>, but instead the expected primary child of the current parent element. For example, if the include element is a child of a <code><Section></code>, then the root element must be a <code><Group></code> element (Each element that support includes as one child type marked as primary). It is possible to specify an include element in another included document.</p>
<tdclass="markdownTableBodyNone">optional </td><tdclass="markdownTableBodyNone">bool </td><tdclass="markdownTableBodyNone"><code>false</code></td><tdclass="markdownTableBodyNone">no </td><tdclass="markdownTableBodyNone">An optional include. If the file cannot be found it is skipped instead of aborting with an error </td></tr>
<p>The content of the include element must be a path to an XML file to be read as include. If the path is relative, it is resolved relative to the directory of the current file (the one that contains the include directive). It is possible to use a path with file selectors. If the file could not be found, the parser will fail, unless the include is marked as optional.</p>
<h1><aclass="anchor"id="settings_xml_types"></a>
Attribute and Value types</h1>
<p>In the above element descriptions a number of types are specified. Most are very basic types, but some need some more explanation to them.</p>
<tdclass="markdownTableBodyNone">bool </td><tdclass="markdownTableBodyNone">A boolean value. Allowed values are <code>true</code> and <code>false</code></td></tr>
<tdclass="markdownTableBodyNone">variant </td><tdclass="markdownTableBodyNone">A string that is read by C++ as string and then stored as <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/qvariant.html">QVariant</a>. It thus must be a string convertible to the desired type via <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/qvariant.html">QVariant</a></td></tr>
<p>The <code>type</code> type must be a simple string that corresponds to a C++ type name (or special ui type, for entry elements). It defines the actual type of for example the default of the <code><Entry></code> element or the contents of a <code><Property></code> element. Typical values would be:</p>
<li><aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/qstring.html">QString</a> or string</li>
<li><aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/qurl.html">QUrl</a> or url</li>
<li><aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/qdatetime.html">QDateTime</a> or datetime</li>
<p>The type you need depends on what kind of data you want to represent via the XML elements. But remember that all types you use must be convertible from a simple string.</p>
<p>A descripter is a simplified string of a boolean logic statement. It us used for the <code>frontend</code> and <code>selectors</code> attributes of various elements. The general idea is that these descriptors serve as "filters". This allows you to create one xml file for all platforms and frontends, by excluding specific elements for specific configurations. See <aclass="el"href="class_qt_mvvm_1_1_i_settings_setup_loader.html#a75b197a1c259e4a7a23498f594a9ec0c"title="Loads the settings setup from the given file. ">QtMvvm::ISettingsSetupLoader::loadSetup</a>.</p>
<p>The allowed symbols and syntax depend on the attribute the descriptor is used for:</p>
<p>The frontend is the name of the GUI implementation beeing used (For example <code>widgest</code> for the QWidgets based gui, and <code>quick</code> for the <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/qt.html">Qt</a> Quick Controls 2 gui). Must be a string of the following format:</p>
<divclass="fragment"><divclass="line"><frontend>[|<frontend>...]</div></div><!-- fragment --><p>With <code><frontend></code> beeing the name of the frontend the element should be visible for. It's basically a list of allowed frontend as simple string. If the attribute is not specified, the element is visible on all frontends.</p>
<p>The selectors are active file selectors (of the <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/qfileselector.html">QFileSelector</a> class). By specifiying this attribute you can set selectors that must be active for the element to be visible. This can for example be used to show a specific element on one platform only. Must be a string of the following format:</p>
<divclass="fragment"><divclass="line"><selector>[&<selector>...][|<frontend>[&<selector>...]...]</div></div><!-- fragment --><p>With <code><selector></code> beeing the names of the selectors that must be set. It's basically a bunch of or condiditions around and conditions. This is a very reduced boolean logic, but it should be enough to create the desired filters. For example, you may want to show an element only on windows or on android when the material design is used. The resulting string would be: <code>windows|android&material</code>.</p>
<p>The action type is meant as a placeholder for a pressable button. An action edit will simply display a button or similar, and instead of representing a value in the settings, pressing it will trigger <aclass="el"href="class_qt_mvvm_1_1_settings_view_model.html#a3da983a9fab974d1428f757dde675945"title="Is called when an action type edit is pressed. ">QtMvvm::SettingsViewModel::callAction</a>. The Entries <code>key</code> attribute is passed as the first parameter to the method. The parameters can be specified by adding a <code><Property></code> to the entry with the key <code>args</code> and the type <code>object</code>. The property of this object are the elements of the map passed as the second parameter.</p>
<h1><aclass="anchor"id="settings_xml_sample"></a>
Sample settings XML file</h1>
<p>The following code block is a sample settings XML file. It is the same that is beeing used in the example application.</p>