Lua: Add Gui Demo to lua tests

Change-Id: I4b9af6702d425867c5f1f6904d6b939a1cede8e6
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2024-06-06 07:50:58 +02:00
parent 7e9af008fc
commit 6bfeefbb1b
3 changed files with 37 additions and 0 deletions

View File

@@ -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
) )

View 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

View File

@@ -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 }