forked from qt-creator/qt-creator
Lua: Add Widget Attribute
Change-Id: Iede7d72eb56301980ca5f98c6877c69d240208a7 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -716,6 +716,11 @@ void Widget::setWindowFlags(Qt::WindowFlags flags)
|
|||||||
access(this)->setWindowFlags(flags);
|
access(this)->setWindowFlags(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::setWidgetAttribute(Qt::WidgetAttribute attr, bool on)
|
||||||
|
{
|
||||||
|
access(this)->setAttribute(attr, on);
|
||||||
|
}
|
||||||
|
|
||||||
void Widget::setToolTip(const QString &title)
|
void Widget::setToolTip(const QString &title)
|
||||||
{
|
{
|
||||||
access(this)->setToolTip(title);
|
access(this)->setToolTip(title);
|
||||||
|
@@ -225,6 +225,7 @@ public:
|
|||||||
void setSize(int, int);
|
void setSize(int, int);
|
||||||
void setWindowTitle(const QString &);
|
void setWindowTitle(const QString &);
|
||||||
void setWindowFlags(Qt::WindowFlags);
|
void setWindowFlags(Qt::WindowFlags);
|
||||||
|
void setWidgetAttribute(Qt::WidgetAttribute, bool on);
|
||||||
void setToolTip(const QString &);
|
void setToolTip(const QString &);
|
||||||
void setNoMargins(int = 0);
|
void setNoMargins(int = 0);
|
||||||
void setNormalMargins(int = 0);
|
void setNormalMargins(int = 0);
|
||||||
@@ -425,6 +426,7 @@ QTC_DEFINE_BUILDER_SETTER(toolTip, setToolTip)
|
|||||||
QTC_DEFINE_BUILDER_SETTER(windowTitle, setWindowTitle)
|
QTC_DEFINE_BUILDER_SETTER(windowTitle, setWindowTitle)
|
||||||
QTC_DEFINE_BUILDER_SETTER(wordWrap, setWordWrap);
|
QTC_DEFINE_BUILDER_SETTER(wordWrap, setWordWrap);
|
||||||
QTC_DEFINE_BUILDER_SETTER(windowFlags, setWindowFlags);
|
QTC_DEFINE_BUILDER_SETTER(windowFlags, setWindowFlags);
|
||||||
|
QTC_DEFINE_BUILDER_SETTER(widgetAttribute, setWidgetAttribute);
|
||||||
|
|
||||||
// Nesting dispatchers
|
// Nesting dispatchers
|
||||||
|
|
||||||
|
@@ -8,6 +8,8 @@
|
|||||||
#include <utils/aspects.h>
|
#include <utils/aspects.h>
|
||||||
#include <utils/layoutbuilder.h>
|
#include <utils/layoutbuilder.h>
|
||||||
|
|
||||||
|
#include <QMetaEnum>
|
||||||
|
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -95,6 +97,7 @@ 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);
|
||||||
HAS_MEM_FUNC(setWindowFlags, hasSetWindowFlags);
|
HAS_MEM_FUNC(setWindowFlags, hasSetWindowFlags);
|
||||||
|
HAS_MEM_FUNC(setWidgetAttribute, hasSetWidgetAttribute);
|
||||||
|
|
||||||
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)
|
||||||
@@ -116,6 +119,16 @@ void setProperties(std::unique_ptr<T> &item, const sol::table &children, QObject
|
|||||||
item->setSize(size->width(), size->height());
|
item->setSize(size->width(), size->height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if constexpr (hasSetWidgetAttribute<T, void (T::*)(Qt::WidgetAttribute, bool on)>::value) {
|
||||||
|
sol::optional<sol::table> widgetAttributes = children.get<sol::optional<sol::table>>(
|
||||||
|
"widgetAttributes");
|
||||||
|
if (widgetAttributes) {
|
||||||
|
for (const auto &kv : *widgetAttributes)
|
||||||
|
item->setWidgetAttribute(
|
||||||
|
static_cast<Qt::WidgetAttribute>(kv.first.as<int>()), kv.second.as<bool>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if constexpr (hasOnTextChanged<T, void (T::*)(const QString &)>::value) {
|
if constexpr (hasOnTextChanged<T, void (T::*)(const QString &)>::value) {
|
||||||
sol::optional<sol::protected_function> onTextChanged
|
sol::optional<sol::protected_function> onTextChanged
|
||||||
= children.get<sol::optional<sol::protected_function>>("onTextChanged");
|
= children.get<sol::optional<sol::protected_function>>("onTextChanged");
|
||||||
@@ -369,85 +382,14 @@ void setupGuiModule()
|
|||||||
sol::base_classes,
|
sol::base_classes,
|
||||||
sol::bases<Object, Thing>());
|
sol::bases<Object, Thing>());
|
||||||
|
|
||||||
gui["WindowType"] = l.create_table_with(
|
auto mirrorEnum = [&gui](QMetaEnum metaEnum) {
|
||||||
"Widget",
|
sol::table widgetAttributes = gui.create(metaEnum.name());
|
||||||
Qt::Widget,
|
for (int i = 0; i < metaEnum.keyCount(); ++i)
|
||||||
"Window",
|
widgetAttributes.set(metaEnum.key(i), metaEnum.value(i));
|
||||||
Qt::Window,
|
};
|
||||||
"Dialog",
|
|
||||||
Qt::Dialog,
|
|
||||||
"Sheet",
|
|
||||||
Qt::Sheet,
|
|
||||||
"Drawer",
|
|
||||||
Qt::Drawer,
|
|
||||||
"Popup",
|
|
||||||
Qt::Popup,
|
|
||||||
"Tool",
|
|
||||||
Qt::Tool,
|
|
||||||
"ToolTip",
|
|
||||||
Qt::ToolTip,
|
|
||||||
"SplashScreen",
|
|
||||||
Qt::SplashScreen,
|
|
||||||
"Desktop",
|
|
||||||
Qt::Desktop,
|
|
||||||
"SubWindow",
|
|
||||||
Qt::SubWindow,
|
|
||||||
"ForeignWindow",
|
|
||||||
Qt::ForeignWindow,
|
|
||||||
"CoverWindow",
|
|
||||||
Qt::CoverWindow,
|
|
||||||
|
|
||||||
"WindowType_Mask",
|
mirrorEnum(QMetaEnum::fromType<Qt::WidgetAttribute>());
|
||||||
Qt::WindowType_Mask,
|
mirrorEnum(QMetaEnum::fromType<Qt::WindowType>());
|
||||||
"MSWindowsFixedSizeDialogHint",
|
|
||||||
Qt::MSWindowsFixedSizeDialogHint,
|
|
||||||
"MSWindowsOwnDC",
|
|
||||||
Qt::MSWindowsOwnDC,
|
|
||||||
"BypassWindowManagerHint",
|
|
||||||
Qt::BypassWindowManagerHint,
|
|
||||||
"X11BypassWindowManagerHint",
|
|
||||||
Qt::X11BypassWindowManagerHint,
|
|
||||||
"FramelessWindowHint",
|
|
||||||
Qt::FramelessWindowHint,
|
|
||||||
"WindowTitleHint",
|
|
||||||
Qt::WindowTitleHint,
|
|
||||||
"WindowSystemMenuHint",
|
|
||||||
Qt::WindowSystemMenuHint,
|
|
||||||
"WindowMinimizeButtonHint",
|
|
||||||
Qt::WindowMinimizeButtonHint,
|
|
||||||
"WindowMaximizeButtonHint",
|
|
||||||
Qt::WindowMaximizeButtonHint,
|
|
||||||
"WindowMinMaxButtonsHint",
|
|
||||||
Qt::WindowMinMaxButtonsHint,
|
|
||||||
"WindowContextHelpButtonHint",
|
|
||||||
Qt::WindowContextHelpButtonHint,
|
|
||||||
"WindowShadeButtonHint",
|
|
||||||
Qt::WindowShadeButtonHint,
|
|
||||||
"WindowStaysOnTopHint",
|
|
||||||
Qt::WindowStaysOnTopHint,
|
|
||||||
"WindowTransparentForInput",
|
|
||||||
Qt::WindowTransparentForInput,
|
|
||||||
"WindowOverridesSystemGestures",
|
|
||||||
Qt::WindowOverridesSystemGestures,
|
|
||||||
"WindowDoesNotAcceptFocus",
|
|
||||||
Qt::WindowDoesNotAcceptFocus,
|
|
||||||
"MaximizeUsingFullscreenGeometryHint",
|
|
||||||
Qt::MaximizeUsingFullscreenGeometryHint,
|
|
||||||
|
|
||||||
"CustomizeWindowHint",
|
|
||||||
Qt::CustomizeWindowHint,
|
|
||||||
"WindowStaysOnBottomHint",
|
|
||||||
Qt::WindowStaysOnBottomHint,
|
|
||||||
"WindowCloseButtonHint",
|
|
||||||
Qt::WindowCloseButtonHint,
|
|
||||||
"MacWindowToolBarButtonHint",
|
|
||||||
Qt::MacWindowToolBarButtonHint,
|
|
||||||
"BypassGraphicsProxyWidget",
|
|
||||||
Qt::BypassGraphicsProxyWidget,
|
|
||||||
"NoDropShadowWindowHint",
|
|
||||||
Qt::NoDropShadowWindowHint,
|
|
||||||
"WindowFullscreenButtonHint",
|
|
||||||
Qt::WindowFullscreenButtonHint);
|
|
||||||
|
|
||||||
gui.new_usertype<Stack>(
|
gui.new_usertype<Stack>(
|
||||||
"Stack",
|
"Stack",
|
||||||
|
@@ -17,9 +17,12 @@ gui.widget = {}
|
|||||||
---@alias LayoutChild string|BaseAspect|Layout|Widget|function
|
---@alias LayoutChild string|BaseAspect|Layout|Widget|function
|
||||||
---@alias LayoutChildren LayoutChild[]
|
---@alias LayoutChildren LayoutChild[]
|
||||||
|
|
||||||
|
---@class WidgetAttributeMapT<T>: { [WidgetAttribute]: T }
|
||||||
|
|
||||||
---@class (exact) BaseWidgetOptions
|
---@class (exact) BaseWidgetOptions
|
||||||
---@field size? integer[] Two integers, representing the width and height of the widget.
|
---@field size? integer[] Two integers, representing the width and height of the widget.
|
||||||
---@field windowFlags? WindowType[] The window flags of the widget.
|
---@field windowFlags? WindowType[] The window flags of the widget.
|
||||||
|
---@field widgetAttributes? WidgetAttributeMapT<boolean> The widget attributes of the widget.
|
||||||
gui.baseWidgetOptions = {}
|
gui.baseWidgetOptions = {}
|
||||||
|
|
||||||
---@class (exact) WidgetOptions : BaseWidgetOptions
|
---@class (exact) WidgetOptions : BaseWidgetOptions
|
||||||
@@ -247,6 +250,111 @@ gui.WindowType = {
|
|||||||
WindowFullscreenButtonHint = 0,
|
WindowFullscreenButtonHint = 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
---@enum (key) WidgetAttribute
|
||||||
|
gui.WidgetAttribute = {
|
||||||
|
WA_Disabled = 0,
|
||||||
|
WA_UnderMouse = 0,
|
||||||
|
WA_MouseTracking = 0,
|
||||||
|
WA_OpaquePaintEvent = 0,
|
||||||
|
WA_StaticContents = 0,
|
||||||
|
WA_LaidOut = 0,
|
||||||
|
WA_PaintOnScreen = 0,
|
||||||
|
WA_NoSystemBackground = 0,
|
||||||
|
WA_UpdatesDisabled = 0,
|
||||||
|
WA_Mapped = 0,
|
||||||
|
WA_InputMethodEnabled = 0,
|
||||||
|
WA_WState_Visible = 0,
|
||||||
|
WA_WState_Hidden = 0,
|
||||||
|
WA_ForceDisabled = 0,
|
||||||
|
WA_KeyCompression = 0,
|
||||||
|
WA_PendingMoveEvent = 0,
|
||||||
|
WA_PendingResizeEvent = 0,
|
||||||
|
WA_SetPalette = 0,
|
||||||
|
WA_SetFont = 0,
|
||||||
|
WA_SetCursor = 0,
|
||||||
|
WA_NoChildEventsFromChildren = 0,
|
||||||
|
WA_WindowModified = 0,
|
||||||
|
WA_Resized = 0,
|
||||||
|
WA_Moved = 0,
|
||||||
|
WA_PendingUpdate = 0,
|
||||||
|
WA_InvalidSize = 0,
|
||||||
|
WA_CustomWhatsThis = 0,
|
||||||
|
WA_LayoutOnEntireRect = 0,
|
||||||
|
WA_OutsideWSRange = 0,
|
||||||
|
WA_GrabbedShortcut = 0,
|
||||||
|
WA_TransparentForMouseEvents = 0,
|
||||||
|
WA_PaintUnclipped = 0,
|
||||||
|
WA_SetWindowIcon = 0,
|
||||||
|
WA_NoMouseReplay = 0,
|
||||||
|
WA_DeleteOnClose = 0,
|
||||||
|
WA_RightToLeft = 0,
|
||||||
|
WA_SetLayoutDirection = 0,
|
||||||
|
WA_NoChildEventsForParent = 0,
|
||||||
|
WA_ForceUpdatesDisabled = 0,
|
||||||
|
WA_WState_Created = 0,
|
||||||
|
WA_WState_CompressKeys = 0,
|
||||||
|
WA_WState_InPaintEvent = 0,
|
||||||
|
WA_WState_Reparented = 0,
|
||||||
|
WA_WState_ConfigPending = 0,
|
||||||
|
WA_WState_Polished = 0,
|
||||||
|
WA_WState_OwnSizePolicy = 0,
|
||||||
|
WA_WState_ExplicitShowHide = 0,
|
||||||
|
WA_ShowModal = 0,
|
||||||
|
WA_MouseNoMask = 0,
|
||||||
|
WA_NoMousePropagation = 0,
|
||||||
|
WA_Hover = 0,
|
||||||
|
WA_InputMethodTransparent = 0,
|
||||||
|
WA_QuitOnClose = 0,
|
||||||
|
WA_KeyboardFocusChange = 0,
|
||||||
|
WA_AcceptDrops = 0,
|
||||||
|
WA_DropSiteRegistered = 0,
|
||||||
|
WA_WindowPropagation = 0,
|
||||||
|
WA_NoX11EventCompression = 0,
|
||||||
|
WA_TintedBackground = 0,
|
||||||
|
WA_X11OpenGLOverlay = 0,
|
||||||
|
WA_AlwaysShowToolTips = 0,
|
||||||
|
WA_MacOpaqueSizeGrip = 0,
|
||||||
|
WA_SetStyle = 0,
|
||||||
|
WA_SetLocale = 0,
|
||||||
|
WA_MacShowFocusRect = 0,
|
||||||
|
WA_MacNormalSize = 0,
|
||||||
|
WA_MacSmallSize = 0,
|
||||||
|
WA_MacMiniSize = 0,
|
||||||
|
WA_LayoutUsesWidgetRect = 0,
|
||||||
|
WA_StyledBackground = 0,
|
||||||
|
WA_CanHostQMdiSubWindowTitleBar = 0,
|
||||||
|
WA_MacAlwaysShowToolWindow = 0,
|
||||||
|
WA_StyleSheet = 0,
|
||||||
|
WA_ShowWithoutActivating = 0,
|
||||||
|
WA_X11BypassTransientForHint = 0,
|
||||||
|
WA_NativeWindow = 0,
|
||||||
|
WA_DontCreateNativeAncestors = 0,
|
||||||
|
WA_DontShowOnScreen = 0,
|
||||||
|
WA_X11NetWmWindowTypeDesktop = 0,
|
||||||
|
WA_X11NetWmWindowTypeDock = 0,
|
||||||
|
WA_X11NetWmWindowTypeToolBar = 0,
|
||||||
|
WA_X11NetWmWindowTypeMenu = 0,
|
||||||
|
WA_X11NetWmWindowTypeUtility = 0,
|
||||||
|
WA_X11NetWmWindowTypeSplash = 0,
|
||||||
|
WA_X11NetWmWindowTypeDialog = 0,
|
||||||
|
WA_X11NetWmWindowTypeDropDownMenu = 0,
|
||||||
|
WA_X11NetWmWindowTypePopupMenu = 0,
|
||||||
|
WA_X11NetWmWindowTypeToolTip = 0,
|
||||||
|
WA_X11NetWmWindowTypeNotification = 0,
|
||||||
|
WA_X11NetWmWindowTypeCombo = 0,
|
||||||
|
WA_X11NetWmWindowTypeDND = 0,
|
||||||
|
WA_SetWindowModality = 0,
|
||||||
|
WA_WState_WindowOpacitySet = 0,
|
||||||
|
WA_TranslucentBackground = 0,
|
||||||
|
WA_AcceptTouchEvents = 0,
|
||||||
|
WA_WState_AcceptedTouchBeginEvent = 0,
|
||||||
|
WA_TouchPadAcceptSingleTouchEvents = 0,
|
||||||
|
WA_X11DoNotAcceptFocus = 0,
|
||||||
|
WA_AlwaysStackOnTop = 0,
|
||||||
|
WA_TabletTracking = 0,
|
||||||
|
WA_ContentsMarginsRespectsSafeArea = 0,
|
||||||
|
WA_StyleSheetTarget = 0
|
||||||
|
}
|
||||||
---@class Space : Layout
|
---@class Space : Layout
|
||||||
gui.space = {}
|
gui.space = {}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user