A simple extensions consisting of:
- A button in the mail view "File as Expense"
- When clicked it forwards the email to some hardcoded email address.
The whole thing must be an external plugin that is dynamically loaded.
A simple extensions consisting of:
The whole thing must be an external plugin that is dynamically loaded.
Status | Assigned | Task | ||
---|---|---|---|---|
Open | None | T8035 Extensions/Scripting | ||
Resolved | cmollekopf | T8111 Showcase: File as expense extensions |
This has now been implemented and is available from develop. The mechanism consists of two parts:
The extension point in MailViewer.qml:
Row { Kube.ExtensionPoint { extensionPoint: "extensions/mailview" context: {"mail": footer.mail, "subject": footer.subject, "accountId": currentAccount} } }
The ExtensionPoint in the positioner (it's a repeater on top of an extension loading model).
The ExtensionPoint will simply instantiate any components that are installed in the relevant location (as defined by extensionPoint).
The context contains all information that the extension ultimately has available to work with.
Extension implementation in main.qml:
import QtQuick 2.7 import org.kube.framework 1.0 as Kube import org.kube.extensionapi 1.0 Kube.Button { property variant context: {} visible: true activeFocusOnTab: false text: qsTr("File as Expense") onClicked: { ExtensionApi.forwardMail({mail: context.mail, to: ["test1@kolab.org"], subject: "Expense: " + context.subject, accountId: context.accountId}) } }
The extensions main Component must be called main.qml (by convention, otherwise it won't be found).
The extensionapi plugin exposes a dedicated ExtensionApi that we can use to:
Arguably the use of Kube.Button is therefore also not ideal. We could instead separate that into org.kube.controls and declare that ok, or somehow expose the controls through the extension plugin as well (not sure how that would work exactly).