Lua: Fix Gui meta documentation

Change-Id: I0cd897080f5880227d175daf486e8c69386c9aa2
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Marcus Tillmanns
2024-08-20 08:39:25 +02:00
parent 964c8da31a
commit 157af836fd
2 changed files with 71 additions and 45 deletions

View File

@@ -47,7 +47,7 @@ static void processChildren(T *item, const sol::table &children)
item->addItem(stretch); item->addItem(stretch);
} else { } else {
qWarning() << "Incompatible object added to layout item: " << (int) child.get_type() qWarning() << "Incompatible object added to layout item: " << (int) child.get_type()
<< " (expected LayoutItem, Aspect or function returning LayoutItem)"; << " (expected Layout, Aspect or function returning Layout)";
} }
} }
} }

View File

@@ -8,14 +8,29 @@ gui.Object = {}
---The base class of all gui layout classes. ---The base class of all gui layout classes.
---@class Layout : Object ---@class Layout : Object
gui.Layout = {} gui.layout = {}
---The base class of all widget classes, an empty widget itself. ---The base class of all widget classes, an empty widget itself.
---@class Widget : Object ---@class Widget : Object
gui.Widget = {} gui.widget = {}
---@param children Layout ---@alias LayoutChild string|BaseAspect|Layout|Widget|function
---@alias LayoutChildren LayoutChild[]
---@class (exact) WidgetOptions
---@field onTextChanged? function The function to be called when the text of the widget changes, if applicable.
---@field onClicked? function The function to be called when the widget is clicked, if applicable.
---@field text? string The text of the widget, if applicable.
---@field title? string The title of the widget, if applicable.
---@field value? integer The value of the widget, if applicable.
---@field size? integer[] Two integers, representing the width and height of the widget.
---@field windowFlags? WindowType[] The window flags of the widget.
---@field [1]? Layout The layout of the widget, if applicable.
gui.widgetOptions = {}
---@param options WidgetOptions
---@return Widget ---@return Widget
function gui.Widget(options) end
---Show the widget. (see [QWidget::show](https://doc.qt.io/qt-5/qwidget.html#show)) ---Show the widget. (see [QWidget::show](https://doc.qt.io/qt-5/qwidget.html#show))
function gui.widget:show() end function gui.widget:show() end
@@ -27,7 +42,7 @@ function gui.widget:activateWindow() end
---@class Column : Layout ---@class Column : Layout
local column = {} local column = {}
---@param children Layout|string|BaseAspect|function ---@param children LayoutChildren
---@return Column ---@return Column
function gui.Column(children) end function gui.Column(children) end
@@ -35,14 +50,15 @@ function gui.Column(children) end
---@class Group : Widget ---@class Group : Widget
local group = {} local group = {}
---@param options WidgetOptions
---@return Group ---@return Group
function gui.Group(children) end function gui.Group(options) end
---Row layout. ---Row layout.
---@class Row : Layout ---@class Row : Layout
local row = {} local row = {}
---@param children Layout|string|BaseAspect|function ---@param children LayoutChildren
---@return Row ---@return Row
function gui.Row(children) end function gui.Row(children) end
@@ -50,7 +66,7 @@ function gui.Row(children) end
---@class Flow : Layout ---@class Flow : Layout
local flow = {} local flow = {}
---@param children Layout|string|BaseAspect|function ---@param children LayoutChildren
---@return Flow ---@return Flow
function gui.Flow(children) end function gui.Flow(children) end
@@ -58,7 +74,7 @@ function gui.Flow(children) end
---@class Grid : Layout ---@class Grid : Layout
local grid = {} local grid = {}
---@param children Layout|string|BaseAspect|function ---@param children LayoutChildren
---@return Grid ---@return Grid
function gui.Grid(children) end function gui.Grid(children) end
@@ -66,7 +82,7 @@ function gui.Grid(children) end
---@class Form : Layout ---@class Form : Layout
local form = {} local form = {}
---@param children Layout|string|BaseAspect|function ---@param children LayoutChildren
---@return Form ---@return Form
function gui.Form(children) end function gui.Form(children) end
@@ -74,70 +90,80 @@ function gui.Form(children) end
---@class Stack : Widget ---@class Stack : Widget
local stack = {} local stack = {}
---@param children Layout|string|BaseAspect|function ---@param options WidgetOptions
---@return Stack ---@return Stack
function gui.Stack(children) end function gui.Stack(options) end
---A Tab widget. ---A Tab widget.
---@class Tab : Widget ---@class Tab : Widget
local tab = {} local tab = {}
---@param children Layout|string|BaseAspect|function ---@param name string
---@param layout Layout
---@return Tab ---@return Tab
function gui.Tab(children) end function gui.Tab(name, layout) end
---@class (exact) TabOptions
---@field [1] string The name of the tab.
---@field [2] Layout The layout of the tab.
gui.tabOptions = {}
---@param options TabOptions
---@return Tab tab The new tab.
function gui.Tab(options) end
---A Multiline text edit. ---A Multiline text edit.
---@class TextEdit : Widget ---@class TextEdit : Widget
local textEdit = {} local textEdit = {}
---@param children Layout|string|BaseAspect|function ---@param options WidgetOptions
---@return TextEdit ---@return TextEdit
function gui.TextEdit(children) end function gui.TextEdit(options) end
---@class PushButton : Widget ---@class PushButton : Widget
local pushButton = {} local pushButton = {}
---@param children Layout|string|BaseAspect|function ---@param options WidgetOptions
---@return PushButton ---@return PushButton
function gui.PushButton(children) end function gui.PushButton(options) end
---@class Label : LayoutItem ---@class Label : Widget
local label = {} local label = {}
---@param children LayoutItem|string|BaseAspect|function ---@param options WidgetOptions
---@return Label ---@return Label
function gui.Label(children) end function gui.Label(options) end
---@class SpinBox : Widget ---@class SpinBox : Widget
local spinBox = {} local spinBox = {}
---@param children Layout|string|BaseAspect|function ---@param options WidgetOptions
---@return SpinBox ---@return SpinBox
function gui.SpinBox(children) end function gui.SpinBox(options) end
---@class Splitter : Widget ---@class Splitter : Widget
local splitter = {} local splitter = {}
---@param children Layout|string|BaseAspect|function ---@param options WidgetOptions
---@return Splitter ---@return Splitter
function gui.Splitter(children) end function gui.Splitter(options) end
---@class ToolBar : Widget ---@class ToolBar : Widget
local toolBar = {} local toolBar = {}
---@param children Layout|string|BaseAspect|function ---@param options WidgetOptions
---@return ToolBar ---@return ToolBar
function gui.ToolBar(children) end function gui.ToolBar(options) end
---@class TabWidget : Widget ---@class TabWidget : Widget
local tabWidget = {} local tabWidget = {}
---@param children Layout|string|BaseAspect|function ---@param options Tab[]
---@return TabWidget ---@return TabWidget
function gui.TabWidget(children) end function gui.TabWidget(options) end
---@param name string ---@param name string
---@param child Layout|string|BaseAspect|function ---@param child WidgetOptions
---@return TabWidget ---@return TabWidget
function gui.TabWidget(name, child) end function gui.TabWidget(name, child) end
@@ -162,21 +188,6 @@ function gui.normalMargin() end
---Sets the alignment of a Grid layout according to the Form layout rules. ---Sets the alignment of a Grid layout according to the Form layout rules.
function gui.withFormAlignment() end function gui.withFormAlignment() end
---Sets the size of the parent object if possible.
function gui.resize(width, height) end
---Sets the spacing of the gui.
function gui.spacing(spacing) end
---Sets the field growth policy of the gui.
function gui.fieldGrowthPolicy(policy) end
---Sets the onClicked handler of the parent object if possible.
function gui.onClicked(f) end
---Sets the onTextChanged handler of the parent object if possible.
function gui.onTextChanged(f) end
--- Enum representing various window types. --- Enum representing various window types.
---@enum WindowType ---@enum WindowType
gui.WindowType = { gui.WindowType = {
@@ -220,6 +231,14 @@ gui.WindowType = {
WindowFullscreenButtonHint = 0, WindowFullscreenButtonHint = 0,
} }
---@class Space : Layout
gui.space = {}
---Adds a non-strecthable space with size size to the layout.
---@param size integer size in pixels of the space.
---@return Space
function gui.Space(size) end
---@class Span : Layout ---@class Span : Layout
gui.span = {} gui.span = {}
@@ -246,4 +265,11 @@ function gui.Span(col, layout) end
---@param layout Layout The inner layout. ---@param layout Layout The inner layout.
---@return Span ---@return Span
function gui.Span(col, row, layout) end function gui.Span(col, row, layout) end
---@class Stretch : Layout
gui.stretch = {}
---Adds a stretchable space to the layout.
---@param factor integer The factor by which the space should stretch.
function gui.Stretch(factor) end
return gui return gui