Lua: Add fixedSize to builder property

Change-Id: I5779b91985659899cd17164d91217bce7a5800b9
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Artur Twardy
2024-10-22 15:08:47 +02:00
parent cb92246bba
commit 71a82b32b8
4 changed files with 15 additions and 0 deletions

View File

@@ -709,6 +709,11 @@ void Widget::setSize(int w, int h)
access(this)->resize(w, h);
}
void Widget::setFixedSize(int w, int h)
{
access(this)->setFixedSize(w, h);
}
void Widget::setAutoFillBackground(bool on)
{
access(this)->setAutoFillBackground(on);

View File

@@ -248,6 +248,7 @@ public:
void setAutoFillBackground(bool);
void setLayout(const Layout &layout);
void setSize(int, int);
void setFixedSize(int, int);
void setWindowTitle(const QString &);
void setWindowFlags(Qt::WindowFlags);
void setWidgetAttribute(Qt::WidgetAttribute, bool on);
@@ -523,6 +524,7 @@ QTC_DEFINE_BUILDER_SETTER(autoFillBackground, setAutoFillBackground);
QTC_DEFINE_BUILDER_SETTER(readOnly, setReadOnly);
QTC_DEFINE_BUILDER_SETTER(markdown, setMarkdown);
QTC_DEFINE_BUILDER_SETTER(basePath, setBasePath);
QTC_DEFINE_BUILDER_SETTER(fixedSize, setFixedSize);
// Nesting dispatchers

View File

@@ -116,6 +116,7 @@ HAS_MEM_FUNC(setMinimumHeight, hasSetMinimumHeight);
HAS_MEM_FUNC(onReturnPressed, hasOnReturnPressed);
HAS_MEM_FUNC(onRightSideIconClicked, hasOnRightSideIconClicked);
HAS_MEM_FUNC(setTextInteractionFlags, hasSetTextInteractionFlags);
HAS_MEM_FUNC(setFixedSize, hasSetFixedSize);
template<class T>
void setProperties(std::unique_ptr<T> &item, const sol::table &children, QObject *guard) {
@@ -126,6 +127,12 @@ void setProperties(std::unique_ptr<T> &item, const sol::table &children, QObject
}
}
if constexpr (hasSetFixedSize<T, void (T::*)(int, int)>::value) {
sol::optional<QSize> size = children.get<sol::optional<QSize>>("fixedSize");
if (size)
item->setFixedSize(size->width(), size->height());
}
if constexpr (hasSetWordWrap<T, void (T::*)(bool)>::value) {
const auto wrap = children.get<sol::optional<bool>>("wordWrap");
if (wrap)

View File

@@ -37,6 +37,7 @@ gui.baseWidgetOptions = {}
---@field value? integer The value of the widget, if applicable.
---@field flat? boolean A boolean, representing whether the widget should be flat, if applicable.
---@field [1]? Layout The layout of the widget, if applicable.
---@field fixedSize? integer[] Two integers representing the width and height
gui.widgetOptions = {}
---@param options WidgetOptions