mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-11-04 21:16:56 +01:00
fixedSize improved and setWidgetSize
This commit is contained in:
parent
a6b8d15d19
commit
d8c75c11a2
3 changed files with 51 additions and 11 deletions
|
@ -52,6 +52,7 @@ function main()
|
|||
textEditor = createPlainTextEdit("", mainWidget)
|
||||
layoutAddWidget(mainLayout, textEditor)
|
||||
|
||||
setWidgetSize(mainWindow, 650, 450)
|
||||
showWidget(mainWindow, ShowNormal)
|
||||
return GuiExecuted
|
||||
end
|
||||
|
|
|
@ -70,9 +70,10 @@ void LuaEngineGui::pushClass(lua_State *L_p)
|
|||
pushFunction(L_p, "executeWidget", executeWidget);
|
||||
pushFunction(L_p, "showWidget", showWidget);
|
||||
pushFunction(L_p, "getWidgetText", getWidgetText);
|
||||
pushFunction(L_p, "setWidgetFixedSize", setWidgetFixedSize);
|
||||
pushFunction(L_p, "setWidgetFixed", setWidgetFixed);
|
||||
pushFunction(L_p, "setWidgetLayout", setWidgetLayout);
|
||||
pushFunction(L_p, "setWidgetText", setWidgetText);
|
||||
pushFunction(L_p, "setWidgetSize", setWidgetSize);
|
||||
pushVariant(L_p, "ShowCurrent", 0);
|
||||
pushVariant(L_p, "ShowNormal", 1);
|
||||
pushVariant(L_p, "ShowMinimised", 2);
|
||||
|
@ -247,13 +248,18 @@ int LuaEngineGui::executeWidget(lua_State *L_p)
|
|||
void *pointer = getPointer(L_p, 1);
|
||||
if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
||||
QVariant isFixed = ((QObject*)pointer)->property("isFixed");
|
||||
QVariant isSizeSet = ((QObject*)pointer)->property("isSizeSet");
|
||||
if (isFixed.type() == QVariant::Bool && isFixed.toBool()) {
|
||||
((QWidget*)pointer)->setMinimumSize(((QWidget*)pointer)->sizeHint());
|
||||
((QWidget*)pointer)->setMaximumSize(((QWidget*)pointer)->sizeHint());
|
||||
if (!(isSizeSet.type() == QVariant::Bool && isSizeSet.toBool())) {
|
||||
((QWidget*)pointer)->setMinimumSize(((QWidget*)pointer)->sizeHint());
|
||||
((QWidget*)pointer)->setMaximumSize(((QWidget*)pointer)->sizeHint());
|
||||
}
|
||||
}
|
||||
else {
|
||||
((QWidget*)pointer)->setMinimumSize(((QWidget*)pointer)->sizeHint());
|
||||
((QWidget*)pointer)->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
||||
if (!(isSizeSet.type() == QVariant::Bool && isSizeSet.toBool())) {
|
||||
((QWidget*)pointer)->setMinimumSize(((QWidget*)pointer)->sizeHint());
|
||||
((QWidget*)pointer)->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
||||
}
|
||||
}
|
||||
if (((QObject*)pointer)->inherits("QDialog")) {
|
||||
((QDialog*)pointer)->exec();
|
||||
|
@ -282,13 +288,18 @@ int LuaEngineGui::showWidget(lua_State *L_p)
|
|||
showMode = getVariant(L_p, 2).toInt();
|
||||
}
|
||||
QVariant isFixed = ((QObject*)pointer)->property("isFixed");
|
||||
QVariant isSizeSet = ((QObject*)pointer)->property("isSizeSet");
|
||||
if (isFixed.type() == QVariant::Bool && isFixed.toBool()) {
|
||||
((QWidget*)pointer)->setMinimumSize(((QWidget*)pointer)->sizeHint());
|
||||
((QWidget*)pointer)->setMaximumSize(((QWidget*)pointer)->sizeHint());
|
||||
if (!(isSizeSet.type() == QVariant::Bool && isSizeSet.toBool())) {
|
||||
((QWidget*)pointer)->setMinimumSize(((QWidget*)pointer)->sizeHint());
|
||||
((QWidget*)pointer)->setMaximumSize(((QWidget*)pointer)->sizeHint());
|
||||
}
|
||||
}
|
||||
else {
|
||||
((QWidget*)pointer)->setMinimumSize(((QWidget*)pointer)->sizeHint());
|
||||
((QWidget*)pointer)->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
||||
if (!(isSizeSet.type() == QVariant::Bool && isSizeSet.toBool())) {
|
||||
((QWidget*)pointer)->setMinimumSize(((QWidget*)pointer)->sizeHint());
|
||||
((QWidget*)pointer)->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
||||
}
|
||||
}
|
||||
switch (showMode) {
|
||||
case 1:
|
||||
|
@ -337,7 +348,7 @@ int LuaEngineGui::setMenuShortcut(lua_State *L_p)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineGui::setWidgetFixedSize(lua_State *L_p)
|
||||
int LuaEngineGui::setWidgetFixed(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 1) {
|
||||
void *pointer = getPointer(L_p, 1);
|
||||
|
@ -347,10 +358,15 @@ int LuaEngineGui::setWidgetFixedSize(lua_State *L_p)
|
|||
isFixed = getVariant(L_p, 2).toBool();
|
||||
}
|
||||
((QObject*)pointer)->setProperty("isFixed", isFixed);
|
||||
QVariant isSizeSet = ((QObject*)pointer)->property("isSizeSet");
|
||||
if (isFixed && ((QWidget*)pointer)->isVisible()) {
|
||||
((QWidget*)pointer)->setMinimumSize(((QWidget*)pointer)->sizeHint());
|
||||
((QWidget*)pointer)->setMaximumSize(((QWidget*)pointer)->sizeHint());
|
||||
}
|
||||
else if (isFixed && (isSizeSet.type() == QVariant::Bool && isSizeSet.toBool())) {
|
||||
((QWidget*)pointer)->setMinimumSize(((QWidget*)pointer)->size());
|
||||
((QWidget*)pointer)->setMaximumSize(((QWidget*)pointer)->size());
|
||||
}
|
||||
else if (((QWidget*)pointer)->isVisible()) {
|
||||
((QWidget*)pointer)->setMinimumSize(((QWidget*)pointer)->sizeHint());
|
||||
((QWidget*)pointer)->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
||||
|
@ -376,6 +392,28 @@ int LuaEngineGui::setWidgetLayout(lua_State *L_p)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineGui::setWidgetSize(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 3) {
|
||||
void *pointer = getPointer(L_p, 1);
|
||||
if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
||||
QVariant isFixed = ((QObject*)pointer)->property("isFixed");
|
||||
if (isFixed.type() == QVariant::Bool && isFixed.toBool()) {
|
||||
((QWidget*)pointer)->setMinimumSize(getVariant(L_p, 2).toInt(), getVariant(L_p, 3).toInt());
|
||||
((QWidget*)pointer)->setMaximumSize(getVariant(L_p, 2).toInt(), getVariant(L_p, 3).toInt());
|
||||
((QWidget*)pointer)->resize(getVariant(L_p, 2).toInt(), getVariant(L_p, 3).toInt());
|
||||
((QObject*)pointer)->setProperty("isSizeSet", true);
|
||||
}
|
||||
else {
|
||||
((QWidget*)pointer)->resize(getVariant(L_p, 2).toInt(), getVariant(L_p, 3).toInt());
|
||||
((QObject*)pointer)->setProperty("isSizeSet", true);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineGui::setWidgetText(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 2) {
|
||||
|
|
|
@ -37,8 +37,9 @@ public:
|
|||
static int showWidget(lua_State *L_p);
|
||||
static int setLayoutMargins(lua_State *L_p);
|
||||
static int setMenuShortcut(lua_State *L_p);
|
||||
static int setWidgetFixedSize(lua_State *L_p);
|
||||
static int setWidgetFixed(lua_State *L_p);
|
||||
static int setWidgetLayout(lua_State *L_p);
|
||||
static int setWidgetSize(lua_State *L_p);
|
||||
static int setWidgetText(lua_State *L_p);
|
||||
static int layoutAddLayout(lua_State *L_p);
|
||||
static int layoutAddWidget(lua_State *L_p);
|
||||
|
|
Loading…
Reference in a new issue