Extending Qt Bridge
January 09, 2020 by Vikas Pachdha | Comments
APIs
Following APIs can be defined in the JSX file to customise or extend the Qt Bridge behaviour.
-
preExport(documentInstance)
The preExport(...) API is called before the PSD document is exported. The document instance is sent as an argument. The user can make changes to the document and, if required, revert those changes once the export is done by defining postExport(...) API.
Details about Photoshop object model are available at https://www.adobe.com/devnet/photoshop/scripting.html
-
postExport(documentInstance)
The postExport(...) API is called after the PSD document is exported. The document instance is sent as an argument. The user can make changes to the document instance. For example you might want to revert the changes made to the document in the preExport(...) API.
-
customQmlId(generatedQmlId, psdLayerInstance)
The API customQmlId(...) is called every time a default QML id is generated for a PSD layer and user can return the QML id to be assigned to the layer. The parameter generatedQmlId is the default QML id generated by the Qt Bridge plugin for the layer and the parameter layerInstance is the PSD layer object.
Note: Return null to use the default generated QML id.
Example override JSX:
The following script logs the export start and finish of the exported PSD document to a export.log file inside the home directory. The QML Ids are prefixed with "m_" and the document and layer ids are removed.
myCustomScript.jsx
var logFile = null preExport = function (documentInstance) { if (openLogFile("~/export.log")) { var date = new Date(); logFile.writeln(date + ": Exporting: " + documentInstance.name); } } postExport = function (documentInstance) { if (logFile) { var date = new Date(); logFile.writeln(date + ": Exporting done: " + documentInstance.name); logFile.close(); } } customDefaultQmlId = function(generatedQmlId, psdLayerInstance) { return "m_" + generatedQmlId.replace(/_[0-9]*_[0-9]*$/g, ""); } function openLogFile(path) { logFile = new File(path); var fileCreated = false; return logFile.open("w"); }
Report bugs and suggestions at https://bugreports.qt.io/projects/QDS/
Blog Topics:
Comments
Subscribe to our newsletter
Subscribe Newsletter
Try Qt 6.8 Now!
Download the latest release here: www.qt.io/download.
Qt 6.8 release focuses on technology trends like spatial computing & XR, complex data visualization in 2D & 3D, and ARM-based development for desktop.
We're Hiring
Check out all our open positions here and follow us on Instagram to see what it's like to be #QtPeople.