add setWidgetImageSize

This commit is contained in:
Syping 2020-05-19 16:15:42 +02:00
parent 85fb61371e
commit 9d045413f9
2 changed files with 85 additions and 58 deletions

View file

@ -97,6 +97,7 @@ void LuaEngineGui::pushClass(lua_State *L_p)
pushFunction(L_p, "setWidgetChecked", setWidgetChecked); pushFunction(L_p, "setWidgetChecked", setWidgetChecked);
pushFunction(L_p, "setWidgetEnabled", setWidgetEnabled); pushFunction(L_p, "setWidgetEnabled", setWidgetEnabled);
pushFunction(L_p, "setWidgetFixed", setWidgetFixed); pushFunction(L_p, "setWidgetFixed", setWidgetFixed);
pushFunction(L_p, "setWidgetImageSize", setWidgetImageSize);
pushFunction(L_p, "setWidgetLayout", setWidgetLayout); pushFunction(L_p, "setWidgetLayout", setWidgetLayout);
pushFunction(L_p, "setWidgetMaximum", setWidgetMaximum); pushFunction(L_p, "setWidgetMaximum", setWidgetMaximum);
pushFunction(L_p, "setWidgetMinimum", setWidgetMinimum); pushFunction(L_p, "setWidgetMinimum", setWidgetMinimum);
@ -584,6 +585,20 @@ int LuaEngineGui::setWidgetFixed(lua_State *L_p)
return 0; return 0;
} }
int LuaEngineGui::setWidgetImageSize(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 3) {
void *pointer = getPointer(L_p, 1);
if (pointer != NULL) {
if (((QObject*)pointer)->inherits("QPushButton")) {
((QPushButton*)pointer)->setIconSize(QSize(getVariant(L_p, 2).toInt(), getVariant(L_p, 3).toInt()));
}
return 0;
}
}
return 0;
}
int LuaEngineGui::setWidgetLayout(lua_State *L_p) int LuaEngineGui::setWidgetLayout(lua_State *L_p)
{ {
if (getArgumentCount(L_p) >= 2) { if (getArgumentCount(L_p) >= 2) {
@ -930,14 +945,16 @@ int LuaEngineGui::createLayout(lua_State *L_p)
QLayout *layoutParent = nullptr; QLayout *layoutParent = nullptr;
if (getArgumentCount(L_p) >= 2) { if (getArgumentCount(L_p) >= 2) {
void *pointer = getPointer(L_p, 2); void *pointer = getPointer(L_p, 2);
if (pointer != NULL && ((QObject*)pointer)->inherits("QMainWindow")) { if (pointer != NULL) {
parent = ((QMainWindow*)pointer)->centralWidget(); if (((QObject*)pointer)->inherits("QMainWindow")) {
} parent = ((QMainWindow*)pointer)->centralWidget();
else if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) { }
parent = (QWidget*)pointer; else if (((QObject*)pointer)->inherits("QWidget")) {
} parent = (QWidget*)pointer;
else if (pointer != NULL && ((QObject*)pointer)->inherits("QLayout")) { }
layoutParent = (QLayout*)pointer; else if (((QObject*)pointer)->inherits("QLayout")) {
layoutParent = (QLayout*)pointer;
}
} }
} }
void *layout; void *layout;
@ -1019,21 +1036,23 @@ int LuaEngineGui::createMenu(lua_State *L_p)
{ {
if (getArgumentCount(L_p) >= 2) { if (getArgumentCount(L_p) >= 2) {
void *pointer = getPointer(L_p, 2); void *pointer = getPointer(L_p, 2);
if (pointer != NULL && ((QObject*)pointer)->inherits("QMenuBar")) { if (pointer != NULL) {
QMenu *menu = new QMenu((QWidget*)pointer); if (((QObject*)pointer)->inherits("QMenuBar")) {
menu->setObjectName(nameForPointer(menu)); QMenu *menu = new QMenu((QWidget*)pointer);
menu->setTitle(getVariant(L_p, 1).toString()); menu->setObjectName(nameForPointer(menu));
((QMenuBar*)pointer)->addAction(menu->menuAction()); menu->setTitle(getVariant(L_p, 1).toString());
pushPointer(L_p, menu); ((QMenuBar*)pointer)->addAction(menu->menuAction());
return 1; pushPointer(L_p, menu);
} return 1;
else if (pointer != NULL && ((QObject*)pointer)->inherits("QMenu")) { }
QMenu *menu = new QMenu((QWidget*)pointer); else if (((QObject*)pointer)->inherits("QMenu")) {
menu->setObjectName(nameForPointer(menu)); QMenu *menu = new QMenu((QWidget*)pointer);
menu->setTitle(getVariant(L_p, 1).toString()); menu->setObjectName(nameForPointer(menu));
((QMenu*)pointer)->addAction(menu->menuAction()); menu->setTitle(getVariant(L_p, 1).toString());
pushPointer(L_p, menu); ((QMenu*)pointer)->addAction(menu->menuAction());
return 1; pushPointer(L_p, menu);
return 1;
}
} }
} }
return 0; return 0;
@ -1058,22 +1077,25 @@ int LuaEngineGui::createMenuEntry(lua_State *L_p)
{ {
if (getArgumentCount(L_p) >= 2) { if (getArgumentCount(L_p) >= 2) {
void *pointer = getPointer(L_p, 2); void *pointer = getPointer(L_p, 2);
if (pointer != NULL && ((QObject*)pointer)->inherits("QMenu")) { if (pointer != NULL) {
QAction *action = new QAction(getVariant(L_p, 1).toString(), (QObject*)pointer); if (((QObject*)pointer)->inherits("QMenu")) {
action->setObjectName(nameForPointer(action)); QAction *action = new QAction(getVariant(L_p, 1).toString(), (QObject*)pointer);
((QMenu*)pointer)->addAction(action); action->setObjectName(nameForPointer(action));
if (getArgumentCount(L_p) >= 3) { ((QMenu*)pointer)->addAction(action);
action->setShortcut(QKeySequence::fromString(getVariant(L_p, 3).toString())); if (getArgumentCount(L_p) >= 3) {
action->setShortcutContext(Qt::ApplicationShortcut); action->setShortcut(QKeySequence::fromString(getVariant(L_p, 3).toString()));
action->setShortcutContext(Qt::ApplicationShortcut);
}
pushPointer(L_p, action);
return 1;
}
else if (((QObject*)pointer)->inherits("QToolBar")) {
QAction *action = new QAction(getVariant(L_p, 1).toString(), (QObject*)pointer);
action->setObjectName(nameForPointer(action));
((QToolBar*)pointer)->addAction(action);
pushPointer(L_p, action);
return 1;
} }
pushPointer(L_p, action);
return 1;
}
else if (pointer != NULL && ((QObject*)pointer)->inherits("QToolBar")) {
QAction *action = new QAction(getVariant(L_p, 1).toString(), (QObject*)pointer);
action->setObjectName(nameForPointer(action));
((QToolBar*)pointer)->addAction(action);
pushPointer(L_p, action);
} }
} }
return 0; return 0;
@ -1083,15 +1105,17 @@ int LuaEngineGui::createMenuSeparator(lua_State *L_p)
{ {
if (getArgumentCount(L_p) >= 1) { if (getArgumentCount(L_p) >= 1) {
void *pointer = getPointer(L_p, 1); void *pointer = getPointer(L_p, 1);
if (pointer != NULL && ((QObject*)pointer)->inherits("QMenu")) { if (pointer != NULL) {
QAction *action = ((QMenu*)pointer)->addSeparator(); if (((QObject*)pointer)->inherits("QMenu")) {
pushPointer(L_p, action); QAction *action = ((QMenu*)pointer)->addSeparator();
return 1; pushPointer(L_p, action);
} return 1;
else if (pointer != NULL && ((QObject*)pointer)->inherits("QToolBar")) { }
QAction *action = ((QToolBar*)pointer)->addSeparator(); else if (((QObject*)pointer)->inherits("QToolBar")) {
pushPointer(L_p, action); QAction *action = ((QToolBar*)pointer)->addSeparator();
return 1; pushPointer(L_p, action);
return 1;
}
} }
} }
return 0; return 0;
@ -1491,17 +1515,19 @@ QWidget* LuaEngineGui::windowForObject(QObject *object)
void LuaEngineGui::lpForPointer(void *pointer, QLayout **layout, QWidget **parent) void LuaEngineGui::lpForPointer(void *pointer, QLayout **layout, QWidget **parent)
{ {
if (pointer != NULL && ((QObject*)pointer)->inherits("QMainWindow")) { if (pointer != NULL) {
*parent = ((QMainWindow*)pointer)->centralWidget(); if (((QObject*)pointer)->inherits("QMainWindow")) {
} *parent = ((QMainWindow*)pointer)->centralWidget();
else if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) { }
*parent = (QWidget*)pointer; else if (((QObject*)pointer)->inherits("QWidget")) {
} *parent = (QWidget*)pointer;
else if (pointer != NULL && ((QObject*)pointer)->inherits("QLayout")) { }
QWidget *widget = windowForObject((QObject*)pointer); else if (((QObject*)pointer)->inherits("QLayout")) {
if (widget != nullptr) { QWidget *widget = windowForObject((QObject*)pointer);
*layout = (QLayout*)pointer; if (widget != nullptr) {
*parent = widget; *layout = (QLayout*)pointer;
*parent = widget;
}
} }
} }
} }

View file

@ -44,6 +44,7 @@ public:
static int setWidgetChecked(lua_State *L_p); static int setWidgetChecked(lua_State *L_p);
static int setWidgetEnabled(lua_State *L_p); static int setWidgetEnabled(lua_State *L_p);
static int setWidgetFixed(lua_State *L_p); static int setWidgetFixed(lua_State *L_p);
static int setWidgetImageSize(lua_State *L_p);
static int setWidgetLayout(lua_State *L_p); static int setWidgetLayout(lua_State *L_p);
static int setWidgetMaximum(lua_State *L_p); static int setWidgetMaximum(lua_State *L_p);
static int setWidgetMinimum(lua_State *L_p); static int setWidgetMinimum(lua_State *L_p);