Lua: Bind Gui properties readOnly and markdown

Change-Id: Ib01106c51a70faa091f2e1a3027dc0a561f586c6
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2024-09-19 15:29:50 +02:00
parent af95f81a9b
commit 55c6007bfe

View File

@@ -94,6 +94,8 @@ void constructWidget(std::unique_ptr<T> &widget, const sol::table &children)
HAS_MEM_FUNC(onTextChanged, hasOnTextChanged); HAS_MEM_FUNC(onTextChanged, hasOnTextChanged);
HAS_MEM_FUNC(onClicked, hasOnClicked); HAS_MEM_FUNC(onClicked, hasOnClicked);
HAS_MEM_FUNC(setText, hasSetText); HAS_MEM_FUNC(setText, hasSetText);
HAS_MEM_FUNC(setMarkdown, hasSetMarkdown);
HAS_MEM_FUNC(setReadOnly, hasSetReadOnly);
HAS_MEM_FUNC(setTitle, hasSetTitle); HAS_MEM_FUNC(setTitle, hasSetTitle);
HAS_MEM_FUNC(setValue, hasSetValue); HAS_MEM_FUNC(setValue, hasSetValue);
HAS_MEM_FUNC(setSize, hasSetSize); HAS_MEM_FUNC(setSize, hasSetSize);
@@ -176,7 +178,14 @@ void setProperties(std::unique_ptr<T> &item, const sol::table &children, QObject
} }
} }
if constexpr (hasSetText<T, void (T::*)(const QString &)>::value) { if constexpr (hasSetText<T, void (T::*)(const QString &)>::value) {
item->setText(children.get_or<QString>("text", "")); auto text = children.get<sol::optional<QString>>("text");
if (text)
item->setText(*text);
}
if constexpr (hasSetMarkdown<T, void (T::*)(const QString &)>::value) {
auto markdown = children.get<sol::optional<QString>>("markdown");
if (markdown)
item->setMarkdown(*markdown);
} }
if constexpr (hasSetTitle<T, void (T::*)(const QString &)>::value) { if constexpr (hasSetTitle<T, void (T::*)(const QString &)>::value) {
item->setTitle(children.get_or<QString>("title", "")); item->setTitle(children.get_or<QString>("title", ""));
@@ -186,6 +195,11 @@ void setProperties(std::unique_ptr<T> &item, const sol::table &children, QObject
if (value) if (value)
item->setValue(*value); item->setValue(*value);
} }
if constexpr (hasSetReadOnly<T, void (T::*)(bool)>::value) {
sol::optional<bool> readOnly = children.get<sol::optional<bool>>("readOnly");
if (readOnly)
item->setReadOnly(*readOnly);
}
} }
template<class T> template<class T>