Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QtCreator License Template for Projects?

QtCreator License Template for Projects?

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
11 Posts 4 Posters 5.5k Views 5 Watching
  • 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.
  • fl0mllF Offline
    fl0mllF Offline
    fl0mll
    wrote on last edited by fl0mll
    #1

    Does anyone have a solution to set a custom license header for any project. Currently I use Tools -> Options -> C++ -> File Naming -> License Template to generate the comment header for all generated files. But sometimes I work on projects with different header templates. So I want to set a custom template file for any project.

    Any ideas?

    ADD:
    I created some custom wizards for my company so I select the license at the wizard.

    U 1 Reply Last reply
    1
    • fl0mllF Offline
      fl0mllF Offline
      fl0mll
      wrote on last edited by fl0mll
      #2

      I took a look at the QtCreator code https://github.com/qtproject/qt-creator/blob/master/src/plugins/cpptools/abstracteditorsupport.cpp. It looks like that nothing is implemented for a solution.

      QString AbstractEditorSupport::licenseTemplate(const QString &file, const QString &className)
      {
          const QString license = Internal::CppFileSettings::licenseTemplate();
          Utils::MacroExpander expander;
          expander.registerVariable("Cpp:License:FileName", tr("The file name."),
                                    [file]() { return Utils::FileName::fromString(file).fileName(); });
          expander.registerVariable("Cpp:License:ClassName", tr("The class name."),
                                    [className]() { return className; });
      
          return Utils::TemplateEngine::processText(&expander, license, 0);
      }
      

      But I think it easy could be integrated. What's the right way to get a information out of the .pro file?

      1. Extend the object Project by method licenseTemplate() -> It should return the path to the license header template file of the project.
      2. Set the licenseTemplate member variable by a variable at the .pro file like LICESENE_TEMPLATE
      LICENSE_TEMPLATE = "~/path-to-the-template-file/template-file.h"
      

      I want to access the LICENSE_TEMPLATE from the .pro file at the AbstractEditorSupport::licenseTemplate() method. Can anyone help me?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Looks like an interesting feature for Qt Creator. That's something you should bring to the Qt Creator mailing list. You'll find there Qt Creator's developers/maintainers. This forum is more user oriented.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        fl0mllF 1 Reply Last reply
        1
        • SGaistS SGaist

          Hi,

          Looks like an interesting feature for Qt Creator. That's something you should bring to the Qt Creator mailing list. You'll find there Qt Creator's developers/maintainers. This forum is more user oriented.

          fl0mllF Offline
          fl0mllF Offline
          fl0mll
          wrote on last edited by
          #4

          @SGaist Thank you for the information. I will post it at the mailling list and if I had time I will implement this feature and submit a pull request on github.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Github is just a mirror, it's not used at all for Qt development.

            The official repositories are on https://code.qt.io

            For submission, you have to go through gerrit.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            fl0mllF 1 Reply Last reply
            1
            • SGaistS SGaist

              Github is just a mirror, it's not used at all for Qt development.

              The official repositories are on https://code.qt.io

              For submission, you have to go through gerrit.

              fl0mllF Offline
              fl0mllF Offline
              fl0mll
              wrote on last edited by
              #6

              @SGaist Thank you! I will try it and post the solution here.

              1 Reply Last reply
              0
              • fl0mllF fl0mll

                Does anyone have a solution to set a custom license header for any project. Currently I use Tools -> Options -> C++ -> File Naming -> License Template to generate the comment header for all generated files. But sometimes I work on projects with different header templates. So I want to set a custom template file for any project.

                Any ideas?

                ADD:
                I created some custom wizards for my company so I select the license at the wizard.

                U Offline
                U Offline
                USchmidt
                wrote on last edited by
                #7

                @fl0mll said in QtCreator License Template for Projects?:

                Does anyone have a solution to set a custom license header for any project. Currently I use Tools -> Options -> C++ -> File Naming -> License Template to generate the comment header for all generated files. But sometimes I work on projects with different header templates. So I want to set a custom template file for any project.

                Any ideas?

                ADD:
                I created some custom wizards for my company so I select the license at the wizard.

                Hi, I am trying to do the same thing but cant find the information on how to set the license file within a wizard.Can you post how you did it?
                Thanks!

                aha_1980A 1 Reply Last reply
                0
                • U USchmidt

                  @fl0mll said in QtCreator License Template for Projects?:

                  Does anyone have a solution to set a custom license header for any project. Currently I use Tools -> Options -> C++ -> File Naming -> License Template to generate the comment header for all generated files. But sometimes I work on projects with different header templates. So I want to set a custom template file for any project.

                  Any ideas?

                  ADD:
                  I created some custom wizards for my company so I select the license at the wizard.

                  Hi, I am trying to do the same thing but cant find the information on how to set the license file within a wizard.Can you post how you did it?
                  Thanks!

                  aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Hi @USchmidt,

                  please see the documentation on how to add custom wizards.

                  Regards

                  Qt has to stay free or it will die.

                  U 1 Reply Last reply
                  0
                  • aha_1980A aha_1980

                    Hi @USchmidt,

                    please see the documentation on how to add custom wizards.

                    Regards

                    U Offline
                    U Offline
                    USchmidt
                    wrote on last edited by
                    #9

                    Hi @aha_1980,
                    thanks, but I know the basics and have some custom wizards in use already, I just dont know how to set the license template file with the wizard.
                    As it says here documentation :

                    In the License template field, you can use predefined wizard variables to specify the path and filename of the license to use in the source and header files.
                    

                    But I cant find the information on which predefined variable to set. What I would like to do is to pick a license text file with the wizard (that part I know how to do) and assign it as the license info for the files created by the wizard.

                    aha_1980A 1 Reply Last reply
                    0
                    • U USchmidt

                      Hi @aha_1980,
                      thanks, but I know the basics and have some custom wizards in use already, I just dont know how to set the license template file with the wizard.
                      As it says here documentation :

                      In the License template field, you can use predefined wizard variables to specify the path and filename of the license to use in the source and header files.
                      

                      But I cant find the information on which predefined variable to set. What I would like to do is to pick a license text file with the wizard (that part I know how to do) and assign it as the license info for the files created by the wizard.

                      aha_1980A Offline
                      aha_1980A Offline
                      aha_1980
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @USchmidt I'd just add some special template headers already containing the license.

                      The predefined variables only refer to one license for now, not for different licenses per project.

                      Btw, the related task is QTCREATORBUG-5783

                      Regards

                      Qt has to stay free or it will die.

                      U 1 Reply Last reply
                      2
                      • aha_1980A aha_1980

                        @USchmidt I'd just add some special template headers already containing the license.

                        The predefined variables only refer to one license for now, not for different licenses per project.

                        Btw, the related task is QTCREATORBUG-5783

                        Regards

                        U Offline
                        U Offline
                        USchmidt
                        wrote on last edited by
                        #11

                        @aha_1980, ok, I was hoping to keep the license text separate, but I guess this will have to do for now.
                        Thanks for your help.

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved