added updateUi command

This commit is contained in:
Syping 2019-09-25 19:49:43 +02:00
parent 5b5914f5b4
commit e189120982
2 changed files with 19 additions and 0 deletions

View file

@ -19,6 +19,7 @@
#include <QPlainTextEdit>
#include <QRadioButton>
#include <QProgressBar>
#include <QApplication>
#include <QMainWindow>
#include <QToolButton>
#include <QPushButton>
@ -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;

View file

@ -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);