mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-12-22 11:55:29 +01:00
add setWidgetImageSize
This commit is contained in:
parent
85fb61371e
commit
9d045413f9
2 changed files with 85 additions and 58 deletions
|
@ -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,16 +945,18 @@ 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")) {
|
||||
if (pointer != NULL) {
|
||||
if (((QObject*)pointer)->inherits("QMainWindow")) {
|
||||
parent = ((QMainWindow*)pointer)->centralWidget();
|
||||
}
|
||||
else if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
||||
else if (((QObject*)pointer)->inherits("QWidget")) {
|
||||
parent = (QWidget*)pointer;
|
||||
}
|
||||
else if (pointer != NULL && ((QObject*)pointer)->inherits("QLayout")) {
|
||||
else if (((QObject*)pointer)->inherits("QLayout")) {
|
||||
layoutParent = (QLayout*)pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
void *layout;
|
||||
int layoutType = 0;
|
||||
if (getArgumentCount(L_p) >= 1) {
|
||||
|
@ -1019,7 +1036,8 @@ 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")) {
|
||||
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());
|
||||
|
@ -1027,7 +1045,7 @@ int LuaEngineGui::createMenu(lua_State *L_p)
|
|||
pushPointer(L_p, menu);
|
||||
return 1;
|
||||
}
|
||||
else if (pointer != NULL && ((QObject*)pointer)->inherits("QMenu")) {
|
||||
else if (((QObject*)pointer)->inherits("QMenu")) {
|
||||
QMenu *menu = new QMenu((QWidget*)pointer);
|
||||
menu->setObjectName(nameForPointer(menu));
|
||||
menu->setTitle(getVariant(L_p, 1).toString());
|
||||
|
@ -1036,6 +1054,7 @@ int LuaEngineGui::createMenu(lua_State *L_p)
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1058,7 +1077,8 @@ 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")) {
|
||||
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);
|
||||
|
@ -1069,11 +1089,13 @@ int LuaEngineGui::createMenuEntry(lua_State *L_p)
|
|||
pushPointer(L_p, action);
|
||||
return 1;
|
||||
}
|
||||
else if (pointer != NULL && ((QObject*)pointer)->inherits("QToolBar")) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -1083,17 +1105,19 @@ 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")) {
|
||||
if (pointer != NULL) {
|
||||
if (((QObject*)pointer)->inherits("QMenu")) {
|
||||
QAction *action = ((QMenu*)pointer)->addSeparator();
|
||||
pushPointer(L_p, action);
|
||||
return 1;
|
||||
}
|
||||
else if (pointer != NULL && ((QObject*)pointer)->inherits("QToolBar")) {
|
||||
else if (((QObject*)pointer)->inherits("QToolBar")) {
|
||||
QAction *action = ((QToolBar*)pointer)->addSeparator();
|
||||
pushPointer(L_p, action);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1491,19 +1515,21 @@ QWidget* LuaEngineGui::windowForObject(QObject *object)
|
|||
|
||||
void LuaEngineGui::lpForPointer(void *pointer, QLayout **layout, QWidget **parent)
|
||||
{
|
||||
if (pointer != NULL && ((QObject*)pointer)->inherits("QMainWindow")) {
|
||||
if (pointer != NULL) {
|
||||
if (((QObject*)pointer)->inherits("QMainWindow")) {
|
||||
*parent = ((QMainWindow*)pointer)->centralWidget();
|
||||
}
|
||||
else if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
||||
else if (((QObject*)pointer)->inherits("QWidget")) {
|
||||
*parent = (QWidget*)pointer;
|
||||
}
|
||||
else if (pointer != NULL && ((QObject*)pointer)->inherits("QLayout")) {
|
||||
else if (((QObject*)pointer)->inherits("QLayout")) {
|
||||
QWidget *widget = windowForObject((QObject*)pointer);
|
||||
if (widget != nullptr) {
|
||||
*layout = (QLayout*)pointer;
|
||||
*parent = widget;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString LuaEngineGui::nameForPointer(void *pointer)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue