I recently inquired about using the NewFile.addPostNewAction and Andrew provided example code that helped me get it to work for my application.
After seeing how useful that code was, I went looking for similar functions which would add something like the following when a file is saved:
Save.addPreSaveAction()
Save.addPostSaveAction()
But I couldn't find anything. A search on the forum found a very old thread at:
viewtopic.php?f=30&t=2351&p=7668&hilit= ... ve*#p7668
(I didn't know if I should reply to such an old thread or start this one. Let me know if a reply is always preferred.)
That inquiry was basically the same, but the solution offered at the time seems much more complicated than the similar functionality that is now found in NewFile.js regarding post actions for New and Open files.
Also, apparently that old solution didn't handle non-GUI cases where the file is saved.
So, my question is if there has been an update to QCAD that I've not found or anything else which implements functionality similar to NewFile.addPostNewAction, but for actions which are Pre and Post Save for a file?
Thanks in advance.
jcn
Pre and Post Save functions
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Re: Pre and Post Save functions
There's no such high-level notification mechanism for saving / exporting as saving can also happen in the background (auto save).
You'd have to resort to the lower level "listener" mechanism to get notified when a file is saved (i.e. exported). You can find an example implementation here:
https://github.com/qcad/qcad/blob/maste ... istener.js
The interfaces on this level are:
RExportListenerAdapter which triggers signals preExport and postExport
and analogous
RImportListenerAdapter which triggers signals preImport and postImport
You'd have to resort to the lower level "listener" mechanism to get notified when a file is saved (i.e. exported). You can find an example implementation here:
https://github.com/qcad/qcad/blob/maste ... istener.js
The interfaces on this level are:
RExportListenerAdapter which triggers signals preExport and postExport
and analogous
RImportListenerAdapter which triggers signals preImport and postImport
Re: Pre and Post Save functions
OK, thanks.
I will try that approach.
I will try that approach.