Receiving signal when creating new Document
-
Dear all,
I'm trying to catch the signal when a new document is created. On my app constructor, I connect to the following slots:
SAMSON::getActiveLayer()->connectDocumentSignalToSlot(this, SB_SLOT(&MyApp::onDocumentEvent)); SAMSON::getActiveDocument()->connectDocumentSignalToSlot(this, SB_SLOT(&MyApp::onDocumentEvent));This way I can catch for example when a new layer is created, or when my document is closed. But this code remains oblivious to the creation of a new document, and thus whenever one is created I am unable to update my signal connections and events coming from the new document are not fetched by my app.
I'm trying to use this to do some operations in my app when loading a custom model thorugh a .sam file (I implemented serialization and unserialization).
Thank you for your help and best regards,
Elisa
-
Dear @Elisa
Here you connect signal to slots for pointers of a current active layer and a current active document. There is no possibility now to listen to an event of the creation of a new document.
Do I understand correctly that you want for your App to do some operations automatically once a .sam file was imported?
What you can do is to create a timer in your App and connect to it a function in which you will be doing something like this:
if(SAMSON::getActiveDocument()->documentSignalIsConnectedToSlot(this, SB_SLOT(&MyApp::onDocumentEvent)) == false) { SAMSON::getActiveDocument()->connectDocumentSignalToSlot(this, SB_SLOT(&MyApp::onDocumentEvent)); }
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login