Skip to content
This repository was archived by the owner on Mar 4, 2023. It is now read-only.

Commit d1e76ac

Browse files
committed
completed generator doc
1 parent b613946 commit d1e76ac

File tree

8 files changed

+459
-18
lines changed

8 files changed

+459
-18
lines changed

deploy.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,8 @@
2020
"installs": {
2121
"ProjectTemplate": "Tools/QtCreator/share/qtcreator/templates/wizards/projects/qtmvvm",
2222
"qbs/Qt/settingsgenerator": "Tools/QtCreator/share/qtcreator/qbs/share/qbs/modules/Qt/settingsgenerator"
23-
}
23+
},
24+
"hostbuilds": [
25+
"bin/qsettingsgenerator*"
26+
]
2427
}

doc/Doxyfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,9 @@ EXCLUDE_SYMBOLS = QtMvvm::__helpertypes \
999999
# command).
10001000

10011001
EXAMPLE_PATH = ../examples \
1002-
./snippets
1002+
./snippets \
1003+
../src/settingsconfig \
1004+
../tools/settingsgenerator
10031005

10041006
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
10051007
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and

doc/qsettingsgenerator.dox

+336
Large diffs are not rendered by default.

doc/settingsxml.dox

+27-11
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,24 @@ QtMvvm::ISettingsSetupLoader. The files are read via that service and mapped to
99
QtMvvm::SettingsElements::Setup.
1010

1111
@section settings_xml_translator Translations
12-
All the settings files you have can be easily translated via a standard ts/qm file. In order for
13-
this to work, all you have to do is add the following lines to your pro file:
12+
All the settings files you have can be easily translated via a standard ts/qm file. The following
13+
explains how exactly.
14+
15+
The mvvm core module comes with a special make taget, called `lupdate` that will automatically
16+
run lupdate when your sources change to update the TRANSLATIONS files. To not run this automatically,
17+
call qmake with `qmake CONFIG+=no_auto_lupdate ...`. In both cases, you can always run `make lupdate`
18+
to explicitly update the dependencies.
19+
20+
With this step enabled, the only thing left to do is to add the settings xml file to the translation
21+
targets so it gets included as a source when running the lupdate target. To do so, simply add it
22+
to the `SETTINGS_TRANSLATIONS` qmake variable:
1423

1524
@code{.pro}
16-
QTMVVM_TS_SETTINGS += settings.xml
17-
_never_true_condition: SOURCES += $$files($$PWD/.ts-dummy/*)
18-
PRE_TARGETDEPS += qtmvvm-tsgen #optional
25+
SETTINGS_TRANSLATIONS += settings.xml
1926
@endcode
2027

21-
This will automatically generate a dummy cpp file in the `.ts-dummy` folder for each file
22-
added to the `QTMVVM_TS_SETTINGS` variable. These files contain dummy code that will then be
23-
read by lupdate automatically and added to all your ts files.
28+
This will internally generate a cpp file that is parsed and included in lupdate when running it
29+
via the builtin lupdate target.
2430

2531
@section settings_xml_elements Elements
2632
The possible elements of such a file
@@ -162,6 +168,7 @@ long as for the last two their type is `object`
162168
key | string | <i>Required</i> | no | The key of the property
163169
type | @ref settings_xml_types_type | <i>Required</i> | no | The type of the properties value
164170
tr | bool | `false` | no | Specify whether the properties value (content) should be translated. Does not apply to `list` or `object` types
171+
ztr | bool | `false` | no | Like tr, but does not translate the text, only generate the translation in the ts file
165172

166173

167174
@subsubsection settings_xml_elements_property_elements Content
@@ -185,6 +192,7 @@ same.
185192
--------|-------------------------------|-------------------|---------------|-------------
186193
type | @ref settings_xml_types_type | <i>Required</i> | no | The type of the list element
187194
tr | bool | `false` | no | Specify whether the element value (content) should be translated. Does not apply to `list` or `object` types
195+
ztr | bool | `false` | no | Like tr, but does not translate the text, only generate the translation in the ts file
188196

189197
@subsubsection settings_xml_elements_element_elements Content
190198
The content depend on the `type` attribute. The following tables shows which type leads
@@ -206,9 +214,11 @@ element must be a `<Group>` element (Each element that support includes as one c
206214
marked as primary). It is possible to specify an include element in another included document.
207215

208216
@subsubsection settings_xml_elements_include_attribs Attributes
209-
Name | Type | Default | Translated | Description
210-
------------|-------|-----------|---------------|-------------
211-
optional | bool | `false` | no | An optional include. If the file cannot be found it is skipped instead of aborting with an error
217+
Name | Type | Default | Translated | Description
218+
------------|---------------------------------------|---------------|---------------|-------------
219+
optional | bool | `false` | no | An optional include. If the file cannot be found it is skipped instead of aborting with an error
220+
frontends | @ref settings_xml_types_descriptor | <i>Empty</i> | no | @copybrief QtMvvm::SettingsElements::Entry::frontends
221+
selectors | @ref settings_xml_types_descriptor | <i>Empty</i> | no | @copybrief QtMvvm::SettingsElements::Entry::selectors
212222

213223
@subsubsection settings_xml_elements_include_elements Content
214224
The content of the include element must be a path to an XML file to be read as include. If the
@@ -300,4 +310,10 @@ The following code block is a sample settings XML file. It is the same that is b
300310
the example application.
301311

302312
@include settings.xml
313+
314+
@section settings_xml_xsd The XSD for the settings files
315+
The following file is the XSD the parser operates on. You can use it to verify your settings
316+
xml files.
317+
318+
@include settingsconfig.xsd
303319
*/

doc/snippets/generatortest.xml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Settings name="TestSettings"
3+
prefix="SOME_EXPORT"
4+
baseKey="tests"
5+
scope="DestroyOnAppQuit">
6+
<Include>QtCore/QDateTime</Include>
7+
<Include local="false">QtCore/QUrl</Include>
8+
<Include local="true">testbackend.h</Include>
9+
10+
<Backend class="TestBackend">
11+
<Param type="QString" asStr="true">Test Backend</Param>
12+
<Param type="int">42</Param>
13+
</Backend>
14+
15+
<TypeMapping key="range" type="int"/>
16+
17+
<Node key="emptyNode"/>
18+
<Entry key="emptyEntry"
19+
type="bool"/>
20+
<Entry key="advancedEntry"
21+
type="QString"
22+
qmlGroupKey="qmlAdvancedEntry"
23+
default="Hello World"
24+
tr="true"
25+
trContext="some_context"/>
26+
<Entry key="codeEntry"
27+
type="QUrl">
28+
<Code>QUrl::fromLocalFile(QStringLiteral("/path/to/something"))</Code>
29+
</Entry>
30+
31+
<Node key="parentNode">
32+
<Node key="emptyChildNode"/>
33+
<Node key="fullChildNode">
34+
<Entry key="replaceEntry"
35+
type="range"
36+
default="42"/>
37+
</Node>
38+
<Entry key="parentEntry"
39+
type="bool"
40+
default="true">
41+
<Node key="subNode"/>
42+
<Entry key="nodeWithCodeEntry"
43+
type="int">
44+
<Node key="someNode"/>
45+
<Code>
46+
qRound(42.8)
47+
</Code>
48+
</Entry>
49+
<Entry key="leafEntry"
50+
type="QString"
51+
default="translate me"
52+
tr="true"/>
53+
</Entry>
54+
</Node>
55+
56+
<Entry key="voidEntry"
57+
type="void"/>
58+
<Entry key="variantEntry"
59+
type="QVariant"/>
60+
<Entry key="simpleListEntry"
61+
type="QList&lt;int&gt;">
62+
<Code>{42}</Code>
63+
</Entry>
64+
65+
<ListNode key="listNode">
66+
<Entry key="simpleChild"
67+
type="bool"/>
68+
<Node key="someNode">
69+
<Entry key="deepChild"
70+
type="int"
71+
default="22"/>
72+
<Entry key="deepParent"
73+
type="QString"
74+
default="___">
75+
<Entry key="simpleChild"
76+
type="bool"
77+
default="true"/>
78+
</Entry>
79+
</Node>
80+
<ListNode key="childList">
81+
<Entry key="valueEntry"
82+
type="double"
83+
default="4.2"/>
84+
</ListNode>
85+
</ListNode>
86+
</Settings>

mkspecs/features/qsettingstranslator.prf

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ QSETTINGSTRANSLATOR_DIR = $$QSETTINGSTRANSLATOR_DIR$$SUFFIX
3131
lupdate_trcond_c.variable_out = TRANSLATIONS_CONDITION
3232
lupdate_trcond_c.commands = echo created > ${QMAKE_FILE_OUT}
3333
lupdate_trcond_c.output = $$QSETTINGSTRANSLATOR_DIR/trcond.cpp
34-
lupdate_trcond_c.CONFIG += combine no_link
34+
lupdate_trcond_c.CONFIG += combine no_link explicit_dependencies
3535
QMAKE_EXTRA_COMPILERS += lupdate_trcond_c
3636

3737
lupdate_fakepri_c.name = fakepri ${QMAKE_FILE_IN}

src/mvvmcore/mvvmcore.pro

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ SOURCES += \
4242
settingsconfigloader.cpp
4343

4444
android {
45-
#QT += androidextras
45+
QT += androidextras
4646

4747
HEADERS += \
4848
androidsettingsaccessor.h \

tools/settingsgenerator/qsettingsgenerator.xsd

+1-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@
100100

101101
<xs:complexType name="ListNodeType" qxg:declare="true">
102102
<xs:complexContent>
103-
<xs:extension base="NodeType">
104-
<xs:attribute name="listEntry" type="xs:boolean" default="false" use="optional"/>
105-
</xs:extension>
103+
<xs:extension base="NodeType"/>
106104
</xs:complexContent>
107105
</xs:complexType>
108106

0 commit comments

Comments
 (0)