mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-11-04 21:16:56 +01:00
getWidgetText -> getObjectText, setWidgetText -> setObjectText,
getWindow -> getObjectWindow
This commit is contained in:
parent
9d045413f9
commit
01d43e6e20
4 changed files with 88 additions and 81 deletions
|
@ -116,7 +116,7 @@ end
|
|||
function compileScript()
|
||||
local filePath = showFileDialog(SaveFileDialog, "Select output file...", currentFilter, mainWindow)
|
||||
if (filePath ~= nil) then
|
||||
local compileArgs = { getWidgetText(scriptLineEdit) }
|
||||
local compileArgs = { getObjectText(scriptLineEdit) }
|
||||
if (currentSstub ~= nil) then
|
||||
compileArgs[2] = "--luaengine"
|
||||
compileArgs[3] = sstubDir.."/"..currentSstub
|
||||
|
|
|
@ -56,5 +56,5 @@ function scriptButtonPressed()
|
|||
end
|
||||
|
||||
function runScript()
|
||||
executeProcess(_LuaEngineRT, getWidgetText(scriptLineEdit), true)
|
||||
executeProcess(_LuaEngineRT, getObjectText(scriptLineEdit), true)
|
||||
end
|
||||
|
|
|
@ -82,8 +82,10 @@ void LuaEngineGui::pushClass(lua_State *L_p)
|
|||
pushVariant(L_p, "GuiExecuted", "GuiExecuted");
|
||||
|
||||
// Object
|
||||
pushFunction(L_p, "getWindow", getWindow);
|
||||
pushFunction(L_p, "getObjectText", getObjectText);
|
||||
pushFunction(L_p, "getObjectWindow", getObjectWindow);
|
||||
pushFunction(L_p, "setObjectImage", setObjectImage);
|
||||
pushFunction(L_p, "setObjectText", setObjectText);
|
||||
|
||||
// Widget
|
||||
pushFunction(L_p, "closeWidget", closeWidget);
|
||||
|
@ -93,7 +95,6 @@ void LuaEngineGui::pushClass(lua_State *L_p)
|
|||
pushFunction(L_p, "isWidgetEnabled", isWidgetEnabled);
|
||||
pushFunction(L_p, "isWidgetVisible", isWidgetVisible);
|
||||
pushFunction(L_p, "getWidgetPixelRatio", getWidgetPixelRatio);
|
||||
pushFunction(L_p, "getWidgetText", getWidgetText);
|
||||
pushFunction(L_p, "setWidgetChecked", setWidgetChecked);
|
||||
pushFunction(L_p, "setWidgetEnabled", setWidgetEnabled);
|
||||
pushFunction(L_p, "setWidgetFixed", setWidgetFixed);
|
||||
|
@ -103,7 +104,6 @@ void LuaEngineGui::pushClass(lua_State *L_p)
|
|||
pushFunction(L_p, "setWidgetMinimum", setWidgetMinimum);
|
||||
pushFunction(L_p, "setWidgetReadOnly", setWidgetReadOnly);
|
||||
pushFunction(L_p, "setWidgetSize", setWidgetSize);
|
||||
pushFunction(L_p, "setWidgetText", setWidgetText);
|
||||
pushFunction(L_p, "setWidgetValue", setWidgetValue);
|
||||
pushFunction(L_p, "setWidgetVisible", setWidgetVisible);
|
||||
pushFunction(L_p, "widgetAddText", widgetAddText);
|
||||
|
@ -517,6 +517,54 @@ int LuaEngineGui::setObjectImage(lua_State *L_p)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineGui::setObjectText(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 2) {
|
||||
void *pointer = getPointer(L_p, 1);
|
||||
if (pointer != NULL) {
|
||||
if (((QObject*)pointer)->inherits("QAction")) {
|
||||
((QAction*)pointer)->setText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QCheckBox")) {
|
||||
((QCheckBox*)pointer)->setText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QGroupBox")) {
|
||||
((QGroupBox*)pointer)->setTitle(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QLabel")) {
|
||||
((QLabel*)pointer)->setText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QLineEdit")) {
|
||||
((QLineEdit*)pointer)->setText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QPlainTextEdit")) {
|
||||
((QPlainTextEdit*)pointer)->setPlainText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QProgressBar")) {
|
||||
QString progressBarText = getVariant(L_p, 2).toString();
|
||||
((QProgressBar*)pointer)->setFormat(progressBarText);
|
||||
((QProgressBar*)pointer)->setTextVisible(!progressBarText.isEmpty());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QPushButton")) {
|
||||
((QPushButton*)pointer)->setText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QRadioButton")) {
|
||||
((QRadioButton*)pointer)->setText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QTextEdit")) {
|
||||
((QTextEdit*)pointer)->setHtml(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QToolButton")) {
|
||||
((QToolButton*)pointer)->setText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QWidget")) {
|
||||
((QWidget*)pointer)->setWindowTitle(getVariant(L_p, 2).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineGui::setWidgetChecked(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 1) {
|
||||
|
@ -686,51 +734,6 @@ int LuaEngineGui::setWidgetSize(lua_State *L_p)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineGui::setWidgetText(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 2) {
|
||||
void *pointer = getPointer(L_p, 1);
|
||||
if (pointer != NULL) {
|
||||
if (((QObject*)pointer)->inherits("QCheckBox")) {
|
||||
((QCheckBox*)pointer)->setText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QGroupBox")) {
|
||||
((QGroupBox*)pointer)->setTitle(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QLabel")) {
|
||||
((QLabel*)pointer)->setText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QLineEdit")) {
|
||||
((QLineEdit*)pointer)->setText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QPlainTextEdit")) {
|
||||
((QPlainTextEdit*)pointer)->setPlainText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QProgressBar")) {
|
||||
QString progressBarText = getVariant(L_p, 2).toString();
|
||||
((QProgressBar*)pointer)->setFormat(progressBarText);
|
||||
((QProgressBar*)pointer)->setTextVisible(!progressBarText.isEmpty());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QPushButton")) {
|
||||
((QPushButton*)pointer)->setText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QRadioButton")) {
|
||||
((QRadioButton*)pointer)->setText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QTextEdit")) {
|
||||
((QTextEdit*)pointer)->setHtml(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QToolButton")) {
|
||||
((QToolButton*)pointer)->setText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QWidget")) {
|
||||
((QWidget*)pointer)->setWindowTitle(getVariant(L_p, 2).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineGui::setWidgetValue(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 2) {
|
||||
|
@ -1408,43 +1411,20 @@ int LuaEngineGui::isWidgetVisible(lua_State *L_p)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineGui::getWindow(lua_State *L_p)
|
||||
int LuaEngineGui::getObjectText(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 1) {
|
||||
void *pointer = getPointer(L_p, 1);
|
||||
if (pointer != NULL) {
|
||||
void *window = windowForObject((QObject*)pointer);
|
||||
if (window != nullptr) {
|
||||
pushPointer(L_p, window);
|
||||
if (((QObject*)pointer)->inherits("QAction")) {
|
||||
pushVariant(L_p, ((QAction*)pointer)->text());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineGui::getWidgetPixelRatio(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 1) {
|
||||
void *pointer = getPointer(L_p, 1);
|
||||
if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
||||
pushVariant(L_p, ((QWidget*)pointer)->devicePixelRatioF());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineGui::getWidgetText(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 1) {
|
||||
void *pointer = getPointer(L_p, 1);
|
||||
if (pointer != NULL) {
|
||||
if (((QObject*)pointer)->inherits("QCheckBox")) {
|
||||
else if (((QObject*)pointer)->inherits("QCheckBox")) {
|
||||
pushVariant(L_p, ((QCheckBox*)pointer)->text());
|
||||
return 1;
|
||||
}
|
||||
if (((QObject*)pointer)->inherits("QGroupBox")) {
|
||||
else if (((QObject*)pointer)->inherits("QGroupBox")) {
|
||||
pushVariant(L_p, ((QGroupBox*)pointer)->title());
|
||||
return 1;
|
||||
}
|
||||
|
@ -1489,6 +1469,33 @@ int LuaEngineGui::getWidgetText(lua_State *L_p)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineGui::getObjectWindow(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 1) {
|
||||
void *pointer = getPointer(L_p, 1);
|
||||
if (pointer != NULL) {
|
||||
void *window = windowForObject((QObject*)pointer);
|
||||
if (window != nullptr) {
|
||||
pushPointer(L_p, window);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineGui::getWidgetPixelRatio(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 1) {
|
||||
void *pointer = getPointer(L_p, 1);
|
||||
if (pointer != NULL && ((QObject*)pointer)->inherits("QWidget")) {
|
||||
pushVariant(L_p, ((QWidget*)pointer)->devicePixelRatioF());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QWidget* LuaEngineGui::windowForObject(QObject *object)
|
||||
{
|
||||
bool isWindow = false;
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
static int setLayoutMargins(lua_State *L_p);
|
||||
static int setMenuShortcut(lua_State *L_p);
|
||||
static int setObjectImage(lua_State *L_p);
|
||||
static int setObjectText(lua_State *L_p);
|
||||
static int setWidgetChecked(lua_State *L_p);
|
||||
static int setWidgetEnabled(lua_State *L_p);
|
||||
static int setWidgetFixed(lua_State *L_p);
|
||||
|
@ -50,7 +51,6 @@ public:
|
|||
static int setWidgetMinimum(lua_State *L_p);
|
||||
static int setWidgetReadOnly(lua_State *L_p);
|
||||
static int setWidgetSize(lua_State *L_p);
|
||||
static int setWidgetText(lua_State *L_p);
|
||||
static int setWidgetValue(lua_State *L_p);
|
||||
static int setWidgetVisible(lua_State *L_p);
|
||||
static int layoutAddLayout(lua_State *L_p);
|
||||
|
@ -85,9 +85,9 @@ public:
|
|||
static int isWidgetChecked(lua_State *L_p);
|
||||
static int isWidgetEnabled(lua_State *L_p);
|
||||
static int isWidgetVisible(lua_State *L_p);
|
||||
static int getObjectText(lua_State *L_p);
|
||||
static int getObjectWindow(lua_State *L_p);
|
||||
static int getWidgetPixelRatio(lua_State *L_p);
|
||||
static int getWidgetText(lua_State *L_p);
|
||||
static int getWindow(lua_State *L_p);
|
||||
|
||||
private:
|
||||
lua_State *L;
|
||||
|
|
Loading…
Reference in a new issue