Declarative appletscript: last touches
Marco Martin
notmart at gmail.com
Wed Dec 8 23:38:21 CET 2010
Hi all,
since the release is getting near, i want to get the declarative engine as
"right" as possible, since it will be pretty important in the future.
now one of the key features of it is the "fallback chain" for different
profiles, like device targets (and i pretty much wasted an evening looking for
a solution).
depending for now from an environment variable (will have to be smarter in the
future?) the proper main qml file for the ui will be loaded. so far so good.
then is possible to load javascript files with a imilar fallback chain, for
instance it would be possible to do:
import "plasmapackage:/code/utils.js" as Utils
a custon networkaccessmanager does the lookup and looks for the js file, from
the most specific (like, meego, tablet profile) to the most generic.
to load images or other resources is possible to either use the
"plasmapackage://" "protocol" or a form like
plasmoid.file("images", "shadow.svgz")
(tht is not possible to use to load global js files since at that point and
out of the main object plasmoid doesn't exists yet)
third thing: load qml files with the same method would be rather nice for qml
files themselves in the same way as javascript files, but that doesn't work :)
it's only possible to import complete folders, so if from a "specific" folder
to import a more "generic" i have to do some ugly thing like
import "../../generic/ui/"
the above is necessary since is not possible to add an import from c++ (it is
possible to add search paths, but the import directive has always to be
explicit in the qml file)
Now i have some options:
a) leaving it as is, and if someone wants to share some qml files, has to use
those relative paths
b) requiring in the qmldir file in the same folder of the main qml file the
list of all files that are elsewhere in the package filesystem
c) auto generating a qmldir file that lists every qml file of the package, so
that would be enough to do something like
import devicefallback 1.0
each solution kinda suck, but after a wasted evening I'm leaning towards the
first for now (requiring import "../../generic/ui/")
other than that, there are still some issues in the script engine, like if
everything that has been binded is ok (i really feel i could repent some day
for having provided bindings for qgraohcslayouts) if the pi is ok etc.
if you have an idea of what the hell i talked about in this message
(especially Artur and Aaron i would say;) please take a look ;)
Cheers,
Marco Martin
More information about the Plasma-devel
mailing list