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

View file

@ -44,6 +44,7 @@ public:
static int setWidgetChecked(lua_State *L_p);
static int setWidgetEnabled(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 setWidgetMaximum(lua_State *L_p);
static int setWidgetMinimum(lua_State *L_p);