The way Plasmoids currently create user interfaces for configuration is not really what one would hope it to be. We have set out to fix this for Plasma Workspaces 2 and today after some back and forth between Marco and myself, we are edging closer to what could well be a solution as near perfect as one could hope for. Before showing what we’ve come up with, let me explain how it works right now.
The current system was really designed for components written in C++ and coming from the world of QWidgets. At its most basic, a Plasmoid written in C++ would create a configuration interface “by hand” in the C++ code full of QPushButtons and the like. If they were fancy, they’d use Qt Designer to visually design the interface and then the build system would generate the code from that. If the developer was going for the extra brownie points, they may have used KConfigXT files which describe the configuration data using XML. This too would be converted at build time into C++ and compiled into the C++ library containing the component.
This was ultimately very flexible. The Plasmoid could do whatever it wanted, after all. However, it meant that we required compiled C++ code at some point. This was obviously at odds with the design goal of Plasmoids that came in the form of architecture independent script bundles.
So I wrote a small class that took the KConfigXT XML and parsed it into the same kind of object that the kconfig_compiler helper tool did. We then used Qt’s ability to load Qt Designer files and create user interfaces at runtime and, voila, we had the ability to show a configuration interface from a scripted Plasmoid with zero C++ code.
There were two downsides to this. First, it meant that the developer had to learn how to write a KConfigXT file (Plasmate helps automate that, at least) and how to use Qt Designer. Normally this wouldn’t be too much to ask, but we’re trying to keep the barrier to entry low and the Plasmoid developer had just gone through the trouble of learning QML and/or Javascript to get this far. So this was not great.
The real problem, however, was that the scripted Plasmoid had no ability whatsoever to interact with the configuration interface. It was simply a static thing that got shown to the user on behalf of the Plasmoid by libplasma. This means that if the Plasmoid needed to create widgets on the fly, populate lists or comboboxes with data from the Plasmoid itself, validate data and more .. there was very little it could do. This prevented some Plasmoids from being QML only and forced C++/QML hybrids in some cases simply because of the configuration dialog.
With libplasma2 and Plasma Worskpaces 2 we decided to Do The Right Thing(tm) and see if we could make it possible to write configuration pages in QML. Keep in mind that …read more
Source: FULL ARTICLE at Planet KDE