Created attachment 112877 [details] Minimal examples for QML and Javascript The following command prints different things when called from a QML script (X-Plasma-API=declarativescript) or from plain Javascript (X-Plasma-API=javascript): print(Object.keys(KWin)); In QML: [objectName,objectNameChanged,readConfig,readConfig,registerWindow,registerShortcut] In Javascript: "PlacementArea,MovementArea,MaximizeArea,MaximizeFullArea,FullScreenArea,WorkArea,FullArea,ScreenArea,ElectricTop,ElectricTopRight,ElectricRight,ElectricBottomRight,ElectricBottom,ElectricBottomLeft,ElectricLeft,ElectricTopLeft,ELECTRIC_COUNT,ElectricNone" Because of this there is no way to use these enums in QML. I added my testcases as an attachment.
which Qt version are you using?
I am using Qt 5.10.1.
The enums might be available on the workspace object.
It does not seem so (I added workspace to the examples from the attachment), neither in JS nor QML.
The problem is that KWin sets JSEngineGlobalMethodsWrapper as context property but in QML enums are bound to a type and not a specific instance. So KWin would need to qmlRegisterType under an import to make this work. Not sure that import can be under the same name as the context property, so a simple "KWin.PlacementArea" like is done in JS is probably not possible. Another approach would be to add a bunch of CONSTANT int Q_PROPERTYs on the object to make it behave exactly like the JS one. (Also I noticed the class is missing the electric border enum that JS has)
My analysis is slightly different. For JS the WorkspaceWrapper is exported as "KWin", while for QML the JSEngineGlobalMethodsWrapper is exported as KWin. I don't really see a solution to make this work in an API compatible way, which I think is not that much of a problem. We never tried to have JS and QML API compatible.
This issue report is quite old. Can you please confirm, that it still persists with KDE 5.23?
Dear Bug Submitter, This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information as soon as possible and set the bug status as REPORTED. Due to regular bug tracker maintenance, if the bug is still in NEEDSINFO status with no change in 30 days the bug will be closed as RESOLVED > WORKSFORME due to lack of needed information. For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging If you have already provided the requested information, please mark the bug as REPORTED so that the KDE team knows that the bug is ready to be confirmed. Thank you for helping us make KDE software even better for everyone!
This bug has been in NEEDSINFO status with no change for at least 30 days. The bug is now closed as RESOLVED > WORKSFORME due to lack of needed information. For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging Thank you for helping us make KDE software even better for everyone!