forked from qt-creator/qt-creator
Lua: Wizards
Adds a simple lua file wizard, and a lua plugin wizard. Change-Id: I0ea08cdc5eabe7396cb49abd265fce16f5960416 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -4,6 +4,7 @@ add_qtc_plugin(Lua
|
|||||||
PUBLIC_DEPENDS lua546 sol2
|
PUBLIC_DEPENDS lua546 sol2
|
||||||
PUBLIC_DEFINES LUA_AVAILABLE
|
PUBLIC_DEFINES LUA_AVAILABLE
|
||||||
SOURCES
|
SOURCES
|
||||||
|
wizards/wizards.qrc
|
||||||
bindings/action.cpp
|
bindings/action.cpp
|
||||||
bindings/async.cpp
|
bindings/async.cpp
|
||||||
bindings/core.cpp
|
bindings/core.cpp
|
||||||
|
1
src/plugins/lua/wizards/luafile/script.lua
Normal file
1
src/plugins/lua/wizards/luafile/script.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
print("Hello, World!")
|
41
src/plugins/lua/wizards/luafile/wizard.json
Normal file
41
src/plugins/lua/wizards/luafile/wizard.json
Normal file
@@ -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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
9
src/plugins/lua/wizards/plugin/.luarc.json
Normal file
9
src/plugins/lua/wizards/plugin/.luarc.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"workspace.library": [
|
||||||
|
"%{JS: Lua.metaFolder()}"
|
||||||
|
],
|
||||||
|
"hint.paramName": "Literal",
|
||||||
|
"hint.enable": true,
|
||||||
|
"hint.await": true,
|
||||||
|
"hint.arrayIndex": "Disable"
|
||||||
|
}
|
7
src/plugins/lua/wizards/plugin/init.lua.tpl
Normal file
7
src/plugins/lua/wizards/plugin/init.lua.tpl
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
local function setup()
|
||||||
|
print("Hello from Lua!")
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
setup = setup
|
||||||
|
}
|
24
src/plugins/lua/wizards/plugin/plugin.lua.tpl
Normal file
24
src/plugins/lua/wizards/plugin/plugin.lua.tpl
Normal file
@@ -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]]
|
15
src/plugins/lua/wizards/plugin/project.json
Normal file
15
src/plugins/lua/wizards/plugin/project.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"name": "Qt Creator",
|
||||||
|
"executable": "%\{IDE:Executable:FilePath\}",
|
||||||
|
"arguments": [
|
||||||
|
"-tcs",
|
||||||
|
"-load",
|
||||||
|
"Lua",
|
||||||
|
"-loadluaplugin",
|
||||||
|
"%\{ActiveProject:ProjectDirectory\}"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
163
src/plugins/lua/wizards/plugin/wizard.json
Normal file
163
src/plugins/lua/wizards/plugin/wizard.json
Normal file
@@ -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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
11
src/plugins/lua/wizards/wizards.qrc
Normal file
11
src/plugins/lua/wizards/wizards.qrc
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/lua/wizards">
|
||||||
|
<file>luafile/wizard.json</file>
|
||||||
|
<file>luafile/script.lua</file>
|
||||||
|
<file>plugin/init.lua.tpl</file>
|
||||||
|
<file>plugin/plugin.lua.tpl</file>
|
||||||
|
<file>plugin/project.json</file>
|
||||||
|
<file>plugin/wizard.json</file>
|
||||||
|
<file>plugin/.luarc.json</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
Reference in New Issue
Block a user