forked from qt-creator/qt-creator
Lua: Add bindings for Widget:activateWindow() and windowFlags
Change-Id: I5b3935bfdfe4c182de00891ea06b189a0d439688 Reviewed-by: <lie@spyro-soft.com> Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -711,6 +711,11 @@ void Widget::setWindowTitle(const QString &title)
|
||||
access(this)->setWindowTitle(title);
|
||||
}
|
||||
|
||||
void Widget::setWindowFlags(Qt::WindowFlags flags)
|
||||
{
|
||||
access(this)->setWindowFlags(flags);
|
||||
}
|
||||
|
||||
void Widget::setToolTip(const QString &title)
|
||||
{
|
||||
access(this)->setToolTip(title);
|
||||
@@ -736,6 +741,11 @@ void Widget::setContentsMargins(int left, int top, int right, int bottom)
|
||||
access(this)->setContentsMargins(left, top, right, bottom);
|
||||
}
|
||||
|
||||
void Widget::activateWindow()
|
||||
{
|
||||
access(this)->activateWindow();
|
||||
}
|
||||
|
||||
QWidget *Widget::emerge() const
|
||||
{
|
||||
return access(this);
|
||||
|
@@ -224,10 +224,12 @@ public:
|
||||
void setLayout(const Layout &layout);
|
||||
void setSize(int, int);
|
||||
void setWindowTitle(const QString &);
|
||||
void setWindowFlags(Qt::WindowFlags);
|
||||
void setToolTip(const QString &);
|
||||
void setNoMargins(int = 0);
|
||||
void setNormalMargins(int = 0);
|
||||
void setContentsMargins(int left, int top, int right, int bottom);
|
||||
void activateWindow();
|
||||
};
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT Label : public Widget
|
||||
@@ -421,6 +423,7 @@ QTC_DEFINE_BUILDER_SETTER(title, setTitle)
|
||||
QTC_DEFINE_BUILDER_SETTER(toolTip, setToolTip)
|
||||
QTC_DEFINE_BUILDER_SETTER(windowTitle, setWindowTitle)
|
||||
QTC_DEFINE_BUILDER_SETTER(wordWrap, setWordWrap);
|
||||
QTC_DEFINE_BUILDER_SETTER(windowFlags, setWindowFlags);
|
||||
|
||||
// Nesting dispatchers
|
||||
|
||||
|
@@ -94,10 +94,22 @@ HAS_MEM_FUNC(setText, hasSetText);
|
||||
HAS_MEM_FUNC(setTitle, hasSetTitle);
|
||||
HAS_MEM_FUNC(setValue, hasSetValue);
|
||||
HAS_MEM_FUNC(setSize, hasSetSize);
|
||||
HAS_MEM_FUNC(setWindowFlags, hasSetWindowFlags);
|
||||
|
||||
template<class T>
|
||||
void setProperties(std::unique_ptr<T> &item, const sol::table &children, QObject *guard)
|
||||
{
|
||||
if constexpr (hasSetWindowFlags<T, void (T::*)(Qt::WindowFlags)>::value) {
|
||||
sol::optional<sol::table> windowFlags = children.get<sol::optional<sol::table>>(
|
||||
"windowFlags");
|
||||
if (windowFlags) {
|
||||
Qt::WindowFlags flags;
|
||||
for (const auto &kv : *windowFlags)
|
||||
flags.setFlag(static_cast<Qt::WindowType>(kv.second.as<int>()));
|
||||
item->setWindowFlags(flags);
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (hasSetSize<T, void (T::*)(int, int)>::value) {
|
||||
sol::optional<sol::table> size = children.get<sol::optional<sol::table>>("size");
|
||||
if (size) {
|
||||
@@ -316,9 +328,91 @@ void setupGuiModule()
|
||||
}),
|
||||
"show",
|
||||
&Widget::show,
|
||||
"activateWindow",
|
||||
&Widget::activateWindow,
|
||||
sol::base_classes,
|
||||
sol::bases<Object, Thing>());
|
||||
|
||||
gui["WindowType"] = l.create_table_with(
|
||||
"Widget",
|
||||
Qt::Widget,
|
||||
"Window",
|
||||
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",
|
||||
Qt::WindowType_Mask,
|
||||
"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>(
|
||||
"Stack",
|
||||
sol::call_constructor,
|
||||
|
@@ -16,7 +16,12 @@ gui.Widget = {}
|
||||
|
||||
---@param children Layout
|
||||
---@return Widget
|
||||
function gui.Widget(children) end
|
||||
|
||||
---Show the widget. (see [QWidget::show](https://doc.qt.io/qt-5/qwidget.html#show))
|
||||
function gui.widget:show() end
|
||||
|
||||
---Sets the top-level widget containing this widget to be the active window. (see [QWidget::activateWindow](https://doc.qt.io/qt-5/qwidget.html#activateWindow))
|
||||
function gui.widget:activateWindow() end
|
||||
|
||||
---Column layout
|
||||
---@class Column : Layout
|
||||
@@ -65,7 +70,6 @@ local form = {}
|
||||
---@return Form
|
||||
function gui.Form(children) end
|
||||
|
||||
|
||||
---A stack of multiple widgets.
|
||||
---@class Stack : Widget
|
||||
local stack = {}
|
||||
@@ -136,6 +140,7 @@ function gui.TabWidget(children) end
|
||||
---@param child Layout|string|BaseAspect|function
|
||||
---@return TabWidget
|
||||
function gui.TabWidget(name, child) end
|
||||
|
||||
---A "Line break" in the gui.
|
||||
function gui.br() end
|
||||
|
||||
@@ -172,4 +177,47 @@ function gui.onClicked(f) end
|
||||
---Sets the onTextChanged handler of the parent object if possible.
|
||||
function gui.onTextChanged(f) end
|
||||
|
||||
--- Enum representing various window types.
|
||||
---@enum WindowType
|
||||
gui.WindowType = {
|
||||
Widget = 0,
|
||||
Window = 0,
|
||||
Dialog = 0,
|
||||
Sheet = 0,
|
||||
Drawer = 0,
|
||||
Popup = 0,
|
||||
Tool = 0,
|
||||
ToolTip = 0,
|
||||
SplashScreen = 0,
|
||||
Desktop = 0,
|
||||
SubWindow = 0,
|
||||
ForeignWindow = 0,
|
||||
CoverWindow = 0,
|
||||
WindowType_Mask = 0,
|
||||
MSWindowsFixedSizeDialogHint = 0,
|
||||
MSWindowsOwnDC = 0,
|
||||
BypassWindowManagerHint = 0,
|
||||
X11BypassWindowManagerHint = 0,
|
||||
FramelessWindowHint = 0,
|
||||
WindowTitleHint = 0,
|
||||
WindowSystemMenuHint = 0,
|
||||
WindowMinimizeButtonHint = 0,
|
||||
WindowMaximizeButtonHint = 0,
|
||||
WindowMinMaxButtonsHint = 0,
|
||||
WindowContextHelpButtonHint = 0,
|
||||
WindowShadeButtonHint = 0,
|
||||
WindowStaysOnTopHint = 0,
|
||||
WindowTransparentForInput = 0,
|
||||
WindowOverridesSystemGestures = 0,
|
||||
WindowDoesNotAcceptFocus = 0,
|
||||
MaximizeUsingFullscreenGeometryHint = 0,
|
||||
CustomizeWindowHint = 0,
|
||||
WindowStaysOnBottomHint = 0,
|
||||
WindowCloseButtonHint = 0,
|
||||
MacWindowToolBarButtonHint = 0,
|
||||
BypassGraphicsProxyWidget = 0,
|
||||
NoDropShadowWindowHint = 0,
|
||||
WindowFullscreenButtonHint = 0,
|
||||
}
|
||||
|
||||
return gui
|
||||
|
Reference in New Issue
Block a user