Porting C++ plasmoid and dataengine to plasma5
Simone Gaiarin
simgunz at gmail.com
Wed Jul 13 12:07:54 UTC 2016
Hi all,
time ago I've designed a Plasma 4 plasmoid together with a dataengine to
configure and control a process (redshift).
The structure is the following:
- The plasmoid allow the user to start and stop the process, this is done
by running a servicejob to commmunicate the dataengine to take an action
- The dataengine controls the process (start and stop it) [I need a custom
dataengine and I cannot use the executable dataengine]
- Multiple instances of the plasmoid and the dataengine share the
configuaration via KConfigXT (Singleton) in this way when the user access
the plasmoid configuration this is propagated to the dataengine and synced
with other instances of the plasmoid
Now I want to port this to plasma 5 but I'm facing huge difficulties. I've
managed to port the dataengine, rewrite the CMakeFiles and I've partially
rewritten the apple in QML.
The problem now is how to manage the configuration.
I know that the plasmoid configuration can be accessed via
plasmoid.configuration and that I can map the fields in main.xml to the ui
elements of the config dialog. The problem is how to synchronize this
configuration with the other instances of the plasmoid (each plasmoid has
his own configuration in plasma 5).
How to pass this configuration to the dataengine?
Any idea to do this in a simple way?
I've tried to extend my plasmoid with a C++ plugin so that in C++ I can
still use the old KConfigXT system in order to share a config file between
the plasmoid and the dataengine.
My current solution is pretty ugly but it works. It's the following:
- When the configuration of the plasmoid is edited (I check this throught
the signal userConfiguringChanged) I get the values from
plasmoid.configuration and send it to the plasmoid C++ plugin (with a
custom method writeConfig)
- The plasmoid C++ plugin use KonfigXT to save the configuration and emits
a signal myConfigChanged
- The plasmoid run the service job so that the dataengine can act
- From all the instances of the plasmoid I monitor the dataengine onNewData
signal and when it is catched I read the configuration from the C++ plugin
(with a custom method readConfig) and the plugin read it from disk
In the configuration of all the instances of the plasmoid and the
dataengine one are synchronized all the time. It's overly complicated
though compared to the plasma 4 solution.
Various doubt:
1) The plasmoid configuration system is explained here:
http://aseigo.blogspot.dk/2013/02/elegant-plasmoid-configuration.html. Is
it there any other page of documentation for this?
2) Which is the proper way to extend the QML plasmoid in C++. I've seen two
approaches.
- plasmoid.nativeInterface as suggested
in plasma-framework/templates/cpp-plasmoid/ (<- This should be documented
in techbase, it's quite hidden)
- The other as explained here
http://doc.qt.io/qt-5/qtqml-tutorials-extending-qml-example.html and how
I've seen implemented in many plasmoids
Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20160713/f76cd881/attachment-0001.html>
More information about the Plasma-devel
mailing list