forked from qt-creator/qt-creator
LUA: Add flat flag for the WidgetOptions in Gui bindings
Change-Id: I4aab77c8c0289734a50eb86b14c8aa01b6e64fa8 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -887,6 +887,11 @@ void PushButton::setIconPath(const Utils::FilePath &iconPath)
|
||||
access(this)->setIcon(icon.icon());
|
||||
}
|
||||
|
||||
void PushButton::setFlat(bool flat)
|
||||
{
|
||||
access(this)->setFlat(flat);
|
||||
}
|
||||
|
||||
void PushButton::onClicked(const std::function<void ()> &func, QObject *guard)
|
||||
{
|
||||
QObject::connect(access(this), &QAbstractButton::clicked, guard, func);
|
||||
|
@@ -291,6 +291,7 @@ public:
|
||||
|
||||
void setText(const QString &);
|
||||
void setIconPath(const Utils::FilePath &);
|
||||
void setFlat(bool);
|
||||
void onClicked(const std::function<void()> &, QObject *guard);
|
||||
};
|
||||
|
||||
|
@@ -101,9 +101,16 @@ HAS_MEM_FUNC(setWindowFlags, hasSetWindowFlags);
|
||||
HAS_MEM_FUNC(setWidgetAttribute, hasSetWidgetAttribute);
|
||||
HAS_MEM_FUNC(setAutoFillBackground, hasSetAutoFillBackground);
|
||||
HAS_MEM_FUNC(setIconPath, hasSetIconPath);
|
||||
HAS_MEM_FUNC(setFlat, hasSetFlat);
|
||||
|
||||
template<class T>
|
||||
void setProperties(std::unique_ptr<T> &item, const sol::table &children, QObject *guard) {
|
||||
if constexpr (hasSetFlat<T, void (T::*)(bool)>::value) {
|
||||
const auto flat = children.get<sol::optional<bool>>("flat");
|
||||
if (flat)
|
||||
item->setFlat(*flat);
|
||||
}
|
||||
|
||||
if constexpr (hasSetIconPath<T, void (T::*)(const Utils::FilePath &)>::value) {
|
||||
const auto iconPath = children.get<sol::optional<Utils::FilePath>>("iconPath");
|
||||
if (iconPath)
|
||||
|
@@ -33,6 +33,7 @@ gui.baseWidgetOptions = {}
|
||||
---@field iconPath? FilePath The path to the icon of the widget, if applicable. Empty or not existent paths set null icon. (see [QIcon](https://doc.qt.io/qt-5/qicon.html#QIcon))
|
||||
---@field text? string The text of the widget, if applicable.
|
||||
---@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.
|
||||
gui.widgetOptions = {}
|
||||
|
||||
|
Reference in New Issue
Block a user