add more widget enabled and visible options

This commit is contained in:
Syping 2020-05-16 17:34:14 +02:00
parent 1823511204
commit 9e2b5acca5
2 changed files with 47 additions and 0 deletions

View file

@ -83,6 +83,8 @@ void LuaEngineGui::pushClass(lua_State *L_p)
pushFunction(L_p, "executeWidget", executeWidget);
pushFunction(L_p, "showWidget", showWidget);
pushFunction(L_p, "isWidgetChecked", isWidgetChecked);
pushFunction(L_p, "isWidgetEnabled", isWidgetEnabled);
pushFunction(L_p, "isWidgetVisible", isWidgetVisible);
pushFunction(L_p, "getWidgetText", getWidgetText);
pushFunction(L_p, "setWidgetChecked", setWidgetChecked);
pushFunction(L_p, "setWidgetEnabled", setWidgetEnabled);
@ -94,6 +96,7 @@ void LuaEngineGui::pushClass(lua_State *L_p)
pushFunction(L_p, "setWidgetSize", setWidgetSize);
pushFunction(L_p, "setWidgetText", setWidgetText);
pushFunction(L_p, "setWidgetValue", setWidgetValue);
pushFunction(L_p, "setWidgetVisible", setWidgetVisible);
pushFunction(L_p, "widgetAddText", widgetAddText);
pushVariant(L_p, "ShowCurrent", 0);
pushVariant(L_p, "ShowNormal", 1);
@ -630,6 +633,19 @@ int LuaEngineGui::setWidgetValue(lua_State *L_p)
return 0;
}
int LuaEngineGui::setWidgetVisible(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 2) {
void *pointer = getPointer(L_p, 1);
if (pointer != NULL) {
if (((QObject*)pointer)->inherits("QWidget")) {
((QWidget*)pointer)->setVisible(getVariant(L_p, 2).toBool());
}
}
}
return 0;
}
int LuaEngineGui::layoutAddLayout(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 2) {
@ -1170,6 +1186,34 @@ int LuaEngineGui::isWidgetChecked(lua_State *L_p)
return 0;
}
int LuaEngineGui::isWidgetEnabled(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 1) {
void *pointer = getPointer(L_p, 1);
if (pointer != NULL) {
if (((QObject*)pointer)->inherits("QWidget")) {
pushVariant(L_p, ((QWidget*)pointer)->isEnabled());
return 1;
}
}
}
return 0;
}
int LuaEngineGui::isWidgetVisible(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 1) {
void *pointer = getPointer(L_p, 1);
if (pointer != NULL) {
if (((QObject*)pointer)->inherits("QWidget")) {
pushVariant(L_p, ((QWidget*)pointer)->isVisible());
return 1;
}
}
}
return 0;
}
int LuaEngineGui::getWindow(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 1) {

View file

@ -50,6 +50,7 @@ public:
static int setWidgetSize(lua_State *L_p);
static int setWidgetText(lua_State *L_p);
static int setWidgetValue(lua_State *L_p);
static int setWidgetVisible(lua_State *L_p);
static int layoutAddLayout(lua_State *L_p);
static int layoutAddWidget(lua_State *L_p);
static int widgetAddText(lua_State *L_p);
@ -76,6 +77,8 @@ public:
static int createToolButton(lua_State *L_p);
static int createWidgetTab(lua_State *L_p);
static int isWidgetChecked(lua_State *L_p);
static int isWidgetEnabled(lua_State *L_p);
static int isWidgetVisible(lua_State *L_p);
static int getWidgetText(lua_State *L_p);
static int getWindow(lua_State *L_p);