mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-12-22 11:55:29 +01:00
improve fileDialog
This commit is contained in:
parent
3e4fda83ba
commit
5b5914f5b4
2 changed files with 33 additions and 3 deletions
|
@ -84,6 +84,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, "widgetAddText", widgetAddText);
|
||||
pushVariant(L_p, "ShowCurrent", 0);
|
||||
pushVariant(L_p, "ShowNormal", 1);
|
||||
pushVariant(L_p, "ShowDefault", 2);
|
||||
|
@ -175,6 +176,7 @@ int LuaEngineGui::showFileDialog(lua_State *L_p)
|
|||
fileAcceptMode = QFileDialog::AcceptSave;
|
||||
break;
|
||||
case 2:
|
||||
fileFormats = QString();
|
||||
fileMode = QFileDialog::Directory;
|
||||
fileOptions = QFileDialog::ShowDirsOnly;
|
||||
break;
|
||||
|
@ -182,13 +184,21 @@ int LuaEngineGui::showFileDialog(lua_State *L_p)
|
|||
if (getArgumentCount(L_p) >= 2) {
|
||||
dialogTitle = getVariant(L_p, 2).toString();
|
||||
if (getArgumentCount(L_p) >= 3) {
|
||||
fileFormats = getVariant(L_p, 3).toString();
|
||||
if (getArgumentCount(L_p) >= 4) {
|
||||
void *pointer = getPointer(L_p, 4);
|
||||
if (fileMode == QFileDialog::Directory) {
|
||||
void *pointer = getPointer(L_p, 3);
|
||||
if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
||||
parent = (QWidget*)pointer;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fileFormats = getVariant(L_p, 3).toString();
|
||||
if (getArgumentCount(L_p) >= 4) {
|
||||
void *pointer = getPointer(L_p, 4);
|
||||
if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
||||
parent = (QWidget*)pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -625,6 +635,25 @@ int LuaEngineGui::layoutAddWidget(lua_State *L_p)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineGui::widgetAddText(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 2) {
|
||||
void *pointer = getPointer(L_p, 1);
|
||||
if (pointer != NULL) {
|
||||
if (((QObject*)pointer)->inherits("QLineEdit")) {
|
||||
((QLineEdit*)pointer)->setText(((QLineEdit*)pointer)->text() + getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QPlainTextEdit")) {
|
||||
((QPlainTextEdit*)pointer)->appendPlainText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QTextEdit")) {
|
||||
((QTextEdit*)pointer)->append(getVariant(L_p, 2).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineGui::createCentralWidget(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 1) {
|
||||
|
|
|
@ -49,6 +49,7 @@ public:
|
|||
static int setWidgetValue(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);
|
||||
static int createCentralWidget(lua_State *L_p);
|
||||
static int createCheckBox(lua_State *L_p);
|
||||
static int createDialog(lua_State *L_p);
|
||||
|
|
Loading…
Reference in a new issue