mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-12-22 11:55:29 +01:00
include toolbar functions
This commit is contained in:
parent
aa400ae21d
commit
85fb61371e
2 changed files with 48 additions and 1 deletions
|
@ -40,6 +40,7 @@
|
|||
#include <QLineEdit>
|
||||
#include <QGroupBox>
|
||||
#include <QCheckBox>
|
||||
#include <QToolBar>
|
||||
#include <QMenuBar>
|
||||
#include <QProcess>
|
||||
#include <QWindow>
|
||||
|
@ -174,6 +175,14 @@ void LuaEngineGui::pushClass(lua_State *L_p)
|
|||
// Text Edit
|
||||
pushFunction(L_p, "createTextEdit", createTextEdit);
|
||||
|
||||
// Tool Bar
|
||||
pushFunction(L_p, "createToolBar", createToolBar);
|
||||
pushVariant(L_p, "AllToolBarAreas", (int)Qt::AllToolBarAreas);
|
||||
pushVariant(L_p, "LeftToolBarArea", (int)Qt::LeftToolBarArea);
|
||||
pushVariant(L_p, "RightToolBarArea", (int)Qt::RightToolBarArea);
|
||||
pushVariant(L_p, "TopToolBarArea", (int)Qt::TopToolBarArea);
|
||||
pushVariant(L_p, "BottomToolBarArea", (int)Qt::BottomToolBarArea);
|
||||
|
||||
// Tool Button
|
||||
pushFunction(L_p, "createToolButton", createToolButton);
|
||||
|
||||
|
@ -461,7 +470,14 @@ int LuaEngineGui::setObjectImage(lua_State *L_p)
|
|||
pixelRatio = newPixelRatio;
|
||||
}
|
||||
}
|
||||
if (((QObject*)pointer)->inherits("QCheckBox")) {
|
||||
if (((QObject*)pointer)->inherits("QAction")) {
|
||||
QPixmap objectImage(imagePath);
|
||||
objectImage.setDevicePixelRatio(pixelRatio);
|
||||
QIcon objectIcon;
|
||||
objectIcon.addPixmap(objectImage);
|
||||
((QAction*)pointer)->setIcon(objectIcon);
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QCheckBox")) {
|
||||
QPixmap objectImage(imagePath);
|
||||
objectImage.setDevicePixelRatio(pixelRatio);
|
||||
QIcon objectIcon;
|
||||
|
@ -1053,6 +1069,12 @@ int LuaEngineGui::createMenuEntry(lua_State *L_p)
|
|||
pushPointer(L_p, action);
|
||||
return 1;
|
||||
}
|
||||
else if (pointer != NULL && ((QObject*)pointer)->inherits("QToolBar")) {
|
||||
QAction *action = new QAction(getVariant(L_p, 1).toString(), (QObject*)pointer);
|
||||
action->setObjectName(nameForPointer(action));
|
||||
((QToolBar*)pointer)->addAction(action);
|
||||
pushPointer(L_p, action);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1066,6 +1088,11 @@ int LuaEngineGui::createMenuSeparator(lua_State *L_p)
|
|||
pushPointer(L_p, action);
|
||||
return 1;
|
||||
}
|
||||
else if (pointer != NULL && ((QObject*)pointer)->inherits("QToolBar")) {
|
||||
QAction *action = ((QToolBar*)pointer)->addSeparator();
|
||||
pushPointer(L_p, action);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1239,6 +1266,25 @@ int LuaEngineGui::createTextEdit(lua_State *L_p)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int LuaEngineGui::createToolBar(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 1) {
|
||||
void *pointer = getPointer(L_p, 1);
|
||||
if (pointer != NULL && ((QObject*)pointer)->inherits("QMainWindow")) {
|
||||
Qt::ToolBarArea toolBarArea = Qt::TopToolBarArea;
|
||||
if (getArgumentCount(L_p) >= 2) {
|
||||
toolBarArea = (Qt::ToolBarArea)getVariant(L_p, 2).toInt();
|
||||
}
|
||||
QToolBar *toolBar = new QToolBar((QWidget*)pointer);
|
||||
toolBar->setObjectName(nameForPointer(toolBar));
|
||||
((QMainWindow*)pointer)->addToolBar(toolBarArea, toolBar);
|
||||
pushPointer(L_p, toolBar);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineGui::createToolButton(lua_State *L_p)
|
||||
{
|
||||
QLayout *layout = nullptr;
|
||||
|
|
|
@ -77,6 +77,7 @@ public:
|
|||
static int createStackSwitch(lua_State *L_p);
|
||||
static int createTabBar(lua_State *L_p);
|
||||
static int createTextEdit(lua_State *L_p);
|
||||
static int createToolBar(lua_State *L_p);
|
||||
static int createToolButton(lua_State *L_p);
|
||||
static int createWidgetTab(lua_State *L_p);
|
||||
static int createWidgetStack(lua_State *L_p);
|
||||
|
|
Loading…
Reference in a new issue