diff --git a/src/plugins/lua/CMakeLists.txt b/src/plugins/lua/CMakeLists.txt index c7a62e3a8b8..8a3bb96dc11 100644 --- a/src/plugins/lua/CMakeLists.txt +++ b/src/plugins/lua/CMakeLists.txt @@ -4,6 +4,7 @@ add_qtc_plugin(Lua PUBLIC_DEPENDS lua546 sol2 PUBLIC_DEFINES LUA_AVAILABLE SOURCES + wizards/wizards.qrc bindings/action.cpp bindings/async.cpp bindings/core.cpp diff --git a/src/plugins/lua/wizards/luafile/script.lua b/src/plugins/lua/wizards/luafile/script.lua new file mode 100644 index 00000000000..7df869a15e7 --- /dev/null +++ b/src/plugins/lua/wizards/luafile/script.lua @@ -0,0 +1 @@ +print("Hello, World!") diff --git a/src/plugins/lua/wizards/luafile/wizard.json b/src/plugins/lua/wizards/luafile/wizard.json new file mode 100644 index 00000000000..eb1a0863d00 --- /dev/null +++ b/src/plugins/lua/wizards/luafile/wizard.json @@ -0,0 +1,41 @@ +{ + "version": 1, + "supportedProjectTypes": [], + "id": "Q.Lua", + "category": "R.Lua", + "trDescription": "Creates a simple lua file.", + "trDisplayName": "Lua Script", + "trDisplayCategory": "Lua", + "iconText": "ts", + "enabled": "%{JS: value('Plugins').indexOf('Lua') >= 0}", + "options": [ + { + "key": "DefaultSuffix", + "value": "%{JS: Util.preferredSuffix('text/x-lua')}" + } + ], + "pages": [ + { + "trDisplayName": "Location", + "trShortTitle": "Location", + "typeId": "File" + }, + { + "trDisplayName": "Project Management", + "trShortTitle": "Summary", + "typeId": "Summary" + } + ], + "generators": [ + { + "typeId": "File", + "data": [ + { + "source": "script.lua", + "target": "%{JS: Util.fileName(value('TargetPath'), value('DefaultSuffix'))}", + "openInEditor": true + } + ] + } + ] +} diff --git a/src/plugins/lua/wizards/plugin/.luarc.json b/src/plugins/lua/wizards/plugin/.luarc.json new file mode 100644 index 00000000000..00b63f41f20 --- /dev/null +++ b/src/plugins/lua/wizards/plugin/.luarc.json @@ -0,0 +1,9 @@ +{ + "workspace.library": [ + "%{JS: Lua.metaFolder()}" + ], + "hint.paramName": "Literal", + "hint.enable": true, + "hint.await": true, + "hint.arrayIndex": "Disable" +} diff --git a/src/plugins/lua/wizards/plugin/init.lua.tpl b/src/plugins/lua/wizards/plugin/init.lua.tpl new file mode 100644 index 00000000000..2e4203e2c8e --- /dev/null +++ b/src/plugins/lua/wizards/plugin/init.lua.tpl @@ -0,0 +1,7 @@ +local function setup() + print("Hello from Lua!") +end + +return { + setup = setup +} diff --git a/src/plugins/lua/wizards/plugin/plugin.lua.tpl b/src/plugins/lua/wizards/plugin/plugin.lua.tpl new file mode 100644 index 00000000000..9675a2a0051 --- /dev/null +++ b/src/plugins/lua/wizards/plugin/plugin.lua.tpl @@ -0,0 +1,24 @@ +return { + Name = "%{ProjectName}", + Version = "1.0.0", + CompatVersion = "1.0.0", + Vendor = "%{VendorName}", + Copyright = "%{Copyright}", + License = "%{License}", + Category = "My Plugins", + Description = "%{Description}", + Url = "%{Url}", + Experimental = true, + DisabledByDefault = false, + LongDescription = [[ +This plugin provides some functionality. +You can describe it more here. + ]], + Dependencies = { + { Name = "Core", Version = "%{JS: Util.qtCreatorIdeVersion()}", Required = true }, + { Name = "Lua", Version = "%{JS: Util.qtCreatorIdeVersion()}", Required = true }, + }, + setup = function() + require 'init'.setup() + end +} --[[@as QtcPlugin]] diff --git a/src/plugins/lua/wizards/plugin/project.json b/src/plugins/lua/wizards/plugin/project.json new file mode 100644 index 00000000000..f537bf2ea9d --- /dev/null +++ b/src/plugins/lua/wizards/plugin/project.json @@ -0,0 +1,15 @@ +{ + "targets": [ + { + "name": "Qt Creator", + "executable": "%\{IDE:Executable:FilePath\}", + "arguments": [ + "-tcs", + "-load", + "Lua", + "-loadluaplugin", + "%\{ActiveProject:ProjectDirectory\}" + ] + } + ] +} diff --git a/src/plugins/lua/wizards/plugin/wizard.json b/src/plugins/lua/wizards/plugin/wizard.json new file mode 100644 index 00000000000..f854a49a3c1 --- /dev/null +++ b/src/plugins/lua/wizards/plugin/wizard.json @@ -0,0 +1,163 @@ +{ + "version": 1, + "supportedProjectTypes": [ + "Qt4ProjectManager.Qt4Project" + ], + "id": "R.QtCreatorLuaPlugin", + "category": "G.Library", + "trDescription": "Creates a custom Qt Creator Lua plugin.", + "trDisplayName": "Qt Creator Lua Plugin", + "trDisplayCategory": "Library", + "iconText": "LuaP", + "featuresRequired": [ + "QtSupport.Wizards.FeatureQt", + "QtSupport.Wizards.FeatureDesktop" + ], + "enabled": "%{JS: value('Plugins').indexOf('CMakeProjectManager') >= 0}", + "options": [ + { + "key": "ProjectFile", + "value": "%{ProjectDirectory}/.qtcreator/project.json" + }, + { + "key": "PluginNameLower", + "value": "%{JS: value('PluginName').toLowerCase()}" + }, + { + "key": "PluginSpecFile", + "value": "%{JS: Util.fileName(value('PluginName').toLowerCase(), Util.preferredSuffix('text/x-lua'))}" + }, + { + "key": "SrcFileName", + "value": "init.lua" + }, + { + "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 lua plugin." + } + }, + { + "trDisplayName": "Define Project Details", + "trShortTitle": "Details", + "typeId": "Fields", + "data": [ + { + "name": "ClassPageDescription", + "type": "Label", + "data": { + "trText": "Specify details about your custom Qt Creator lua 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" + } + } + ] + }, + { + "trDisplayName": "Kit Selection", + "trShortTitle": "Kits", + "typeId": "Kits", + "enabled": "%{JS: !value('IsSubproject')}", + "data": { + "projectFilePath": "%{ProjectFile}" + } + }, + { + "trDisplayName": "Project Management", + "trShortTitle": "Summary", + "typeId": "Summary" + } + ], + "generators": [ + { + "typeId": "File", + "data": [ + { + "source": "project.json", + "target": "%{ProjectFile}", + "openAsProject": true + }, + { + "source": "init.lua.tpl", + "target": "%{SrcFileName}" + }, + { + "source": ".luarc.json" + }, + { + "source": "plugin.lua.tpl", + "target": "%{PluginSpecFile}", + "openInEditor": true + } + ] + } + ] +} diff --git a/src/plugins/lua/wizards/wizards.qrc b/src/plugins/lua/wizards/wizards.qrc new file mode 100644 index 00000000000..098c2c3f418 --- /dev/null +++ b/src/plugins/lua/wizards/wizards.qrc @@ -0,0 +1,11 @@ + + + luafile/wizard.json + luafile/script.lua + plugin/init.lua.tpl + plugin/plugin.lua.tpl + plugin/project.json + plugin/wizard.json + plugin/.luarc.json + +