Lua: Add Widget autoFillBackground

Change-Id: I132f6ba374318dc7eec33fc141aa60a4fc64116c
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: <lie@spyro-soft.com>
This commit is contained in:
Marcus Tillmanns
2024-08-22 14:48:43 +02:00
parent 81212f8384
commit 25e5ab9426
4 changed files with 16 additions and 0 deletions

View File

@@ -701,6 +701,11 @@ void Widget::setSize(int w, int h)
access(this)->resize(w, h);
}
void Widget::setAutoFillBackground(bool on)
{
access(this)->setAutoFillBackground(on);
}
void Widget::setLayout(const Layout &layout)
{
access(this)->setLayout(access(&layout));

View File

@@ -221,6 +221,7 @@ public:
QWidget *emerge() const;
void show();
void setAutoFillBackground(bool);
void setLayout(const Layout &layout);
void setSize(int, int);
void setWindowTitle(const QString &);
@@ -427,6 +428,7 @@ QTC_DEFINE_BUILDER_SETTER(windowTitle, setWindowTitle)
QTC_DEFINE_BUILDER_SETTER(wordWrap, setWordWrap);
QTC_DEFINE_BUILDER_SETTER(windowFlags, setWindowFlags);
QTC_DEFINE_BUILDER_SETTER(widgetAttribute, setWidgetAttribute);
QTC_DEFINE_BUILDER_SETTER(autoFillBackground, setAutoFillBackground);
// Nesting dispatchers

View File

@@ -98,6 +98,7 @@ HAS_MEM_FUNC(setValue, hasSetValue);
HAS_MEM_FUNC(setSize, hasSetSize);
HAS_MEM_FUNC(setWindowFlags, hasSetWindowFlags);
HAS_MEM_FUNC(setWidgetAttribute, hasSetWidgetAttribute);
HAS_MEM_FUNC(setAutoFillBackground, hasSetAutoFillBackground);
template<class T>
void setProperties(std::unique_ptr<T> &item, const sol::table &children, QObject *guard)
@@ -129,6 +130,13 @@ void setProperties(std::unique_ptr<T> &item, const sol::table &children, QObject
}
}
if constexpr (hasSetAutoFillBackground<T, void (T::*)(bool)>::value) {
sol::optional<bool> autoFillBackground = children.get<sol::optional<bool>>(
"autoFillBackground");
if (autoFillBackground)
item->setAutoFillBackground(*autoFillBackground);
}
if constexpr (hasOnTextChanged<T, void (T::*)(const QString &)>::value) {
sol::optional<sol::protected_function> onTextChanged
= children.get<sol::optional<sol::protected_function>>("onTextChanged");

View File

@@ -23,6 +23,7 @@ gui.widget = {}
---@field size? integer[] Two integers, representing the width and height of the widget.
---@field windowFlags? WindowType[] The window flags of the widget.
---@field widgetAttributes? WidgetAttributeMapT<boolean> The widget attributes of the widget.
---@field autoFillBackground? boolean A boolean, representing whether the widget should automatically fill its background.
gui.baseWidgetOptions = {}
---@class (exact) WidgetOptions : BaseWidgetOptions