diff --git a/src/luaenginegui/luaengine/LuaEngineGui.cpp b/src/luaenginegui/luaengine/LuaEngineGui.cpp index 9735efd..bfc34a4 100644 --- a/src/luaenginegui/luaengine/LuaEngineGui.cpp +++ b/src/luaenginegui/luaengine/LuaEngineGui.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,13 @@ LuaEngineGui::LuaEngineGui(QObject *parent, bool loadBaseLibraries) : LuaEngine( void LuaEngineGui::pushClass(lua_State *L_p) { + // Update UI + pushFunction(L_p, "updateUi", updateUi); + pushVariant(L_p, "AllEvents", (int)QEventLoop::AllEvents); + pushVariant(L_p, "ExcludeUserInputEvents", (int)QEventLoop::ExcludeUserInputEvents); + pushVariant(L_p, "ExcludeSocketNotifiers", (int)QEventLoop::ExcludeSocketNotifiers); + pushVariant(L_p, "WaitForMoreEvents", (int)QEventLoop::WaitForMoreEvents); + // File Dialog pushFunction(L_p, "showFileDialog", showFileDialog); pushVariant(L_p, "OpenFileDialog", 0); @@ -161,6 +169,16 @@ void LuaEngineGui::pushClass(LuaEngine *luaEngine) pushClass(luaEngine->luaState()); } +int LuaEngineGui::updateUi(lua_State *L_p) +{ + QEventLoop::ProcessEventsFlags events = QEventLoop::AllEvents; + if (getArgumentCount(L_p) >= 1) { + events = (QEventLoop::ProcessEventsFlags)getVariant(L_p, 1).toInt(); + } + QApplication::processEvents(events); + return 0; +} + int LuaEngineGui::showFileDialog(lua_State *L_p) { QWidget *parent = nullptr; diff --git a/src/luaenginegui/luaengine/LuaEngineGui.h b/src/luaenginegui/luaengine/LuaEngineGui.h index ee4149b..e043dbb 100644 --- a/src/luaenginegui/luaengine/LuaEngineGui.h +++ b/src/luaenginegui/luaengine/LuaEngineGui.h @@ -30,6 +30,7 @@ public: LuaEngineGui(QObject *parent = nullptr, bool loadBaseLibraries = true); static void pushClass(lua_State *L_p); static void pushClass(LuaEngine *luaEngine); + static int updateUi(lua_State *L_p); static int showFileDialog(lua_State *L_p); static int showMessageBox(lua_State *L_p); static int closeWidget(lua_State *L_p);