forked from qt-creator/qt-creator
Lua: Add viewportMargins option for supported widgets
Change-Id: If4d6110bd382d459f0e59adcb3159da0f83cea18 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -1134,6 +1134,11 @@ void MarkdownBrowser::setEnableCodeCopyButton(bool enable)
|
||||
access(this)->setEnableCodeCopyButton(enable);
|
||||
}
|
||||
|
||||
void MarkdownBrowser::setViewportMargins(int left, int top, int right, int bottom)
|
||||
{
|
||||
access(this)->setMargins(QMargins(left, top, right, bottom));
|
||||
}
|
||||
|
||||
// Special If
|
||||
|
||||
If::If(
|
||||
|
@@ -460,6 +460,7 @@ public:
|
||||
void setMarkdown(const QString &);
|
||||
void setBasePath(const Utils::FilePath &);
|
||||
void setEnableCodeCopyButton(bool enable);
|
||||
void setViewportMargins(int left, int top, int right, int bottom);
|
||||
};
|
||||
|
||||
// Special
|
||||
|
@@ -115,6 +115,7 @@ CREATE_HAS_FUNC(setFixedSize, QSize())
|
||||
CREATE_HAS_FUNC(setVisible, bool())
|
||||
CREATE_HAS_FUNC(setIcon, Utils::Icon());
|
||||
CREATE_HAS_FUNC(setContentsMargins, int(), int(), int(), int());
|
||||
CREATE_HAS_FUNC(setViewportMargins, int(), int(), int(), int());
|
||||
CREATE_HAS_FUNC(setCursor, Qt::CursorShape())
|
||||
CREATE_HAS_FUNC(setMinimumWidth, int());
|
||||
CREATE_HAS_FUNC(setEnableCodeCopyButton, bool());
|
||||
@@ -128,6 +129,12 @@ void setProperties(std::unique_ptr<T> &item, const sol::table &children, QObject
|
||||
item->setContentsMargins(margins->left(), margins->top(), margins->right(), margins->bottom());
|
||||
}
|
||||
|
||||
if constexpr (has_setViewportMargins<T>) {
|
||||
sol::optional<QMargins> margins = children.get<sol::optional<QMargins>>("viewportMargins"sv);
|
||||
if (margins)
|
||||
item->setViewportMargins(margins->left(), margins->top(), margins->right(), margins->bottom());
|
||||
}
|
||||
|
||||
if constexpr (has_setCursor<T>) {
|
||||
const auto cursor = children.get<sol::optional<Qt::CursorShape>>("cursor"sv);
|
||||
if (cursor)
|
||||
|
@@ -232,6 +232,7 @@ local markdownBrowser = {}
|
||||
|
||||
---@class (exact) MarkdownBrowserOptions : WidgetOptions
|
||||
---@field enableCodeCopyButton? boolean Enable or disable the code copy button
|
||||
---@field viewportMargins? integer[] Four integers representing left, top, right and bottom margins
|
||||
local markdownBrowserOptions = {}
|
||||
|
||||
---@param options MarkdownBrowserOptions
|
||||
|
Reference in New Issue
Block a user