Quicklaunch QML porting questions

Sebastian Kügler sebas at kde.org
Thu Jan 19 11:35:15 UTC 2012


Hi Ingomar,

On Wednesday, January 18, 2012 23:32:10 Ingomar Wesp wrote:
> I'm about to start porting the quicklaunch applet to QML. Since I'm just
> getting started with QML and the JavaScript API, I'm still unsure as to
> what's possible, so please bear with me if I'm missing something that's
> completely obvious.
> 
> Judging from what I've read and tried so far, there seem to be two ways
> to go:
> 
> 1) Create a pure QML plasmoid and put most of the logic into a
> dataengine and services (i.e. let each of the dataengine's sources act
> as a model containing the launchers for a quicklaunch applet). This
> approach would allow other applications/applets access to the lists of
> launchers (which might or might not make sense) and it provides for a
> reasonably clean separation of logic and user interface.
> 
> However, the applet itself needs to provide access to dialogs that do
> not seem to be available from the JavaScript API (KOpenWithDialog and
> KPropertiesDialog). Even if it's possible to instantiate them from
> a service (it it?), this seems to be a very bad idea.
> 
> 2) Create a hybrid plasmoid that uses QML for most of the UI and a C++
> QML extension for the parts that I can't do with JS. Considering that I
> need C++ for the two dialogs anyway, maybe supplying the applet
> with a local model is a cleaner approach than using a DataEngine at all
> (since it might not make sense to even provide global access to the
> launchers that are shown in the various applets).
> 
> Maybe there are other options? Anything (apart from the documentation on
> techbase) that should have a look at?

Yes, there is. You can create a dynamically loaded import in C++ as well, and 
this might even be the cleanest solution (it would make it possible to keep 
your plasmoid in pure QML, as long as this plugin is installed, and also makes 
it easy to build other QuickLaunch or so Plasmoids using the same C++ code):

- You load the list of launchers from plasmoid.readConfig()
- You instantiate a "launcher model", which is basically a QList<QObject*> 
  with a custom type representing your launchers (icon, comment, etc.)
- You create a Grid, Flow, List or whatever in QML to display this model

For further reading:
* http://doc.qt.nokia.com/4.8-snapshot/qml-extending.html#object-and-list-
property-types
* http://doc.qt.nokia.com/4.8-snapshot/declarative-tutorials-extending-
chapter6-plugins.html

I'm not saying *THIS IS WHAT YOU WANT*, but have a look at it, and see if it 
makes sense for you...

Cheers,
-- 
sebas

http://www.kde.org | http://vizZzion.org | GPG Key ID: 9119 0EF9


More information about the Plasma-devel mailing list