KTp::GlobalPresence in QML.
David Edmundson
david at davidedmundson.co.uk
Sun Apr 28 23:10:12 UTC 2013
I plan to convert the presence applet to QML for 0.7.
We need to do this before Plasma Workspace 5, otherwise it won't run.
So we may as well do it now. It also allows us to show a better
tooltip with account state via the AccountsModel.
Should be pretty trivial.
I need to expose the GlobalPresence class to QML, however I'm unsure
on how to do this well.
The problem:
- GlobalPresence deals with KTp::Presence objects for retrieving and
setting current presence
- QML cannot read KTp::Presence objects as they don't inherit from QObject.
Possible solutions:
- Change KTp::Presence to inherit from QObject.
KTp::Presence stores data. Data has no clear parent so should always
be stored with shared pointers, otherwise you get in crazy situations
and things breaking all over the place. QObjects also have a lot of
overhead in creation and should be avoided when we don't need to.
- Make a wrapper class around GlobalPresence that converts
KTp::Presence objects to QVariantMaps
Arbitrary QVariantMaps don't make for very readable code in the QML.
You have to read the C++ code to know how to use an object in QML.
- Use a dataengine / serviceprovider
Basically exactly the same as above, but with 10 times as much code.
We used to have one, it made nwoki go insane and rewrite the whole
thing in C++.
- Modify GlobalPresence to deal with the individual properties.
i.e
setPresenceType(Tp::ConnectionStatus)
setPresenceMessage(QString)
KTp::Presence has convenient methods for i18n'ing words like "online"
and finding the right icon and such. This would lose that, we also
lose a 1-1 mapping with our C++ code, that we're moving towards (a
bit)
- Any opinions/other ideas?
Related:
- I'm also going to need to add methods to open the accounts KCM,
start chats and add contacts to the TelepathyManager QML class. Any
objections?
More information about the KDE-Telepathy
mailing list