SAMSON Forum
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • SAMSON Connect
    • Get SAMSON

    Receiving signal when creating new Document

    Apps
    3
    4
    2657
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      Elisa last edited by Elisa

      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

      1 Reply Last reply Reply Quote 0
      • DmitriyMarin
        DmitriyMarin last edited by

        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));
        
        }
        

        Dmitriy,
        The SAMSON Team, https://s-c.io

        1 Reply Last reply Reply Quote 1
        • Stephane
          Stephane last edited by

          Dear @Elisa, we will expose these signals in 0.8.0.

          1 Reply Last reply Reply Quote 0
          • E
            Elisa last edited by

            Thank you both, I will use the timer as a workaround for now.

            Seems 0.8.0 is going to have a lot of interesting changes :)

            1 Reply Last reply Reply Quote 0
            • First post
              Last post