Permalink
Browse files

Add GUI file saving

  • Loading branch information...
feragon committed Aug 9, 2016
1 parent 53541f0 commit f1da956ae8daaa8d5c165f4265c8d980c671e422
Showing with 28 additions and 1 deletion.
  1. +4 −0 lcUI/lua/qtbridge.cpp
  2. +1 −1 lcUI/ui/mainwindow.ui
  3. +23 −0 lcUILua/ui/mainwindow.lua
View
@@ -113,6 +113,9 @@ void addQtWindowBindings(lua_State *L) {
.addStaticFunction("getOpenFileName", [](QWidget *parent, QString& caption, QString& dir, QString& filter) {
return QFileDialog::getOpenFileName(parent, caption, dir, filter);
})
.addStaticFunction("getSaveFileName", [](QWidget *parent, QString& caption, QString& dir, QString& filter) {
return QFileDialog::getSaveFileName(parent, caption, dir, filter);
})
.endClass()
.beginExtendClass<QDockWidget, QWidget>("QDockWidget")
@@ -177,6 +180,7 @@ void addLCBindings(lua_State *L) {
})
.addFunction("cursor", &CadMdiChild::cursor)
.addFunction("document", &CadMdiChild::document)
.addFunction("exportDXF", &CadMdiChild::exportDXF)
.addProperty("id", &CadMdiChild::id, &CadMdiChild::setId)
.addFunction("import", &CadMdiChild::import)
.addFunction("selection", &CadMdiChild::selection)
View
@@ -41,7 +41,7 @@
<x>0</x>
<y>0</y>
<width>981</width>
<height>19</height>
<height>28</height>
</rect>
</property>
<widget class="QMenu" name="menuDemo_Project">
View
@@ -31,6 +31,27 @@ function open_file()
end
end
function save_file()
if(active_widget() == nil) then
return
end
local fileName = qt.QFileDialog.getSaveFileName(
mainWindow,
qt.QObject.tr("Save File"),
qt.QString(""),
qt.QObject.tr("dxf(*.dxf);;dwg(*.dwg)")
)
if(not fileName:isEmpty()) then
if(active_widget() == nil) then
return
end
active_widget():exportDXF(fileName:toStdString(), 6)
end
end
function active_layer()
return layers:activeLayer()
end
@@ -86,6 +107,8 @@ local function create_menu()
luaInterface:luaConnect(mainWindow:findChild("actionNew"), "triggered(bool)", new_file)
luaInterface:luaConnect(mainWindow:findChild("actionOpen"), "triggered(bool)", open_file)
luaInterface:luaConnect(mainWindow:findChild("actionSave_2"), "triggered(bool)", save_file)
luaInterface:luaConnect(mainWindow:findChild("actionSave_As"), "triggered(bool)", save_file)
luaInterface:luaConnect(mainWindow:findChild("actionUndo"), "triggered(bool)", undo)
luaInterface:luaConnect(mainWindow:findChild("actionRedo"), "triggered(bool)", redo)

0 comments on commit f1da956

Please sign in to comment.