Lua: Expose setTextInteractionFlags in Label

Change-Id: Ide3598d4be59ba2f7c41ee7153a81952c5ed9775
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Artur Twardy
2024-10-22 17:40:33 +02:00
parent a78dabb626
commit cb92246bba
2 changed files with 31 additions and 3 deletions

View File

@@ -115,9 +115,17 @@ HAS_MEM_FUNC(setCompleter, hasSetCompleter);
HAS_MEM_FUNC(setMinimumHeight, hasSetMinimumHeight); HAS_MEM_FUNC(setMinimumHeight, hasSetMinimumHeight);
HAS_MEM_FUNC(onReturnPressed, hasOnReturnPressed); HAS_MEM_FUNC(onReturnPressed, hasOnReturnPressed);
HAS_MEM_FUNC(onRightSideIconClicked, hasOnRightSideIconClicked); HAS_MEM_FUNC(onRightSideIconClicked, hasOnRightSideIconClicked);
HAS_MEM_FUNC(setTextInteractionFlags, hasSetTextInteractionFlags);
template<class T> template<class T>
void setProperties(std::unique_ptr<T> &item, const sol::table &children, QObject *guard) { void setProperties(std::unique_ptr<T> &item, const sol::table &children, QObject *guard) {
if constexpr (hasSetTextInteractionFlags<T, void (T::*)(Qt::TextInteractionFlags)>::value) {
const auto interactionFlags = children.get<sol::optional<sol::table>>("interactionFlags");
if (interactionFlags) {
item->setTextInteractionFlags(tableToFlags<Qt::TextInteractionFlag>(*interactionFlags));
}
}
if constexpr (hasSetWordWrap<T, void (T::*)(bool)>::value) { if constexpr (hasSetWordWrap<T, void (T::*)(bool)>::value) {
const auto wrap = children.get<sol::optional<bool>>("wordWrap"); const auto wrap = children.get<sol::optional<bool>>("wordWrap");
if (wrap) if (wrap)
@@ -509,6 +517,7 @@ void setupGuiModule()
mirrorEnum(gui, QMetaEnum::fromType<Qt::WidgetAttribute>()); mirrorEnum(gui, QMetaEnum::fromType<Qt::WidgetAttribute>());
mirrorEnum(gui, QMetaEnum::fromType<Qt::WindowType>()); mirrorEnum(gui, QMetaEnum::fromType<Qt::WindowType>());
mirrorEnum(gui, QMetaEnum::fromType<Qt::TextFormat>()); mirrorEnum(gui, QMetaEnum::fromType<Qt::TextFormat>());
mirrorEnum(gui, QMetaEnum::fromType<Qt::TextInteractionFlag>());
gui.new_usertype<Stack>( gui.new_usertype<Stack>(
"Stack", "Stack",

View File

@@ -161,12 +161,17 @@ local pushButton = {}
function gui.PushButton(options) end function gui.PushButton(options) end
---@class Label : Widget ---@class Label : Widget
---@field textFormat? TextFormat The text format enum
---@field wordWrap? bool
---@field text string Returns the content of the Label as string ---@field text string Returns the content of the Label as string
local label = {} local label = {}
---@param options WidgetOptions ---@class (exact) LabelOptions : BaseWidgetOptions
---@param interactionFlags? TextInteractionFlag[]
---@param textFormat? TextFormat The text format enum
---@param wordWrap? bool
gui.labelOptions = {}
---@param options LabelOptions
---@return Label ---@return Label
function gui.Label(options) end function gui.Label(options) end
@@ -239,6 +244,20 @@ 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
--- Enum representing Text interaction flags
---@enum TextInteractionFlag
gui.TextInteractionFlag {
NoTextInteraction = 0,
TextSelectableByMouse = 0,
TextSelectableByKeyboard = 0,
LinksAccessibleByMouse = 0,
LinksAccessibleByKeyboard = 0,
TextEditable = 0,
TextEditorInteraction = TextSelectableByMouse | TextSelectableByKeyboard | TextEditable,
TextBrowserInteraction = TextSelectableByMouse | LinksAccessibleByMouse | LinksAccessibleByKeyboard
}
--- Enum representing text format types --- Enum representing text format types
---@enum TextFormat ---@enum TextFormat
gui.TextFormat = { gui.TextFormat = {