{
    "version": 1,
    "supportedProjectTypes": [ "CMakeProjectManager.CMakeProject" ],
    "id": "R.QtCreatorPlugin",
    "category": "G.Library",
    "trDescription": "Creates a custom Qt Creator plugin.",
    "trDisplayName": "Qt Creator C++ Plugin",
    "trDisplayCategory": "Library",
    "icon": "qtcreatorplugin.png",
    "iconKind": "Themed",
    "featuresRequired": [ "QtSupport.Wizards.FeatureQt", "QtSupport.Wizards.FeatureDesktop" ],
    "enabled": "%{JS: value('Plugins').indexOf('CMakeProjectManager') >= 0}",

    "options":
    [
        { "key": "ProjectFile", "value": "%{ProjectDirectory}/CMakeLists.txt" },
        { "key": "PluginNameLower", "value": "%{JS: value('PluginName').toLowerCase()}"},
        { "key": "PluginJsonFile", "value": "%{JS: Util.fileName(value('PluginName'), 'json.in')}" },
        { "key": "LibraryDefine", "value": "%{JS: Cpp.headerGuard(value('PluginName')) + '_LIBRARY'}" },
        { "key": "LibraryExport", "value": "%{JS: Cpp.headerGuard(value('PluginName')) + '_EXPORT'}" },
        { "key": "SrcFileName", "value": "%{JS: Util.fileName(value('PluginNameLower'), Util.preferredSuffix('text/x-c++src'))}" },
        { "key": "MocFileName", "value": "%{JS: Util.fileName(value('PluginNameLower'), 'moc')}" },
        { "key": "ConstantsHdrFileName", "value": "%{JS: Util.fileName(value('PluginNameLower') + 'constants', Util.preferredSuffix('text/x-c++hdr'))}" },
        { "key": "TrHdrFileName", "value": "%{JS: Util.fileName(value('PluginNameLower') + 'tr', Util.preferredSuffix('text/x-c++hdr'))}" },
        { "key": "CN", "value": "%{JS: Cpp.className(value('PluginName') + 'Plugin')}" },
        { "key": "HasTranslation", "value": "%{JS: value('TsFileName') !== ''}" }
    ],

    "pages":
    [
        {
            "trDisplayName": "Project Location",
            "trShortTitle": "Location",
            "typeId": "Project",
            "data": { "trDescription": "This wizard creates a custom Qt Creator plugin." }
        },
        {
            "trDisplayName": "Define Project Details",
            "trShortTitle": "Details",
            "typeId": "Fields",
            "data":
            [
                {
                    "name": "ClassPageDescription",
                    "type": "Label",
                    "data":
                    {
                        "trText": "Specify details about your custom Qt Creator plugin.",
                        "wordWrap": true
                    }
                },
                {
                    "name": "PluginName",
                    "trDisplayName": "Plugin name:",
                    "mandatory": true,
                    "type": "LineEdit",
                    "data":
                    {
                        "validator": "[a-zA-Z_][a-zA-Z_0-9]*",
                        "text": "%{JS: value('ProjectName').charAt(0).toUpperCase() + value('ProjectName').slice(1)}"
                    }
                },
                {
                    "name": "VendorName",
                    "persistenceKey": "VendorName",
                    "trDisplayName": "Vendor name:",
                    "mandatory": true,
                    "type": "LineEdit",
                    "data":
                    {
                        "trText": "MyCompany"
                    }
                },
                {
                    "name": "Copyright",
                    "trDisplayName": "Copyright:",
                    "mandatory": true,
                    "type": "LineEdit",
                    "data":
                    {
                        "trText": "(C) %{VendorName}"
                    }
                },
                {
                    "name": "License",
                    "trDisplayName": "License:",
                    "mandatory": true,
                    "type": "LineEdit",
                    "data":
                    {
                        "trText": "Put short license information here"
                    }
                },
                {
                    "name": "Description",
                    "trDisplayName": "Description:",
                    "mandatory": true,
                    "type": "LineEdit",
                    "data":
                    {
                        "trText": "Put a short description of your plugin here"
                    }
                },
                {
                    "name": "Url",
                    "persistenceKey": "VendorUrl",
                    "trDisplayName": "URL:",
                    "mandatory": true,
                    "type": "LineEdit",
                    "data":
                    {
                        "text": "https://www.%{JS: encodeURIComponent(value('VendorName').toLowerCase())}.com"
                    }
                },
                {
                    "name": "QtCreatorBuild",
                    "persistenceKey": "QtCreatorBuild",
                    "trDisplayName": "Qt Creator build:",
                    "mandatory": true,
                    "type": "PathChooser",
                    "data":
                    {
                        "kind": "existingDirectory"
                    }
                }
            ]
        },
        {
            "trDisplayName": "Translation File",
            "trShortTitle": "Translation",
            "typeId": "QtTranslation"
        },
        {
            "trDisplayName": "Kit Selection",
            "trShortTitle": "Kits",
            "typeId": "Kits",
            "data": { "projectFilePath": "%{ProjectFile}" }
        },
        {
            "trDisplayName": "Project Management",
            "trShortTitle": "Summary",
            "typeId": "Summary"
        }
    ],
    "generators":
    [
        {
            "typeId": "File",
            "data":
            [
                {
                    "source": "CMakeLists.txt",
                    "openAsProject": true
                },
                {
                    "source": "README.md",
                    "openInEditor": true
                },
                {
                    "source": "github_workflows_build_cmake.yml",
                    "target": ".github/workflows/build_cmake.yml"
                },
                {
                    "source": "github_workflows_README.md",
                    "target": ".github/workflows/README.md"
                },
                {
                    "source": "github_scripts_registerPlugin.js",
                    "target": ".github/scripts/registerPlugin.js"
                },
                {
                    "source": "github_scripts_plugin.json",
                    "target": ".github/scripts/plugin.json"
                },
                {
                    "source": "myplugin.cpp",
                    "target": "%{SrcFileName}"
                },
                {
                    "source": "mypluginconstants.h",
                    "target": "%{ConstantsHdrFileName}"
                },
                {
                    "source": "myplugintr.h",
                    "target": "%{TrHdrFileName}"
                },
                {
                    "source": "MyPlugin.json.in",
                    "target": "%{PluginJsonFile}"
                },
                {
                    "source": "../projects/translation.ts",
                    "target": "%{TsFileName}",
                    "condition": "%{HasTranslation}"
                },
                {
                    "source": "../projects/git.ignore",
                    "target": ".gitignore",
                    "condition": "%{JS: !value('IsSubproject') && value('VersionControl') === 'G.Git'}"
                }
            ]
        }
    ]
}
