forked from qt-creator/qt-creator
Lua: Add Gui Demo to lua tests
Change-Id: I4b9af6702d425867c5f1f6904d6b939a1cede8e6 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -7,4 +7,5 @@ add_qtc_lua_plugin(luatests
|
|||||||
luatests/tst_aspectcontainer.lua
|
luatests/tst_aspectcontainer.lua
|
||||||
luatests/tst_fetch.lua
|
luatests/tst_fetch.lua
|
||||||
luatests/tst_utils.lua
|
luatests/tst_utils.lua
|
||||||
|
luatests/guidemo.lua
|
||||||
)
|
)
|
||||||
|
23
src/plugins/luatests/luatests/guidemo.lua
Normal file
23
src/plugins/luatests/luatests/guidemo.lua
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
-- Copyright (C) 2024 The Qt Company Ltd.
|
||||||
|
-- SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
|
local Utils = require("Utils")
|
||||||
|
local Gui = require("Gui")
|
||||||
|
|
||||||
|
local function using(tbl)
|
||||||
|
local result = _G
|
||||||
|
for k, v in pairs(tbl) do result[k] = v end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
local function show()
|
||||||
|
--- "using namespace Gui"
|
||||||
|
local _ENV = using(Gui)
|
||||||
|
|
||||||
|
Widget {
|
||||||
|
size = { 400, 300 },
|
||||||
|
Row { "Hello World!" },
|
||||||
|
}:show()
|
||||||
|
end
|
||||||
|
|
||||||
|
return show
|
@@ -64,6 +64,19 @@ local function setup()
|
|||||||
text = "Run lua tests",
|
text = "Run lua tests",
|
||||||
onTrigger = function() a.sync(runTests)() end,
|
onTrigger = function() a.sync(runTests)() end,
|
||||||
})
|
})
|
||||||
|
Action.create("LuaTests.layoutDemo", {
|
||||||
|
text = "Lua Layout Demo",
|
||||||
|
onTrigger = function()
|
||||||
|
local script, err = loadfile(Utils.FilePath.fromUserInput(script_path()):parentDir():resolvePath(
|
||||||
|
"guidemo.lua"):nativePath())
|
||||||
|
if not script then
|
||||||
|
print("Failed to load demo:", err)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
script()()
|
||||||
|
end,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
return { setup = setup }
|
return { setup = setup }
|
||||||
|
Reference in New Issue
Block a user