From 25e5ab942685cbf3c20ba935a6cede8b3596d55a Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Thu, 22 Aug 2024 14:48:43 +0200 Subject: [PATCH] Lua: Add Widget autoFillBackground Change-Id: I132f6ba374318dc7eec33fc141aa60a4fc64116c Reviewed-by: Cristian Adam Reviewed-by: --- src/libs/utils/layoutbuilder.cpp | 5 +++++ src/libs/utils/layoutbuilder.h | 2 ++ src/plugins/lua/bindings/gui.cpp | 8 ++++++++ src/plugins/lua/meta/gui.lua | 1 + 4 files changed, 16 insertions(+) diff --git a/src/libs/utils/layoutbuilder.cpp b/src/libs/utils/layoutbuilder.cpp index d52f4ac6ab4..f31f4a96d0d 100644 --- a/src/libs/utils/layoutbuilder.cpp +++ b/src/libs/utils/layoutbuilder.cpp @@ -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)); diff --git a/src/libs/utils/layoutbuilder.h b/src/libs/utils/layoutbuilder.h index d1d34f05784..d041d6120d2 100644 --- a/src/libs/utils/layoutbuilder.h +++ b/src/libs/utils/layoutbuilder.h @@ -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 diff --git a/src/plugins/lua/bindings/gui.cpp b/src/plugins/lua/bindings/gui.cpp index 106d4ab8ffd..a5af280559e 100644 --- a/src/plugins/lua/bindings/gui.cpp +++ b/src/plugins/lua/bindings/gui.cpp @@ -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 void setProperties(std::unique_ptr &item, const sol::table &children, QObject *guard) @@ -129,6 +130,13 @@ void setProperties(std::unique_ptr &item, const sol::table &children, QObject } } + if constexpr (hasSetAutoFillBackground::value) { + sol::optional autoFillBackground = children.get>( + "autoFillBackground"); + if (autoFillBackground) + item->setAutoFillBackground(*autoFillBackground); + } + if constexpr (hasOnTextChanged::value) { sol::optional onTextChanged = children.get>("onTextChanged"); diff --git a/src/plugins/lua/meta/gui.lua b/src/plugins/lua/meta/gui.lua index 21e69449c1f..0bf3c54dc06 100644 --- a/src/plugins/lua/meta/gui.lua +++ b/src/plugins/lua/meta/gui.lua @@ -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 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