[Development] Settings API for QML
Thiago Macieira
thiago.macieira at intel.com
Wed Dec 12 00:30:25 CET 2012
On terça-feira, 11 de dezembro de 2012 15.10.18, Alan Alpert wrote:
> The two-way binding would be tricky. You don't have a reference to the
> property and I'd prefer this not be baked into the language.
>
> But here's another way of doing roughly that:
> Rectangle {
> Persistent.property("width", 400, "application.width");
> Persistent.property("height");//Last value is the path to
> store/retrieve from, auto-chosen if left blank. Leave out default and
> you get 0/null/""
> Persistent.properties: [ ["height",400], ["width",400,
> "application.width"] ] //Another possible attached property syntax.
> }
>
> The "Persistent" attached property knows which item it's attached to
> and the property name, so it can handle everything itself. Like it
> sets the property on startup and watches the change signal for when to
> update the persistent data (or just gets it again when it dies).
Please forgive me my lack of QML-fu here. What I'd like to have if I were
coding such an application would be something like:
- load an element of type PersistentSettings or something
- declare a list of property names, their types and their settings paths
this is where I don't know the QML syntax
Then I should be able to use and modify the properties via
settings.propertyname. If the setting is modified, it might get saved at some
point. Moreover, if the policy is such that the setting is updated
synchronously from the backend, the application might react immediately to the
setting changing (à la GNOME and Mac OS X).
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20121211/66dac3dc/attachment.sig>
More information about the Development
mailing list