├── .gitignore ├── qtutil ├── Readme.txt ├── QtUtilConfig.cmake.in ├── qtutilconf.h ├── qthumbwheel.h ├── CMakeLists.txt └── qmenuaction.h ├── qlua ├── images │ ├── luadoc.icns │ ├── luadoc.ico │ ├── luadoc.png │ ├── torch.icns │ ├── torch.ico │ └── torch.png ├── qlua.rc ├── qlua.qrc ├── QLuaConfig.cmake.in ├── qluaconf.h.in ├── qluaconsole.h ├── qluaapplication.h ├── qlua.plist.in ├── qlua.cpp └── CMakeLists.txt ├── packages ├── qtcore │ ├── init.lua │ ├── CMakeLists.txt │ └── qtcore.h ├── qtide │ ├── images │ │ ├── up.png │ │ ├── down.png │ │ ├── home.png │ │ ├── left.png │ │ ├── stop.png │ │ ├── web.png │ │ ├── clear.png │ │ ├── editcut.png │ │ ├── filenew.png │ │ ├── history.png │ │ ├── refresh.png │ │ ├── right.png │ │ ├── trash.png │ │ ├── editcopy.png │ │ ├── editfind.png │ │ ├── editpaste.png │ │ ├── editprefs.png │ │ ├── editredo.png │ │ ├── editundo.png │ │ ├── fileopen.png │ │ ├── fileprint.png │ │ ├── filequit.png │ │ ├── filesave.png │ │ ├── helpindex.png │ │ ├── editbalance.png │ │ ├── filenewlua.png │ │ ├── playerload.png │ │ ├── playerpause.png │ │ ├── playerplay.png │ │ ├── playerstop.png │ │ └── playerrestart.png │ ├── qtide.h │ ├── qtide.qrc │ ├── qluamdimain.h │ ├── CMakeLists.txt │ ├── qluamainwindow.h │ ├── qluaeditor.h │ ├── qluabrowser.h │ ├── qluasdimain.h │ ├── qtide.cpp │ ├── qluagotodialog.ui │ ├── qluamode.h │ ├── README.txt │ ├── qluamode_txt.cpp │ ├── SETTINGS.txt │ ├── qluafinddialog.ui │ ├── qluaide.h │ ├── qluareplacedialog.ui │ ├── qluatextedit.h │ ├── init.lua │ ├── prefs.lua │ └── qluamode_hlp.cpp ├── qt │ └── CMakeLists.txt ├── qtgui │ ├── init.lua │ ├── CMakeLists.txt │ ├── qtgui.h │ ├── qtluagui.cpp │ └── qtluagui.h ├── CMakeLists.txt ├── qtuiloader │ ├── CMakeLists.txt │ ├── uiloader.h │ ├── init.lua │ ├── test.lua │ ├── test.ui │ └── uiloader.cpp ├── qtsvg │ ├── CMakeLists.txt │ ├── init.lua │ ├── qtsvg.h │ ├── qtluasvggenerator.h │ ├── qtluasvggenerator.cpp │ └── qtsvg.cpp └── qtwidget │ ├── CMakeLists.txt │ ├── qtwidget.h │ ├── qtlualistener.h │ ├── qtluaprinter.h │ ├── qtlualistener.cpp │ ├── qtluaprinter.cpp │ └── qtluapainter.h ├── qtlua ├── QtLuaConfig.cmake.in ├── qtluautils.h ├── qtluaconf.h.in ├── CMakeLists.txt └── qtluaengine.h ├── doc ├── index.md ├── qtuiloader.md └── qtsvg.md ├── mkdocs.yml ├── rocks └── qtlua-scm-1.rockspec ├── README.md ├── cmake ├── MacroAddQtLuaModule.cmake ├── MacroQt4AutoGen.cmake ├── FindReadline.cmake ├── QtLuaPaths.cmake ├── FindLua.cmake └── InstallRequiredQtLibraries.cmake ├── Copyright.txt └── CMakeLists.txt /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /qtutil/Readme.txt: -------------------------------------------------------------------------------- 1 | 2 | Currently unused. 3 | -------------------------------------------------------------------------------- /qlua/images/luadoc.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/qlua/images/luadoc.icns -------------------------------------------------------------------------------- /qlua/images/luadoc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/qlua/images/luadoc.ico -------------------------------------------------------------------------------- /qlua/images/luadoc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/qlua/images/luadoc.png -------------------------------------------------------------------------------- /qlua/images/torch.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/qlua/images/torch.icns -------------------------------------------------------------------------------- /qlua/images/torch.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/qlua/images/torch.ico -------------------------------------------------------------------------------- /qlua/images/torch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/qlua/images/torch.png -------------------------------------------------------------------------------- /packages/qtcore/init.lua: -------------------------------------------------------------------------------- 1 | 2 | require 'qt' 3 | qt.require 'libqtcore' 4 | 5 | local qt = qt 6 | 7 | -------------------------------------------------------------------------------- /packages/qtide/images/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/up.png -------------------------------------------------------------------------------- /packages/qtide/images/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/down.png -------------------------------------------------------------------------------- /packages/qtide/images/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/home.png -------------------------------------------------------------------------------- /packages/qtide/images/left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/left.png -------------------------------------------------------------------------------- /packages/qtide/images/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/stop.png -------------------------------------------------------------------------------- /packages/qtide/images/web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/web.png -------------------------------------------------------------------------------- /packages/qtide/images/clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/clear.png -------------------------------------------------------------------------------- /packages/qtide/images/editcut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/editcut.png -------------------------------------------------------------------------------- /packages/qtide/images/filenew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/filenew.png -------------------------------------------------------------------------------- /packages/qtide/images/history.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/history.png -------------------------------------------------------------------------------- /packages/qtide/images/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/refresh.png -------------------------------------------------------------------------------- /packages/qtide/images/right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/right.png -------------------------------------------------------------------------------- /packages/qtide/images/trash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/trash.png -------------------------------------------------------------------------------- /packages/qtide/images/editcopy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/editcopy.png -------------------------------------------------------------------------------- /packages/qtide/images/editfind.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/editfind.png -------------------------------------------------------------------------------- /packages/qtide/images/editpaste.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/editpaste.png -------------------------------------------------------------------------------- /packages/qtide/images/editprefs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/editprefs.png -------------------------------------------------------------------------------- /packages/qtide/images/editredo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/editredo.png -------------------------------------------------------------------------------- /packages/qtide/images/editundo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/editundo.png -------------------------------------------------------------------------------- /packages/qtide/images/fileopen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/fileopen.png -------------------------------------------------------------------------------- /packages/qtide/images/fileprint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/fileprint.png -------------------------------------------------------------------------------- /packages/qtide/images/filequit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/filequit.png -------------------------------------------------------------------------------- /packages/qtide/images/filesave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/filesave.png -------------------------------------------------------------------------------- /packages/qtide/images/helpindex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/helpindex.png -------------------------------------------------------------------------------- /packages/qt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #ADD_TORCH_DOK(dok qt "QT Interface" "Lua executable and QT classes generic interface" 6.1) 2 | -------------------------------------------------------------------------------- /packages/qtide/images/editbalance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/editbalance.png -------------------------------------------------------------------------------- /packages/qtide/images/filenewlua.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/filenewlua.png -------------------------------------------------------------------------------- /packages/qtide/images/playerload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/playerload.png -------------------------------------------------------------------------------- /packages/qtide/images/playerpause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/playerpause.png -------------------------------------------------------------------------------- /packages/qtide/images/playerplay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/playerplay.png -------------------------------------------------------------------------------- /packages/qtide/images/playerstop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/playerstop.png -------------------------------------------------------------------------------- /packages/qtide/images/playerrestart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/torch/qtlua/HEAD/packages/qtide/images/playerrestart.png -------------------------------------------------------------------------------- /qlua/qlua.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "images/torch.ico" 2 | IDI_ICON2 ICON DISCARDABLE "images/luadoc.ico" 3 | -------------------------------------------------------------------------------- /qlua/qlua.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/torch.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /packages/qtgui/init.lua: -------------------------------------------------------------------------------- 1 | 2 | require 'qt' 3 | require 'qtcore' 4 | 5 | if qt and qt.qApp and qt.qApp:runsWithoutGraphics() then 6 | print("qlua: not loading module qtgui (running with -nographics)") 7 | return 8 | end 9 | 10 | qt.require 'libqtgui' 11 | 12 | 13 | -------------------------------------------------------------------------------- /qlua/QLuaConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # This file was automatically generated. 2 | # See @CMAKE_CURRENT_SOURCE_DIR@/CMakeLists.txt 3 | 4 | SET(QLUA_FOUND ON) 5 | SET(QLUA_INCLUDE_DIR "@QLUA_INCLUDE_DIR@") 6 | SET(QLUA_DEFINITIONS "@QLUA_DEFINITIONS@") 7 | SET(QLUA_LIBRARIES "@QLUA_LIBRARIES@") 8 | -------------------------------------------------------------------------------- /packages/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # -*- cmake -*- 2 | 3 | # We compile all existing packages 4 | FILE(GLOB _all_files *) 5 | FOREACH(_file ${_all_files}) 6 | IF(EXISTS "${_file}/CMakeLists.txt") 7 | ADD_SUBDIRECTORY(${_file}) 8 | ENDIF(EXISTS "${_file}/CMakeLists.txt") 9 | ENDFOREACH(_file ${_all_files}) 10 | -------------------------------------------------------------------------------- /qtlua/QtLuaConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # This file was automatically generated. 2 | # See @CMAKE_CURRENT_SOURCE_DIR@/CMakeLists.txt 3 | 4 | SET(QTLUA_FOUND ON) 5 | SET(QTLUA_INCLUDE_DIR "@QTLUA_INCLUDE_DIR@") 6 | SET(QTLUA_DEFINITIONS "@QTLUA_DEFINITIONS@") 7 | SET(QTLUA_LIBRARIES "@QTLUA_LIBRARIES@") 8 | 9 | 10 | -------------------------------------------------------------------------------- /qtutil/QtUtilConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # This file was automatically generated. 2 | # See @CMAKE_CURRENT_SOURCE_DIR@/CMakeLists.txt 3 | 4 | SET(QTUTIL_FOUND ON) 5 | SET(QTUTIL_INCLUDE_DIR "@QTUTIL_INCLUDE_DIR@") 6 | SET(QTUTIL_DEFINITIONS "@QTUTIL_DEFINITIONS@") 7 | SET(QTUTIL_LIBRARIES "@QTUTIL_LIBRARIES@") 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/qtcore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # -*- cmake -*- 2 | 3 | INCLUDE(${QT_USE_FILE}) 4 | INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}") 5 | 6 | SET(qtcore_SRC qtcore.h qtcore.cpp) 7 | 8 | MACRO_INSTALL_QTLUA_FILES(qtcore init.lua) 9 | 10 | MACRO_ADD_QTLUA_MODULE(libqtcore ${qtcore_SRC}) 11 | 12 | #ADD_TORCH_DOK(dok qtcore "QT Interface" "Core interface" 6.2) 13 | -------------------------------------------------------------------------------- /doc/index.md: -------------------------------------------------------------------------------- 1 | # QtLua: a Lua interface to QT 2 | 3 | This package includes several useful sub-packages: 4 | 5 | - [qt](qt.md): the global Qt system 6 | - [qtcore](qtcore.md): Core interface 7 | - [qtgui](qtgui.md): GUI 8 | - [qtuiloader](qtuiloader.md): QT Designer UI files loader 9 | - [qtide](qtide.md): QLua Integrated Development Environment (IDE) 10 | - [qtsvg](qtsvg.md): Qt SVG support 11 | - [qtwidget](qtwidget.md): widgets and events 12 | 13 | 14 | -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: qtlua 2 | theme : simplex 3 | repo_url : https://github.com/torch/qtlua 4 | use_directory_urls : false 5 | markdown_extensions: [extra] 6 | docs_dir : doc 7 | pages: 8 | - [index.md, Home] 9 | - [qt.md, Global Qt System] 10 | - [qtcore.md, Core Interface] 11 | - [qtgui.md, Graphical User Interface] 12 | - [qtuiloader.md, Qt Designer UI Files Loader] 13 | - [qtide.md, Integrated Development Environment] 14 | - [qtsvg.md, SVG Support] 15 | - [qtwidget.md, Widgets and Events] 16 | -------------------------------------------------------------------------------- /packages/qtuiloader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # -*- cmake -*- 2 | 3 | SET(QT_USE_QTXML 1) 4 | SET(QT_USE_QTUITOOLS 1) 5 | INCLUDE(${QT_USE_FILE}) 6 | INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}") 7 | 8 | SET(qtuiloader_SRC uiloader.h uiloader.cpp) 9 | 10 | MACRO_INSTALL_QTLUA_FILES(qtuiloader init.lua test.lua test.ui) 11 | 12 | MACRO_ADD_QTLUA_MODULE(libqtuiloader ${qtuiloader_SRC}) 13 | 14 | #ADD_TORCH_DOK(dok qtuiloader "QT Interface" "QT Designer UI files loader" 6.) 15 | -------------------------------------------------------------------------------- /packages/qtsvg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # -*- cmake -*- 2 | 3 | SET(QT_USE_QTXML 1) 4 | SET(QT_USE_QTSVG 1) 5 | INCLUDE(${QT_USE_FILE}) 6 | INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}") 7 | 8 | SET(qtsvg_SRC 9 | qtsvg.h qtsvg.cpp 10 | qtluasvggenerator.h qtluasvggenerator.cpp ) 11 | 12 | MACRO_QT4_AUTOGEN(qtsvg_GEN ${qtsvg_SRC}) 13 | MACRO_ADD_QTLUA_MODULE(libqtsvg ${qtsvg_SRC} ${qtsvg_GEN}) 14 | 15 | MACRO_INSTALL_QTLUA_FILES(qtsvg init.lua) 16 | 17 | #ADD_TORCH_DOK(dok qtsvg "QT Interface" "SVG" 6.) 18 | -------------------------------------------------------------------------------- /packages/qtwidget/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # -*- cmake -*- 2 | 3 | INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}") 4 | INCLUDE(${QT_USE_FILE}) 5 | 6 | SET(qtwidget_SRC 7 | qtluapainter.h qtluapainter.cpp 8 | qtluaprinter.h qtluaprinter.cpp 9 | qtlualistener.h qtlualistener.cpp 10 | qtwidget.h qtwidget.cpp ) 11 | 12 | MACRO_INSTALL_QTLUA_FILES(qtwidget init.lua) 13 | 14 | MACRO_QT4_AUTOGEN(qtwidget_GEN ${qtwidget_SRC}) 15 | MACRO_ADD_QTLUA_MODULE(libqtwidget ${qtwidget_SRC} ${qtwidget_GEN}) 16 | 17 | #ADD_TORCH_DOK(dok qtwidget "QT Interface" "Widgets and events" 6.) 18 | 19 | -------------------------------------------------------------------------------- /packages/qtgui/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # -*- cmake -*- 2 | 3 | IF (QT_QTWEBKIT_FOUND) 4 | SET(QT_USE_QTWEBKIT 1) 5 | SET(QT_USE_QTNETWORK 1) 6 | ADD_DEFINITIONS("-DHAVE_QTWEBKIT=1") 7 | ENDIF (QT_QTWEBKIT_FOUND) 8 | 9 | INCLUDE(${QT_USE_FILE}) 10 | INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}") 11 | 12 | SET(qtgui_SRC qtgui.h qtgui.cpp qtluagui.h qtluagui.cpp) 13 | 14 | MACRO_INSTALL_QTLUA_FILES(qtgui init.lua) 15 | 16 | MACRO_QT4_AUTOGEN(qtgui_GEN ${qtgui_SRC}) 17 | MACRO_ADD_QTLUA_MODULE(libqtgui ${qtgui_SRC} ${qtgui_GEN}) 18 | 19 | #ADD_TORCH_DOK(dok qtgui "QT Interface" "GUI" 6.) 20 | -------------------------------------------------------------------------------- /packages/qtsvg/init.lua: -------------------------------------------------------------------------------- 1 | 2 | require 'qt' 3 | qt.require 'libqtsvg' 4 | 5 | local qt = qt 6 | local type = type 7 | 8 | qtsvg = qtsvg or {} 9 | 10 | function qtsvg.loadsvg(filename) 11 | return qt.QSvgRenderer(filename) 12 | end 13 | 14 | function qtsvg.paintsvg(port,svg,...) 15 | if type(port) == "table" then 16 | port = port.port 17 | end 18 | if not qt.isa(port, "QtLuaPainter") then 19 | error("arg 1 is not a valid painting device", 2) 20 | end 21 | if type(svg) == "string" then 22 | svg = loadsvg(svg) 23 | end 24 | if not qt.isa(svg, "QSvgRenderer") then 25 | error("arg 2 is not a string or a svg renderer", 2) 26 | end 27 | port:gbegin() 28 | svg:render(port:painter(), ...) 29 | port:gend(true) 30 | end 31 | 32 | return qtsvg 33 | -------------------------------------------------------------------------------- /qtutil/qtutilconf.h: -------------------------------------------------------------------------------- 1 | // -*- C -*- 2 | 3 | #ifndef QTUTILCONF_H 4 | #define QTUTILCONF_H 5 | 6 | #ifdef _WIN32 7 | # ifdef libqtutil_EXPORTS 8 | # define QTUTILAPI __declspec(dllexport) 9 | # else 10 | # define QTUTILAPI __declspec(dllimport) 11 | # endif 12 | #else 13 | # define QTUTILAPI 14 | #endif 15 | 16 | #ifdef __cplusplus 17 | # define QTUTIL_EXTERNC extern "C" 18 | #else 19 | # define QTUTIL_EXTERNC extern 20 | #endif 21 | 22 | #endif 23 | 24 | 25 | 26 | 27 | /* ------------------------------------------------------------- 28 | Local Variables: 29 | c++-font-lock-extra-types: ( "\\sw+_t" "lua_[A-Z]\\sw*[a-z]\\sw*" ) 30 | c-font-lock-extra-types: ( "\\sw+_t" "lua_[A-Z]\\sw*[a-z]\\sw*" ) 31 | End: 32 | ------------------------------------------------------------- */ 33 | -------------------------------------------------------------------------------- /rocks/qtlua-scm-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "qtlua" 2 | version = "scm-1" 3 | 4 | source = { 5 | url = "git://github.com/torch/qtlua.git", 6 | } 7 | 8 | description = { 9 | summary = "Powerful QT interface to Lua", 10 | detailed = [[ 11 | ]], 12 | homepage = "https://github.com/torch/qtlua", 13 | license = "BSD" 14 | } 15 | 16 | dependencies = { 17 | "lua >= 5.1", 18 | } 19 | 20 | build = { 21 | type = "command", 22 | build_command = [[ 23 | cmake -E make_directory build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DLUA=$(LUA) -DLUALIB=$(LUALIB) -DLUA_BINDIR="$(LUA_BINDIR)" -DLUA_INCDIR="$(LUA_INCDIR)" -DLUA_LIBDIR="$(LUA_LIBDIR)" -DLUADIR="$(LUADIR)" -DLIBDIR="$(LIBDIR)" -DCONFDIR="$(CONFDIR)" && $(MAKE) 24 | ]], 25 | install_command = "cd build && $(MAKE) install" 26 | } 27 | -------------------------------------------------------------------------------- /packages/qtide/qtide.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QTIDE_H 4 | #define QTIDE_H 5 | 6 | extern "C" { 7 | #include "lua.h" 8 | #include "lauxlib.h" 9 | } 10 | #include "qtluaengine.h" 11 | #include "qtluautils.h" 12 | 13 | 14 | #ifdef _WIN32 15 | # ifdef libqtide_EXPORTS 16 | # define QTIDE_API __declspec(dllexport) 17 | # else 18 | # define QTIDE_API __declspec(dllimport) 19 | # endif 20 | #else 21 | # define QTIDE_API /**/ 22 | #endif 23 | 24 | #define LUA_EXTERNC extern "C" 25 | 26 | LUA_EXTERNC QTIDE_API int luaopen_libqtide(lua_State *L); 27 | 28 | #endif 29 | 30 | 31 | /* ------------------------------------------------------------- 32 | Local Variables: 33 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 34 | End: 35 | ------------------------------------------------------------- */ 36 | 37 | -------------------------------------------------------------------------------- /packages/qtgui/qtgui.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QTGUI_H 4 | #define QTGUI_H 5 | 6 | extern "C" { 7 | #include "lua.h" 8 | #include "lauxlib.h" 9 | } 10 | #include "qtluaengine.h" 11 | #include "qtluautils.h" 12 | 13 | 14 | #ifdef _WIN32 15 | # ifdef libqtgui_EXPORTS 16 | # define QTGUI_API __declspec(dllexport) 17 | # else 18 | # define QTGUI_API __declspec(dllimport) 19 | # endif 20 | #else 21 | # define QTGUI_API /**/ 22 | #endif 23 | 24 | #define LUA_EXTERNC extern "C" 25 | 26 | LUA_EXTERNC QTGUI_API int luaopen_libqtgui(lua_State *L); 27 | 28 | 29 | #endif 30 | 31 | 32 | /* ------------------------------------------------------------- 33 | Local Variables: 34 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 35 | End: 36 | ------------------------------------------------------------- */ 37 | 38 | 39 | -------------------------------------------------------------------------------- /packages/qtsvg/qtsvg.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QTSVG_H 4 | #define QTSVG_H 5 | 6 | extern "C" { 7 | #include "lua.h" 8 | #include "lauxlib.h" 9 | } 10 | #include "qtluaengine.h" 11 | #include "qtluautils.h" 12 | 13 | 14 | #ifdef _WIN32 15 | # ifdef libqtsvg_EXPORTS 16 | # define QTSVG_API __declspec(dllexport) 17 | # else 18 | # define QTSVG_API __declspec(dllimport) 19 | # endif 20 | #else 21 | # define QTSVG_API /**/ 22 | #endif 23 | 24 | #define LUA_EXTERNC extern "C" 25 | 26 | LUA_EXTERNC QTSVG_API int luaopen_libqtsvg(lua_State *L); 27 | 28 | 29 | #endif 30 | 31 | 32 | /* ------------------------------------------------------------- 33 | Local Variables: 34 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 35 | End: 36 | ------------------------------------------------------------- */ 37 | 38 | 39 | -------------------------------------------------------------------------------- /packages/qtcore/qtcore.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QTCORE_H 4 | #define QTCORE_H 5 | 6 | extern "C" { 7 | #include "lua.h" 8 | #include "lauxlib.h" 9 | } 10 | #include "qtluaengine.h" 11 | #include "qtluautils.h" 12 | 13 | 14 | #ifdef _WIN32 15 | # ifdef libqtcore_EXPORTS 16 | # define QTCORE_API __declspec(dllexport) 17 | # else 18 | # define QTCORE_API __declspec(dllimport) 19 | # endif 20 | #else 21 | # define QTCORE_API /**/ 22 | #endif 23 | 24 | #define LUA_EXTERNC extern "C" 25 | 26 | LUA_EXTERNC QTCORE_API int luaopen_libqtcore(lua_State *L); 27 | 28 | 29 | #endif 30 | 31 | 32 | /* ------------------------------------------------------------- 33 | Local Variables: 34 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 35 | End: 36 | ------------------------------------------------------------- */ 37 | 38 | 39 | -------------------------------------------------------------------------------- /packages/qtwidget/qtwidget.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QTWIDGET_H 4 | #define QTWIDGET_H 5 | 6 | extern "C" { 7 | #include "lua.h" 8 | #include "lauxlib.h" 9 | } 10 | #include "qtluaengine.h" 11 | #include "qtluautils.h" 12 | 13 | 14 | #ifdef _WIN32 15 | # ifdef libqtwidget_EXPORTS 16 | # define QTWIDGET_API __declspec(dllexport) 17 | # else 18 | # define QTWIDGET_API __declspec(dllimport) 19 | # endif 20 | #else 21 | # define QTWIDGET_API /**/ 22 | #endif 23 | 24 | #define LUA_EXTERNC extern "C" 25 | 26 | LUA_EXTERNC QTWIDGET_API int luaopen_libqtwidget(lua_State *L); 27 | 28 | 29 | #endif 30 | 31 | 32 | /* ------------------------------------------------------------- 33 | Local Variables: 34 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 35 | End: 36 | ------------------------------------------------------------- */ 37 | 38 | 39 | -------------------------------------------------------------------------------- /packages/qtuiloader/uiloader.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef UILOADER_H 4 | #define UILOADER_H 5 | 6 | extern "C" { 7 | #include "lua.h" 8 | #include "lauxlib.h" 9 | } 10 | #include "qtluaengine.h" 11 | #include "qtluautils.h" 12 | 13 | 14 | #ifdef _WIN32 15 | # ifdef libqtuiloader_EXPORTS 16 | # define QTUILOADER_API __declspec(dllexport) 17 | # else 18 | # define QTUILOADER_API __declspec(dllimport) 19 | # endif 20 | #else 21 | # define QTUILOADER_API /**/ 22 | #endif 23 | 24 | #define LUA_EXTERNC extern "C" 25 | 26 | LUA_EXTERNC QTUILOADER_API int luaopen_libqtuiloader(lua_State *L); 27 | 28 | 29 | #endif 30 | 31 | 32 | /* ------------------------------------------------------------- 33 | Local Variables: 34 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 35 | End: 36 | ------------------------------------------------------------- */ 37 | 38 | 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | QtLua: a Lua interface to QT 2 | ============================== 3 | 4 | This package includes several useful sub-packages: 5 | 6 | - [qt](doc/qt.md): the global Qt system 7 | - [qtcore](doc/qtcore.md): Core interface 8 | - [qtgui](doc/qtgui.md): GUI 9 | - [qtuiloader](doc/qtuiloader.md): QT Designer UI files loader 10 | - [qtide](doc/qtide.md): QLua Integrated Development Environment (IDE) 11 | - [qtsvg](doc/qtsvg.md): Qt SVG support 12 | - [qtwidget](doc/qtwidget.md): widgets and events 13 | 14 | See `qt` and `qtcore` for some binding design notes. A [readthedocs rendered](http://qtlua.readthedocs.io/en/latest/) version of these documents is also available. 15 | 16 | To the best of our knowledge, Torch's QtLua implementation is unrelated to -- and very likely incompatible with -- any other Qt-Lua interop projects including: 17 | 18 | - http://www.nongnu.org/libqtlua/ 19 | - https://github.com/tdzl2003/luaqt 20 | -------------------------------------------------------------------------------- /packages/qtuiloader/init.lua: -------------------------------------------------------------------------------- 1 | 2 | require 'qtcore' 3 | 4 | if qt and qt.qApp and qt.qApp:runsWithoutGraphics() then 5 | print("qlua: not loading module qtuiloader (running with -nographics)") 6 | return 7 | end 8 | 9 | qt.require 'libqtuiloader' 10 | 11 | local qt = qt 12 | 13 | qtuiloader = qtuiloader or {} 14 | local M = qtuiloader 15 | 16 | local theloader = nil 17 | 18 | function M.loader() 19 | if (not theloader or not theloader:tobool()) then 20 | theloader = qt.QUiLoader() 21 | end 22 | return theloader; 23 | end 24 | 25 | local loaderFunctions = { 26 | "load", "availableWidgets", "createWidget", 27 | "createLayout", "createAction", "createActionGroup" } 28 | 29 | for i = 1,#loaderFunctions do 30 | local f = loaderFunctions[i] 31 | M[f] = function(...) 32 | local uiloader = M.loader() 33 | return uiloader[f](uiloader,...) 34 | end 35 | end 36 | 37 | return M 38 | -------------------------------------------------------------------------------- /qlua/qluaconf.h.in: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | #ifndef QLUACONF_H 4 | #define QLUACONF_H 5 | 6 | #ifdef WIN32 7 | # ifdef libqlua_EXPORTS 8 | # define QLUAAPI __declspec(dllexport) 9 | # else 10 | # define QLUAAPI __declspec(dllimport) 11 | # endif 12 | #else 13 | # define QLUAAPI /**/ 14 | #endif 15 | 16 | #cmakedefine QLUA_VERSION "@QLUA_VERSION@" 17 | 18 | #cmakedefine HAVE_IO_H 1 19 | #cmakedefine HAVE_CGETS_S 1 20 | 21 | #cmakedefine HAVE_FCNTL_H 1 22 | #cmakedefine HAVE_PTHREAD_H 1 23 | #cmakedefine HAVE_SIGNAL_H 1 24 | #cmakedefine HAVE_UNISTD_H 1 25 | #cmakedefine HAVE_ERRNO_H 1 26 | #cmakedefine HAVE_SYS_SELECT_H 1 27 | #cmakedefine HAVE_SYS_TIME_H 1 28 | #cmakedefine HAVE_SYS_TYPES_H 1 29 | #cmakedefine HAVE_ISATTY 1 30 | #cmakedefine HAVE_PTHREAD_SIGMASK 1 31 | #cmakedefine HAVE_RL_COMPLETION_MATCHES 1 32 | #cmakedefine HAVE_SIGACTION 1 33 | #cmakedefine HAVE_SIGPROCMASK 1 34 | #cmakedefine HAVE_READLINE 1 35 | #cmakedefine HAVE_XINITTHREADS 1 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /packages/qtgui/qtluagui.cpp: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | 4 | #include "qtluagui.h" 5 | 6 | 7 | 8 | QtLuaAction::QtLuaAction(QtLuaEngine *e, QObject *p) 9 | : QAction(p), enabled(true), override(false), engine(0) 10 | { 11 | setEngine(e); 12 | QCoreApplication *app = QCoreApplication::instance(); 13 | if (app && app->inherits("QLuaApplication")) 14 | connect(app, SIGNAL(newEngine(QtLuaEngine*)), 15 | this, SLOT(setEngine(QtLuaEngine*)) ); 16 | } 17 | 18 | void 19 | QtLuaAction::stateChanged() 20 | { 21 | bool ready = override || (engine && engine->runSignalHandlers()); 22 | QAction::setEnabled(ready && enabled); 23 | } 24 | 25 | 26 | void 27 | QtLuaAction::setEngine(QtLuaEngine *e) 28 | { 29 | if (engine) 30 | disconnect(engine, 0, this, 0); 31 | if ((engine = e)) 32 | connect(engine, SIGNAL(stateChanged(int)), 33 | this, SLOT(stateChanged()) ); 34 | stateChanged(); 35 | } 36 | 37 | 38 | 39 | 40 | 41 | /* ------------------------------------------------------------- 42 | Local Variables: 43 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*" "qreal") 44 | End: 45 | ------------------------------------------------------------- */ 46 | -------------------------------------------------------------------------------- /packages/qtide/qtide.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/editredo.png 4 | images/editundo.png 5 | images/editcopy.png 6 | images/editcut.png 7 | images/editpaste.png 8 | images/editfind.png 9 | images/editbalance.png 10 | images/editprefs.png 11 | images/filenew.png 12 | images/filenewlua.png 13 | images/fileopen.png 14 | images/fileprint.png 15 | images/filesave.png 16 | images/filequit.png 17 | images/helpindex.png 18 | images/playerpause.png 19 | images/playerplay.png 20 | images/playerstop.png 21 | images/playerload.png 22 | images/playerrestart.png 23 | images/home.png 24 | images/left.png 25 | images/right.png 26 | images/up.png 27 | images/down.png 28 | images/history.png 29 | images/refresh.png 30 | images/stop.png 31 | images/clear.png 32 | images/trash.png 33 | images/web.png 34 | 35 | 36 | -------------------------------------------------------------------------------- /cmake/MacroAddQtLuaModule.cmake: -------------------------------------------------------------------------------- 1 | # -*- cmake -*- 2 | # 3 | # MACRO_ADD_QTLUA_MODULE( <...sourcefiles..>) 4 | # Adds a target for a qtlua module. 5 | # Links with the right libraries (lua,qtlua,qt4). 6 | # Adds the right include dirs and definitions. 7 | # Declares the install rule for the target. 8 | 9 | # MACRO_INSTALL_QTLUA_FILES( <...luafiles..>) 10 | # Install lua files for a module. 11 | 12 | 13 | MACRO(MACRO_ADD_QTLUA_MODULE modulename) 14 | FIND_PACKAGE(QtLua REQUIRED) 15 | 16 | ADD_DEFINITIONS(${QTLUA_DEFINITIONS} ${LUA_DEFINITIONS}) 17 | INCLUDE_DIRECTORIES(${QTLUA_INCLUDE_DIR} ${LUA_INCLUDE_DIR}) 18 | 19 | ADD_LIBRARY("${modulename}" MODULE ${ARGN}) 20 | TARGET_LINK_LIBRARIES("${modulename}" ${QTLUA_LIBRARIES} ${LUA_LIBRARIES} ${QT_LIBRARIES}) 21 | 22 | SET_TARGET_PROPERTIES("${modulename}" PROPERTIES PREFIX "") 23 | 24 | INSTALL(TARGETS "${modulename}" 25 | RUNTIME DESTINATION ${QtLua_INSTALL_LUA_CPATH_SUBDIR} 26 | LIBRARY DESTINATION ${QtLua_INSTALL_LUA_CPATH_SUBDIR}) 27 | 28 | ENDMACRO(MACRO_ADD_QTLUA_MODULE modulename) 29 | 30 | 31 | MACRO(MACRO_INSTALL_QTLUA_FILES modulename) 32 | INSTALL(FILES ${ARGN} 33 | DESTINATION "${QtLua_INSTALL_LUA_PATH_SUBDIR}/${modulename}") 34 | ENDMACRO(MACRO_INSTALL_QTLUA_FILES modulename) 35 | 36 | 37 | -------------------------------------------------------------------------------- /packages/qtgui/qtluagui.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QTLUAGUI_H 4 | #define QTLUAGUI_H 5 | 6 | #include "qtgui.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | 15 | class QTGUI_API QtLuaAction : public QAction 16 | { 17 | Q_OBJECT 18 | Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) 19 | Q_PROPERTY(bool autoDisable READ autoDisable WRITE setAutoDisable) 20 | public: 21 | QtLuaAction(QtLuaEngine *e = 0, QObject *p = 0); 22 | bool isEnabled() const { return enabled; } 23 | bool autoDisable() const { return !override; } 24 | public slots: 25 | void stateChanged(); 26 | void setEngine(QtLuaEngine *e); 27 | void setEnabled(bool b) { enabled=b; stateChanged(); } 28 | void setDisabled(bool b) { enabled=!b; stateChanged(); } 29 | void setAutoDisable(bool b) { override=!b; stateChanged(); } 30 | private: 31 | bool enabled; 32 | bool override; 33 | QPointer engine; 34 | }; 35 | 36 | 37 | 38 | 39 | #endif 40 | 41 | 42 | /* ------------------------------------------------------------- 43 | Local Variables: 44 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*" "qreal") 45 | End: 46 | ------------------------------------------------------------- */ 47 | 48 | 49 | -------------------------------------------------------------------------------- /qtlua/qtluautils.h: -------------------------------------------------------------------------------- 1 | // -*- C -*- 2 | 3 | #ifndef QTLUAUTILS_H 4 | #define QTLUAUTILS_H 5 | 6 | extern "C" { 7 | #include "lua.h" 8 | #include "lauxlib.h" 9 | } 10 | #include "qtluaconf.h" 11 | 12 | #ifdef _WIN32 13 | # ifdef libqtlua_EXPORTS 14 | # define QTLUAAPI __declspec(dllexport) 15 | # else 16 | # define QTLUAAPI __declspec(dllimport) 17 | # endif 18 | #else 19 | # define QTLUAAPI 20 | #endif 21 | 22 | 23 | #ifdef __cplusplus 24 | # define QTLUA_EXTERNC extern "C" 25 | #else 26 | # define QTLUA_EXTERNC extern 27 | #endif 28 | 29 | QTLUA_EXTERNC QTLUAAPI void luaQ_getfield(lua_State *L, int index, const char *name); 30 | QTLUA_EXTERNC QTLUAAPI int luaQ_tracebackskip(lua_State *L, int skip); 31 | QTLUA_EXTERNC QTLUAAPI int luaQ_traceback(lua_State *L); 32 | QTLUA_EXTERNC QTLUAAPI int luaQ_complete(lua_State *L); 33 | QTLUA_EXTERNC QTLUAAPI int luaQ_print(lua_State *L, int nr); 34 | QTLUA_EXTERNC QTLUAAPI int luaQ_pcall(lua_State *L, int na, int nr, int eh, int oh); 35 | QTLUA_EXTERNC QTLUAAPI void luaQ_doevents(lua_State *L); 36 | QTLUA_EXTERNC QTLUAAPI int luaopen_qt(lua_State *L); 37 | 38 | #endif 39 | 40 | 41 | 42 | 43 | /* ------------------------------------------------------------- 44 | Local Variables: 45 | c++-font-lock-extra-types: ( "\\sw+_t" "lua_[A-Z]\\sw*[a-z]\\sw*" ) 46 | c-font-lock-extra-types: ( "\\sw+_t" "lua_[A-Z]\\sw*[a-z]\\sw*" ) 47 | End: 48 | ------------------------------------------------------------- */ 49 | -------------------------------------------------------------------------------- /packages/qtwidget/qtlualistener.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QTLUALISTENER_H 4 | #define QTLUALISTENER_H 5 | 6 | #include "lua.h" 7 | #include "lauxlib.h" 8 | #include "qtluaengine.h" 9 | #include "qtluautils.h" 10 | 11 | #include "qtwidget.h" 12 | 13 | 14 | #include 15 | #include 16 | 17 | 18 | class QTWIDGET_API QtLuaListener : public QObject 19 | { 20 | Q_OBJECT 21 | public: 22 | QtLuaListener(QWidget *w); 23 | 24 | signals: 25 | void sigClose(); 26 | void sigResize(int w, int h); 27 | void sigKeyPress(QString text, QByteArray key, QByteArray modifiers); 28 | void sigKeyRelease(QString text, QByteArray key, QByteArray modifiers); 29 | void sigMousePress(int x, int y, QByteArray button, QByteArray m, QByteArray b); 30 | void sigMouseRelease(int x, int y, QByteArray button, QByteArray m, QByteArray b); 31 | void sigMouseDoubleClick(int x, int y, QByteArray button, QByteArray m, QByteArray b); 32 | void sigMouseMove(int x, int y, QByteArray m, QByteArray b); 33 | void sigEnter(bool enter); 34 | void sigFocus(bool focus); 35 | void sigShow(bool show); 36 | void sigPaint(); 37 | 38 | protected: 39 | bool eventFilter(QObject *object, QEvent *event); 40 | private: 41 | QWidget *w; 42 | }; 43 | 44 | 45 | #endif 46 | 47 | 48 | /* ------------------------------------------------------------- 49 | Local Variables: 50 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 51 | End: 52 | ------------------------------------------------------------- */ 53 | 54 | 55 | -------------------------------------------------------------------------------- /packages/qtsvg/qtluasvggenerator.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QTLUASVGGENERATOR_H 4 | #define QTLUASVGGENERATOR_H 5 | 6 | extern "C" { 7 | #include "lua.h" 8 | #include "lauxlib.h" 9 | } 10 | #include "qtluaengine.h" 11 | #include "qtluautils.h" 12 | 13 | #include "qtsvg.h" 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | class QTSVG_API QtLuaSvgGenerator : public QObject, public QSvgGenerator 23 | { 24 | Q_OBJECT 25 | Q_PROPERTY(QString description READ description WRITE setDescription) 26 | Q_PROPERTY(QSize size READ size WRITE setSize) 27 | Q_PROPERTY(QString title READ title WRITE setTitle) 28 | Q_PROPERTY(int resolution READ resolution WRITE setResolution) 29 | public: 30 | ~QtLuaSvgGenerator(); 31 | QtLuaSvgGenerator(QObject *parent=0); 32 | QtLuaSvgGenerator(QString fileName, QObject *parent=0); 33 | Q_INVOKABLE QPaintDevice* device() { return this; } 34 | Q_INVOKABLE QByteArray data(); 35 | QString description() const; 36 | QSize size() const; 37 | QString title() const; 38 | int resolution() const; 39 | public slots: 40 | void setDescription(QString s); 41 | void setSize(QSize s); 42 | void setTitle(QString s); 43 | void setResolution(int r); 44 | public: 45 | struct Private; 46 | private: 47 | Private *d; 48 | signals: 49 | void closing(QObject*); 50 | }; 51 | 52 | 53 | 54 | 55 | #endif 56 | 57 | 58 | /* ------------------------------------------------------------- 59 | Local Variables: 60 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*" "qreal") 61 | End: 62 | ------------------------------------------------------------- */ 63 | 64 | 65 | -------------------------------------------------------------------------------- /qlua/qluaconsole.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QLUACONSOLE_H 4 | #define QLUACONSOLE_H 5 | 6 | #include "qluaconf.h" 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | class QtLuaEngine; 13 | 14 | class QLUAAPI QLuaConsole : public QObject 15 | { 16 | Q_OBJECT 17 | Q_PROPERTY(bool captureOutput 18 | READ captureOutput WRITE setCaptureOutput) 19 | Q_PROPERTY(bool printCapturedOutput 20 | READ printCapturedOutput WRITE setPrintCapturedOutput) 21 | public: 22 | QLuaConsole(QObject *parent); 23 | bool captureOutput() const; 24 | bool printCapturedOutput() const; 25 | 26 | typedef void (*CtrlCHandler)(int); 27 | static const CtrlCHandler ctrlCDefault; 28 | static const CtrlCHandler ctrlCIgnore; 29 | static const CtrlCHandler ctrlCBreak; 30 | CtrlCHandler setCtrlCHandler(CtrlCHandler handler); 31 | 32 | public slots: 33 | void setCaptureOutput(bool); 34 | void setPrintCapturedOutput(bool); 35 | void setQtLuaEngine(QtLuaEngine *engine, bool breakStopsLua=false); 36 | void readLine(QByteArray prompt); 37 | void abortReadLine(); 38 | void redisplayReadLine(); 39 | void addToHistory(QByteArray line); 40 | void drainOutput(); 41 | 42 | signals: 43 | void consoleOutput(QByteArray output); 44 | void ttyInput(QByteArray input); 45 | void ttyEndOfFile(); 46 | void ttyBreak(); 47 | 48 | public: 49 | struct Private; 50 | private: 51 | Private *d; 52 | }; 53 | 54 | 55 | 56 | #endif 57 | 58 | 59 | /* ------------------------------------------------------------- 60 | Local Variables: 61 | c++-font-lock-extra-types: ( "\\sw+_t" "[A-Z]\\sw*[a-z]\\sw*" ) 62 | End: 63 | ------------------------------------------------------------- */ 64 | 65 | -------------------------------------------------------------------------------- /qtlua/qtluaconf.h.in: -------------------------------------------------------------------------------- 1 | // -*- C -*- 2 | 3 | #ifndef QTLUACONF_H 4 | #define QTLUACONF_H 5 | 6 | #ifdef WIN32 7 | # ifdef libqtlua_EXPORTS 8 | # define QTLUAAPI __declspec(dllexport) 9 | # else 10 | # define QTLUAAPI __declspec(dllimport) 11 | # endif 12 | #else 13 | # define QTLUAAPI 14 | #endif 15 | 16 | #ifdef __cplusplus 17 | # define QTLUA_EXTERNC extern "C" 18 | #else 19 | # define QTLUA_EXTERNC extern 20 | #endif 21 | 22 | #if !defined LUA_VERSION_NUM || LUA_VERSION_NUM==501 23 | # define lua_pushglobaltable(L) lua_pushvalue(L, LUA_GLOBALSINDEX) 24 | # define lua_setuservalue lua_setfenv 25 | # define lua_getuservalue lua_getfenv 26 | # define luaQ_typerror luaL_typerror 27 | static void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { 28 | luaL_checkstack(L, nup+1, "too many upvalues"); 29 | for (; l->name != NULL; l++) { /* fill the table with given functions */ 30 | int i; 31 | lua_pushstring(L, l->name); 32 | for (i = 0; i < nup; i++) /* copy upvalues to the top */ 33 | lua_pushvalue(L, -(nup+1)); 34 | lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ 35 | lua_settable(L, -(nup + 3)); 36 | } 37 | lua_pop(L, nup); /* remove upvalues */ 38 | } 39 | #else 40 | # define lua_objlen lua_rawlen 41 | # define LUA_PATHSEP ";" 42 | static int luaQ_typerror(lua_State *L, int narg, const char *tname) 43 | { 44 | return luaL_error(L, "%s expected, got %s", tname, luaL_typename(L, narg)); 45 | } 46 | #endif 47 | 48 | #endif 49 | 50 | 51 | /* ------------------------------------------------------------- 52 | Local Variables: 53 | c++-font-lock-extra-types: ( "\\sw+_t" "lua_[A-Z]\\sw*[a-z]\\sw*" ) 54 | c-font-lock-extra-types: ( "\\sw+_t" "lua_[A-Z]\\sw*[a-z]\\sw*" ) 55 | End: 56 | ------------------------------------------------------------- */ 57 | -------------------------------------------------------------------------------- /qtutil/qthumbwheel.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QTHUMBWHEEL_H 4 | #define QTHUMBWHEEL_H 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class QMouseEvent; 12 | class QPaintEvent; 13 | class QResizeEvent; 14 | 15 | // Reimplemented the thumbwheel widget from qt solutions from scratch. 16 | // http://doc.trolltech.com/solutions/4/qtthumbwheel/qtthumbwheel.html. 17 | // Note: limitedDrag does nothing. 18 | 19 | class QThumbWheel : public QAbstractSlider 20 | { 21 | Q_OBJECT 22 | Q_PROPERTY(int cogCount 23 | READ cogCount WRITE setCogCount) 24 | Q_PROPERTY(double transmissionRatio 25 | READ transmissionRatio WRITE setTransmissionRatio) 26 | Q_PROPERTY(bool wrapsAround 27 | READ wrapsAround WRITE setWrapsAround) 28 | public: 29 | QThumbWheel(QWidget *parent = 0); 30 | QThumbWheel(int mi, int ma, int st, int v, Qt::Orientation o, QWidget *p=0); 31 | ~QThumbWheel(); 32 | int cogCount(); 33 | double transmissionRatio(); 34 | bool wrapsAround(); 35 | public slots: 36 | void setCogCount(int); 37 | void setTransmissionRatio(double); 38 | void setWrapsAround(bool); 39 | 40 | protected: 41 | QSize sizeHint() const; 42 | QSize minimumSizeHint() const; 43 | void resizeEvent(QResizeEvent *); 44 | void paintEvent(QPaintEvent*); 45 | void mousePressEvent(QMouseEvent*); 46 | void mouseReleaseEvent(QMouseEvent*); 47 | void mouseMoveEvent(QMouseEvent*); 48 | 49 | private: 50 | struct Private; 51 | Private *d; 52 | }; 53 | 54 | 55 | #endif 56 | 57 | 58 | 59 | 60 | /* ------------------------------------------------------------- 61 | Local Variables: 62 | c++-font-lock-extra-types: ( "\\sw+_t" "[A-Z]\\sw*[a-z]\\sw*" ) 63 | End: 64 | ------------------------------------------------------------- */ 65 | 66 | -------------------------------------------------------------------------------- /qtutil/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # -*- cmake -*- 2 | 3 | SET(QTLUA_DEFINITIONS) 4 | SET(QTLUA_INCLUDE_DIR 5 | "${CMAKE_CURRENT_SOURCE_DIR}" 6 | "${CMAKE_CURRENT_BINARY_DIR}") 7 | 8 | ADD_DEFINITIONS( ${QTUTIL_DEFINITIONS} ${LUA_DEFINITIONS}) 9 | INCLUDE_DIRECTORIES(${QTUTIL_INCLUDE_DIR} ${LUA_INCLUDE_DIR}) 10 | INCLUDE(${QT_USE_FILE}) 11 | 12 | 13 | # --- compile library 14 | 15 | SET(qtutil_SRC 16 | "qmenuaction.h" "qmenuaction.cpp" 17 | "qthumbwheel.h" "qthumbwheel.cpp" ) 18 | 19 | MACRO_QT4_AUTOGEN(qtutil_GEN ${qtutil_SRC}) 20 | 21 | ADD_LIBRARY(libqtutil SHARED ${qtutil_SRC} ${qtutil_GEN}) 22 | TARGET_LINK_LIBRARIES(libqtutil ${LUA_LIBRARIES} ${QT_LIBRARIES}) 23 | SET_TARGET_PROPERTIES(libqtutil PROPERTIES 24 | LINKER_LANGUAGE CXX 25 | OUTPUT_NAME "qtutil" ) 26 | 27 | # --- install library and include files 28 | 29 | INSTALL(TARGETS libqtutil 30 | RUNTIME DESTINATION ${QtLua_INSTALL_BIN_SUBDIR} 31 | LIBRARY DESTINATION ${QtLua_INSTALL_LIB_SUBDIR} 32 | ARCHIVE DESTINATION ${QtLua_INSTALL_LIB_SUBDIR} ) 33 | 34 | # --- config for internal use 35 | 36 | SET(QTUTIL_LIBRARIES "libqtutil") 37 | SET(QTUTIL_DEFINITIONS) 38 | CONFIGURE_FILE(QtUtilConfig.cmake.in 39 | "${QtLua_INSTALL_FINDLUA_DIR}/QtUtilConfig.cmake") 40 | SET(QtUtil_DIR "${QtLua_INSTALL_FINDLUA_DIR}" CACHE PATH 41 | "Directory containing QtUtilConfig.cmake") 42 | MARK_AS_ADVANCED(QtUtil_DIR) 43 | 44 | # --- config for external use 45 | 46 | GET_TARGET_PROPERTY(QTUTIL_OUTPUT_NAME libqtutil LOCATION) 47 | GET_FILENAME_COMPONENT(QTUTIL_OUTPUT_NAME ${QTUTIL_OUTPUT_NAME} NAME) 48 | SET(QTUTIL_LIBRARIES "${QtLua_INSTALL_LIB}/${QTUTIL_OUTPUT_NAME}") 49 | SET(QTUTIL_INCLUDE_DIR "${QtLua_INSTALL_INCLUDE}/qtutil") 50 | CONFIGURE_FILE("QtUtilConfig.cmake.in" 51 | "${QtLua_BINARY_DIR}/cmake-external/QtUtilConfig.cmake") 52 | INSTALL(FILES "${QtLua_BINARY_DIR}/cmake-external/QtUtilConfig.cmake" 53 | DESTINATION "${QtLua_INSTALL_CMAKE_SUBDIR}") 54 | 55 | -------------------------------------------------------------------------------- /packages/qtide/qluamdimain.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QLUAMDIMAIN_H 4 | #define QLUAMDIMAIN_H 5 | 6 | #include "qtide.h" 7 | #include "qluamainwindow.h" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | 20 | // MDI Wrapper 21 | 22 | class QTIDE_API QLuaMdiMain : public QLuaMainWindow 23 | { 24 | Q_OBJECT 25 | Q_PROPERTY(bool tabMode READ isTabMode WRITE setTabMode) 26 | Q_PROPERTY(QByteArray clientClass READ clientClass WRITE setClientClass) 27 | 28 | public: 29 | ~QLuaMdiMain(); 30 | QLuaMdiMain(QWidget *parent=0); 31 | 32 | Q_INVOKABLE QMdiArea* mdiArea(); 33 | Q_INVOKABLE bool isActive(QWidget *w); 34 | Q_INVOKABLE bool isTabMode() const; 35 | Q_INVOKABLE QByteArray clientClass() const; 36 | Q_INVOKABLE QWidget *activeWindow() const; 37 | 38 | virtual bool canClose(); 39 | virtual void loadSettings(); 40 | virtual void saveMdiSettings(); 41 | virtual QMenuBar *menuBar(); 42 | virtual QToolBar *createToolBar(); 43 | virtual QMenuBar *createMenuBar(); 44 | virtual QStatusBar *createStatusBar(); 45 | QAction *tileAction(); 46 | QAction *cascadeAction(); 47 | QAction *tabModeAction(); 48 | QAction *dockAction(); 49 | 50 | public slots: 51 | bool activate(QWidget *w); 52 | bool adopt(QWidget *w); 53 | void adoptAll(); 54 | void setTabMode(bool b); 55 | void setClientClass(QByteArray c); 56 | void doNew(); 57 | 58 | public: 59 | class Client; 60 | class Private; 61 | class Shell; 62 | private: 63 | Private *d; 64 | }; 65 | 66 | 67 | #endif 68 | 69 | 70 | /* ------------------------------------------------------------- 71 | Local Variables: 72 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 73 | End: 74 | ------------------------------------------------------------- */ 75 | 76 | -------------------------------------------------------------------------------- /Copyright.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2014 Idiap Research Institute (Ronan Collobert) 2 | Copyright (c) 2012-2014 Deepmind Technologies (Koray Kavukcuoglu) 3 | Copyright (c) 2011-2012 NEC Laboratories America (Koray Kavukcuoglu) 4 | Copyright (c) 2011-2013 NYU (Clement Farabet) 5 | Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert, Leon Bottou, Iain Melvin, Jason Weston) 6 | Copyright (c) 2006 Idiap Research Institute (Samy Bengio) 7 | Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert, Samy Bengio, Johnny Mariethoz) 8 | 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | 14 | 1. Redistributions of source code must retain the above copyright 15 | notice, this list of conditions and the following disclaimer. 16 | 17 | 2. Redistributions in binary form must reproduce the above copyright 18 | notice, this list of conditions and the following disclaimer in the 19 | documentation and/or other materials provided with the distribution. 20 | 21 | 3. Neither the names of Deepmind Technologies, NYU, NEC Laboratories America 22 | and IDIAP Research Institute nor the names of its contributors may be 23 | used to endorse or promote products derived from this software without 24 | specific prior written permission. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 30 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 | POSSIBILITY OF SUCH DAMAGE. 37 | -------------------------------------------------------------------------------- /packages/qtide/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # -*- cmake -*- 2 | 3 | INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}") 4 | 5 | # we need qt>=4.4 for this section 6 | IF (QT4_FOUND AND WITH_QTLUA_IDE) 7 | IF (QTVERSION AND NOT QT_VERSION_MAJOR) 8 | STRING(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*" 9 | "\\1*10000+\\2*100+\\3" qt_version_expr "${QTVERSION}") 10 | MATH(EXPR QT_VERSION "${qt_version_expr}") 11 | ELSEIF (QT_VERSION_MAJOR) 12 | MATH(EXPR QT_VERSION 13 | "${QT_VERSION_MAJOR}*10000+${QT_VERSION_MINOR}*100+${QT_VERSION_PATCH}") 14 | ENDIF (QTVERSION AND NOT QT_VERSION_MAJOR) 15 | IF (NOT QT_VERSION OR QT_VERSION LESS "40400") 16 | MESSAGE(STATUS "Disabling package QTIDE (Needs Qt>=4.4.0)") 17 | SET(WITH_QTLUA_IDE FALSE) 18 | ENDIF (NOT QT_VERSION OR QT_VERSION LESS "40400") 19 | ENDIF (QT4_FOUND AND WITH_QTLUA_IDE) 20 | 21 | # proceed 22 | IF (WITH_QTLUA_IDE) 23 | # find qt 24 | IF (QT_QTWEBKIT_FOUND) 25 | SET(QT_USE_QTWEBKIT 1) 26 | SET(QT_USE_QTNETWORK 1) 27 | ADD_DEFINITIONS("-DHAVE_QTWEBKIT=1") 28 | ENDIF (QT_QTWEBKIT_FOUND) 29 | INCLUDE(${QT_USE_FILE}) 30 | # find qlua 31 | FIND_PACKAGE(QLua REQUIRED) 32 | INCLUDE_DIRECTORIES(${QLUA_INCLUDE_DIR}) 33 | ADD_DEFINITIONS(${QLUA_DEFINITIONS}) 34 | 35 | SET(qtide_SRC 36 | qtide.h qtide.cpp qtide.qrc 37 | qluatextedit.h qluatextedit.cpp 38 | qluagotodialog.ui qluafinddialog.ui qluareplacedialog.ui 39 | qluaide.h qluaide.cpp 40 | qluamainwindow.h qluamainwindow.cpp 41 | qluabrowser.h qluabrowser.cpp 42 | qluaeditor.h qluaeditor.cpp 43 | qluasdimain.h qluasdimain.cpp 44 | qluamdimain.h qluamdimain.cpp 45 | qluamode.h qluamode.cpp 46 | qluamode_txt.cpp 47 | qluamode_hlp.cpp 48 | qluamode_lua.cpp 49 | qluamode_c.cpp ) 50 | 51 | MACRO_QT4_AUTOGEN(qtide_GEN ${qtide_SRC}) 52 | MACRO_ADD_QTLUA_MODULE(libqtide ${qtide_SRC} ${qtide_GEN}) 53 | TARGET_LINK_LIBRARIES(libqtide ${QLUA_LIBRARIES}) 54 | 55 | MACRO_INSTALL_QTLUA_FILES(qtide init.lua prefs.lua prefs.ui) 56 | # ADD_TORCH_DOK(dok qtide "QT Interface" "QT IDE for Lua" 6.) 57 | 58 | ENDIF(WITH_QTLUA_IDE) 59 | 60 | -------------------------------------------------------------------------------- /qtlua/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # -*- cmake -*- 2 | 3 | SET(QTLUA_DEFINITIONS) 4 | SET(QTLUA_INCLUDE_DIR 5 | "${CMAKE_CURRENT_SOURCE_DIR}" 6 | "${CMAKE_CURRENT_BINARY_DIR}") 7 | 8 | ADD_DEFINITIONS( ${QTLUA_DEFINITIONS} ${LUA_DEFINITIONS}) 9 | INCLUDE_DIRECTORIES(${QTLUA_INCLUDE_DIR} ${LUA_INCLUDE_DIR}) 10 | SET(QT_DONT_USE_QTGUI 1) 11 | INCLUDE(${QT_USE_FILE}) 12 | 13 | CONFIGURE_FILE("qtluaconf.h.in" "${CMAKE_CURRENT_BINARY_DIR}/qtluaconf.h") 14 | 15 | # --- compile library 16 | 17 | SET(qtlua_SRC "qtluautils.h" "qtluautils.cpp" "qtluaengine.h" "qtluaengine.cpp") 18 | MACRO_QT4_AUTOGEN(qtlua_GEN ${qtlua_SRC}) 19 | 20 | ADD_LIBRARY(libqtlua SHARED ${qtlua_SRC} ${qtlua_GEN}) 21 | TARGET_LINK_LIBRARIES(libqtlua ${LUA_LIBRARIES} ${QT_LIBRARIES}) 22 | SET_TARGET_PROPERTIES(libqtlua PROPERTIES 23 | LINKER_LANGUAGE CXX 24 | OUTPUT_NAME "qtlua" ) 25 | 26 | # --- install library and include files 27 | 28 | INSTALL(TARGETS libqtlua 29 | RUNTIME DESTINATION ${QtLua_INSTALL_BIN_SUBDIR} 30 | LIBRARY DESTINATION ${QtLua_INSTALL_LIB_SUBDIR} 31 | ARCHIVE DESTINATION ${QtLua_INSTALL_LIB_SUBDIR} ) 32 | 33 | INSTALL(FILES 34 | ${CMAKE_CURRENT_SOURCE_DIR}/qtluaengine.h 35 | ${CMAKE_CURRENT_SOURCE_DIR}/qtluautils.h 36 | ${CMAKE_CURRENT_BINARY_DIR}/qtluaconf.h 37 | DESTINATION ${QtLua_INSTALL_INCLUDE_SUBDIR}/qtlua 38 | ) 39 | 40 | # --- config for internal use 41 | 42 | SET(QTLUA_LIBRARIES "libqtlua") 43 | SET(QTLUA_DEFINITIONS) 44 | CONFIGURE_FILE(QtLuaConfig.cmake.in 45 | "${QtLua_BINARY_DIR}/cmake/QtLuaConfig.cmake") 46 | SET(QtLua_DIR "${QtLua_BINARY_DIR}/cmake" CACHE PATH 47 | "Directory containing QtLuaConfig.cmake") 48 | MARK_AS_ADVANCED(QtLua_DIR) 49 | 50 | # --- config for external use 51 | 52 | GET_TARGET_PROPERTY(QTLUA_OUTPUT_NAME libqtlua LOCATION) 53 | GET_FILENAME_COMPONENT(QTLUA_OUTPUT_NAME ${QTLUA_OUTPUT_NAME} NAME) 54 | SET(QTLUA_LIBRARIES "${QtLua_INSTALL_LIB}/${QTLUA_OUTPUT_NAME}") 55 | SET(QTLUA_INCLUDE_DIR "${QtLua_INSTALL_INCLUDE}/qtlua") 56 | CONFIGURE_FILE("QtLuaConfig.cmake.in" 57 | "${QtLua_BINARY_DIR}/cmake-external/QtLuaConfig.cmake") 58 | INSTALL(FILES "${QtLua_BINARY_DIR}/cmake-external/QtLuaConfig.cmake" 59 | DESTINATION "${QtLua_INSTALL_CMAKE_SUBDIR}") 60 | 61 | -------------------------------------------------------------------------------- /packages/qtide/qluamainwindow.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QLUAMAINWINDOW_H 4 | #define QLUAMAINWINDOW_H 5 | 6 | #include "qtide.h" 7 | 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | 20 | class QLuaEditor; 21 | class QLuaTextEdit; 22 | class QLuaTextEditModeFactory; 23 | class QMenu; 24 | class QMenuBar; 25 | class QStatusBar; 26 | class QToolBar; 27 | class QUrl; 28 | 29 | 30 | 31 | 32 | // Text Editor 33 | 34 | class QTIDE_API QLuaMainWindow : public QMainWindow 35 | { 36 | Q_OBJECT 37 | public: 38 | ~QLuaMainWindow(); 39 | QLuaMainWindow(QString objName, QWidget *parent=0); 40 | Q_INVOKABLE QAction *hasAction(QByteArray what); 41 | Q_INVOKABLE QAction *stdAction(QByteArray what); 42 | virtual QAction *createAction(QByteArray name); 43 | virtual QMenuBar *menuBar(); 44 | virtual QMenuBar *createMenuBar(); 45 | virtual QToolBar *toolBar(); 46 | virtual QToolBar *createToolBar(); 47 | virtual QStatusBar *statusBar(); 48 | virtual QStatusBar *createStatusBar(); 49 | virtual QPrinter *loadPageSetup(); 50 | virtual void savePageSetup(); 51 | virtual void loadSettings(); 52 | virtual void saveSettings(); 53 | virtual bool canClose(); 54 | 55 | public slots: 56 | virtual void updateActions(); 57 | virtual void updateActionsLater(); 58 | virtual void clearStatusMessage(); 59 | virtual void showStatusMessage(const QString & message, int timeout=0); 60 | virtual bool openFile(QString fileName, bool inOther=false); 61 | virtual bool newDocument(); 62 | protected: 63 | virtual void closeEvent(QCloseEvent *e); 64 | QAction *newAction(QString title); 65 | QAction *newAction(QString title, bool checked); 66 | QMenu *newMenu(QString title); 67 | public: 68 | class Private; 69 | private: 70 | Private *d; 71 | }; 72 | 73 | 74 | 75 | 76 | 77 | #endif 78 | 79 | 80 | /* ------------------------------------------------------------- 81 | Local Variables: 82 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 83 | End: 84 | ------------------------------------------------------------- */ 85 | 86 | -------------------------------------------------------------------------------- /cmake/MacroQt4AutoGen.cmake: -------------------------------------------------------------------------------- 1 | # -*- cmake -*- 2 | # 3 | # MACRO_QT4_AUTOGEN( <..infiles..>) 4 | # examines the files <...infiles...> and produces rules 5 | # to generate C++ files that should be compiled. 6 | # The names of the generated files is added into variable . 7 | # The following cases are recognized (emulating qmake) 8 | # 9 | # 1- For each header files containing the string Q_OBJECT 10 | # a file named is generated using moc. 11 | # 2- For each resource file , 12 | # a file named is generated using rcc. 13 | # 3- For each source file or 14 | # containing the string Q_OBJECT, a file named 15 | # is generated using . It is expected that the C++ file 16 | # includes this file. 17 | # 4- For each designed file , 18 | # a file named is generated using uic. 19 | # 20 | # Copyright (c) 2007, Leon Bottou 21 | # 22 | # Redistribution and use is allowed according to the terms of the BSD license. 23 | 24 | INCLUDE(MacroAddFileDependencies) 25 | 26 | MACRO(MACRO_QT4_AUTOGEN outfiles) 27 | FOREACH (it ${ARGN}) 28 | GET_FILENAME_COMPONENT(ext "${it}" EXT) 29 | IF ("${ext}" MATCHES "^\\.(ui)$") 30 | QT4_WRAP_UI(${outfiles} "${it}") 31 | ELSEIF ("${ext}" MATCHES "^\\.(qrc)$") 32 | QT4_ADD_RESOURCES(${outfiles} "${it}") 33 | ELSEIF ("${ext}" MATCHES "^\\.(h)$") 34 | GET_FILENAME_COMPONENT(abs "${it}" ABSOLUTE) 35 | IF (EXISTS "${abs}") 36 | FILE(READ "${abs}" _contents) 37 | STRING(REGEX MATCH "Q_OBJECT" _match "${_contents}") 38 | IF (_match) 39 | QT4_WRAP_CPP(${outfiles} "${it}") 40 | ENDIF (_match) 41 | ENDIF(EXISTS "${abs}") 42 | ELSEIF ("${ext}" MATCHES "^\\.(cpp|cxx)$") 43 | GET_FILENAME_COMPONENT(abs "${it}" ABSOLUTE) 44 | GET_FILENAME_COMPONENT(nam "${it}" NAME_WE) 45 | IF (EXISTS "${abs}") 46 | FILE(READ "${abs}" _contents) 47 | STRING(REGEX MATCH "Q_OBJECT" _match "${_contents}") 48 | IF (_match) 49 | QT4_GENERATE_MOC("${abs}" "${CMAKE_CURRENT_BINARY_DIR}/${nam}.moc") 50 | MACRO_ADD_FILE_DEPENDENCIES("${it}" "${CMAKE_CURRENT_BINARY_DIR}/${nam}.moc") 51 | ENDIF (_match) 52 | ENDIF(EXISTS "${abs}") 53 | ENDIF ("${ext}" MATCHES "^\\.(ui)$") 54 | ENDFOREACH(it) 55 | ENDMACRO(MACRO_QT4_AUTOGEN outfiles) -------------------------------------------------------------------------------- /cmake/FindReadline.cmake: -------------------------------------------------------------------------------- 1 | # - Find the readline library 2 | # This module defines 3 | # READLINE_INCLUDE_DIR, path to readline/readline.h, etc. 4 | # READLINE_LIBRARIES, the libraries required to use READLINE. 5 | # READLINE_FOUND, If false, do not try to use READLINE. 6 | # also defined, but not for general use are 7 | # READLINE_readline_LIBRARY, where to find the READLINE library. 8 | # READLINE_ncurses_LIBRARY, where to find the ncurses library [might not be defined] 9 | 10 | # Apple readline does not support readline hooks 11 | # So we look for another one by default 12 | IF(APPLE) 13 | FIND_PATH(READLINE_INCLUDE_DIR NAMES readline/readline.h PATHS 14 | /sw/include 15 | /opt/local/include 16 | /opt/include 17 | /usr/local/include 18 | /usr/include/ 19 | NO_DEFAULT_PATH 20 | ) 21 | ENDIF(APPLE) 22 | FIND_PATH(READLINE_INCLUDE_DIR NAMES readline/readline.h) 23 | 24 | 25 | # Apple readline does not support readline hooks 26 | # So we look for another one by default 27 | IF(APPLE) 28 | FIND_LIBRARY(READLINE_readline_LIBRARY NAMES readline PATHS 29 | /sw/lib 30 | /opt/local/lib 31 | /opt/lib 32 | /usr/local/lib 33 | /usr/lib 34 | NO_DEFAULT_PATH 35 | ) 36 | ENDIF(APPLE) 37 | FIND_LIBRARY(READLINE_readline_LIBRARY NAMES readline) 38 | 39 | # Sometimes readline really needs ncurses 40 | IF(APPLE) 41 | FIND_LIBRARY(READLINE_ncurses_LIBRARY NAMES ncurses PATHS 42 | /sw/lib 43 | /opt/local/lib 44 | /opt/lib 45 | /usr/local/lib 46 | /usr/lib 47 | NO_DEFAULT_PATH 48 | ) 49 | ENDIF(APPLE) 50 | FIND_LIBRARY(READLINE_ncurses_LIBRARY NAMES ncurses) 51 | 52 | MARK_AS_ADVANCED( 53 | READLINE_INCLUDE_DIR 54 | READLINE_readline_LIBRARY 55 | READLINE_ncurses_LIBRARY 56 | ) 57 | 58 | SET( READLINE_FOUND "NO" ) 59 | IF(READLINE_INCLUDE_DIR) 60 | IF(READLINE_readline_LIBRARY) 61 | SET( READLINE_FOUND "YES" ) 62 | SET( READLINE_LIBRARIES 63 | ${READLINE_readline_LIBRARY} 64 | ) 65 | 66 | # some readline libraries depend on ncurses 67 | IF(READLINE_ncurses_LIBRARY) 68 | SET(READLINE_LIBRARIES ${READLINE_LIBRARIES} ${READLINE_ncurses_LIBRARY}) 69 | ENDIF(READLINE_ncurses_LIBRARY) 70 | 71 | ENDIF(READLINE_readline_LIBRARY) 72 | ENDIF(READLINE_INCLUDE_DIR) 73 | 74 | IF(READLINE_FOUND) 75 | MESSAGE(STATUS "Found readline library") 76 | ELSE(READLINE_FOUND) 77 | IF(READLINE_FIND_REQUIRED) 78 | MESSAGE(FATAL_ERROR "Could not find readline -- please give some paths to CMake") 79 | ENDIF(READLINE_FIND_REQUIRED) 80 | ENDIF(READLINE_FOUND) 81 | -------------------------------------------------------------------------------- /packages/qtide/qluaeditor.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QLUAEDITOR_H 4 | #define QLUAEDITOR_H 5 | 6 | #include "qtide.h" 7 | #include "qluatextedit.h" 8 | #include "qluamainwindow.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | 16 | 17 | 18 | // Text Editor 19 | 20 | class QTIDE_API QLuaEditor : public QLuaMainWindow 21 | { 22 | Q_OBJECT 23 | Q_PROPERTY(QString fileName READ fileName WRITE setFileName) 24 | 25 | public: 26 | QLuaEditor(QWidget *parent=0); 27 | 28 | Q_INVOKABLE virtual bool readFile(QFile &file); 29 | Q_INVOKABLE virtual bool writeFile(QFile &file, bool rename=false); 30 | Q_INVOKABLE bool readFile(QString fname); 31 | Q_INVOKABLE bool writeFile(QString fname, bool rename=true); 32 | Q_INVOKABLE QLuaTextEdit *widget(); 33 | QString fileName() const; 34 | void setFileName(QString fname); 35 | 36 | virtual QAction *createAction(QByteArray); 37 | virtual QToolBar *createToolBar(); 38 | virtual QMenuBar *createMenuBar(); 39 | virtual QStatusBar *createStatusBar(); 40 | virtual bool canClose(); 41 | virtual void loadSettings(); 42 | virtual void saveSettings(); 43 | 44 | public slots: 45 | virtual bool openFile(QString fileName, bool inOther=false); 46 | virtual bool newDocument(); 47 | virtual void updateStatusBar(); 48 | virtual void updateWindowTitle(); 49 | virtual void updateActions(); 50 | virtual void doSave(); 51 | virtual void doSaveAs(); 52 | virtual void doPrint(); 53 | virtual void doSelectAll(); 54 | virtual void doUndo(); 55 | virtual void doRedo(); 56 | virtual void doCut(); 57 | virtual void doCopy(); 58 | virtual void doPaste(); 59 | virtual void doGoto(); 60 | virtual void doFind(); 61 | virtual void doReplace(); 62 | virtual void doMode(QLuaTextEditModeFactory*); 63 | virtual void doLineWrap(bool); 64 | virtual void doLineNumbers(bool); 65 | virtual void doHighlight(bool); 66 | virtual void doAutoIndent(bool); 67 | virtual void doAutoMatch(bool); 68 | virtual void doCompletion(bool); 69 | virtual void doBalance(); 70 | virtual void doLoad(); 71 | virtual void doEval(); 72 | virtual void doRestart(); 73 | 74 | public: 75 | class Private; 76 | private: 77 | Private *d; 78 | }; 79 | 80 | 81 | 82 | 83 | #endif 84 | 85 | 86 | /* ------------------------------------------------------------- 87 | Local Variables: 88 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 89 | End: 90 | ------------------------------------------------------------- */ 91 | 92 | -------------------------------------------------------------------------------- /packages/qtide/qluabrowser.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QLUABROWSER_H 4 | #define QLUABROWSER_H 5 | 6 | #include "qtide.h" 7 | #include "qluamainwindow.h" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #if HAVE_QTWEBKIT 14 | # include 15 | # include 16 | # include 17 | #else 18 | class QWebPage; 19 | class QWebView; 20 | #endif 21 | 22 | // Text Editor 23 | 24 | class QTIDE_API QLuaBrowser : public QLuaMainWindow 25 | { 26 | Q_OBJECT 27 | Q_PROPERTY(QUrl url READ url WRITE setUrl) 28 | Q_PROPERTY(QUrl homeUrl READ homeUrl WRITE setHomeUrl) 29 | Q_PROPERTY(QString baseTitle READ baseTitle WRITE setBaseTitle) 30 | Q_PROPERTY(QString pageTitle READ pageTitle) 31 | Q_PROPERTY(QString html READ toHtml WRITE setHtml) 32 | public: 33 | QLuaBrowser(QWidget *parent=0); 34 | QUrl url() const; 35 | QUrl homeUrl() const; 36 | QString baseTitle() const; 37 | QString pageTitle() const; 38 | QString toHtml() const; 39 | Q_INVOKABLE QWebView *view(); 40 | Q_INVOKABLE QWebPage *page(); 41 | public slots: 42 | void setUrl(QUrl url); 43 | void setHomeUrl(QUrl url); 44 | void setBaseTitle(QString s); 45 | void setHtml(QString html); 46 | virtual bool openFile(QString fileName, bool inOther=false); 47 | virtual bool newDocument(); 48 | virtual void doOpenLocation(); 49 | virtual void doOpenBrowser(); 50 | virtual void doSaveAs(); 51 | virtual void doPrint(); 52 | virtual void doCopy(); 53 | virtual void doEdit(); 54 | virtual void doFind(); 55 | virtual void doHome(); 56 | virtual void doForward(); 57 | virtual void doBackward(); 58 | virtual void doStop(); 59 | virtual void doReload(); 60 | virtual void doZoomIn(); 61 | virtual void doZoomOut(); 62 | virtual void doZoomReset(); 63 | virtual void updateWindowTitle(); 64 | virtual void updateWindowIcon(); 65 | virtual void updateActions(); 66 | public: 67 | virtual QAction *createAction(QByteArray); 68 | virtual QToolBar *createToolBar(); 69 | virtual QMenuBar *createMenuBar(); 70 | virtual QStatusBar *createStatusBar(); 71 | virtual void loadSettings(); 72 | virtual void saveSettings(); 73 | class Private; 74 | class WebView; 75 | class FindDialog; 76 | private: 77 | Private *d; 78 | }; 79 | 80 | #endif 81 | 82 | 83 | 84 | /* ------------------------------------------------------------- 85 | Local Variables: 86 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 87 | End: 88 | ------------------------------------------------------------- */ 89 | -------------------------------------------------------------------------------- /qlua/qluaapplication.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QLUAAPPLICATION_H 4 | #define QLUAAPPLICATION_H 5 | 6 | #include "qluaconf.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #define QLUA_ORG "QLua" 15 | #define LUA_DOMAIN "lua.org" 16 | 17 | class QtLuaEngine; 18 | 19 | class QLuaConsole; 20 | 21 | class QLUAAPI QLuaApplication : public QApplication 22 | { 23 | Q_OBJECT 24 | Q_PROPERTY(QString aboutMessage READ aboutMessage WRITE setAboutMessage) 25 | 26 | public: 27 | ~QLuaApplication(); 28 | QLuaApplication(int &argc, char **argv, 29 | bool guiEnabled=true, bool oneThread=false); 30 | int main(int argc, char **argv); 31 | static QLuaApplication *instance(); 32 | static QLuaConsole *console(); 33 | static QtLuaEngine *engine(); 34 | bool isAcceptingCommands() const; 35 | bool isClosingDown() const; 36 | QString aboutMessage() const; 37 | Q_INVOKABLE double timeForLastCommand() const; 38 | Q_INVOKABLE QVariant readSettings(QString key); 39 | Q_INVOKABLE void writeSettings(QString key, QVariant value); 40 | Q_INVOKABLE QStringList filesToOpen(); 41 | Q_INVOKABLE bool runsWithoutGraphics() const; 42 | 43 | public slots: 44 | void setupConsoleOutput(); 45 | void setAboutMessage(QString msg); 46 | bool runCommand(QByteArray cmd); 47 | void restart(bool redoCmdLine=true); 48 | bool close(); 49 | void about(); 50 | 51 | protected: 52 | bool event(QEvent *e); 53 | bool notify(QObject *receiver, QEvent *event); 54 | 55 | signals: 56 | void newEngine(QtLuaEngine *engine); 57 | void acceptingCommands(bool); 58 | void luaCommandEcho(QByteArray ps1, QByteArray ps2, QByteArray cmd); 59 | void luaConsoleOutput(QByteArray out); 60 | void anyoneHandlesConsoleOutput(bool &pbool); 61 | void fileOpenEvent(); 62 | void windowShown(QWidget *window); 63 | 64 | private: 65 | struct Private; 66 | Private *d; 67 | }; 68 | 69 | // Silly logic for mac bugs 70 | #ifdef Q_WS_MAC 71 | # ifndef QT_MAC_USE_COCOA 72 | # define QT_MAC_USE_NATIVE_MENUBAR 1 73 | # else 74 | # define QT_MAC_STEAL_STATUSBAR 1 75 | # if QT_VERSION >= 0xFFFFFF // Not fixed in 40503 yet 76 | # define QT_MAC_USE_NATIVE_MENUBAR 1 77 | # endif 78 | # endif 79 | #endif 80 | 81 | #endif 82 | 83 | 84 | /* ------------------------------------------------------------- 85 | Local Variables: 86 | c++-font-lock-extra-types: ( "\\sw+_t" "[A-Z]\\sw*[a-z]\\sw*" ) 87 | End: 88 | ------------------------------------------------------------- */ 89 | 90 | -------------------------------------------------------------------------------- /packages/qtsvg/qtluasvggenerator.cpp: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | 4 | #include "qtluasvggenerator.h" 5 | 6 | #include 7 | 8 | struct QtLuaSvgGenerator::Private 9 | { 10 | QString description; 11 | QSize size; 12 | QString title; 13 | int resolution; 14 | QBuffer *buffer; 15 | }; 16 | 17 | 18 | QtLuaSvgGenerator::~QtLuaSvgGenerator() 19 | { 20 | emit closing(this); 21 | delete d; 22 | } 23 | 24 | 25 | QtLuaSvgGenerator::QtLuaSvgGenerator(QObject *parent) 26 | : QObject(parent), d(new Private) 27 | { 28 | d->buffer = new QBuffer(this); 29 | QSvgGenerator::setOutputDevice(d->buffer); 30 | d->resolution = QSvgGenerator::resolution(); 31 | d->size = QSvgGenerator::size(); 32 | } 33 | 34 | 35 | QtLuaSvgGenerator::QtLuaSvgGenerator(QString fileName, QObject *parent) 36 | : QObject(parent), d(new Private) 37 | { 38 | d->buffer = 0; 39 | QSvgGenerator::setFileName(fileName); 40 | d->resolution = QSvgGenerator::resolution(); 41 | d->size = QSvgGenerator::size(); 42 | } 43 | 44 | 45 | QString 46 | QtLuaSvgGenerator::description() const 47 | { 48 | return d->description; 49 | } 50 | 51 | 52 | QSize 53 | QtLuaSvgGenerator::size() const 54 | { 55 | return d->size; 56 | } 57 | 58 | 59 | QString 60 | QtLuaSvgGenerator::title() const 61 | { 62 | return d->title; 63 | } 64 | 65 | 66 | int 67 | QtLuaSvgGenerator::resolution() const 68 | { 69 | return d->resolution; 70 | } 71 | 72 | 73 | QByteArray 74 | QtLuaSvgGenerator::data() 75 | { 76 | if (d->buffer) 77 | return d->buffer->data(); 78 | return QByteArray(); 79 | } 80 | 81 | 82 | void 83 | QtLuaSvgGenerator::setDescription(QString s) 84 | { 85 | d->description = s; 86 | #if QT_VERSION >= 0x40500 87 | QSvgGenerator::setDescription(s); 88 | #endif 89 | } 90 | 91 | 92 | void 93 | QtLuaSvgGenerator::setSize(QSize s) 94 | { 95 | d->size = s; 96 | QSvgGenerator::setSize(s); 97 | #if QT_VERSION >= 0x40500 98 | QSvgGenerator::setViewBox(QRect(QPoint(0,0), s)); 99 | #endif 100 | } 101 | 102 | 103 | void 104 | QtLuaSvgGenerator::setTitle(QString s) 105 | { 106 | d->title = s; 107 | #if QT_VERSION >= 0x40500 108 | QSvgGenerator::setTitle(s); 109 | #endif 110 | } 111 | 112 | 113 | void 114 | QtLuaSvgGenerator::setResolution(int r) 115 | { 116 | d->resolution = r; 117 | QSvgGenerator::setResolution(r); 118 | } 119 | 120 | 121 | 122 | 123 | /* ------------------------------------------------------------- 124 | Local Variables: 125 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 126 | End: 127 | ------------------------------------------------------------- */ 128 | -------------------------------------------------------------------------------- /qlua/qlua.plist.in: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | CFBundleInfoDictionaryVersion 7 | 6.0 8 | CFBundleIconFile 9 | torch.icns 10 | CFBundlePackageType 11 | APPL 12 | CFBundleName 13 | MacQLua 14 | CFBundleGetInfoString 15 | MacQlua - A GUI for Lua, Torch, Milde. 16 | CFBundleSignature 17 | LUA 18 | CFBundleExecutable 19 | macqlua 20 | CFBundleIdentifier 21 | org.lua.qlua 22 | CFBundleShortVersionString 23 | @QLUA_VERSION@ 24 | CFBundleVersion 25 | QLua-@QLUA_VERSION@ Lua-@LUA_VERSION@ 26 | CFBundleDocumentTypes 27 | 28 | 29 | CFBundleTypeExtensions 30 | 31 | lua 32 | 33 | CFBundleTypeMIMETypes 34 | 35 | text/x-lua-code 36 | application/x-lua-code 37 | 38 | CFBundleTypeIconFile 39 | luadoc.icns 40 | CFBundleTypeName 41 | Lua Program File 42 | CFBundleTypeRole 43 | Editor 44 | LSIsAppleDefaultForType 45 | 46 | LSItemContentTypes 47 | 48 | org.lua.lua-code 49 | 50 | 51 | 52 | UTExportedTypeDeclarations 53 | 54 | 55 | UTTypeConformsTo 56 | 57 | public.data 58 | public.content 59 | 60 | UTTypeDescription 61 | Lua Program File 62 | UTTypeIdentifier 63 | org.lua.lua-code 64 | UTTypeIconFile 65 | luadoc.icns 66 | UTTypeTagSpecification 67 | 68 | public.filename-extension 69 | 70 | lua 71 | 72 | public.mime-type 73 | 74 | text/x-lua-code 75 | application/x-lua-code 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /qtutil/qmenuaction.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QMENUACTION_H 4 | #define QMENUACTION_H 5 | 6 | #include "qtutilconf.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | QTUTILAPI class QMenuAction : public QAction 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | QMenuAction(QObject *parent = 0); 25 | QMenuAction(const QString &text, QObject *parent); 26 | QMenuAction(const QIcon &icon, const QString &text, QObject *parent); 27 | ~QMenuAction(); 28 | 29 | QMenuBar *buildMenuBar(QWidget *parent = 0); 30 | QMenu *buildMenu(QWidget *parent = 0); 31 | 32 | void addAction(QAction *action); 33 | void addActions(QList actions); 34 | QList actions() const; 35 | 36 | QAction *addAction(const QString &text); 37 | QAction *addAction(const QIcon &icon, const QString &text); 38 | QAction *addAction(const QString &text, 39 | const QObject *receiver, const char* member, 40 | const QKeySequence &shortcut = 0); 41 | QAction *addAction(const QIcon &icon, const QString &text, 42 | const QObject *receiver, const char* member, 43 | const QKeySequence &shortcut = 0); 44 | 45 | QMenuAction *addMenu(QMenuAction *menu); 46 | QMenuAction *addMenu(const QString &title); 47 | QMenuAction *addMenu(const QIcon &icon, const QString &title); 48 | QAction *addSeparator(); 49 | 50 | void insertAction(QAction *before, QAction *action); 51 | void insertActions(QAction *before, QList actions); 52 | QMenuAction *insertMenu(QAction *before, QMenuAction *menu); 53 | QAction *insertSeparator(QAction *before); 54 | 55 | void removeAction(QAction *action); 56 | 57 | bool isEmpty() const; 58 | void clear(); 59 | QAction *menuAction(); 60 | void setTitle(const QString &title); 61 | QString title () const; 62 | QAction *exec(const QPoint &point, QAction *action = 0); 63 | 64 | signals: 65 | void aboutToHide (); 66 | void aboutToShow (); 67 | void hovered(QAction *action); 68 | void triggered(QAction *action); 69 | 70 | protected: 71 | void syncAction(QAction *from, QAction *to); 72 | void copyMenu(QWidget *menu); 73 | 74 | protected slots: 75 | void p_destroyed(QObject*); 76 | void p_hovered(QAction*); 77 | void p_triggered(QAction*); 78 | void p_changed(); 79 | 80 | public: 81 | struct Private; 82 | private: 83 | Private *d; 84 | }; 85 | 86 | 87 | 88 | #endif 89 | /* ------------------------------------------------------------- 90 | Local Variables: 91 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 92 | End: 93 | ------------------------------------------------------------- */ 94 | 95 | -------------------------------------------------------------------------------- /packages/qtide/qluasdimain.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QLUASDIMAIN_H 4 | #define QLUASDIMAIN_H 5 | 6 | #include "qtide.h" 7 | #include "qluatextedit.h" 8 | #include "qluamainwindow.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | 17 | 18 | // QLuaConsoleWidget 19 | 20 | class QTIDE_API QLuaConsoleWidget : public QLuaTextEdit 21 | { 22 | Q_OBJECT 23 | Q_PROPERTY(bool printTimings READ printTimings WRITE setPrintTimings) 24 | public: 25 | ~QLuaConsoleWidget(); 26 | QLuaConsoleWidget(QWidget *parent = 0); 27 | void addOutput(QString text, QTextCharFormat format); 28 | bool printTimings() const; 29 | public slots: 30 | void setPrintTimings(bool); 31 | void addOutput(QString text, QString format="comment"); 32 | void moveToEnd(); 33 | signals: 34 | void statusMessage(const QString &); 35 | public: 36 | class Private; 37 | private: 38 | Private *d; 39 | }; 40 | 41 | 42 | 43 | // SDI Console 44 | 45 | class QTIDE_API QLuaSdiMain : public QLuaMainWindow 46 | { 47 | Q_OBJECT 48 | Q_PROPERTY(int historySize READ historySize WRITE setHistorySize) 49 | Q_PROPERTY(int consoleLines READ consoleLines WRITE setConsoleLines) 50 | public: 51 | QLuaSdiMain(QWidget *parent=0); 52 | Q_INVOKABLE QLuaConsoleWidget *consoleWidget(); 53 | Q_INVOKABLE QLuaTextEdit *editorWidget(); 54 | virtual QAction *createAction(QByteArray); 55 | virtual QToolBar *createToolBar(); 56 | virtual QMenuBar *createMenuBar(); 57 | virtual QStatusBar *createStatusBar(); 58 | virtual bool canClose(); 59 | virtual void loadSettings(); 60 | virtual void saveSettings(); 61 | int historySize() const; 62 | int consoleLines() const; 63 | void setHistorySize(int n); 64 | void setConsoleLines(int n); 65 | 66 | public slots: 67 | virtual void doSaveAs(); 68 | virtual void doPrint(); 69 | virtual void doSelectAll(); 70 | virtual void doUndo(); 71 | virtual void doRedo(); 72 | virtual void doCut(); 73 | virtual void doCopy(); 74 | virtual void doPaste(); 75 | virtual void doFind(); 76 | virtual void doLineWrap(bool); 77 | virtual void doHighlight(bool); 78 | virtual void doAutoIndent(bool); 79 | virtual void doAutoMatch(bool); 80 | virtual void doCompletion(bool); 81 | virtual void doBalance(); 82 | virtual void doClear(); 83 | virtual void doEval(); 84 | virtual void updateStatusBar(); 85 | virtual void updateActions(); 86 | virtual bool newDocument(); 87 | 88 | public: 89 | class Private; 90 | class HSWidget; 91 | class HSModel; 92 | class HSView; 93 | private: 94 | Private *d; 95 | }; 96 | 97 | 98 | #endif 99 | 100 | 101 | /* ------------------------------------------------------------- 102 | Local Variables: 103 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 104 | End: 105 | ------------------------------------------------------------- */ 106 | 107 | -------------------------------------------------------------------------------- /packages/qtide/qtide.cpp: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | 4 | #include "qtide.h" 5 | #include "qluatextedit.h" 6 | #include "qluamainwindow.h" 7 | #include "qluabrowser.h" 8 | #include "qluaeditor.h" 9 | #include "qluaide.h" 10 | #include "qluasdimain.h" 11 | #include "qluamdimain.h" 12 | #include "qtluaengine.h" 13 | #include "qtluautils.h" 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | 20 | #include 21 | 22 | 23 | // ======================================== 24 | // QLUAEDITOR 25 | 26 | 27 | int 28 | qluaide_new(lua_State *L) 29 | { 30 | luaQ_pushqt(L, QLuaIde::instance()); 31 | return 1; 32 | } 33 | 34 | 35 | static int 36 | no_methodcall(lua_State *L) 37 | { 38 | luaL_error(L, "This class prevents lua to call this method"); 39 | return 0; 40 | } 41 | 42 | 43 | static luaL_Reg qluaide_lib[] = { 44 | { "new", qluaide_new }, 45 | { "deleteLater", no_methodcall }, 46 | { 0, 0 } 47 | }; 48 | 49 | 50 | static int qluaide_hook(lua_State *L) 51 | { 52 | lua_getfield(L, -1, "__metatable"); 53 | luaQ_register(L, qluaide_lib, QCoreApplication::instance()); 54 | return 0; 55 | } 56 | 57 | 58 | 59 | 60 | 61 | // ======================================== 62 | // REGISTER 63 | 64 | 65 | 66 | 67 | LUA_EXTERNC QTIDE_API int 68 | luaopen_libqtide(lua_State *L) 69 | { 70 | // load module 'qt' 71 | if (luaL_dostring(L, "require 'qt'")) 72 | lua_error(L); 73 | if (QApplication::type() == QApplication::Tty) 74 | luaL_error(L, "Graphics have been disabled (running with -nographics)"); 75 | // register metatypes 76 | qRegisterMetaType("QPrinter*"); 77 | // register classes 78 | QtLuaEngine::registerMetaObject(&QLuaBrowser::staticMetaObject); 79 | QtLuaEngine::registerMetaObject(&QLuaTextEdit::staticMetaObject); 80 | QtLuaEngine::registerMetaObject(&QLuaTextEditMode::staticMetaObject); 81 | QtLuaEngine::registerMetaObject(&QLuaConsoleWidget::staticMetaObject); 82 | QtLuaEngine::registerMetaObject(&QLuaEditor::staticMetaObject); 83 | QtLuaEngine::registerMetaObject(&QLuaSdiMain::staticMetaObject); 84 | QtLuaEngine::registerMetaObject(&QLuaMdiMain::staticMetaObject); 85 | #if HAVE_QTWEBKIT 86 | QtLuaEngine::registerMetaObject(&QWebFrame::staticMetaObject); 87 | QtLuaEngine::registerMetaObject(&QWebPage::staticMetaObject); 88 | QtLuaEngine::registerMetaObject(&QWebView::staticMetaObject); 89 | QtLuaEngine::registerMetaObject(&QLuaBrowser::staticMetaObject); 90 | #endif 91 | // class 'qluaide' 92 | lua_pushcfunction(L, qluaide_hook); 93 | luaQ_pushmeta(L, &QLuaIde::staticMetaObject); 94 | lua_call(L, 1, 0); 95 | // return 96 | return 1; 97 | } 98 | 99 | 100 | 101 | 102 | /* ------------------------------------------------------------- 103 | Local Variables: 104 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 105 | End: 106 | ------------------------------------------------------------- */ 107 | 108 | 109 | -------------------------------------------------------------------------------- /packages/qtide/qluagotodialog.ui: -------------------------------------------------------------------------------- 1 | 2 | QLuaGotoDialog 3 | 4 | 5 | 6 | 0 7 | 0 8 | 238 9 | 92 10 | 11 | 12 | 13 | Go to Line 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | Go to line: 22 | 23 | 24 | spinBox 25 | 26 | 27 | 28 | 29 | 30 | 31 | 1 32 | 33 | 34 | 1 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | Qt::Horizontal 44 | 45 | 46 | QSizePolicy::MinimumExpanding 47 | 48 | 49 | 50 | 220 51 | 0 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | Qt::Horizontal 60 | 61 | 62 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 63 | 64 | 65 | 66 | 67 | 68 | 69 | spinBox 70 | buttonBox 71 | 72 | 73 | 74 | 75 | buttonBox 76 | accepted() 77 | QLuaGotoDialog 78 | accept() 79 | 80 | 81 | 227 82 | 67 83 | 84 | 85 | 157 86 | 91 87 | 88 | 89 | 90 | 91 | buttonBox 92 | rejected() 93 | QLuaGotoDialog 94 | reject() 95 | 96 | 97 | 228 98 | 73 99 | 100 | 101 | 237 102 | 91 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # -*- cmake -*- 2 | 3 | project(QtLua) 4 | 5 | IF(APPLE) 6 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR) 7 | CMAKE_POLICY(VERSION 2.8.12) 8 | SET(CMAKE_MACOSX_RPATH TRUE) # @rpath in libs 9 | ELSE() 10 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) 11 | CMAKE_POLICY(VERSION 2.8) 12 | ENDIF() 13 | 14 | # --- avoid warnings 15 | IF(POLICY CMP0026) 16 | CMAKE_POLICY(SET CMP0026 OLD) 17 | ENDIF() 18 | 19 | SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) 20 | 21 | INCLUDE(QtLuaPaths) 22 | 23 | # --- General 24 | 25 | SET(WITH_QTLUA_IDE ON 26 | CACHE BOOL "Compile qlua ide (require Qt>=4.4)") 27 | 28 | # --- Macros 29 | 30 | INCLUDE(MacroQt4AutoGen) 31 | INCLUDE(MacroAddQtLuaModule) 32 | INCLUDE(CheckCXXSourceCompiles) 33 | INCLUDE(CheckCXXSourceRuns) 34 | 35 | # --- Qt4 36 | 37 | SET(QT_MIN_VERSION "4.3.0") 38 | FIND_PACKAGE(Qt4 REQUIRED) 39 | 40 | # --- Lua 41 | 42 | # Include Lua Files 43 | FIND_PACKAGE(Lua REQUIRED) 44 | INCLUDE_DIRECTORIES(${LUA_INCDIR}) 45 | LINK_DIRECTORIES(${LUA_LIBDIR}) 46 | 47 | ## Hard to check because of issues with RPATH 48 | ## The compiled program looks for the lua library 49 | ## relative to its own location (arg!) 50 | # # was lua compiled with c++? 51 | # SET(CMAKE_REQUIRED_DEFINITIONS ${LUA_DEFINITIONS}) 52 | # SET(CMAKE_REQUIRED_INCLUDES ${LUA_INCLUDE_DIR}) 53 | # SET(CMAKE_REQUIRED_LIBRARIES ${LUA_LIBRARIES}) 54 | # CHECK_CXX_SOURCE_RUNS(" 55 | # #include 56 | # #include \"lua.h\" 57 | # #include \"lauxlib.h\" 58 | # int result = 1; 59 | # int foo(lua_State *L) { 60 | # try { luaL_error(L,\"error\"); } catch(...) { result=0; throw; } 61 | # return 0; } 62 | # int main() { lua_State *L = luaL_newstate(); 63 | # lua_pushcfunction(L, foo); 64 | # lua_pcall(L, 0, 0, 0); exit(result); }" 65 | # LUA_COMPILED_WITH_CXX) 66 | # SET(CMAKE_REQUIRED_DEFINITIONS) 67 | # SET(CMAKE_REQUIRED_INCLUDES) 68 | # SET(CMAKE_REQUIRED_LIBRARIES) 69 | # MESSAGE("HEYYY <${LUA_COMPILED_WITH_CXX}>") 70 | # IF (NOT "${LUA_COMPILED_WITH_CXX}" EQUAL "0") 71 | # MESSAGE(FATAL_ERROR "Lua not compiled with C++ exceptions support") 72 | # ENDIF (NOT "${LUA_COMPILED_WITH_CXX}" EQUAL "0") 73 | 74 | 75 | # --- compile libqtlua 76 | 77 | # ADD_SUBDIRECTORY(qtutil) 78 | ADD_SUBDIRECTORY(qtlua) 79 | FIND_PACKAGE(QtLua REQUIRED) 80 | ADD_SUBDIRECTORY(qlua) 81 | ADD_SUBDIRECTORY(packages) 82 | 83 | # --- install qt libraries 84 | 85 | IF (WIN32 AND NOT CYGWIN) 86 | SET(QT_INSTALL_LIBRARIES "OFF" 87 | CACHE BOOL "Copy the required Qt DLLs into the Torch install dirs") 88 | ENDIF (WIN32 AND NOT CYGWIN) 89 | 90 | IF (QT_INSTALL_LIBRARIES) 91 | # -- turn on all the qt modules we use 92 | SET(QT_USE_QTUITOOLS 1) 93 | SET(QT_USE_QTWEBKIT 1) 94 | SET(QT_USE_QTOPENGL 1) 95 | SET(QT_USE_QTXML 1) 96 | SET(QT_USE_QTSVG 1) 97 | # -- this takes care of the install 98 | INCLUDE("InstallRequiredQtLibraries") 99 | ENDIF (QT_INSTALL_LIBRARIES) 100 | -------------------------------------------------------------------------------- /packages/qtuiloader/test.lua: -------------------------------------------------------------------------------- 1 | 2 | -- A little demo of the capabilities of package uiloader. 3 | 4 | 5 | require 'paths' 6 | require 'qtuiloader' 7 | require 'qtwidget' 8 | require 'qt' 9 | 10 | 11 | -- search file test.ui 12 | local testui = paths.thisfile('test.ui') 13 | 14 | -- demo proper 15 | function demo() 16 | 17 | local widget = qtuiloader.load(testui) 18 | local painter = qt.QtLuaPainter(widget.frame) 19 | 20 | local function min(a,b) 21 | if (a < b) then return a else return b end 22 | end 23 | 24 | local function draw(w) 25 | painter:newpath() 26 | painter:moveto(-100,-100); 27 | painter:curveto(-100,100,100,-100,100,100); 28 | painter:closepath() 29 | if widget.checkBoxFC.checked then 30 | painter:setcolor("red"); 31 | painter:fill(false) 32 | end 33 | if widget.checkBoxSC.checked then 34 | painter:setcolor("blue"); 35 | painter:setlinewidth(5); 36 | painter:stroke(false) 37 | end 38 | if widget.checkBoxST.checked then 39 | painter:moveto(-70,-80) 40 | painter:setcolor("black") 41 | painter:setfont(qt.QFont{serif=true,italic=true,size=16}) 42 | painter:show(widget.lineEdit.text) 43 | end 44 | if widget.checkBoxFR.checked then 45 | painter:newpath() 46 | painter:rectangle(-50,-50,100,100) 47 | painter:setcolor(1,1,0,.5) 48 | painter:fill() 49 | end 50 | end 51 | 52 | local zrot = 0 53 | 54 | local function paint() 55 | local xrot = widget.verticalSlider.value 56 | painter:gbegin() 57 | painter:showpage() 58 | painter:gsave() 59 | painter:translate(painter.width/2, painter.height/2) 60 | local s = min(painter.width,painter.height) 61 | painter:scale(s/250, s/250) 62 | painter:concat(qt.QTransform():rotated(xrot,'XAxis')) 63 | painter:rotate(zrot) 64 | draw() 65 | painter:grestore() 66 | painter:gend() 67 | end 68 | 69 | local timer = qt.QTimer() 70 | timer.interval = 40 71 | timer.singleShot = true 72 | qt.connect(timer,'timeout()', 73 | function() 74 | if qt.isa(widget, "QWidget") and widget.visible then 75 | zrot = ( zrot + widget.horizontalSlider.value ) % 360 76 | paint() 77 | timer:start() 78 | end 79 | end ) 80 | 81 | local listener = qt.QtLuaListener(widget) 82 | qt.connect(listener,'sigClose()', 83 | function() 84 | timer:stop() 85 | timer:deleteLater() 86 | widget:deleteLater() 87 | end ) 88 | qt.connect(listener,'sigShow(bool)', 89 | function(b) 90 | if b then timer:start() end 91 | end ) 92 | 93 | widget.windowTitle = "QtUiLoader demo" 94 | widget:show() 95 | 96 | return { widget=widget, 97 | painter=painter, 98 | listener=listener, 99 | timer=timer } 100 | end 101 | 102 | 103 | 104 | stuff = demo() 105 | 106 | -------------------------------------------------------------------------------- /cmake/QtLuaPaths.cmake: -------------------------------------------------------------------------------- 1 | # workaround another annoying cmake bug 2 | # http://public.kitware.com/Bug/view.php?id=14462 3 | # https://awesome.naquadah.org/bugs/index.php?do=details&task_id=869 4 | MACRO(NORMALIZE_PATH _path_) 5 | get_filename_component(${_path_}_abs "${${_path_}}" ABSOLUTE) 6 | SET(${_path_} "${${_path_}_abs}") 7 | ENDMACRO() 8 | 9 | NORMALIZE_PATH(LUA_BINDIR) 10 | NORMALIZE_PATH(LUA_LIBDIR) 11 | NORMALIZE_PATH(LUA_INCDIR) 12 | NORMALIZE_PATH(LUADIR) 13 | NORMALIZE_PATH(LIBDIR) 14 | NORMALIZE_PATH(CONFDIR) 15 | 16 | # work-around luarocks *ugly* limitations those guys believe that only few 17 | # directories in their PREFIX should be moved around. i really do not know 18 | # what the hell they are thinking. you know what? it is sad. 19 | GET_FILENAME_COMPONENT(CMAKE_INSTALL_PREFIX "${LUA_BINDIR}" PATH) 20 | SET(QtLua_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) 21 | FILE(RELATIVE_PATH QtLua_INSTALL_BIN_SUBDIR "${CMAKE_INSTALL_PREFIX}" "${LUA_BINDIR}") 22 | FILE(RELATIVE_PATH QtLua_INSTALL_LIB_SUBDIR "${CMAKE_INSTALL_PREFIX}" "${LUA_LIBDIR}") 23 | FILE(RELATIVE_PATH QtLua_INSTALL_INCLUDE_SUBDIR "${CMAKE_INSTALL_PREFIX}" "${LUA_INCDIR}") 24 | FILE(RELATIVE_PATH QtLua_INSTALL_CMAKE_SUBDIR "${CMAKE_INSTALL_PREFIX}" "${CONFDIR}/cmake") 25 | FILE(RELATIVE_PATH QtLua_INSTALL_LUA_PATH_SUBDIR "${CMAKE_INSTALL_PREFIX}" "${LUADIR}") 26 | FILE(RELATIVE_PATH QtLua_INSTALL_LUA_CPATH_SUBDIR "${CMAKE_INSTALL_PREFIX}" "${LIBDIR}") 27 | #### 28 | 29 | SET(QtLua_INSTALL_FINDLUA_DIR "${QtLua_BINARY_DIR}/cmake") 30 | SET(QtLua_INSTALL_BIN "${QtLua_INSTALL_PREFIX}/${QtLua_INSTALL_BIN_SUBDIR}") 31 | SET(QtLua_INSTALL_LIB "${QtLua_INSTALL_PREFIX}/${QtLua_INSTALL_LIB_SUBDIR}") 32 | SET(QtLua_INSTALL_INCLUDE "${QtLua_INSTALL_PREFIX}/${QtLua_INSTALL_INCLUDE_SUBDIR}") 33 | SET(QtLua_INSTALL_CMAKE "${QtLua_INSTALL_PREFIX}/${QtLua_INSTALL_CMAKE_SUBDIR}") 34 | SET(QtLua_INSTALL_LUA_PATH "${QtLua_INSTALL_PREFIX}/${QtLua_INSTALL_LUA_PATH_SUBDIR}") 35 | SET(QtLua_INSTALL_LUA_CPATH "${QtLua_INSTALL_PREFIX}/${QtLua_INSTALL_LUA_CPATH_SUBDIR}") 36 | 37 | # reverse relative path to prefix (ridbus is the palindrom of subdir) 38 | FILE(RELATIVE_PATH QtLua_INSTALL_BIN_RIDBUS "${QtLua_INSTALL_BIN}" "${QtLua_INSTALL_PREFIX}/.") 39 | FILE(RELATIVE_PATH QtLua_INSTALL_CMAKE_RIDBUS "${QtLua_INSTALL_CMAKE}" "${QtLua_INSTALL_PREFIX}/.") 40 | GET_FILENAME_COMPONENT(QtLua_INSTALL_BIN_RIDBUS "${QtLua_INSTALL_BIN_RIDBUS}" PATH) 41 | GET_FILENAME_COMPONENT(QtLua_INSTALL_CMAKE_RIDBUS "${QtLua_INSTALL_CMAKE_RIDBUS}" PATH) 42 | 43 | FILE(RELATIVE_PATH QtLua_INSTALL_BIN2LIB "${QtLua_INSTALL_BIN}" "${QtLua_INSTALL_LIB}") 44 | 45 | IF(UNIX) 46 | OPTION(QtLua_BUILD_WITH_RPATH "Build libraries with rpaths" ON) 47 | 48 | IF(QtLua_BUILD_WITH_RPATH) 49 | FILE(RELATIVE_PATH QtLua_INSTALL_BIN2LIB 50 | "${QtLua_INSTALL_BIN}" "${QtLua_INSTALL_LIB}") 51 | IF(APPLE) 52 | SET(CMAKE_MACOSX_RPATH ON) # @rpath in libs 53 | SET(CMAKE_INSTALL_RPATH "@loader_path/${QtLua_INSTALL_BIN2LIB}") # exec 54 | ELSE() 55 | SET(CMAKE_INSTALL_RPATH "\$ORIGIN/${QtLua_INSTALL_BIN2LIB}") 56 | ENDIF() 57 | ENDIF(QtLua_BUILD_WITH_RPATH) 58 | 59 | ENDIF(UNIX) 60 | 61 | IF (WIN32) 62 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") 63 | SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") 64 | ENDIF (WIN32) 65 | -------------------------------------------------------------------------------- /packages/qtide/qluamode.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QLUAMODE_H 4 | #define QLUAMODE_H 5 | 6 | #include "qtide.h" 7 | #include "qluatextedit.h" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | 25 | 26 | // Class to store user data for each block 27 | 28 | class QTIDE_API QLuaModeUserData : public QTextBlockUserData 29 | { 30 | public: 31 | virtual int highlightState(); 32 | }; 33 | 34 | 35 | 36 | // A convenient base class for creating modes 37 | 38 | class QTIDE_API QLuaMode : public QLuaTextEditMode 39 | { 40 | Q_OBJECT 41 | public: 42 | QLuaMode(QLuaTextEditModeFactory *f, QLuaTextEdit *e); 43 | virtual QSyntaxHighlighter *highlighter(); 44 | virtual bool supportsHighlight() { return true; } 45 | virtual bool supportsMatch() { return true; } 46 | virtual bool supportsBalance() { return true; } 47 | virtual bool supportsIndent() { return true; } 48 | protected: 49 | virtual void setFormat(int pos, int len, QString format); 50 | virtual void setFormat(int pos, int len, QTextCharFormat format); 51 | virtual void setLeftMatch(int pos, int len); 52 | virtual void setMiddleMatch(int pos, int len, int pp, int pl); 53 | virtual void setRightMatch(int pos, int len, int pp, int pl); 54 | virtual void setErrorMatch(int pos, int len, int pp, int pl, bool h=true); 55 | virtual int followMatch(int pos, int len); 56 | virtual void setBalance(int fpos, int tpos); 57 | virtual void setBalance(int fpos, int tpos, bool outer); 58 | virtual void setIndent(int pos, int indent); 59 | virtual void setIndentOverlay(int pos, int indent=-2); 60 | virtual int askCompletion(QString stem, QStringList comps); 61 | virtual void fileCompletion(QString &stem, QStringList &comps); 62 | protected: 63 | virtual void parseBlock(int pos, const QTextBlock &block, 64 | const QLuaModeUserData *idata, 65 | QLuaModeUserData *&odata ) = 0; 66 | public slots: 67 | virtual bool doTab(); 68 | virtual bool doEnter(); 69 | virtual bool doMatch(); 70 | virtual bool doBalance(); 71 | public: 72 | class CompModel; 73 | class CompView; 74 | class Highlighter; 75 | class Private; 76 | private: 77 | Private *d; 78 | }; 79 | 80 | 81 | // A template class for creating mode factories 82 | 83 | 84 | template 85 | class QTIDE_API QLuaModeFactory : public QLuaTextEditModeFactory 86 | { 87 | public: 88 | QLuaModeFactory(const char *n, const char *s) 89 | : QLuaTextEditModeFactory(n,s) {} 90 | 91 | virtual QLuaTextEditMode *create(QLuaTextEdit *parent) 92 | { return new T(this,parent); } 93 | }; 94 | 95 | 96 | #endif 97 | 98 | 99 | 100 | 101 | /* ------------------------------------------------------------- 102 | Local Variables: 103 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 104 | End: 105 | ------------------------------------------------------------- */ 106 | 107 | -------------------------------------------------------------------------------- /packages/qtide/README.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | This directory contains the qlua user 4 | interface as a loadable lua module. 5 | Here is a brief description of the various files: 6 | 7 | 8 | qtide.h 9 | General header 10 | 11 | 12 | qtide.qrc 13 | General resource file 14 | 15 | 16 | qtide.cpp 17 | Lua bindings 18 | 19 | 20 | qluatextedit.h 21 | qluatextedit.cpp 22 | 23 | Class QLuaTextEdit is a text editor widget derived 24 | from QPlainTextEdit with support for line numbers, 25 | find dialog, replace dialog, and printing. 26 | 27 | Class QLuaTextEditMode represents customizable parts of 28 | the editor for various languages. Modes can be changed by passing 29 | a factory to function QLuaTextEdit::setEditorMode(). 30 | 31 | Class QLuaTextEditModeFactory is used to construct QLuaTextEditMode 32 | objects. All factories are chained to easily find the 33 | most appropriate mode. 34 | 35 | 36 | qluamode.h 37 | qluamode.cpp 38 | 39 | Class QLuaMode is an abstract class derived from QLuaTextEditMode 40 | that facilitates the implementation of editor modes with 41 | syntax highlighting, matches, autoindent, completion, etc. 42 | 43 | 44 | qluamode_txt.cpp 45 | qluamode_hlp.cpp 46 | qluamode_lua.cpp 47 | qluamode_c.cpp 48 | 49 | These files define subclasses of QLuaMode for text files, 50 | torch help files, and lua source files. 51 | 52 | 53 | qluamainwindow.h 54 | qluamainwindow.cpp 55 | 56 | Class QLuaMainWindow is derived from QMainWindow 57 | and implements common features of main windows, 58 | particularly to create QActions and to facilitate 59 | the MDI mode. 60 | 61 | 62 | qluaeditor.h 63 | qluaeditor.cpp 64 | 65 | Class QLuaEditor is a subclass of QLuaMainWindow 66 | implementing a complete text editor based on QLuaTextEdit 67 | 68 | 69 | qluasdimain.h 70 | qluasdimain.cpp 71 | 72 | Class QLuaconsoleWidget is a widget derived from QLuaTextEdit 73 | that mirrors the output of the Lua console. 74 | 75 | Class QLuaSdiMain is a subclass of QLuaMainWindow containing 76 | a QLuaconsoleWidget and a small editor for entering commands. 77 | This class also implements the command history support. 78 | 79 | 80 | qluamdimain.h 81 | qluamdimain.cpp 82 | 83 | Class QLuaMdiMain is a main window that captures the other 84 | main windows as subwindows in a mdi setup. This is rather 85 | complicated as it involves copying the subwindow menubars 86 | into the mdi window and displacing the subwindow status bars 87 | into the mdi window as well. 88 | 89 | 90 | qluaide.h 91 | qluaide.cpp 92 | 93 | Class QLuaIde is an invisible object that coordinates 94 | all the windows of the qlua interface. It maintains 95 | a list of active windows, keeps a list of recent files, 96 | opens editors when a lua error occurs, etc. 97 | 98 | 99 | qluabrowser.h 100 | qluabrowser.cpp 101 | 102 | Class QLuaBrowser is a minimal web browser based on qtwebkit 103 | that is convenient for browsing the torch documentation. 104 | When qtwebkit is not available, the class invokes a 105 | real browser instead. 106 | 107 | 108 | prefs.lua 109 | prefs.ui 110 | 111 | The implementation of the preference dialog. 112 | -------------------------------------------------------------------------------- /doc/qtuiloader.md: -------------------------------------------------------------------------------- 1 | 2 | # QtUiLoader Package Reference Manual # 3 | 4 | Package `qtuiloader` provides 5 | functions for dynamically creating widgets 6 | from the user interface files created by program 7 | [Qt Designer](http://doc.trolltech.com/4.4/designer-manual.html). 8 | This is achieved by providing bindings for the Qt class 9 | [QUiLoader](http://doc.trolltech.com/4.4/quiloader.html). 10 | 11 | 12 | 13 | Directory `${`_TorchInstallDir=}/share/lua/5.1/qtuiloader= 14 | contains a small demonstration of this package. 15 | Use program 16 | [Qt Designer](http://doc.trolltech.com/4.4/designer-manual.html) 17 | to examine file `test.ui`. 18 | Then load file `test.lua` into the 19 | [qlua](qt.md#qlua) program. 20 | 21 | ``` 22 | $ cd /usr/local/share/lua/5.1/qtuiloader 23 | $ /usr/local/bin/qlua 24 | Lua 5.1 Copyright (C) 1994-2008 Lua.org, PUC-Rio 25 | > dofile('test.lua') 26 | ``` 27 | 28 | 29 | 30 | ## Functions ## 31 | 32 | Package `qtuiloader` provides a few convenience functions. 33 | Function [qtuiloader.loader](#qtuiloaderloader) returns a 34 | preallocated instance of class [qt.QUiLoader](#quiloader). 35 | Function [qtuiloader.load](#qtuiloaderload) uses 36 | this preallocated loader to construct a widget using a 37 | [Qt Designer](http://doc.trolltech.com/4.4/designer-manual.html) 38 | user interface description. 39 | 40 | 41 | 42 | ### qtuiloader.availableWidgets() ### 43 | 44 | 45 | Expression `qtuiloader.availableWidgets()` returns a 46 | [qt.QStringList](qtcore.md#qstringlist) 47 | containing the names of the supported widget classes. 48 | 49 | 50 | 51 | ### qtuiloader.createWidget(classname,[parent,[objectname]]) ### 52 | 53 | Creates a [widget](qtgui.md#qwidget) of class `classname`. 54 | Argument `classname` can be any of the strings returned 55 | by [`qtuiloader.availableWidgets()`](#qtuiloaderavailablewidgets). 56 | The optional argument `parent` specifies the parent widget 57 | and the optional argument `name` specifies the 58 | [object name](qtcore.md#qobjectobjectname). 59 | 60 | When argument `parent` is `nil` or not specified, 61 | the new widget is owned by the Lua interpreter 62 | and is automatically destroyed when the garbage collector 63 | determines that it is no longer referenced. 64 | 65 | 66 | ### qtuiloader.load(filename,[parent]) ### 67 | 68 | 69 | Expression `qtuiloader.load(filename,parent)` dynamically 70 | constructs and returns the widget described by the 71 | [Qt Designer](http://doc.trolltech.com/4.4/designer-manual.html) 72 | file `filename`. 73 | 74 | When argument `parent` is `nil` or not specified, 75 | the new widget is owned by the Lua interpreter 76 | and is automatically destroyed when the garbage collector 77 | determines that it is no longer referenced. 78 | 79 | 80 | ### qtuiloader.loader() ### 81 | 82 | 83 | Expression `qtuiloader.loader()` 84 | returns a preallocated instance 85 | of class [qt.QUiLoader](#quiloader). 86 | 87 | 88 | 89 | ## Classes ## 90 | 91 | 92 | ### qt.QUiLoader ### 93 | 94 | Class `qt.QUiLoader` provides bindings 95 | for all the functions of the Qt class 96 | [QUiLoader](http://doc.trolltech.com/4.4/quiloader.html). 97 | 98 | To be documented further... 99 | 100 | 101 | -------------------------------------------------------------------------------- /cmake/FindLua.cmake: -------------------------------------------------------------------------------- 1 | # - Find lua 2 | # this module looks for Lua 3 | # 4 | # LUA_EXECUTABLE - the full path to lua 5 | # LUA_LIBRARIES - the lua shared library 6 | # LUA_INCLUDE_DIR - directory for lua includes 7 | # LUA_PACKAGE_PATH - where Lua searches for Lua packages 8 | # LUA_PACKAGE_CPATH - where Lua searches for library packages 9 | # LUA_FOUND - If false, don't attempt to use lua. 10 | 11 | INCLUDE(CheckLibraryExists) 12 | 13 | IF(LUA) # if we are using luarocks 14 | MESSAGE(STATUS "Lua: using information from luarocks") 15 | SET(LUA_EXECUTABLE "${LUA}") 16 | SET(LUA_INCLUDE_DIR "${LUA_INCDIR}") 17 | SET(LUA_PACKAGE_PATH "${LUADIR}") 18 | SET(LUA_PACKAGE_CPATH "${LIBDIR}") 19 | 20 | IF(LUALIB) # present on windows platforms only 21 | SET(LUA_LIBRARIES "${LUALIB}") 22 | ELSE() # too bad, luarocks does not provide it (pfff...) 23 | GET_FILENAME_COMPONENT(LUA_EXEC_NAME ${LUA_EXECUTABLE} NAME_WE) 24 | IF(LUA_EXEC_NAME STREQUAL "luajit") 25 | FIND_LIBRARY(LUA_LIBRARIES 26 | NAMES luajit libluajit 27 | PATHS ${LUA_LIBDIR} 28 | NO_DEFAULT_PATH) 29 | ELSEIF(LUA_EXEC_NAME STREQUAL "lua") 30 | FIND_LIBRARY(LUA_LIBRARIES 31 | NAMES lua liblua 32 | PATHS ${LUA_LIBDIR} 33 | NO_DEFAULT_PATH) 34 | ELSE() 35 | MESSAGE(FATAL_ERROR "You seem to have a non-standard lua installation -- are you using luajit-rocks?") 36 | ENDIF() 37 | MESSAGE(STATUS "Lua library guess (no info from luarocks): ${LUA_LIBRARIES}") 38 | ENDIF() 39 | 40 | ELSE() # standalone -- not using luarocks 41 | 42 | IF(WITH_LUA51) 43 | FIND_PROGRAM(LUA_EXECUTABLE 44 | NAMES 45 | lua51 46 | lua5.1 47 | lua 48 | PATH) 49 | ELSE() 50 | FIND_PROGRAM(LUA_EXECUTABLE 51 | NAMES 52 | luajit 53 | PATH) 54 | ENDIF() 55 | MESSAGE(STATUS "Lua executable: ${LUA_EXECUTABLE}") 56 | 57 | IF(LUA_EXECUTABLE) 58 | GET_FILENAME_COMPONENT(LUA_DIR ${LUA_EXECUTABLE} PATH) 59 | ENDIF(LUA_EXECUTABLE) 60 | 61 | IF(WITH_LUA51) 62 | FIND_LIBRARY(LUA_LIBRARIES 63 | NAMES lua liblua lua-5.1 liblua-5.1 libluajit-5.1 64 | PATHS ${LUA_DIR}/../lib 65 | ${LUA_DIR} 66 | NO_DEFAULT_PATH) 67 | ELSE() 68 | FIND_LIBRARY(LUA_LIBRARIES 69 | NAMES luajit libluajit luajit-5.1 libluajit-5.1 70 | PATHS ${LUA_DIR}/../lib 71 | ${LUA_DIR} 72 | NO_DEFAULT_PATH) 73 | ENDIF() 74 | MESSAGE(STATUS "Lua library: ${LUA_LIBRARIES}") 75 | 76 | FIND_PATH(LUA_INCLUDE_DIR lua.h 77 | ${LUA_DIR}/../include/lua-5.1 78 | ${LUA_DIR}/../include/lua51 79 | ${LUA_DIR}/../include/lua 80 | ${LUA_DIR}/../include 81 | NO_DEFAULT_PATH) 82 | 83 | MESSAGE(STATUS "Lua include directory: ${LUA_INCLUDE_DIR}") 84 | 85 | ENDIF() 86 | 87 | IF(LUA_LIBRARIES) 88 | CHECK_LIBRARY_EXISTS(${LUA_LIBRARIES} luaJIT_setmode "" LUA_JIT) 89 | ENDIF() 90 | 91 | MARK_AS_ADVANCED( 92 | LUA_EXECUTABLE 93 | LUA_LIBRARIES 94 | LUA_INCLUDE_DIR 95 | LUA_PACKAGE_PATH 96 | LUA_PACKAGE_CPATH 97 | ) 98 | 99 | IF(LUA_EXECUTABLE) 100 | IF(LUA_LIBRARIES) 101 | IF(LUA_INCLUDE_DIR) 102 | SET(LUA_FOUND 1) 103 | ENDIF(LUA_INCLUDE_DIR) 104 | ENDIF(LUA_LIBRARIES) 105 | ENDIF(LUA_EXECUTABLE) 106 | 107 | IF (NOT LUA_FOUND AND Lua_FIND_REQUIRED) 108 | MESSAGE(FATAL_ERROR "Could not find Lua") 109 | ENDIF (NOT LUA_FOUND AND Lua_FIND_REQUIRED) 110 | 111 | IF(NOT Lua_FIND_QUIETLY) 112 | IF(LUA_FOUND) 113 | MESSAGE(STATUS "Lua found ${LUA_EXECUTABLE}") 114 | ELSE(LUA_FOUND) 115 | MESSAGE(STATUS "Lua not found. Please specify location") 116 | ENDIF(LUA_FOUND) 117 | ENDIF(NOT Lua_FIND_QUIETLY) 118 | -------------------------------------------------------------------------------- /packages/qtwidget/qtluaprinter.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QTLUAPRINTER_H 4 | #define QTLUAPRINTER_H 5 | 6 | #include "lua.h" 7 | #include "lauxlib.h" 8 | #include "qtluaengine.h" 9 | #include "qtluautils.h" 10 | 11 | #include "qtwidget.h" 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | 20 | 21 | class QTWIDGET_API QtLuaPrinter : public QObject, public QPrinter 22 | { 23 | Q_OBJECT 24 | Q_PROPERTY(bool colorMode READ colorMode WRITE setColorMode) 25 | Q_PROPERTY(bool collateCopies READ collateCopies WRITE setCollateCopies) 26 | Q_PROPERTY(QString creator READ creator WRITE setCreator) 27 | Q_PROPERTY(QString docName READ docName WRITE setDocName) 28 | Q_PROPERTY(bool doubleSidedPrinting READ doubleSidedPrinting 29 | WRITE setDoubleSidedPrinting) 30 | Q_PROPERTY(bool fontEmbeddingEnabled READ fontEmbeddingEnabled 31 | WRITE setFontEmbeddingEnabled) 32 | Q_PROPERTY(int fromPage READ fromPage) 33 | Q_PROPERTY(bool fullPage READ fullPage WRITE setFullPage) 34 | Q_PROPERTY(bool landscape READ landscape WRITE setLandscape) 35 | Q_PROPERTY(int numCopies READ numCopies WRITE setNumCopies) 36 | Q_PROPERTY(QString outputFileName READ outputFileName WRITE setOutputFileName) 37 | Q_PROPERTY(QString outputFormat READ outputFormat WRITE setOutputFormat) 38 | Q_PROPERTY(QString pageSize READ pageSize WRITE setPageSize) 39 | Q_PROPERTY(QString printerName READ printerName WRITE setPrinterName) 40 | Q_PROPERTY(QString printProgram READ printProgram WRITE setPrintProgram) 41 | Q_PROPERTY(int resolution READ resolution WRITE setResolution) 42 | Q_PROPERTY(int toPage READ toPage) 43 | Q_PROPERTY(QRect paperRect READ paperRect) 44 | Q_PROPERTY(QRect pageRect READ pageRect) 45 | Q_PROPERTY(QSizeF paperSize READ paperSize WRITE setPaperSize) 46 | Q_PROPERTY(QString printerState READ printerState) 47 | Q_ENUMS(PrinterState) 48 | 49 | public: 50 | ~QtLuaPrinter(); 51 | QtLuaPrinter(PrinterMode mode, QObject *parent=0) 52 | : QObject(parent), QPrinter(mode), custom(false) {} 53 | QtLuaPrinter(QObject *parent=0) 54 | : QObject(parent), QPrinter(), custom(false) {} 55 | 56 | Q_INVOKABLE QPrinter* printer() { return static_cast(this);} 57 | Q_INVOKABLE QPaintDevice* device() { return static_cast(this);} 58 | Q_INVOKABLE void setFromTo(int f, int t) { QPrinter::setFromTo(f, t); } 59 | Q_INVOKABLE bool newPage() { return QPrinter::newPage(); } 60 | Q_INVOKABLE bool abort() { return QPrinter::abort(); } 61 | Q_INVOKABLE bool setup(QWidget *parent=0); 62 | 63 | bool colorMode() const { return QPrinter::colorMode()==Color;} 64 | void setColorMode(bool b) { QPrinter::setColorMode(b?Color:GrayScale);} 65 | bool landscape() const { return orientation()==Landscape;} 66 | void setLandscape(bool b) { setOrientation(b?Landscape:Portrait);} 67 | bool lastPageFirst() const { return pageOrder()==LastPageFirst;} 68 | void setLastPageFirst(bool b) { setPageOrder(b?LastPageFirst:FirstPageFirst);} 69 | QString pageSize() const; 70 | void setPageSize(QString s); 71 | QString outputFormat() const; 72 | void setOutputFormat(QString s); 73 | QString printerState() const; 74 | QSizeF paperSize() const; 75 | void setPaperSize(QSizeF s); 76 | private: 77 | QSizeF papSize; 78 | bool custom; 79 | signals: 80 | void closing(QObject*); 81 | }; 82 | 83 | 84 | 85 | 86 | #endif 87 | 88 | 89 | /* ------------------------------------------------------------- 90 | Local Variables: 91 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*" "qreal") 92 | End: 93 | ------------------------------------------------------------- */ 94 | 95 | 96 | -------------------------------------------------------------------------------- /packages/qtwidget/qtlualistener.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #include "qtlualistener.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | 16 | #ifndef Q_MOC_RUN 17 | static QMetaEnum 18 | f_enumerator(const char *s) 19 | { 20 | struct QFakeObject : public QObject { 21 | static const QMetaObject* qt() { return &staticQtMetaObject; } 22 | }; 23 | const QMetaObject *mo = QFakeObject::qt(); 24 | int index = (mo) ? mo->indexOfEnumerator(s) : -1; 25 | if (index >= 0) 26 | return mo->enumerator(index); 27 | return QMetaEnum(); 28 | } 29 | #endif 30 | 31 | 32 | 33 | QtLuaListener::QtLuaListener(QWidget *w) 34 | : QObject(w), w(w) 35 | { 36 | w->installEventFilter(this); 37 | } 38 | 39 | 40 | bool 41 | QtLuaListener::eventFilter(QObject *object, QEvent *event) 42 | { 43 | switch(event->type()) 44 | { 45 | case QEvent::Close: 46 | { 47 | emit sigClose(); 48 | break; 49 | } 50 | case QEvent::Resize: 51 | { 52 | QSize s = static_cast(event)->size(); 53 | emit sigResize(s.width(), s.height()); 54 | break; 55 | } 56 | case QEvent::KeyPress: 57 | case QEvent::KeyRelease: 58 | { 59 | QKeyEvent *e = static_cast(event); 60 | QMetaEnum ek = f_enumerator("Key"); 61 | QMetaEnum em = f_enumerator("KeyboardModifiers"); 62 | QByteArray k = ek.valueToKey(e->key()); 63 | QByteArray m = em.valueToKeys(e->modifiers()); 64 | if (event->type() == QEvent::KeyPress) 65 | emit sigKeyPress(e->text(), k, m); 66 | else 67 | emit sigKeyRelease(e->text(), k, m); 68 | break; 69 | } 70 | case QEvent::MouseButtonPress: 71 | case QEvent::MouseButtonRelease: 72 | case QEvent::MouseButtonDblClick: 73 | case QEvent::MouseMove: 74 | { 75 | QMouseEvent *e = static_cast(event); 76 | QMetaEnum em = f_enumerator("KeyboardModifiers"); 77 | QMetaEnum eb = f_enumerator("MouseButtons"); 78 | QByteArray b = eb.valueToKey(e->button()); 79 | QByteArray m = em.valueToKeys(e->modifiers()); 80 | QByteArray s = eb.valueToKeys(e->buttons()); 81 | if (event->type() == QEvent::MouseButtonPress) 82 | emit sigMousePress(e->x(), e->y(), b, m, s); 83 | else if (event->type() == QEvent::MouseButtonRelease) 84 | emit sigMouseRelease(e->x(), e->y(), b, m, s); 85 | else if (event->type() == QEvent::MouseButtonDblClick) 86 | emit sigMouseDoubleClick(e->x(), e->y(), b, m, s); 87 | else 88 | emit sigMouseMove(e->x(), e->y(), m, s); 89 | break; 90 | } 91 | case QEvent::Enter: 92 | case QEvent::Leave: 93 | { 94 | emit sigEnter(event->type() == QEvent::Enter); 95 | break; 96 | } 97 | case QEvent::FocusIn: 98 | case QEvent::FocusOut: 99 | { 100 | emit sigFocus(event->type() == QEvent::FocusIn); 101 | break; 102 | } 103 | case QEvent::Show: 104 | case QEvent::Hide: 105 | { 106 | emit sigShow(event->type() == QEvent::Show); 107 | break; 108 | } 109 | case QEvent::Paint: 110 | { 111 | emit sigPaint(); 112 | break; 113 | } 114 | default: 115 | break; 116 | } 117 | return false; 118 | } 119 | 120 | 121 | 122 | 123 | /* ------------------------------------------------------------- 124 | Local Variables: 125 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 126 | End: 127 | ------------------------------------------------------------- */ 128 | 129 | -------------------------------------------------------------------------------- /packages/qtwidget/qtluaprinter.cpp: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | 4 | #include "qtluaprinter.h" 5 | 6 | #include 7 | #include 8 | 9 | 10 | 11 | struct Option 12 | { 13 | const char *name; 14 | int value; 15 | }; 16 | 17 | #define F(t) {#t, (int) QPrinter::t} 18 | 19 | static Option pageSizes[] = { 20 | F(A4), F(B5), F(Letter), F(Legal), F(Executive), 21 | F(A0), F(A1), F(A2), F(A3), F(A5), F(A6), F(A7), F(A8), F(A9), F(B0), F(B1), 22 | F(B10), F(B2), F(B3), F(B4), F(B6), F(B7), F(B8), F(B9), F(C5E), F(Comm10E), 23 | F(DLE), F(Folio), F(Ledger), F(Tabloid), F(Custom), 24 | {0} }; 25 | 26 | static Option outputFormats[] = { 27 | F(NativeFormat), F(PdfFormat), F(PostScriptFormat), 28 | {0} }; 29 | 30 | static Option printerStates[] = { 31 | F(Idle), F(Active), F(Aborted), F(Error), 32 | {0} }; 33 | 34 | 35 | static const char * 36 | value_to_name(int value, Option *opts) 37 | { 38 | for(; opts->name; opts++) 39 | if (opts->value == value) 40 | return opts->name; 41 | return "unknown"; 42 | } 43 | 44 | 45 | static int 46 | name_to_value(const char *name, Option *opts) 47 | { 48 | for(; opts->name; opts++) 49 | if (! strcmp(name, opts->name)) 50 | return opts->value; 51 | return -1; 52 | } 53 | 54 | 55 | QString 56 | QtLuaPrinter::pageSize() const 57 | { 58 | #if QT_VERSION >= 0x40400 59 | int s = (int)QPrinter::paperSize(); 60 | #else 61 | int s = (int)QPrinter::pageSize(); 62 | #endif 63 | return QString::fromAscii(value_to_name(s, pageSizes)); 64 | } 65 | 66 | 67 | void 68 | QtLuaPrinter::setPageSize(QString r) 69 | { 70 | int s = name_to_value(r.toLocal8Bit().constData(), pageSizes); 71 | if (s >= 0) 72 | { 73 | custom = false; 74 | if (s != QPrinter::Custom) 75 | QPrinter::setPageSize(QPrinter::PageSize(s)); 76 | #if QT_VERSION >= 0x40400 77 | else 78 | custom = true; 79 | if (custom && papSize.isValid()) 80 | QPrinter::setPaperSize(papSize, Point); 81 | #endif 82 | } 83 | } 84 | 85 | 86 | QSizeF 87 | QtLuaPrinter::paperSize() const 88 | { 89 | return papSize; 90 | } 91 | 92 | 93 | void 94 | QtLuaPrinter::setPaperSize(QSizeF s) 95 | { 96 | papSize = s; 97 | #if QT_VERSION >= 0x40400 98 | if (custom && papSize.isValid()) 99 | QPrinter::setPaperSize(papSize, Point); 100 | #endif 101 | } 102 | 103 | 104 | QString 105 | QtLuaPrinter::outputFormat() const 106 | { 107 | int s = (int) QPrinter::outputFormat(); 108 | return QString::fromAscii(value_to_name(s, outputFormats)); 109 | } 110 | 111 | 112 | void 113 | QtLuaPrinter::setOutputFormat(QString r) 114 | { 115 | int s = name_to_value(r.toLocal8Bit().constData(), outputFormats); 116 | if (s >= 0) 117 | QPrinter::setOutputFormat(QPrinter::OutputFormat(s)); 118 | } 119 | 120 | 121 | QString 122 | QtLuaPrinter::printerState() const 123 | { 124 | int s = (int) QPrinter::printerState(); 125 | return QString::fromAscii(value_to_name(s, printerStates)); 126 | } 127 | 128 | 129 | bool 130 | QtLuaPrinter::setup(QWidget *parent) 131 | { 132 | QPointer dialog = new QPrintDialog(this, parent); 133 | dialog->setFromTo(fromPage(), toPage()); 134 | // options 135 | dialog->addEnabledOption(QPrintDialog::PrintToFile); 136 | dialog->addEnabledOption(QPrintDialog::PrintPageRange); 137 | dialog->addEnabledOption(QPrintDialog::PrintCollateCopies); 138 | // exec 139 | int result = dialog->exec(); 140 | delete dialog; 141 | return (result == QDialog::Accepted); 142 | } 143 | 144 | 145 | QtLuaPrinter::~QtLuaPrinter() 146 | { 147 | emit closing(this); 148 | } 149 | 150 | 151 | 152 | 153 | 154 | 155 | /* ------------------------------------------------------------- 156 | Local Variables: 157 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*" "qreal") 158 | End: 159 | ------------------------------------------------------------- */ 160 | -------------------------------------------------------------------------------- /packages/qtide/qluamode_txt.cpp: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | #include "qluatextedit.h" 12 | #include "qluamode.h" 13 | 14 | #include 15 | 16 | 17 | 18 | // ======================================== 19 | // USERDATA 20 | 21 | 22 | namespace { 23 | 24 | struct Match; 25 | 26 | typedef QSharedDataPointer PMatch; 27 | 28 | struct Match : public QSharedData 29 | { 30 | PMatch next; 31 | char type; 32 | int pos; 33 | }; 34 | 35 | struct UserData : public QLuaModeUserData 36 | { 37 | PMatch stack; 38 | }; 39 | 40 | } 41 | 42 | 43 | 44 | 45 | // ======================================== 46 | // QLUAMODETEXT 47 | 48 | 49 | 50 | 51 | class QLuaModeText : public QLuaMode 52 | { 53 | Q_OBJECT 54 | public: 55 | QLuaModeText(QLuaTextEditModeFactory *f, QLuaTextEdit *e); 56 | virtual bool doEnter(); 57 | virtual void parseBlock(int pos, const QTextBlock &block, 58 | const QLuaModeUserData *idata, 59 | QLuaModeUserData *&odata ); 60 | private: 61 | QRegExp reHighlight; 62 | }; 63 | 64 | 65 | QLuaModeText::QLuaModeText(QLuaTextEditModeFactory *f, QLuaTextEdit *e) 66 | : QLuaMode(f,e), 67 | reHighlight("^[|>]") 68 | { 69 | } 70 | 71 | 72 | bool 73 | QLuaModeText::doEnter() 74 | { 75 | e->textCursor().insertBlock(); 76 | return true; 77 | } 78 | 79 | 80 | void 81 | QLuaModeText::parseBlock(int pos, const QTextBlock &block, 82 | const QLuaModeUserData *idata, 83 | QLuaModeUserData *&odata ) 84 | { 85 | int len = block.length(); 86 | QString text = block.text(); 87 | UserData *data = new UserData; 88 | 89 | // input state 90 | if (idata) 91 | *data = *static_cast(idata); 92 | 93 | // highlight 94 | if (text.contains(reHighlight)) 95 | setFormat(pos, len, "quote"); 96 | 97 | // indentation 98 | int indent; 99 | int cpos = e->getBlockIndent(block, indent); 100 | if (indent >= 0) 101 | setIndent(cpos+1, indent); 102 | else 103 | setIndent(block.position()+1, -1); 104 | 105 | // matches 106 | for (int i=0; itype = ic; 113 | m->pos = pos + i; 114 | m->next = data->stack; 115 | data->stack = m; 116 | setLeftMatch(pos + i, 1); 117 | } 118 | else if (ic==')' || ic==']' || ic=='}') 119 | { 120 | PMatch m = data->stack; 121 | if (m) 122 | { 123 | if (m->type == strchr("()[]{}", ic)[-1]) 124 | setRightMatch(pos + i, 1, m->pos, 1); 125 | else 126 | setErrorMatch(pos + i, 1, m->pos, 1); 127 | setBalance(m->pos, pos+i+1, !m->next); 128 | data->stack = m->next; 129 | } 130 | } 131 | } 132 | 133 | // output state 134 | odata = data; 135 | } 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | // ======================================== 144 | // FACTORY 145 | 146 | 147 | const char *textName = QT_TRANSLATE_NOOP("QLuaTextEditMode", "Text"); 148 | 149 | static QLuaModeFactory textModeFactory(textName, "txt"); 150 | 151 | 152 | 153 | // ======================================== 154 | // MOC 155 | 156 | 157 | #include "qluamode_txt.moc" 158 | 159 | 160 | 161 | 162 | 163 | /* ------------------------------------------------------------- 164 | Local Variables: 165 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 166 | End: 167 | ------------------------------------------------------------- */ 168 | -------------------------------------------------------------------------------- /cmake/InstallRequiredQtLibraries.cmake: -------------------------------------------------------------------------------- 1 | # -*- cmake -*- 2 | 3 | # select debug or release versions 4 | STRING(TOUPPER _debug "${CMAKE_BUILD_TYPE}") 5 | IF (NOT "${_debug}" STREQUAL "DEBUG") 6 | SET(_debug "RELEASE") 7 | ENDIF (NOT "${_debug}" STREQUAL "DEBUG") 8 | 9 | 10 | # [from UseQt4.cmake] fix use variables 11 | IF(QT_DONT_USE_QTGUI) 12 | SET(QT_USE_QTGUI 0) 13 | ELSE(QT_DONT_USE_QTGUI) 14 | SET(QT_USE_QTGUI 1) 15 | ENDIF(QT_DONT_USE_QTGUI) 16 | 17 | IF(QT_DONT_USE_QTCORE) 18 | SET(QT_USE_QTCORE 0) 19 | ELSE(QT_DONT_USE_QTCORE) 20 | SET(QT_USE_QTCORE 1) 21 | ENDIF(QT_DONT_USE_QTCORE) 22 | 23 | # [from UseQt4.cmake] list dependent modules, so their modules are automatically on 24 | SET(QT_QT3SUPPORT_MODULE_DEPENDS QTGUI QTSQL QTXML QTNETWORK QTCORE) 25 | SET(QT_QTSVG_MODULE_DEPENDS QTGUI QTXML QTCORE) 26 | SET(QT_QTUITOOLS_MODULE_DEPENDS QTGUI QTXML QTCORE) 27 | SET(QT_QTHELP_MODULE_DEPENDS QTGUI QTSQL QTXML QTCORE) 28 | SET(QT_PHONON_MODULE_DEPENDS QTGUI QTDBUS QTCORE) 29 | SET(QT_QTDBUS_MODULE_DEPENDS QTXML QTCORE) 30 | SET(QT_QTXMLPATTERNS_MODULE_DEPENDS QTNETWORK QTCORE) 31 | SET(QT_QTWEBKIT_MODULE_DEPENDS QTNETWORK PHONON QTCORE) 32 | 33 | # [from UseQt4.cmake] Qt modules (in order of dependence) 34 | FOREACH(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN 35 | QTSCRIPT QTSVG QTUITOOLS QTHELP QTWEBKIT PHONON QTGUI QTTEST 36 | QTDBUS QTXML QTSQL QTXMLPATTERNS QTNETWORK QTCORE) 37 | 38 | IF (QT_USE_${module}) 39 | IF (QT_${module}_FOUND) 40 | FOREACH(_lib ${QT_${module}_LIBRARY_${_debug}} ${QT_${module}_LIB_DEPENDENCIES}) 41 | GET_FILENAME_COMPONENT(_libname "${_lib}" NAME_WE) 42 | IF (EXISTS "${QT_BINARY_DIR}/${_libname}.dll") 43 | # --- DEBUG MESSAGE 44 | # MESSAGE("Will install ${QtLua_INSTALL_BIN_SUBDIR}/${_libname}.dll") 45 | INSTALL(PROGRAMS "${QT_BINARY_DIR}/${_libname}.dll" 46 | DESTINATION "${QtLua_INSTALL_BIN_SUBDIR}") 47 | ENDIF (EXISTS "${QT_BINARY_DIR}/${_libname}.dll") 48 | ENDFOREACH(_lib) 49 | FOREACH(depend_module ${QT_${module}_MODULE_DEPENDS}) 50 | SET(QT_USE_${depend_module} 1) 51 | ENDFOREACH(depend_module ${QT_${module}_MODULE_DEPENDS}) 52 | ENDIF (QT_${module}_FOUND) 53 | ENDIF (QT_USE_${module}) 54 | ENDFOREACH(module) 55 | 56 | # Create qt.conf in torch binary directory 57 | FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" "[Paths]") 58 | INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" 59 | DESTINATION "${QtLua_INSTALL_BIN_SUBDIR}") 60 | 61 | # Install qt plugins 62 | FOREACH(_pdir "codecs" "imageformats") 63 | IF (EXISTS "${QT_PLUGINS_DIR}/${_pdir}") 64 | FILE(GLOB _pdll "${QT_PLUGINS_DIR}/${_pdir}/*.dll") 65 | FOREACH(_dll ${_pdll}) 66 | GET_FILENAME_COMPONENT(_dll "${_dll}" NAME_WE) 67 | STRING(REGEX REPLACE "d4$" "4" _dll_nd "${_dll}") 68 | IF (NOT EXISTS "${QT_PLUGINS_DIR}/${_pdir}/${_dll_nd}.dll") 69 | SET(_dll_nd "${_dll}") 70 | ENDIF (NOT EXISTS "${QT_PLUGINS_DIR}/${_pdir}/${_dll_nd}.dll") 71 | STRING(REGEX REPLACE "4$" "d4" _dll_d "${_dll}") 72 | IF (NOT EXISTS "${QT_PLUGINS_DIR}/${_pdir}/${_dll_d}.dll") 73 | SET(_dll_d "${_dll}") 74 | ENDIF (NOT EXISTS "${QT_PLUGINS_DIR}/${_pdir}/${_dll_d}.dll") 75 | SET(_inst 0) 76 | IF ("${_debug}" STREQUAL "DEBUG" AND "${_dll}" STREQUAL "${_dll_d}") 77 | SET(_inst 1) 78 | ELSEIF (NOT "${_debug}" STREQUAL "DEBUG" AND "${_dll}" STREQUAL "${_dll_nd}") 79 | SET(_inst 1) 80 | ENDIF ("${_debug}" STREQUAL "DEBUG" AND "${_dll}" STREQUAL "${_dll_d}") 81 | IF (_inst) 82 | # --- DEBUG MESSAGE 83 | # MESSAGE("Will install ${QtLua_INSTALL_BIN_SUBDIR}/plugins/${_pdir}/${_dll}.dll") 84 | INSTALL(PROGRAMS "${QT_PLUGINS_DIR}/${_pdir}/${_dll}.dll" 85 | DESTINATION "${QtLua_INSTALL_BIN_SUBDIR}/plugins/${_pdir}" ) 86 | ENDIF(_inst) 87 | ENDFOREACH(_dll) 88 | ENDIF (EXISTS "${QT_PLUGINS_DIR}/${_pdir}") 89 | ENDFOREACH(_pdir) 90 | 91 | -------------------------------------------------------------------------------- /packages/qtide/SETTINGS.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | Here is a collection of settings configurable via QSettings 4 | 5 | 6 | Customizable via a preference dialog 7 | ------------------------------------ 8 | 9 | 10 | editor/font QFont font for editor 11 | editor/size QSize default editor size in chars 12 | editor/tabSize Int tabulation size (default 8) 13 | editor/tabExpand Boolean expands all tabs as spaces 14 | 15 | console/font QFont font for console 16 | console/consoleLines Int max saved lines in console log 17 | console/consoleSize QSize default console size in chars 18 | console/editorSize QSize default console editor size in chars 19 | console/tabSize Int tabulation size in console 20 | console/tabExpand Int expand tabs when saving console log 21 | console/historySize Int maximum history size in console 22 | 23 | luaMode/basicIndent Int basic indentation in lua mode 24 | 25 | formats/userDefined Boolean preference editors should set this to true. 26 | 27 | formats/[m]/[k]/italic Boolean font spec for format [m]/[k] 28 | formats/[m]/[k]/weight Boolean font spec for format [m]/[k] 29 | formats/[m]/[k]/color String text color for format [m]/[k] 30 | formats/[m]/[k]/bgcolor String background color for format [m]/[k] 31 | 32 | 33 | The recognized [m]/[k] combinations are 34 | 35 | (console)/quote user input in console 36 | (console)/comment comments in console (time, start date) 37 | (matcher)/ok highlight for correct syntactical matches 38 | (matcher)/error highlight for incorrect syntactical matches 39 | Text/quote quoted text in text mode 40 | Lua/number numbers in Lua mode 41 | Lua/keyword keywords in Lua mode 42 | Lua/string strings in Lua mode 43 | Lua/comment comments in Lua mode 44 | Lua/function function names in Lua mode 45 | Help/string verbatim text and strings in Help mode 46 | Help/comment section names in Help mode 47 | Help/keyword syntactical stuff in Help mode 48 | Help/url urls and links in Help mode 49 | 50 | 51 | 52 | Automatically remembered from last invocation 53 | --------------------------------------------- 54 | 55 | ide/mode ByteArray mdi or sdi (see init.lua) 56 | ide/geometry Blob mdi window size and position 57 | ide/state Blob mdi window configuration 58 | ide/dockedWindows StringList names of the docked windows 59 | 60 | mdi/[windowname]/state Blob subwindow configuration in mdi mode 61 | mdi/[windowname]/geometry Blob subwindow size and positon in mdi mode 62 | sdi/[windowname]/state Blob window configuration in sdi mode 63 | sdi/[windowname]/geometry Blob window size and positon in sdi mode 64 | 65 | console/autoComplete Boolean auto completion in console editor 66 | console/autoIndent Boolean auto indent in console editor 67 | console/autoMatch Boolean flash matches in console editor 68 | console/autoHighlight Boolean syntax highlight in console editor 69 | console/lineWrap Boolean line wrap in console 70 | console/splitter Blob splitter state in console 71 | 72 | editor/recentFiles StringList recently open files 73 | editor/lineWrap Boolean line wrap in editor 74 | editor/showLineNumbers Boolean line numbers in editor 75 | editor/autoComplete Boolean auto completion in editor 76 | editor/autoIndent Boolean auto indent in editor 77 | editor/autoMatch Boolean flash matches in editor 78 | editor/autoHighlight Boolean syntax highlight in editor 79 | editor/find/caseSensitive Boolean find dialog case sensitive box 80 | editor/find/wholeWords Boolean find dialog whole words box 81 | 82 | 83 | browser/find/caseSensitive Boolean find dialog case sensitive box 84 | browser/find/wholeWords Boolean find dialog whole words box 85 | -------------------------------------------------------------------------------- /packages/qtide/qluafinddialog.ui: -------------------------------------------------------------------------------- 1 | 2 | QLuaFindDialog 3 | 4 | 5 | 6 | 0 7 | 0 8 | 454 9 | 117 10 | 11 | 12 | 13 | Find 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | &Find: 22 | 23 | 24 | findEdit 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | Search &backwards 39 | 40 | 41 | 42 | 43 | 44 | 45 | Qt::Horizontal 46 | 47 | 48 | 49 | 10 50 | 20 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | &Case sensitive 59 | 60 | 61 | 62 | 63 | 64 | 65 | Qt::Horizontal 66 | 67 | 68 | 69 | 10 70 | 20 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | &Whole words 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | Qt::Horizontal 90 | 91 | 92 | QSizePolicy::MinimumExpanding 93 | 94 | 95 | 96 | 20 97 | 20 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | &Next 106 | 107 | 108 | true 109 | 110 | 111 | 112 | 113 | 114 | 115 | Close 116 | 117 | 118 | false 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | findEdit 128 | searchBackwardsBox 129 | caseSensitiveBox 130 | wholeWordsBox 131 | findButton 132 | closeButton 133 | 134 | 135 | 136 | 137 | closeButton 138 | clicked() 139 | QLuaFindDialog 140 | reject() 141 | 142 | 143 | 400 144 | 89 145 | 146 | 147 | 342 148 | 152 149 | 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /packages/qtsvg/qtsvg.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "qtsvg.h" 21 | #include "qtluasvggenerator.h" 22 | 23 | 24 | Q_DECLARE_METATYPE(QPainter*) 25 | Q_DECLARE_METATYPE(QPaintDevice*) 26 | 27 | 28 | // ==================================== 29 | // QTLUASVGGENERATOR 30 | 31 | static int 32 | qtluasvggenerator_new(lua_State *L) 33 | { 34 | QVariant v = luaQ_toqvariant(L, 1, QMetaType::QString); 35 | if (v.type() == QVariant::String) 36 | { 37 | QObject *p = luaQ_optqobject(L, 2); 38 | luaQ_pushqt(L, new QtLuaSvgGenerator(v.toString(), p), !p); 39 | } 40 | else 41 | { 42 | QObject *p = luaQ_optqobject(L, 1); 43 | luaQ_pushqt(L, new QtLuaSvgGenerator(p), !p); 44 | } 45 | return 1; 46 | } 47 | 48 | static struct luaL_Reg qtluasvggenerator_lib[] = { 49 | {"new", qtluasvggenerator_new}, 50 | {0,0} 51 | }; 52 | 53 | static int 54 | qtluasvggenerator_hook(lua_State *L) 55 | { 56 | lua_getfield(L, -1, "__metatable"); 57 | luaQ_register(L, qtluasvggenerator_lib, QCoreApplication::instance()); 58 | return 0; 59 | } 60 | 61 | 62 | // ==================================== 63 | // QSVGRENDERER 64 | 65 | static int 66 | qsvgrenderer_new(lua_State *L) 67 | { 68 | QVariant v = luaQ_toqvariant(L, 1, QMetaType::QString); 69 | if (v.type() == QVariant::String) 70 | { 71 | QObject *p = luaQ_optqobject(L, 2); 72 | luaQ_pushqt(L, new QSvgRenderer(v.toString(), p), !p); 73 | } 74 | else 75 | { 76 | QObject *p = luaQ_optqobject(L, 1); 77 | luaQ_pushqt(L, new QSvgRenderer(p), !p); 78 | } 79 | return 1; 80 | } 81 | 82 | static struct luaL_Reg qsvgrenderer_lib[] = { 83 | {"new", qsvgrenderer_new}, 84 | {0,0} 85 | }; 86 | 87 | static int 88 | qsvgrenderer_hook(lua_State *L) 89 | { 90 | lua_getfield(L, -1, "__metatable"); 91 | luaQ_register(L, qsvgrenderer_lib, QCoreApplication::instance()); 92 | return 0; 93 | } 94 | 95 | 96 | 97 | // ==================================== 98 | // QSVGWIDGET 99 | 100 | 101 | static int 102 | qsvgwidget_new(lua_State *L) 103 | { 104 | QVariant v = luaQ_toqvariant(L, 1, QMetaType::QString); 105 | if (v.type() == QVariant::String) 106 | { 107 | QWidget *p = luaQ_optqobject(L, 2); 108 | luaQ_pushqt(L, new QSvgWidget(v.toString(), p), !p); 109 | } 110 | else 111 | { 112 | QWidget *p = luaQ_optqobject(L, 1); 113 | luaQ_pushqt(L, new QSvgWidget(p), !p); 114 | } 115 | return 1; 116 | } 117 | 118 | static int 119 | qsvgwidget_renderer(lua_State *L) 120 | { 121 | QSvgWidget *w = luaQ_checkqobject(L, 1); 122 | luaQ_pushqt(L, w->renderer()); 123 | return 1; 124 | } 125 | 126 | static struct luaL_Reg qsvgwidget_lib[] = { 127 | {"new", qsvgwidget_new}, 128 | {"renderer", qsvgwidget_renderer}, 129 | {0,0} 130 | }; 131 | 132 | static int 133 | qsvgwidget_hook(lua_State *L) 134 | { 135 | lua_getfield(L, -1, "__metatable"); 136 | luaQ_register(L, qsvgwidget_lib, QCoreApplication::instance()); 137 | return 0; 138 | } 139 | 140 | 141 | // ==================================== 142 | 143 | 144 | LUA_EXTERNC QTSVG_API int 145 | luaopen_libqtsvg(lua_State *L) 146 | { 147 | // load module 'qt' 148 | if (luaL_dostring(L, "require 'qt'")) 149 | lua_error(L); 150 | 151 | // hooks for objects 152 | #define HOOK_QOBJECT(T, t) \ 153 | lua_pushcfunction(L, t ## _hook);\ 154 | luaQ_pushmeta(L, &T::staticMetaObject);\ 155 | lua_call(L, 1, 0); 156 | 157 | HOOK_QOBJECT(QtLuaSvgGenerator, qtluasvggenerator) 158 | HOOK_QOBJECT(QSvgRenderer, qsvgrenderer) 159 | HOOK_QOBJECT(QSvgWidget, qsvgwidget) 160 | 161 | return 0; 162 | } 163 | 164 | 165 | 166 | /* ------------------------------------------------------------- 167 | Local Variables: 168 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 169 | End: 170 | ------------------------------------------------------------- */ 171 | 172 | 173 | -------------------------------------------------------------------------------- /qlua/qlua.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "qluaapplication.h" 14 | 15 | #ifdef Q_WS_X11 16 | extern "C" Display *XOpenDisplay(char*); 17 | extern "C" int XCloseDisplay(Display*); 18 | # ifdef HAVE_XINITTHREADS 19 | extern "C" int XInitThreads(); 20 | # endif 21 | #endif 22 | 23 | 24 | static bool 25 | optionTakesArgument(const char *s) 26 | { 27 | // keep this in sync as much as possible 28 | static const char *optionsWithArg[] = 29 | { // defined by Qt4. 30 | "-style", "-session", "-stylesheet", 31 | #ifdef Q_WS_X11 32 | "-display", "-font", "-fn", "-button", "-btn", 33 | "-background", "-bg", "-foreground", "-fg", 34 | "-name", "-title", "-geometry", "-im", 35 | "-ncols", "-visual", "-inputstyle", 36 | #endif 37 | // defined by QLuaApplication 38 | "-l", "-e", 39 | 0 }; 40 | for (int i=0; optionsWithArg[i]; i++) 41 | if (!strcmp(s, optionsWithArg[i])) 42 | return true; 43 | return false; 44 | } 45 | 46 | 47 | static bool 48 | optionIsIde(const char *s, QByteArray &ideStyle) 49 | { 50 | if (strncmp(s, "-ide", 4)) 51 | return false; 52 | if (s[4] == '=') 53 | ideStyle = s+5; 54 | else if (s[4]) 55 | return false; 56 | return true; 57 | } 58 | 59 | 60 | int 61 | main(int argc, char **argv) 62 | { 63 | int argn = 0; 64 | bool ide = false; 65 | QByteArray ideStyle; 66 | bool graphics = true; 67 | bool onethread = false; 68 | QVector args_for_both; 69 | char *displayName = 0; 70 | // Locale 71 | #ifdef LC_ALL 72 | ::setlocale(LC_ALL, ""); 73 | ::setlocale(LC_NUMERIC, "C"); 74 | #endif 75 | // Split argument list 76 | while (argn0 && (s[0]!='-' || !strcmp(s,"-") || !strcmp(s,"--"))) 80 | break; 81 | else if (!strcmp(s, "-nographics")) 82 | graphics = false; 83 | else if (!strcmp(s, "-onethread")) 84 | onethread = true; 85 | else if (optionIsIde(s, ideStyle)) 86 | ide = true; 87 | else if (!strcmp(s, "-h") && argn <= 1) 88 | graphics = ide = false; 89 | if (!strcmp(s, "-display") && argn+1 < argc) 90 | displayName = argv[argn+1]; 91 | if (optionTakesArgument(s) && argn+1 < argc) 92 | args_for_both += argv[argn++]; 93 | args_for_both += argv[argn++]; 94 | } 95 | args_for_both += 0; 96 | int argc_for_both = args_for_both.size() - 1; 97 | char **argv_for_both = args_for_both.data(); 98 | 99 | // Special behavior for X11. 100 | #ifdef Q_WS_X11 101 | # if defined(HAVE_XINITTHREADS) && (QT_VERSION < 0x40400) 102 | XInitThreads(); 103 | # endif 104 | Display *display = XOpenDisplay(displayName); 105 | if (display) 106 | XCloseDisplay(display); 107 | else if (graphics) 108 | qWarning("Unable to connect X11 server (continuing with -nographics)"); 109 | graphics &= !!display; 110 | #endif 111 | 112 | // Create application object 113 | QLuaApplication app(argc_for_both, argv_for_both, graphics, onethread); 114 | 115 | // Construct arguments for lua 116 | int i = 0; 117 | QVector args_for_lua; 118 | if (i < argc_for_both) 119 | args_for_lua += argv_for_both[i++]; 120 | while(ide && i= argc) 124 | ide = true; 125 | #endif 126 | if (ide) 127 | { 128 | if (ideStyle.isEmpty()) 129 | ideStyle = "-e qtide.start()"; 130 | else 131 | ideStyle = "-e qtide.start('" + ideStyle + "')"; 132 | args_for_lua += const_cast("-lqtide"); 133 | args_for_lua += const_cast(ideStyle.constData()); 134 | } 135 | #if defined(TORCH7) 136 | args_for_lua += "-lenv"; 137 | #endif 138 | while(i < argc_for_both) 139 | args_for_lua += argv_for_both[i++]; 140 | while(argn < argc) 141 | args_for_lua += argv[argn++]; 142 | args_for_lua += 0; 143 | 144 | // Call main function 145 | int argc_for_lua = args_for_lua.size() - 1; 146 | char **argv_for_lua = args_for_lua.data(); 147 | return app.main(argc_for_lua, argv_for_lua); 148 | } 149 | 150 | 151 | 152 | 153 | 154 | /* ------------------------------------------------------------- 155 | Local Variables: 156 | c++-font-lock-extra-types: ( "\\sw+_t" "[A-Z]\\sw*[a-z]\\sw*" ) 157 | End: 158 | ------------------------------------------------------------- */ 159 | 160 | -------------------------------------------------------------------------------- /packages/qtide/qluaide.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QLUAIDE_H 4 | #define QLUAIDE_H 5 | 6 | #include "qtide.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | class QLuaMainWindow; 23 | class QLuaEditor; 24 | class QLuaInspector; 25 | class QLuaSdiMain; 26 | class QLuaMdiMain; 27 | class QLuaBrowser; 28 | 29 | // Text editor widget 30 | 31 | class QTIDE_API QLuaIde : public QObject 32 | { 33 | Q_OBJECT 34 | Q_PROPERTY(bool editOnError READ editOnError WRITE setEditOnError) 35 | Q_PROPERTY(bool mdiDefault READ mdiDefault) 36 | 37 | public: 38 | static QLuaIde *instance(); 39 | static QString fileDialogFilters(); 40 | static QString htmlFilesFilter(); 41 | static QString allFilesFilter(); 42 | 43 | bool editOnError() const; 44 | bool mdiDefault() const; 45 | 46 | Q_INVOKABLE QObjectList windows() const; 47 | Q_INVOKABLE QStringList windowNames() const; 48 | Q_INVOKABLE QStringList recentFiles() const; 49 | Q_INVOKABLE QWidget* previousWindow() const; 50 | Q_INVOKABLE QWidget* activeWindow() const; 51 | Q_INVOKABLE QLuaSdiMain *sdiMain() const; 52 | Q_INVOKABLE QLuaMdiMain *mdiMain() const; 53 | Q_INVOKABLE QMenuBar *globalMenuBar() const; 54 | Q_INVOKABLE QMenuBar *defaultMenuBar(QMenuBar *menu); 55 | Q_INVOKABLE QAction *hasAction(QByteArray name); 56 | Q_INVOKABLE QAction *stdAction(QByteArray name); 57 | 58 | public slots: 59 | QLuaEditor *editor(QString fname = QString()); 60 | QLuaBrowser *browser(QUrl url = QUrl()); 61 | QLuaBrowser *browser(QString url); 62 | QLuaInspector *inspector(); 63 | QLuaSdiMain *createSdiMain(); 64 | QLuaMdiMain *createMdiMain(); 65 | void setEditOnError(bool b); 66 | void addRecentFile(QString fname); 67 | void clearRecentFiles(); 68 | void loadRecentFiles(); 69 | void saveRecentFiles(); 70 | void activateWidget(QWidget *w); 71 | void activateConsole(QWidget *returnTo=0); 72 | void loadWindowGeometry(QWidget *w); 73 | void saveWindowGeometry(QWidget *w); 74 | void updateActions(); 75 | bool openFile(QString fileName, bool inOther=false, QWidget *window=0); 76 | bool newDocument(QWidget *window=0); 77 | bool luaExecute(QByteArray cmd); 78 | bool luaRestart(QByteArray cmd); 79 | bool quit(QWidget *r); 80 | 81 | int messageBox(QString t, QString m, 82 | QMessageBox::StandardButtons buttons, 83 | QMessageBox::StandardButton def = QMessageBox::NoButton, 84 | QMessageBox::Icon icon = QMessageBox::Warning); 85 | 86 | QByteArray messageBox(QString t, QString m, 87 | QByteArray buttons = "Ok", 88 | QByteArray def = "NoButton", 89 | QByteArray icon = "Warning"); 90 | 91 | void doNew(); 92 | void doOpen(); 93 | bool doClose(); 94 | bool doQuit(); 95 | void doReturnToConsole(); 96 | void doReturnToPrevious(); 97 | void doLuaStop(); 98 | void doLuaPause(); 99 | void doPreferences(); 100 | void doHelp(); 101 | 102 | signals: 103 | void windowsChanged(); 104 | void prefsRequested(QWidget *window); 105 | void helpRequested(QWidget *window); 106 | 107 | public: 108 | class Private; 109 | protected: 110 | QLuaIde(); 111 | QAction *newAction(QString title); 112 | QMenu *newMenu(QString title); 113 | private: 114 | Private *d; 115 | }; 116 | 117 | 118 | 119 | 120 | // ======================================== 121 | // QLUAACTIONHELPERS 122 | 123 | 124 | namespace QLuaActionHelpers { 125 | 126 | struct QTIDE_API Connection { 127 | QObject *o; 128 | const char *s; 129 | Connection(QObject *o, const char *s) : o(o),s(s) {} 130 | }; 131 | 132 | struct QTIDE_API NewAction { 133 | NewAction(QString t) : text(t), checkable(false), checked(false) {} 134 | NewAction(QString t, bool b) : text(t), checkable(true), checked(b) {} 135 | QString text; 136 | bool checkable; 137 | bool checked; 138 | }; 139 | 140 | QTIDE_API QAction* operator<<(QAction *a, NewAction b); 141 | QTIDE_API QAction* operator<<(QAction *action, Connection c); 142 | QTIDE_API QAction* operator<<(QAction *action, QIcon icon); 143 | QTIDE_API QAction* operator<<(QAction *action, QActionGroup &group); 144 | QTIDE_API QAction* operator<<(QAction *action, QKeySequence key); 145 | QTIDE_API QAction* operator<<(QAction *action, QString s); 146 | QTIDE_API QAction* operator<<(QAction *action, QVariant v); 147 | QTIDE_API QAction* operator<<(QAction *action, QAction::MenuRole); 148 | 149 | } 150 | 151 | 152 | 153 | 154 | #endif 155 | 156 | 157 | /* ------------------------------------------------------------- 158 | Local Variables: 159 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 160 | End: 161 | ------------------------------------------------------------- */ 162 | 163 | -------------------------------------------------------------------------------- /packages/qtuiloader/test.ui: -------------------------------------------------------------------------------- 1 | 2 | Form 3 | 4 | 5 | 6 | 0 7 | 0 8 | 564 9 | 475 10 | 11 | 12 | 13 | Form 14 | 15 | 16 | 17 | 18 | 19 | The Quick Brown Fox etc. 20 | 21 | 22 | 23 | 24 | 25 | 26 | QFrame::StyledPanel 27 | 28 | 29 | QFrame::Raised 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | Twist 39 | 40 | 41 | 42 | 43 | 44 | 45 | -90 46 | 47 | 48 | 90 49 | 50 | 51 | 5 52 | 53 | 54 | 45 55 | 56 | 57 | Qt::Vertical 58 | 59 | 60 | false 61 | 62 | 63 | QSlider::TicksBothSides 64 | 65 | 66 | 15 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | Speed 78 | 79 | 80 | 81 | 82 | 83 | 84 | 10 85 | 86 | 87 | 1 88 | 89 | 90 | 1 91 | 92 | 93 | 1 94 | 95 | 96 | Qt::Horizontal 97 | 98 | 99 | QSlider::TicksBothSides 100 | 101 | 102 | 1 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | Fill Curve (red) 114 | 115 | 116 | true 117 | 118 | 119 | 120 | 121 | 122 | 123 | Fill Rectangle (translucent yellow) 124 | 125 | 126 | true 127 | 128 | 129 | 130 | 131 | 132 | 133 | Stroke curve (blue) 134 | 135 | 136 | true 137 | 138 | 139 | 140 | 141 | 142 | 143 | Show Text (black) 144 | 145 | 146 | true 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | checkBoxST 158 | toggled(bool) 159 | lineEdit 160 | setEnabled(bool) 161 | 162 | 163 | 331 164 | 449 165 | 166 | 167 | 263 168 | 11 169 | 170 | 171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /packages/qtide/qluareplacedialog.ui: -------------------------------------------------------------------------------- 1 | 2 | QLuaReplaceDialog 3 | 4 | 5 | 6 | 0 7 | 0 8 | 454 9 | 150 10 | 11 | 12 | 13 | Replace 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | Replace: 22 | 23 | 24 | findEdit 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | with: 35 | 36 | 37 | replaceEdit 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | Search &backwards 52 | 53 | 54 | 55 | 56 | 57 | 58 | Qt::Horizontal 59 | 60 | 61 | 62 | 10 63 | 20 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | &Case sensitive 72 | 73 | 74 | 75 | 76 | 77 | 78 | Qt::Horizontal 79 | 80 | 81 | 82 | 10 83 | 20 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | &Whole words 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | Qt::Horizontal 103 | 104 | 105 | QSizePolicy::MinimumExpanding 106 | 107 | 108 | 109 | 20 110 | 20 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | Replace &All 119 | 120 | 121 | false 122 | 123 | 124 | 125 | 126 | 127 | 128 | &Replace 129 | 130 | 131 | true 132 | 133 | 134 | 135 | 136 | 137 | 138 | &Next 139 | 140 | 141 | true 142 | 143 | 144 | 145 | 146 | 147 | 148 | Close 149 | 150 | 151 | false 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | findEdit 161 | replaceEdit 162 | searchBackwardsBox 163 | caseSensitiveBox 164 | wholeWordsBox 165 | findButton 166 | replaceButton 167 | replaceAllButton 168 | closeButton 169 | 170 | 171 | 172 | 173 | closeButton 174 | clicked() 175 | QLuaReplaceDialog 176 | reject() 177 | 178 | 179 | 385 180 | 110 181 | 182 | 183 | 342 184 | 117 185 | 186 | 187 | 188 | 189 | 190 | -------------------------------------------------------------------------------- /packages/qtide/qluatextedit.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QLUATEXTEDIT_H 4 | #define QLUATEXTEDIT_H 5 | 6 | #include "qtide.h" 7 | 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | class QLuaEditor; 26 | class QLuaTextEdit; 27 | class QLuaTextEditMode; 28 | class QLuaTextEditModeFactory; 29 | 30 | 31 | // Text editor widget 32 | 33 | 34 | class QTIDE_API QLuaTextEdit : public QPlainTextEdit 35 | { 36 | Q_OBJECT 37 | Q_PROPERTY(bool showLineNumbers READ showLineNumbers WRITE setShowLineNumbers) 38 | Q_PROPERTY(bool autoComplete READ autoComplete WRITE setAutoComplete) 39 | Q_PROPERTY(bool autoIndent READ autoIndent WRITE setAutoIndent) 40 | Q_PROPERTY(bool autoHighlight READ autoHighlight WRITE setAutoHighlight) 41 | Q_PROPERTY(bool autoMatch READ autoMatch WRITE setAutoMatch) 42 | Q_PROPERTY(bool tabExpand READ tabExpand WRITE setTabExpand) 43 | Q_PROPERTY(int tabSize READ tabSize WRITE setTabSize) 44 | Q_PROPERTY(QSize sizeInChars READ sizeInChars WRITE setSizeInChars) 45 | 46 | public: 47 | 48 | QLuaTextEdit(QWidget *parent=0); 49 | bool showLineNumbers() const; 50 | bool autoComplete() const; 51 | bool autoIndent() const; 52 | bool autoHighlight() const; 53 | bool autoMatch() const; 54 | bool tabExpand() const; 55 | int tabSize() const; 56 | QSize sizeInChars() const; 57 | 58 | int indentAt(int pos); 59 | int indentAt(int pos, QTextBlock block); 60 | int indentAfter(int pos, int dpos=0); 61 | int getBlockIndent(QTextBlock block); 62 | int getBlockIndent(QTextBlock block, int &indent); 63 | int setBlockIndent(QTextBlock block, int indent); 64 | bool readFile(QFile &file); 65 | bool writeFile(QFile &file); 66 | bool print(QPrinter *printer); 67 | 68 | Q_INVOKABLE QLuaTextEditMode *editorMode() const; 69 | Q_INVOKABLE virtual QDialog *makeFindDialog(); 70 | Q_INVOKABLE virtual QDialog *makeReplaceDialog(); 71 | Q_INVOKABLE virtual QDialog *makeGotoDialog(); 72 | Q_INVOKABLE virtual void prepareDialog(QDialog *dialog); 73 | 74 | static QTextCharFormat format(QString key); 75 | static void setFormat(QString key, QTextCharFormat format); 76 | QRectF blockBoundingGeometry(const QTextBlock &block) const; 77 | 78 | public slots: 79 | void setShowLineNumbers(bool b); 80 | void setAutoComplete(bool b); 81 | void setAutoIndent(bool b); 82 | void setAutoHighlight(bool b); 83 | void setAutoMatch(bool b); 84 | void setTabExpand(bool b); 85 | void setTabSize(int s); 86 | void setSizeInChars(QSize size); 87 | bool setEditorMode(QLuaTextEditModeFactory *modeFactory = 0); 88 | bool setEditorMode(QString suffix); 89 | bool readFile(QString fname); 90 | bool writeFile(QString fname); 91 | void showLine(int lineno); 92 | void reHighlight(); 93 | 94 | signals: 95 | void settingsChanged(); 96 | 97 | protected: 98 | virtual QSize sizeHint() const; 99 | virtual void keyPressEvent(QKeyEvent *event); 100 | 101 | public: 102 | class Private; 103 | class GotoDialog; 104 | class FindDialog; 105 | class ReplaceDialog; 106 | class LineNumbers; 107 | private: 108 | friend class QLuaSdiMain; 109 | Private *d; 110 | }; 111 | 112 | 113 | 114 | 115 | // Text editor language support 116 | 117 | 118 | class QTIDE_API QLuaTextEditModeFactory 119 | { 120 | public: 121 | virtual ~QLuaTextEditModeFactory(); 122 | QLuaTextEditModeFactory(const char *name, const char *suffixes); 123 | virtual QLuaTextEditMode *create(QLuaTextEdit *parent) = 0; 124 | virtual QString name(); 125 | virtual QString filter(); 126 | virtual QStringList suffixes(); 127 | static QList factories(); 128 | private: 129 | const char *const name_; 130 | const char *const suffixes_; 131 | QLuaTextEditModeFactory *next; 132 | QLuaTextEditModeFactory *prev; 133 | static QLuaTextEditModeFactory *first; 134 | static QLuaTextEditModeFactory *last; 135 | }; 136 | 137 | 138 | class QTIDE_API QLuaTextEditMode : public QObject 139 | { 140 | Q_OBJECT 141 | protected: 142 | QLuaTextEdit * const e; 143 | QLuaTextEditModeFactory * const f; 144 | public: 145 | QLuaTextEditMode(QLuaTextEditModeFactory *f, QLuaTextEdit *e); 146 | QLuaTextEditModeFactory *factory() const { return f; } 147 | virtual bool supportsHighlight() { return false; } 148 | virtual bool supportsMatch() { return false; } 149 | virtual bool supportsBalance() { return false; } 150 | virtual bool supportsIndent() { return false; } 151 | virtual bool supportsComplete() { return false; } 152 | virtual bool supportsLua() { return false; } 153 | virtual QString name() { return f->name(); } 154 | virtual QString filter() { return f->filter(); } 155 | virtual QStringList suffixes() { return f->suffixes(); } 156 | virtual QSyntaxHighlighter *highlighter() { return 0; } 157 | public slots: 158 | virtual bool doEnter() { return false; } 159 | virtual bool doTab() { return false; } 160 | virtual bool doMatch() { return false; } 161 | virtual bool doBalance() { return false; } 162 | virtual bool doComplete() { return false; } 163 | }; 164 | 165 | 166 | 167 | #endif 168 | 169 | 170 | /* ------------------------------------------------------------- 171 | Local Variables: 172 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 173 | End: 174 | ------------------------------------------------------------- */ 175 | 176 | -------------------------------------------------------------------------------- /packages/qtide/init.lua: -------------------------------------------------------------------------------- 1 | 2 | require 'paths' 3 | require 'qtcore' 4 | require 'qtgui' 5 | 6 | if qt and qt.qApp and qt.qApp:runsWithoutGraphics() then 7 | print("qlua: not loading module qtide (running with -nographics)") 8 | return 9 | end 10 | 11 | qt.require 'libqtide' 12 | 13 | local G = _G 14 | local error = error 15 | local dofile = dofile 16 | local loadstring = loadstring 17 | local print = print 18 | local qt = qt 19 | local string = string 20 | local tonumber = tonumber 21 | local tostring = tostring 22 | local type = type 23 | local paths = paths 24 | local pcall = pcall 25 | 26 | qtide = qtide or {} 27 | 28 | -- Startup -- 29 | 30 | local qluaide = qt.QLuaIde() 31 | 32 | local function realmode(mode) 33 | local defaultmode = 'sdi' 34 | -- if qluaide.mdiDefault then defaultmode = 'mdi' end 35 | return mode or qt.qApp:readSettings("ide/mode") or defaultmode 36 | end 37 | 38 | function qtide.setup(mode) 39 | mode = realmode(mode) 40 | if mode == "mdi" then -- subwindows within a big window 41 | local mdi = qluaide:createMdiMain() 42 | mdi.tabMode = false 43 | mdi.clientClass = "QWidget" 44 | mdi:adoptAll() 45 | elseif mode == "tab" then -- groups all editors in tabs 46 | local mdi = qluaide:createMdiMain() 47 | mdi.tabMode = true 48 | mdi.clientClass = "QLuaEditor" 49 | mdi:adoptAll() 50 | elseif mode == "tab2" then -- groups all editors + console in tabs 51 | local mdi = qluaide:createMdiMain() 52 | mdi.tabMode = true 53 | mdi.clientClass = "QLuaMainWindow" 54 | mdi:adoptAll() 55 | else -- all windows separate 56 | if mode ~= "sdi" then 57 | print("Warning: The recognized ide styles are: sdi, mdi, tab") 58 | mode = 'sdi' 59 | end 60 | local mdi = qt.qLuaMdiMain 61 | if mdi then 62 | mdi:hide() 63 | mdi.tabMode = false 64 | mdi.clientClass = "-none" 65 | mdi:adoptAll() 66 | mdi:deleteLater() 67 | end 68 | end 69 | qt.qApp:writeSettings("ide/mode", mode) 70 | end 71 | 72 | function qtide.start(mode) 73 | qtide.setup(mode) 74 | if not qt.qLuaSdiMain then 75 | qluaide:createSdiMain() 76 | qluaide.editOnError = true 77 | end 78 | end 79 | 80 | 81 | 82 | -- Editor -- 83 | 84 | function qtide.editor(s) 85 | local e = qluaide:editor(s or "") 86 | if e == nil and type(s) == "string" then 87 | error(string.format("Unable to read file '%s'", s)) 88 | end 89 | return e 90 | end 91 | 92 | 93 | function qtide.doeditor(e) 94 | -- validate parameter 95 | if not qt.isa(e, 'QLuaEditor*') then 96 | error(string.format("QLuaEditor expected, got %s.", s)); 97 | end 98 | -- retrieve text 99 | local n = "qt." .. tostring(e.objectName) 100 | local currentfile = nil; 101 | if e.fileName:tobool() then 102 | currentfile = e.fileName:tostring() 103 | end 104 | if (currentfile and not e.windowModified) then 105 | dofile(currentfile) 106 | else 107 | -- load data from editor 108 | local chunk, m = loadstring(e:widget().plainText:tostring(), n) 109 | if not chunk then 110 | print(m) 111 | -- error while parsing the data 112 | local _,_,l,m = string.find(m,"^%[string.*%]:(%d+): +(.*)") 113 | if l and m and qluaide.editOnError then 114 | e:widget():showLine(tonumber(l)) 115 | e:showStatusMessage(m) 116 | end 117 | else 118 | -- execution starts 119 | chunk() 120 | end 121 | end 122 | end 123 | 124 | 125 | -- Inspector -- 126 | 127 | function qtide.inspector(...) 128 | error("Function qtide.inspector is not yet working") 129 | end 130 | 131 | 132 | 133 | 134 | 135 | -- Browser -- 136 | 137 | function qtide.browser(url) 138 | return qluaide:browser(url or "about:/") 139 | end 140 | 141 | 142 | -- Help -- 143 | 144 | local function locate_help_files() 145 | local appname = qt.qApp.applicationName:tostring() 146 | local html = paths.install_html or "." 147 | local index1 = paths.concat(html, appname:lower(), "index.html") 148 | local index2 = paths.concat(html,"index.html") 149 | if index1 and paths.filep(index1) then 150 | return qt.QUrl.fromlocalfile(index1) 151 | elseif index2 and paths.filep(index2) then 152 | return qt.QUrl.fromlocalfile(index2) 153 | else 154 | return qt.QUrl("http://torch.ch/#packages") 155 | end 156 | end 157 | 158 | 159 | helpbrowser = nil 160 | helpurl = locate_help_files() 161 | 162 | function qtide.help() 163 | local appname = qt.qApp.applicationName:tostring() 164 | if not helpurl then 165 | error("The html help files are not installed.") 166 | end 167 | if not qt.isa(helpbrowser, "QWidget") then 168 | helpbrowser = qluaide:browser() 169 | end 170 | helpbrowser.baseTitle = appname .. " Help Browser" 171 | helpbrowser.homeUrl = helpurl; 172 | helpbrowser.url = helpurl 173 | helpbrowser:raise() 174 | return helpbrowser 175 | end 176 | 177 | qt.disconnect(qluaide, 'helpRequested(QWidget*)') 178 | qt.connect(qluaide,'helpRequested(QWidget*)', 179 | function(main) 180 | local success, message = pcall(qtide.help) 181 | if not success and type(message) == "string" then 182 | qluaide:messageBox("QLua Warning", message) 183 | end 184 | end) 185 | 186 | 187 | -- Preferences -- 188 | 189 | 190 | function qtide.preferences() 191 | G.require 'qtide.prefs' 192 | local d = prefs.createPreferencesDialog() 193 | if d and d.dialog:exec() > 0 then 194 | prefs.savePreferences(d) 195 | end 196 | end 197 | 198 | qt.disconnect(qluaide,'prefsRequested(QWidget*)') 199 | qt.connect(qluaide,'prefsRequested(QWidget*)', 200 | function(main) 201 | local success, message = pcall(qtide.preferences) 202 | if not success and type(message) == "string" then 203 | qluaide:messageBox("QLua Warning", message) 204 | end 205 | end) 206 | 207 | return qtide 208 | -------------------------------------------------------------------------------- /doc/qtsvg.md: -------------------------------------------------------------------------------- 1 | 2 | # QtSvg Bindings # 3 | 4 | The package `qtsvg` 5 | contains bindings for classes defined by the Qt module 6 | [QtSvg](http://doc.trolltech.com/4.4/qtsvg.html). 7 | 8 | Besides the capabilites reported below, 9 | all qt variants inherit a set 10 | of [default methods](qt.md#QVariants), 11 | and all qt object classes inherit the capabilities from their 12 | superclasses and automatically expose 13 | [properties, slots and signals](qt.md#QObjects). 14 | 15 | You can also use the function 16 | [qtwidget.newpdf](qtwidget.md#qtwidgetnewpdf), 17 | defined in module `qtwidget`, 18 | to easily generate SVG files. 19 | 20 | 21 | 22 | ### qtsvg.loadsvg(filename) ### 23 | 24 | 25 | Returns a Qt object of 26 | class [qt.QSvgRenderer](#qsvgrenderer) 27 | representing the SVG file `filename`. 28 | 29 | 30 | ### qtsvg.paintsvg(port,svg,...) ### 31 | 32 | 33 | Draws a SVG image. 34 | 35 | Argument `port` must be a 36 | [qt.QtLuaPainter](qtwidget.md#qtluapainter) or a 37 | [qtwidget'' high level port descriptor](qtwidget.md#highlevel). 38 | Argument `svg` can be the SVG filename or 39 | an instance of class [qt.QSvgRenderer](#qsvgrenderer) 40 | such as those returned by function [qtsvg.loadsvg](#qtsvg_loadsvg). 41 | The remaining arguments are the same 42 | as those for the C++ function `QSvgRenderer::render`. 43 | 44 | 45 | 46 | ### qt.QSvgWidget ### 47 | 48 | Class 49 | [QSvgWidget](http://doc.trolltech.com/4.4/qsvgwidget.html) 50 | provides a widget that is used to display the contents 51 | of Scalable Vector Graphics (SVG) files. 52 | 53 | 54 | #### qt.QSvgWidget([filename],[parent]) #### 55 | 56 | Expression `qt.QSvgWidget(parent)` returns a 57 | new widget for rendering SVG data. 58 | 59 | The optional argument `filename` specifies the name 60 | of a file containing the SVG data. Without this argument, 61 | you must use slot `qsvgwidget:load()` to load SVG data. 62 | 63 | The optional argument `parent` specifies the widget parent. 64 | New widgets are always created from the main thread using 65 | the [thread hopping](qt.md#qtqcall) mechanism. 66 | When argument `parent` is `nil` or not specified, 67 | the new widget is owned by the Lua interpreter 68 | and is automatically destroyed when the garbage collector 69 | determines that it is no longer referenced. 70 | 71 | 72 | #### qsvgwidget:renderer() #### 73 | 74 | Returns the [qt.QSvgRenderer](#qsvgrenderer) object 75 | associated with this widget. 76 | 77 | 78 | 79 | ### qt.QSvgRenderer ### 80 | 81 | Class 82 | [QSvgRenderer](http://doc.trolltech.com/4.4/qsvgrenderer.html) 83 | is used to draw the contents of SVG files onto paint devices. 84 | You should use instead function 85 | [qtsvg.paintsvg](#qtsvg_paintsvg) 86 | to easily display SVG data. 87 | 88 | 89 | #### qt.QSvgRenderer([filename],[parent]) #### 90 | 91 | Creates a new instance of class `QSvgRenderer`. 92 | 93 | The optional argument `filename` specifies the name 94 | of a file containing the SVG data. Without this argument, 95 | you must use slot `qsvgwidget:load()` to load SVG data. 96 | 97 | The optional argument `parent` specifies the widget parent. 98 | When argument `parent` is `nil` or not specified, 99 | the new widget is owned by the Lua interpreter 100 | and is automatically destroyed when the garbage collector 101 | determines that it is no longer referenced. 102 | 103 | 104 | 105 | ### qt.QtLuaSvgGenerator ### 106 | 107 | This is a thin wrapper around the Qt class 108 | [QSvgGenerator](http://doc.trolltech.com/4.4/qsvggenerator.html). 109 | 110 | You should use instead function 111 | [qtwidget.newpdf](qtwidget.md#qtwidgetnewpdf) 112 | to easily generate SVG files. 113 | 114 | 115 | #### qt.QtLuaSvgGenerator([filename],[parent]) #### 116 | 117 | Creates a new instance of class `QtLuaSvgGenerator`. 118 | 119 | When argument `filename` is present, the SVG data is written 120 | into the specified file. Otherwise it is written into a memory 121 | buffer accessible using the method 122 | [qsvggenerator:data()](#qtluasvggeneratordata). 123 | 124 | The optional argument `parent` specifies the widget parent. 125 | When argument `parent` is `nil` or not specified, 126 | the new widget is owned by the Lua interpreter 127 | and is automatically destroyed when the garbage collector 128 | determines that it is no longer referenced. 129 | 130 | 131 | #### qtluasvggenerator:data() #### 132 | 133 | 134 | Assuming the `qtluasvggenerator` was created without the `filename` argument, 135 | this function returns a [qt.QByteArray](qtcore.md#qbytearray) 136 | containing the generated SVG data. This data may be incomplete 137 | until [painter:close()](qtwidget.md#painterclose) has 138 | been closed on all painters operating on `qtluasvggenerator`. 139 | 140 | 141 | #### qtluasvggenerator.description #### 142 | 143 | Starting with Qt-4.5, this string property defines 144 | the contents of the `` tag of the SVG file. 145 | 146 | 147 | #### qtluasvggenerator.title #### 148 | 149 | Starting with Qt-4.5, this string property defines 150 | the contents of the `` tag of the SVG file. 151 | 152 | <a name="qtluasvggenerator.size"></a> 153 | #### qtluasvggenerator.size #### 154 | 155 | This property contains a [qt.QSize](qtcore.md#qsize) 156 | variant containing the size of the drawable area. 157 | This information is shown in the `viewBox` attribute of the `<svg>` tag. 158 | 159 | <a name="qtluasvggenerator.resolution"></a> 160 | #### qtluasvggenerator.resolution #### 161 | 162 | This integer property defines the resolution, in dots per inch, 163 | of the coordinate system. 164 | Together with `qtluasvggenerator.size`, this property determines 165 | the contents of the `width` and `height` attributes of the `<svg>` tag. 166 | 167 | -------------------------------------------------------------------------------- /qtlua/qtluaengine.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QTLUAENGINE_H 4 | #define QTLUAENGINE_H 5 | 6 | #include <QtGlobal> 7 | #include <QByteArray> 8 | #include <QList> 9 | #include <QObject> 10 | #include <QMetaObject> 11 | #include <QMetaType> 12 | #include <QPointer> 13 | #include <QString> 14 | #include <QStringList> 15 | #include <QVariant> 16 | 17 | extern "C" { 18 | #include "lua.h" 19 | #include "lauxlib.h" 20 | } 21 | #include "qtluaconf.h" 22 | 23 | typedef QPointer<QObject> QObjectPointer; 24 | 25 | Q_DECLARE_METATYPE(QObjectPointer) 26 | 27 | class QTLUAAPI QtLuaEngine : public QObject 28 | { 29 | Q_OBJECT 30 | Q_ENUMS(State); 31 | Q_PROPERTY(QByteArray lastErrorMessage READ lastErrorMessage) 32 | Q_PROPERTY(QStringList lastErrorLocation READ lastErrorLocation) 33 | Q_PROPERTY(bool printResults READ printResults WRITE setPrintResults) 34 | Q_PROPERTY(bool printErrors READ printErrors WRITE setPrintErrors) 35 | Q_PROPERTY(bool pauseOnError READ pauseOnError WRITE setPauseOnError) 36 | Q_PROPERTY(bool runSignalHandlers READ runSignalHandlers) 37 | Q_PROPERTY(State state READ state); 38 | Q_PROPERTY(bool ready READ isReady); 39 | Q_PROPERTY(bool running READ isRunning); 40 | Q_PROPERTY(bool paused READ isPaused); 41 | public: 42 | QtLuaEngine(QObject *parent = 0); 43 | virtual ~QtLuaEngine(); 44 | // meta objects 45 | static void registerMetaObject(const QMetaObject *mo); 46 | // named objects 47 | void nameObject(QObject *obj, QString name=QString()); 48 | QObject *namedObject(QString name); 49 | QList<QObjectPointer> allNamedObjects(); 50 | // state properties 51 | enum State { Ready, Running, Paused }; 52 | State state() const; 53 | bool isReady() const { return state() == Ready; } 54 | bool isRunning() const { return state() == Running; } 55 | bool isPaused() const { return state() == Paused; } 56 | bool isPausedOnError() const; 57 | // other properties 58 | QByteArray lastErrorMessage() const; 59 | QStringList lastErrorLocation() const; 60 | bool printResults() const; 61 | bool printErrors() const; 62 | bool pauseOnError() const; 63 | bool runSignalHandlers() const; 64 | signals: 65 | void stateChanged(int state); 66 | void errorMessage(QByteArray message); 67 | public slots: 68 | void setPrintResults(bool); 69 | void setPrintErrors(bool); 70 | void setPauseOnError(bool); 71 | bool stop(bool nopause=false); 72 | bool resume(bool nocontinue=false); 73 | bool eval(QByteArray s, bool async=false); 74 | bool eval(QString s, bool async=false); 75 | QVariantList evaluate(QByteArray s); 76 | QVariantList evaluate(QString s); 77 | public: 78 | struct Global; 79 | struct Private; 80 | struct Unlocker; 81 | struct Catcher; 82 | struct Protector; 83 | struct Receiver; 84 | struct Receiver2; 85 | private: 86 | Private *d; 87 | lua_State *L; 88 | friend class QtLuaLocker; 89 | }; 90 | 91 | 92 | class QTLUAAPI QtLuaLocker 93 | { 94 | public: 95 | explicit QtLuaLocker(QtLuaEngine *engine); 96 | explicit QtLuaLocker(QtLuaEngine *engine, int timeOut); 97 | ~QtLuaLocker(); 98 | void setRunning(); 99 | bool isReady() { return (count>0) && engine->isReady(); } 100 | bool isPaused() { return (count>0) && engine->isPaused(); } 101 | operator lua_State*() { return (count>0) ? engine->L : 0; } 102 | private: 103 | Q_DISABLE_COPY(QtLuaLocker) 104 | QtLuaEngine *engine; 105 | int count; 106 | }; 107 | 108 | 109 | QTLUAAPI QtLuaEngine *luaQ_engine(lua_State *L); 110 | QTLUAAPI QVariant luaQ_toqvariant(lua_State *L, int i, int type = 0); 111 | QTLUAAPI QObject* luaQ_toqobject(lua_State *L, int i, const QMetaObject *m=0); 112 | QTLUAAPI void luaQ_pushqt(lua_State *L); 113 | QTLUAAPI void luaQ_pushqt(lua_State *L, const QVariant &var); 114 | QTLUAAPI void luaQ_pushqt(lua_State *L, QObject *obj, bool owned=false); 115 | QTLUAAPI void luaQ_pushmeta(lua_State *L, int type); 116 | QTLUAAPI void luaQ_pushmeta(lua_State *L, const QMetaObject *mo); 117 | QTLUAAPI void luaQ_pushmeta(lua_State *L, const QObject *o); 118 | QTLUAAPI bool luaQ_connect(lua_State *L, QObject *o, const char *s, int fi, 119 | bool direct=false); 120 | QTLUAAPI bool luaQ_disconnect(lua_State *L, QObject*o, const char *s, int fi); 121 | QTLUAAPI void luaQ_doevents(lua_State *L, bool wait); 122 | QTLUAAPI void luaQ_pause(lua_State *L); 123 | QTLUAAPI void luaQ_resume(lua_State *L, bool nocontinue=false); 124 | QTLUAAPI void luaQ_call(lua_State *L, int na, int nr, QObject *obj=0); 125 | QTLUAAPI int luaQ_pcall(lua_State *L, int na, int nr, int eh, QObject *obj=0); 126 | QTLUAAPI void luaQ_register(lua_State *L, const luaL_Reg *l, QObject *obj); 127 | 128 | template<typename T> inline bool 129 | luaQ_isqobject(lua_State *L, int index, T* = 0) 130 | { 131 | T *obj = qobject_cast<T*>(luaQ_toqobject(L, index)); 132 | return (obj != 0); 133 | } 134 | 135 | template<typename T> inline bool 136 | luaQ_isqvariant(lua_State *L, int index, T* = 0) 137 | { 138 | int type = qMetaTypeId<T>(); 139 | QVariant v = luaQ_toqvariant(L, index, type); 140 | return (v.userType() == type); 141 | } 142 | 143 | template<typename T> inline T* 144 | luaQ_checkqobject(lua_State *L, int index, T* = 0) 145 | { 146 | T *obj = qobject_cast<T*>(luaQ_toqobject(L, index)); 147 | if (! obj) 148 | luaQ_typerror(L, index, T::staticMetaObject.className()); 149 | return obj; 150 | } 151 | 152 | template<typename T> inline T 153 | luaQ_checkqvariant(lua_State *L, int index, T* = 0) 154 | { 155 | int type = qMetaTypeId<T>(); 156 | QVariant v = luaQ_toqvariant(L, index, type); 157 | if (v.userType() != type) 158 | luaQ_typerror(L, index, QMetaType::typeName(type)); 159 | return qVariantValue<T>(v); 160 | } 161 | 162 | template<typename T> inline T* 163 | luaQ_optqobject(lua_State *L, int index, T *d = 0) 164 | { 165 | if (!lua_isnoneornil(L, index)) 166 | return luaQ_checkqobject<T>(L, index); 167 | return d; 168 | } 169 | 170 | template<typename T> inline T 171 | luaQ_optqvariant(lua_State *L, int index, T d = T()) 172 | { 173 | if (!lua_isnoneornil(L, index)) 174 | return luaQ_checkqvariant<T>(L, index); 175 | return d; 176 | } 177 | 178 | #endif 179 | 180 | 181 | /* ------------------------------------------------------------- 182 | Local Variables: 183 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 184 | End: 185 | ------------------------------------------------------------- */ 186 | 187 | 188 | -------------------------------------------------------------------------------- /packages/qtuiloader/uiloader.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | 4 | #include "uiloader.h" 5 | extern "C" { 6 | #include "lualib.h" 7 | } 8 | #include <QAction> 9 | #include <QActionGroup> 10 | #include <QApplication> 11 | #include <QByteArray> 12 | #include <QDir> 13 | #include <QFile> 14 | #include <QLayout> 15 | #include <QObject> 16 | #include <QObject> 17 | #include <QStringList> 18 | #include <QUiLoader> 19 | #include <QVariant> 20 | #include <QWidget> 21 | 22 | 23 | #include <stdio.h> 24 | 25 | // ==================================== 26 | 27 | 28 | static int 29 | qtuiloader_new(lua_State *L) 30 | { 31 | if (QApplication::type() == QApplication::Tty) 32 | luaL_error(L, "Graphics have been disabled (running with -nographics)"); 33 | QObject *parent = luaQ_optqobject<QObject>(L, 1, 0); 34 | QUiLoader *q = new QUiLoader(parent); 35 | luaQ_pushqt(L, q, !parent); 36 | return 1; 37 | } 38 | 39 | 40 | static int 41 | qtuiloader_addPluginPath(lua_State *L) 42 | { 43 | QUiLoader *loader = luaQ_checkqobject<QUiLoader>(L, 1); 44 | const char *path = luaL_checkstring(L, 2); 45 | loader->addPluginPath(QFile::decodeName(path)); 46 | return 0; 47 | } 48 | 49 | 50 | static int 51 | qtuiloader_availableWidgets(lua_State *L) 52 | { 53 | QUiLoader *loader = luaQ_checkqobject<QUiLoader>(L, 1); 54 | luaQ_pushqt(L, QVariant(loader->availableWidgets())); 55 | return 1; 56 | } 57 | 58 | 59 | static int 60 | qtuiloader_clearPluginPaths(lua_State *L) 61 | { 62 | QUiLoader *loader = luaQ_checkqobject<QUiLoader>(L, 1); 63 | loader->clearPluginPaths(); 64 | return 0; 65 | } 66 | 67 | 68 | static int 69 | qtuiloader_createAction(lua_State *L) 70 | { 71 | QUiLoader *loader = luaQ_checkqobject<QUiLoader>(L, 1); 72 | QObject *parent = luaQ_optqobject<QObject>(L, 2, 0); 73 | QString name = luaQ_optqvariant<QString>(L, 3, QString()); 74 | luaQ_pushqt(L, loader->createAction(parent, name), !parent); 75 | return 1; 76 | } 77 | 78 | 79 | static int 80 | qtuiloader_createActionGroup(lua_State *L) 81 | { 82 | QUiLoader *loader = luaQ_checkqobject<QUiLoader>(L, 1); 83 | QObject *parent = luaQ_optqobject<QObject>(L, 2, 0); 84 | QString name = luaQ_optqvariant<QString>(L, 3, QString()); 85 | luaQ_pushqt(L, loader->createActionGroup(parent, name), !parent); 86 | return 1; 87 | } 88 | 89 | 90 | static int 91 | qtuiloader_createLayout(lua_State *L) 92 | { 93 | QUiLoader *loader = luaQ_checkqobject<QUiLoader>(L, 1); 94 | QString classname = luaQ_checkqvariant<QString>(L, 2); 95 | QObject *parent = luaQ_optqobject<QObject>(L, 3, 0); 96 | QString name = luaQ_optqvariant<QString>(L, 4, QString()); 97 | luaQ_pushqt(L, loader->createLayout(classname, parent, name), !parent); 98 | return 1; 99 | } 100 | 101 | 102 | static int 103 | qtuiloader_createWidget(lua_State *L) 104 | { 105 | QUiLoader *loader = luaQ_checkqobject<QUiLoader>(L, 1); 106 | QString classname = luaQ_checkqvariant<QString>(L, 2); 107 | QWidget *parent = luaQ_optqobject<QWidget>(L, 3, 0); 108 | QString name = luaQ_optqvariant<QString>(L, 4, QString()); 109 | QWidget *widget = loader->createWidget(classname, parent, name); 110 | luaQ_pushqt(L, widget, !parent); 111 | return 1; 112 | } 113 | 114 | 115 | static int 116 | qtuiloader_load(lua_State *L) 117 | { 118 | // this 119 | QUiLoader *loader = luaQ_checkqobject<QUiLoader>(L, 1); 120 | // file 121 | QFile afile; 122 | QIODevice *file = qobject_cast<QIODevice*>(luaQ_toqobject(L, 2)); 123 | if (!file && lua_isstring(L, 2)) 124 | { 125 | file = &afile; 126 | const char *fn = lua_tostring(L, 2); 127 | afile.setFileName(QFile::decodeName(fn)); 128 | if (! afile.open(QIODevice::ReadOnly)) 129 | luaL_error(L,"cannot open file '%s' for reading (%s)", 130 | fn, afile.errorString().toLocal8Bit().constData() ); 131 | } 132 | else if (!file) 133 | { 134 | file = &afile; 135 | void *udata = luaL_checkudata(L, 2, LUA_FILEHANDLE); 136 | if (! afile.open(*(FILE**)udata, QIODevice::ReadOnly)) 137 | luaL_error(L,"cannot use stream for reading (%s)", 138 | afile.errorString().toLocal8Bit().constData() ); 139 | } 140 | // parent 141 | QWidget *parent = luaQ_optqobject<QWidget>(L, 3); 142 | // load 143 | QWidget *w = loader->load(file, parent); 144 | luaQ_pushqt(L, w, !parent); 145 | return 1; 146 | } 147 | 148 | 149 | static int 150 | qtuiloader_pluginPaths(lua_State *L) 151 | { 152 | QUiLoader *loader = luaQ_checkqobject<QUiLoader>(L, 1); 153 | luaQ_pushqt(L, QVariant(loader->pluginPaths())); 154 | return 1; 155 | } 156 | 157 | 158 | static int 159 | qtuiloader_setWorkingDirectory(lua_State *L) 160 | { 161 | QUiLoader *loader = luaQ_checkqobject<QUiLoader>(L, 1); 162 | const char *dir = luaL_checkstring(L, 2); 163 | loader->setWorkingDirectory(QDir(QFile::decodeName(dir))); 164 | return 0; 165 | } 166 | 167 | 168 | static int 169 | qtuiloader_workingDirectory(lua_State *L) 170 | { 171 | QUiLoader *loader = luaQ_checkqobject<QUiLoader>(L, 1); 172 | QString path = loader->workingDirectory().path(); 173 | lua_pushstring(L, QFile::encodeName(path).constData()); 174 | return 1; 175 | } 176 | 177 | 178 | 179 | 180 | // ===================================== 181 | 182 | static const luaL_Reg qtuiloader_lib[] = { 183 | {"new", qtuiloader_new}, 184 | {"addPluginPath", qtuiloader_addPluginPath}, 185 | {"availableWidgets", qtuiloader_availableWidgets}, 186 | {"clearPluginPaths", qtuiloader_clearPluginPaths}, 187 | {"createAction", qtuiloader_createAction}, 188 | {"createActionGroup", qtuiloader_createActionGroup}, 189 | {"createLayout", qtuiloader_createLayout}, 190 | {"createWidget", qtuiloader_createWidget}, 191 | {"load", qtuiloader_load}, 192 | {"pluginPaths", qtuiloader_pluginPaths}, 193 | {"setWorkingDirectory", qtuiloader_setWorkingDirectory}, 194 | {"workingDirectory", qtuiloader_workingDirectory}, 195 | {NULL, NULL} 196 | }; 197 | 198 | 199 | LUA_EXTERNC QTUILOADER_API int 200 | luaopen_libqtuiloader(lua_State *L) 201 | { 202 | // load module 'qt' 203 | if (luaL_dostring(L, "require 'qt'")) 204 | lua_error(L); 205 | // enrichs class QUiLoader. 206 | luaQ_pushmeta(L, &QUiLoader::staticMetaObject); 207 | luaQ_getfield(L, -1, "__metatable"); 208 | luaQ_register(L, qtuiloader_lib, QCoreApplication::instance()); 209 | return 0; 210 | } 211 | 212 | 213 | 214 | /* ------------------------------------------------------------- 215 | Local Variables: 216 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 217 | End: 218 | ------------------------------------------------------------- */ 219 | 220 | 221 | -------------------------------------------------------------------------------- /qlua/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # -*- cmake -*- 2 | 3 | SET(QLUA_VERSION 0.1) 4 | SET(QLUA_DEFINITIONS) 5 | SET(QLUA_INCLUDE_DIR 6 | "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}") 7 | 8 | #FIND_PACKAGE(Lua REQUIRED) 9 | 10 | ADD_DEFINITIONS(${QLUA_DEFINITIONS} ${QTLUA_DEFINITIONS} ${LUA_DEFINITIONS}) 11 | INCLUDE_DIRECTORIES(${QLUA_INCLUDE_DIR} ${QTLUA_INCLUDE_DIR} ${LUA_INCLUDE_DIR}) 12 | INCLUDE(${QT_USE_FILE}) 13 | 14 | # -- checks 15 | 16 | INCLUDE(CheckIncludeFiles) 17 | INCLUDE(CheckSymbolExists) 18 | INCLUDE(CheckFunctionExists) 19 | 20 | IF (NOT WITHOUT_READLINE) 21 | FIND_PACKAGE(Readline) 22 | IF(READLINE_FOUND) 23 | SET(HAVE_READLINE 1) 24 | INCLUDE_DIRECTORIES(${READLINE_INCLUDE_DIR}) 25 | SET(CMAKE_REQUIRED_INCLUDES ${READLINE_INCLUDE_DIR}) 26 | SET(CMAKE_REQUIRED_LIBRARIES ${READLINE_LIBRARIES}) 27 | CHECK_SYMBOL_EXISTS(rl_completion_matches 28 | "stdio.h;readline/readline.h" HAVE_RL_COMPLETION_MATCHES) 29 | SET(CMAKE_REQUIRED_INCLUDES) 30 | SET(CMAKE_REQUIRED_LIBRARIES) 31 | ENDIF(READLINE_FOUND) 32 | ENDIF (NOT WITHOUT_READLINE) 33 | 34 | IF (WIN32 AND NOT UNIX) 35 | CHECK_INCLUDE_FILES(io.h HAVE_IO_H) 36 | CHECK_SYMBOL_EXISTS(_cgets_s "conio.h" HAVE_CGETS_S) 37 | ELSE (WIN32 AND NOT UNIX) 38 | CHECK_INCLUDE_FILES(fcntl.h HAVE_FCNTL_H) 39 | CHECK_INCLUDE_FILES(pthread.h HAVE_PTHREAD_H) 40 | CHECK_INCLUDE_FILES(signal.h HAVE_SIGNAL_H) 41 | CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H) 42 | CHECK_INCLUDE_FILES(errno.h HAVE_ERRNO_H) 43 | CHECK_INCLUDE_FILES(sys/select.h HAVE_SYS_SELECT_H) 44 | CHECK_INCLUDE_FILES(sys/time.h HAVE_SYS_TIME_H) 45 | CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H) 46 | CHECK_SYMBOL_EXISTS(isatty "unistd.h" HAVE_ISATTY) 47 | CHECK_SYMBOL_EXISTS(sigprocmask "signal.h" HAVE_SIGPROCMASK) 48 | CHECK_SYMBOL_EXISTS(sigaction "signal.h" HAVE_SIGACTION) 49 | CHECK_SYMBOL_EXISTS(signal "signal.h" HAVE_SIGNAL) 50 | ENDIF(WIN32 AND NOT UNIX) 51 | 52 | SET(CMAKE_REQUIRED_LIBRARIES ${QT_LIBRARIES}) 53 | CHECK_SYMBOL_EXISTS(pthread_sigmask "pthread.h;signal.h" HAVE_PTHREAD_SIGMASK) 54 | CHECK_FUNCTION_EXISTS(XInitThreads HAVE_XINITTHREADS) 55 | SET(CMAKE_REQUIRED_LIBRARIES) 56 | 57 | # --- configure 58 | 59 | CONFIGURE_FILE("qluaconf.h.in" "${CMAKE_CURRENT_BINARY_DIR}/qluaconf.h") 60 | 61 | # --- Compile libqlua 62 | 63 | SET(QLUA_LIBRARIES libqlua) 64 | 65 | SET(libqlua_SRC 66 | "qluaapplication.h" "qluaapplication.cpp" 67 | "qlua.qrc" "qluaconsole.h" ) 68 | IF (WIN32 AND NOT UNIX) 69 | SET(libqlua_SRC ${libqlua_SRC} "qluaconsole_win.cpp") 70 | ELSE (WIN32 AND NOT UNIX) 71 | SET(libqlua_SRC ${libqlua_SRC} "qluaconsole_unix.cpp") 72 | ENDIF(WIN32 AND NOT UNIX) 73 | 74 | MACRO_QT4_AUTOGEN(libqlua_GEN ${libqlua_SRC}) 75 | 76 | ADD_LIBRARY(libqlua SHARED ${libqlua_SRC} ${libqlua_GEN}) 77 | SET_TARGET_PROPERTIES(libqlua PROPERTIES OUTPUT_NAME "qlua") 78 | SET_TARGET_PROPERTIES(libqlua PROPERTIES PREFIX "lib" IMPORT_PREFIX "lib") 79 | 80 | IF(APPLE) 81 | SET_TARGET_PROPERTIES(libqlua PROPERTIES COMPILE_FLAGS "-DAPPLE") 82 | ENDIF(APPLE) 83 | 84 | TARGET_LINK_LIBRARIES(libqlua 85 | ${QTLUA_LIBRARIES} 86 | ${LUA_LIBRARIES} 87 | ${READLINE_LIBRARIES} 88 | ${QT_LIBRARIES}) 89 | 90 | 91 | # --- config for internal use 92 | 93 | SET(QLUA_LIBRARIES "libqlua") 94 | SET(QLUA_DEFINITIONS) 95 | CONFIGURE_FILE(QLuaConfig.cmake.in 96 | "${QtLua_INSTALL_FINDLUA_DIR}/QLuaConfig.cmake") 97 | SET(QLua_DIR "${QtLua_INSTALL_FINDLUA_DIR}" CACHE PATH 98 | "Directory containing QLuaConfig.cmake") 99 | MARK_AS_ADVANCED(QLua_DIR) 100 | 101 | 102 | # --- Compile qlua 103 | 104 | IF(LUA_JIT AND APPLE) 105 | set ( CMAKE_EXE_LINKER_FLAGS "-pagezero_size 10000 -image_base 100000000 ${CMAKE_EXE_LINKER_FLAGS}" ) 106 | ENDIF(LUA_JIT AND APPLE) 107 | 108 | SET(qlua_SRC "qlua.cpp") 109 | 110 | ADD_EXECUTABLE(qlua ${qlua_SRC}) 111 | 112 | TARGET_LINK_LIBRARIES(qlua libqlua) 113 | 114 | IF(Q_WS_X11) 115 | FIND_PACKAGE(X11 REQUIRED) 116 | TARGET_LINK_LIBRARIES(qlua ${X11_LIBRARIES}) 117 | ENDIF(Q_WS_X11) 118 | 119 | IF(WITH_QTLUA_IDE AND WIN32) 120 | # winqlua has only the ide 121 | ADD_EXECUTABLE(winqlua WIN32 ${qlua_SRC} qlua.rc) 122 | TARGET_LINK_LIBRARIES(winqlua ${QLUA_LIBRARIES} ${QT_QTMAIN_LIBRARY}) 123 | SET_TARGET_PROPERTIES(winqlua PROPERTIES COMPILE_FLAGS "-DWINQLUA") 124 | # wintorch loads torch-env with both console and ide 125 | ADD_EXECUTABLE(wintorch ${qlua_SRC} qlua.rc) 126 | TARGET_LINK_LIBRARIES(wintorch ${QLUA_LIBRARIES} ${QT_QTMAIN_LIBRARY}) 127 | SET_TARGET_PROPERTIES(wintorch PROPERTIES COMPILE_FLAGS "-DWINQLUA -DTORCH7") 128 | ENDIF(WITH_QTLUA_IDE AND WIN32) 129 | 130 | IF(WITH_QTLUA_IDE AND APPLE) 131 | ADD_EXECUTABLE(macqlua ${qlua_SRC}) 132 | TARGET_LINK_LIBRARIES(macqlua ${QLUA_LIBRARIES}) 133 | SET_TARGET_PROPERTIES(macqlua PROPERTIES COMPILE_FLAGS "-DMACQLUA") 134 | ENDIF(WITH_QTLUA_IDE AND APPLE) 135 | 136 | IF(APPLE) 137 | SET_TARGET_PROPERTIES(qlua PROPERTIES COMPILE_FLAGS "-DAPPLE") 138 | ENDIF(APPLE) 139 | 140 | # --- install 141 | 142 | 143 | INSTALL(TARGETS libqlua qlua 144 | RUNTIME DESTINATION ${QtLua_INSTALL_BIN_SUBDIR} 145 | LIBRARY DESTINATION ${QtLua_INSTALL_LIB_SUBDIR} 146 | ARCHIVE DESTINATION ${QtLua_INSTALL_LIB_SUBDIR} ) 147 | 148 | IF (WITH_QTLUA_IDE AND WIN32) 149 | INSTALL(TARGETS winqlua 150 | RUNTIME DESTINATION ${QtLua_INSTALL_BIN_SUBDIR} 151 | LIBRARY DESTINATION ${QtLua_INSTALL_LIB_SUBDIR} 152 | ARCHIVE DESTINATION ${QtLua_INSTALL_LIB_SUBDIR} ) 153 | INSTALL(TARGETS wintorch 154 | RUNTIME DESTINATION ${QtLua_INSTALL_BIN_SUBDIR} 155 | LIBRARY DESTINATION ${QtLua_INSTALL_LIB_SUBDIR} 156 | ARCHIVE DESTINATION ${QtLua_INSTALL_LIB_SUBDIR} ) 157 | ENDIF(WITH_QTLUA_IDE AND WIN32) 158 | 159 | IF (WITH_QTLUA_IDE AND APPLE) 160 | OPTION(GENERATE_MACQLUA_BUNDLE 161 | "Install a Mac OS bundle (set CMAKE_INSTALL_PREFIX=.../MacQLua.app/Contents)" ON) 162 | IF(GENERATE_MACQLUA_BUNDLE) 163 | CONFIGURE_FILE("qlua.plist.in" "${CMAKE_CURRENT_BINARY_DIR}/Info.plist") 164 | INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/Info.plist" 165 | DESTINATION "${QtLua_INSTALL_PREFIX}" 166 | PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) 167 | INSTALL(TARGETS macqlua 168 | RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/MacOS" ) 169 | INSTALL(FILES 170 | "${CMAKE_CURRENT_SOURCE_DIR}/images/torch.icns" 171 | "${CMAKE_CURRENT_SOURCE_DIR}/images/luadoc.icns" 172 | DESTINATION "${QtLua_INSTALL_PREFIX}/Resources" 173 | PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) 174 | ENDIF(GENERATE_MACQLUA_BUNDLE) 175 | INSTALL(TARGETS macqlua 176 | RUNTIME DESTINATION ${QtLua_INSTALL_BIN_SUBDIR} 177 | LIBRARY DESTINATION ${QtLua_INSTALL_LIB_SUBDIR} 178 | ARCHIVE DESTINATION ${QtLua_INSTALL_LIB_SUBDIR} ) 179 | ENDIF(WITH_QTLUA_IDE AND APPLE) 180 | 181 | -------------------------------------------------------------------------------- /packages/qtide/prefs.lua: -------------------------------------------------------------------------------- 1 | 2 | require 'qtuiloader' 3 | 4 | local G = _G 5 | local dofile = dofile 6 | local error = error 7 | local ipairs = ipairs 8 | local loadstring = loadstring 9 | local pairs = pairs 10 | local paths = paths 11 | local pcall = pcall 12 | local print = print 13 | local qt = qt 14 | local string = string 15 | local tonumber = tonumber 16 | local tostring = tostring 17 | local type = type 18 | 19 | qtide.prefs = qtide.prefs or {} 20 | local M = qtide.prefs 21 | 22 | local uiPreferences = paths.thisfile("prefs.ui") 23 | 24 | local function getFontForLabel(label) 25 | local f = qt.QFontDialog.getFont(label.font, label) 26 | if qt.isa(f,'QFont') then 27 | label.font = f 28 | end 29 | end 30 | 31 | local function readSettingsNumber(a,k) 32 | local v = a:readSettings(k) 33 | if qt.type(v) then v = v:tostring() end 34 | return tonumber(v) 35 | end 36 | 37 | local function readSettingsBoolean(a,k) 38 | local v = a:readSettings(k) 39 | if qt.type(v) then v = v:tostring() end 40 | if v == "true" then return true end 41 | if v == "false" then return false end 42 | return nil 43 | end 44 | 45 | function M.createPreferencesDialog() 46 | if not paths.filep(uiPreferences) then 47 | error("Unable to locate file 'prefs.ui'") 48 | end 49 | local v = nil 50 | local d = {} 51 | local a = qt.qApp 52 | -- create dialog 53 | d.dialog = G.qtuiloader.load(uiPreferences) 54 | -- cache subwidgets 55 | d.labelFontConsole = d.dialog.labelFontConsole 56 | d.btnFontConsole = d.dialog.btnFontConsole 57 | d.spnConsoleLines = d.dialog.spnConsoleLines 58 | d.spnHistorySize = d.dialog.spnHistorySize 59 | d.spnConsoleSizeW = d.dialog.spnConsoleSizeW 60 | d.spnConsoleSizeH = d.dialog.spnConsoleSizeH 61 | d.spnInputSizeW = d.dialog.spnInputSizeW 62 | d.spnInputSizeH = d.dialog.spnInputSizeH 63 | d.spnConsoleTabSize = d.dialog.spnConsoleTabSize 64 | d.chkConsoleTabExpand = d.dialog.chkConsoleTabExpand 65 | d.labelFontEditor = d.dialog.labelFontEditor 66 | d.btnFontEditor = d.dialog.btnFontEditor 67 | d.spnEditorSizeW = d.dialog.spnEditorSizeW 68 | d.spnEditorSizeH = d.dialog.spnEditorSizeH 69 | d.spnEditorTabSize = d.dialog.spnEditorTabSize 70 | d.chkEditorTabExpand = d.dialog.chkEditorTabExpand 71 | d.comboMode = d.dialog.comboMode 72 | d.spnBaseIndent = d.dialog.spnBaseIndent 73 | d.comboFormat = d.dialog.comboFormat 74 | d.labelFormat = d.dialog.labelFormat 75 | d.chkBold = d.dialog.chkBold 76 | d.chkItalic = d.dialog.chkItalic 77 | d.btnForeground = d.dialog.btnForeground 78 | d.btnBackground = d.dialog.btnBackground 79 | -- set window title 80 | d.dialog.windowTitle = a.applicationName:tostring() .. " Preferences" 81 | -- connect font buttons 82 | qt.connect(d.btnFontEditor,'clicked()', 83 | function() getFontForLabel(d.labelFontEditor) end, true) 84 | qt.connect(d.btnFontConsole,'clicked()', 85 | function() getFontForLabel(d.labelFontConsole) end, true) 86 | -- connect color buttons 87 | -- default font 88 | local f = qt.QFont{typewriter=true, fixedPitch=true, family="monospace"} 89 | if qt.isa(qt.qLuaSdiMain,'QLuaSdiMain') then 90 | f = qt.QFont(qt.qLuaSdiMain:consoleWidget().font:info()) 91 | end 92 | -- read editor/font 93 | v = a:readSettings("editor/font") 94 | if not qt.isa(v,"QFont") then v = f end 95 | d.labelFontEditor.font = v 96 | -- read editor/size 97 | v = a:readSettings("editor/size") 98 | if qt.isa(v,"QSize") then 99 | local t = v:totable() 100 | d.spnEditorSizeW.value = t.width 101 | d.spnEditorSizeH.value = t.height 102 | end 103 | -- read editor/tabSize 104 | v = readSettingsNumber(a,"editor/tabSize") 105 | if type(v) == "number" and v > 0 and v <= 16 then 106 | d.spnEditorTabSize.value = v 107 | end 108 | -- read editor/tabExpand 109 | v = readSettingsBoolean(a,"editor/tabExpand") 110 | if type(v) == "boolean" then 111 | d.chkEditorTabExpand.checked = v 112 | end 113 | -- read console/font 114 | v = a:readSettings("console/font") 115 | if not qt.isa(v,"QFont") then v = f end 116 | d.labelFontConsole.font = v 117 | -- read console/consoleLines 118 | v = readSettingsNumber(a,"console/consoleLines") 119 | if type(v) == "number" and v > 0 and v <= 99999 then 120 | d.spnConsoleLines.value = v 121 | end 122 | -- read console/historySize 123 | v = readSettingsNumber(a,"console/historySize") 124 | if type(v) == "number" and v > 0 and v <= 9999 then 125 | d.spnHistorySize.value = v 126 | end 127 | -- read console/editorSize 128 | v = a:readSettings("console/editorSize") 129 | if qt.isa(v,"QSize") then 130 | local t = v:totable() 131 | d.spnInputSizeW.value = t.width 132 | d.spnInputSizeH.value = t.height 133 | end 134 | -- read console/consoleSize 135 | v = a:readSettings("console/consoleSize") 136 | if qt.isa(v,"QSize") then 137 | local t = v:totable() 138 | d.spnConsoleSizeW.value = t.width 139 | d.spnConsoleSizeH.value = t.height 140 | end 141 | -- read console/tabSize 142 | v = readSettingsNumber(a,"editor/tabSize") 143 | if type(v) == "number" and v > 0 and v <= 16 then 144 | d.spnEditorTabSize.value = v 145 | end 146 | -- read console/tabExpand 147 | v = readSettingsBoolean(a,"editor/tabExpand") 148 | if type(v) == "boolean" then 149 | d.chkEditorTabExpand.checked = v 150 | end 151 | -- formats (not yet implemented) 152 | d.dialog.tabFormats:deleteLater() -- to avoid confusion 153 | -- return 154 | return d 155 | end 156 | 157 | 158 | function M.savePreferences(d) 159 | local a = qt.qApp 160 | local f,w,h,ts,te,cl,hs 161 | local ide = qt.QLuaIde() 162 | -- find windows 163 | local windows = {} 164 | for i,n in pairs(ide:windowNames():totable()) do 165 | windows[i] = qt[n:tostring()] 166 | end 167 | -- save editor/font 168 | f = d.labelFontEditor.font 169 | a:writeSettings("editor/font", f) 170 | -- save editor/size 171 | w = d.spnEditorSizeW.value 172 | h = d.spnEditorSizeH.value 173 | a:writeSettings("editor/size", qt.QSize{width=w,height=h}) 174 | -- save editor/tabSize 175 | ts = d.spnEditorTabSize.value 176 | a:writeSettings("editor/tabSize", ts) 177 | -- save editor/tabExpand 178 | te = d.chkEditorTabExpand.checked 179 | a:writeSettings("editor/tabExpand", te) 180 | -- update editors 181 | for _,w in pairs(windows) do 182 | if qt.isa(w, 'QLuaEditor') then 183 | local e = w:widget() 184 | e.font = f 185 | e.tabSize = ts 186 | e.tabExpand = te 187 | end 188 | end 189 | -- save console/font 190 | f = d.labelFontConsole.font 191 | a:writeSettings("console/font", f) 192 | -- save console/consoleSize 193 | w = d.spnConsoleSizeW.value 194 | h = d.spnConsoleSizeH.value 195 | a:writeSettings("console/consoleSize", qt.QSize{width=w,height=h}) 196 | -- save console/editorSize 197 | w = d.spnInputSizeW.value 198 | h = d.spnInputSizeH.value 199 | a:writeSettings("console/editorSize", qt.QSize{width=w,height=h}) 200 | -- save console/tabSize 201 | ts = d.spnConsoleTabSize.value 202 | a:writeSettings("console/tabSize", ts) 203 | -- save console/tabExpand 204 | te = d.chkConsoleTabExpand.checked 205 | a:writeSettings("console/tabExpand", te) 206 | -- save console/consoleLines 207 | cl = d.spnConsoleLines.value 208 | a:writeSettings("console/consoleLines", cl) 209 | -- save console/historySize 210 | hs = d.spnHistorySize.value 211 | a:writeSettings("console/historySize", cl) 212 | -- update console 213 | for _,w in pairs(windows) do 214 | if qt.isa(w, 'QLuaSdiMain') then 215 | local e = w:editorWidget() 216 | local c = w:consoleWidget() 217 | e.font = f 218 | e.tabSize = ts 219 | c.font = f 220 | c.tabSize = ts 221 | c.tabExpand = te 222 | w.consoleLines = cl 223 | w.historySize = hs 224 | end 225 | end 226 | 227 | end 228 | 229 | return M 230 | -------------------------------------------------------------------------------- /packages/qtide/qluamode_hlp.cpp: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- */ 2 | 3 | #include <QtGlobal> 4 | #include <QDebug> 5 | #include <QList> 6 | #include <QRegExp> 7 | #include <QStack> 8 | 9 | 10 | #include "qluatextedit.h" 11 | #include "qluamode.h" 12 | 13 | #include <string.h> 14 | 15 | 16 | 17 | // ======================================== 18 | // USERDATA 19 | 20 | 21 | namespace { 22 | 23 | struct UserData : public QLuaModeUserData 24 | { 25 | bool verbatim; 26 | UserData() : verbatim(false) { } 27 | virtual int highlightState() { return (verbatim) ? 1 : 0; } 28 | }; 29 | 30 | } 31 | 32 | 33 | 34 | 35 | // ======================================== 36 | // QLUAMODETEXT 37 | 38 | 39 | 40 | 41 | class QLuaModeHelp : public QLuaMode 42 | { 43 | Q_OBJECT 44 | public: 45 | QLuaModeHelp(QLuaTextEditModeFactory *f, QLuaTextEdit *e); 46 | virtual bool doEnter(); 47 | virtual bool supportsHighlight() { return true; } 48 | virtual bool supportsMatch() { return true; } 49 | virtual bool supportsBalance() { return false; } 50 | virtual bool supportsIndent() { return true; } 51 | virtual void parseBlock(int pos, const QTextBlock &block, 52 | const QLuaModeUserData *idata, 53 | QLuaModeUserData *&odata ); 54 | void gotLine(UserData *d, int pos, int len, QString); 55 | private: 56 | QRegExp reSection, reHRule, reIndent, reEmpty, reToken; 57 | QRegExp reFormat1, reFormat2, reEVerb; 58 | }; 59 | 60 | 61 | QLuaModeHelp::QLuaModeHelp(QLuaTextEditModeFactory *f, QLuaTextEdit *e) 62 | : QLuaMode(f,e), 63 | reSection("^\\-\\-\\-\\+.*$"), 64 | reHRule("^(\\-\\-\\-)+"), 65 | reIndent("^( |\t)+(\\*|[1aAiI]\\.|\\$(?=.+:\\s+.*\\$))[ \t]+"), 66 | reEmpty("^\\s*$"), 67 | reToken("(<[^>]*>?|#\\w+|\\[\\[|\\]\\[|\\]\\]|==|__|\\*|=|_)"), 68 | reFormat1("^(==|__|\\*|=|_)(\\S+\\S?)(\\1)"), 69 | reFormat2("^(==|__|\\*|=|_)(\\S.*\\S)(\\1)"), 70 | reEVerb("</verbatim>") 71 | { 72 | reFormat1.setMinimal(false); 73 | reFormat2.setMinimal(true); 74 | } 75 | 76 | 77 | bool 78 | QLuaModeHelp::doEnter() 79 | { 80 | e->textCursor().insertBlock(); 81 | return true; 82 | } 83 | 84 | 85 | void 86 | QLuaModeHelp::parseBlock(int pos, const QTextBlock &block, 87 | const QLuaModeUserData *idata, 88 | QLuaModeUserData *&odata ) 89 | { 90 | QString text = block.text(); 91 | UserData *data = new UserData; 92 | // input state 93 | if (idata) 94 | *data = *static_cast<const UserData*>(idata); 95 | // process line 96 | gotLine(data, pos, block.length(), block.text()); 97 | // output state 98 | odata = data; 99 | } 100 | 101 | 102 | void 103 | QLuaModeHelp::gotLine(UserData *d, int pos, int len, QString line) 104 | { 105 | int i = 0; 106 | int matchPos = 0; 107 | int matchLen = 0; 108 | QString matchToken; 109 | while (i < len) 110 | { 111 | int p; 112 | if (d->verbatim) 113 | { 114 | if ((p = reEVerb.indexIn(line, i)) >= 0) 115 | { 116 | setFormat(pos, p, "string"); 117 | setIndentOverlay(pos+p); 118 | d->verbatim = false; 119 | i = p; 120 | } 121 | else 122 | { 123 | i = len; 124 | setFormat(pos, len-1, "string"); 125 | } 126 | continue; 127 | } 128 | if (i == 0) 129 | { 130 | if ((pos == 0) || (p = reSection.indexIn(line, i)) >= 0) 131 | { 132 | setFormat(pos,len-1,"comment"); 133 | setIndent(pos+0, 0); 134 | i = len; 135 | continue; 136 | } 137 | if ((p = reHRule.indexIn(line, i)) >= 0) 138 | { 139 | int l = reHRule.matchedLength(); 140 | setFormat(pos, l, "keyword"); 141 | setIndent(pos, -1); 142 | i = i + l; 143 | continue; 144 | 145 | } 146 | if ((p = reIndent.indexIn(line, i)) >= 0) 147 | { 148 | int l = reIndent.matchedLength(); 149 | int m = reIndent.pos(2); 150 | setFormat(pos, l, "keyword"); 151 | setIndent(pos, e->indentAt(m)); 152 | setIndent(pos+l, e->indentAt(pos+l)); 153 | i = i + l; 154 | continue; 155 | } 156 | if ((p = reEmpty.indexIn(line, i)) >= 0) 157 | { 158 | setIndent(pos+1, -1); 159 | i = len; 160 | continue; 161 | } 162 | } 163 | if ((p = reToken.indexIn(line, i)) >= 0) 164 | { 165 | int l = reToken.matchedLength(); 166 | QString k = line.mid(p, l); 167 | setFormat(pos+p, l, "keyword"); 168 | if (k == "]]" && matchLen>0) 169 | { 170 | if (matchToken == "[[") { 171 | int opos = matchPos+matchLen; 172 | setFormat(opos, pos+p-opos, "url"); 173 | } 174 | setRightMatch(pos+p, l, matchPos, matchLen); 175 | matchLen = 0; 176 | } 177 | else if (k == "][" && matchLen>0) 178 | { 179 | if (matchToken == "[[") { 180 | int opos = matchPos+matchLen; 181 | setFormat(opos, pos+p-opos, "url"); 182 | setMiddleMatch(pos+p, l, matchPos, matchLen); 183 | } else 184 | setErrorMatch(pos+p, l, matchPos, matchLen); 185 | matchPos = pos+p; 186 | matchLen = l; 187 | matchToken = k; 188 | } 189 | else if (k == "[[" && matchLen<=0) 190 | { 191 | setLeftMatch(pos+p, l); 192 | matchPos = pos+p; 193 | matchLen = l; 194 | matchToken = k; 195 | } 196 | else if (k == "[[" || k == "][" || k == "]]") 197 | { 198 | setErrorMatch(pos+p, l, matchPos, matchLen); 199 | matchLen = 0; 200 | } 201 | else if (k[0] == '#') 202 | { 203 | setFormat(pos+p, l, "url"); 204 | } 205 | else if (k == "<verbatim>") 206 | { 207 | d->verbatim = true; 208 | setFormat(pos+p+l, len-p-1, "string"); 209 | setIndentOverlay(pos+p+l, -1); 210 | i = len; 211 | continue; 212 | } 213 | else if (k[0] != '<') 214 | { 215 | int q; 216 | int q1 = p; 217 | int q2 = p; 218 | if ((q = reFormat1.indexIn(line, p, 219 | QRegExp::CaretAtOffset) ) == p) 220 | { 221 | l = reFormat1.matchedLength(); 222 | k = reFormat1.cap(1); 223 | q1 = reFormat1.pos(2); 224 | q2 = reFormat1.pos(3); 225 | } 226 | else if ((q = reFormat2.indexIn(line, p, 227 | QRegExp::CaretAtOffset) ) == p) 228 | { 229 | l = reFormat2.matchedLength(); 230 | k = reFormat2.cap(1); 231 | q1 = reFormat2.pos(2); 232 | q2 = reFormat2.pos(3); 233 | } 234 | QTextCharFormat fmt = e->format("Help/string"); 235 | if (k == "__" || k == "==" || k == "*") 236 | fmt.setFontWeight(QFont::Bold); 237 | setFormat(pos+p, l, (q>=0) ? "keyword" : "normal"); 238 | if (q >= 0) 239 | { 240 | setLeftMatch(pos+p, q1-p); 241 | setFormat(pos+q1, q2-q1, fmt); 242 | setRightMatch(pos+q2, p+l-q2, pos+p, q1-p); 243 | } 244 | } 245 | i = p+l; 246 | continue; 247 | } 248 | i = len; 249 | } 250 | } 251 | 252 | 253 | // ======================================== 254 | // FACTORY 255 | 256 | 257 | const char *helpName = QT_TRANSLATE_NOOP("QLuaTextEditMode", "Help"); 258 | 259 | static QLuaModeFactory<QLuaModeHelp> textModeFactory(helpName, "hlp"); 260 | 261 | 262 | 263 | // ======================================== 264 | // MOC 265 | 266 | 267 | #include "qluamode_hlp.moc" 268 | 269 | 270 | 271 | 272 | 273 | /* ------------------------------------------------------------- 274 | Local Variables: 275 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*") 276 | End: 277 | ------------------------------------------------------------- */ 278 | -------------------------------------------------------------------------------- /packages/qtwidget/qtluapainter.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | #ifndef QTLUAPAINTER_H 4 | #define QTLUAPAINTER_H 5 | 6 | #include "lua.h" 7 | #include "lauxlib.h" 8 | #include "qtluaengine.h" 9 | #include "qtluautils.h" 10 | 11 | #include "qtwidget.h" 12 | 13 | #include <QBrush> 14 | #include <QByteArray> 15 | #include <QFlags> 16 | #include <QMetaType> 17 | #include <QImage> 18 | #include <QObject> 19 | #include <QPaintDevice> 20 | #include <QPainter> 21 | #include <QPainterPath> 22 | #include <QPen> 23 | #include <QPoint> 24 | #include <QPrinter> 25 | #include <QRegion> 26 | #include <QTransform> 27 | #include <QVariant> 28 | #include <QWidget> 29 | 30 | class QEvent; 31 | class QCloseEvent; 32 | class QFocusEvent; 33 | class QPaintEvent; 34 | class QResizeEvent; 35 | class QKeyEvent; 36 | class QMouseEvent; 37 | class QMainWindow; 38 | class QtLuaPrinter; 39 | 40 | Q_DECLARE_METATYPE(QGradient) 41 | Q_DECLARE_METATYPE(QPainterPath) 42 | Q_DECLARE_METATYPE(QPolygon) 43 | Q_DECLARE_METATYPE(QPolygonF) 44 | Q_DECLARE_METATYPE(QPainter*) 45 | Q_DECLARE_METATYPE(QPrinter*) 46 | Q_DECLARE_METATYPE(QPaintDevice*) 47 | 48 | class QTWIDGET_API QtLuaPainter : public QObject 49 | { 50 | Q_OBJECT 51 | Q_PROPERTY(QPen pen READ currentpen WRITE setpen) 52 | Q_PROPERTY(QBrush brush READ currentbrush WRITE setbrush) 53 | Q_PROPERTY(QPointF point READ currentpoint WRITE setpoint) 54 | Q_PROPERTY(QPainterPath path READ currentpath WRITE setpath) 55 | Q_PROPERTY(QPainterPath clippath READ currentclip WRITE setclip) 56 | Q_PROPERTY(QFont font READ currentfont WRITE setfont) 57 | Q_PROPERTY(QTransform matrix READ currentmatrix WRITE setmatrix) 58 | // special 59 | Q_PROPERTY(QBrush background READ currentbackground WRITE setbackground) 60 | Q_PROPERTY(CompositionMode compositionmode READ currentmode WRITE setmode) 61 | Q_PROPERTY(RenderHints renderhints READ currenthints WRITE sethints) 62 | Q_PROPERTY(AngleUnit angleUnit READ currentangleunit WRITE setangleunit) 63 | Q_PROPERTY(QString styleSheet READ currentstylesheet WRITE setstylesheet) 64 | Q_PROPERTY(int width READ width) 65 | Q_PROPERTY(int height READ height) 66 | Q_PROPERTY(int depth READ depth) 67 | Q_ENUMS(CompositionMode AngleUnit) 68 | Q_FLAGS(RenderHints TextFlags) 69 | 70 | public: 71 | ~QtLuaPainter(); 72 | QtLuaPainter(); 73 | QtLuaPainter(QImage image); 74 | QtLuaPainter(QPixmap pixmap); 75 | QtLuaPainter(int w, int h, bool monochrome=false); 76 | QtLuaPainter(QString fileName, const char *format = 0); 77 | QtLuaPainter(QWidget *widget, bool buffered=true); 78 | QtLuaPainter(QObject *object); 79 | 80 | Q_INVOKABLE QImage image() const; 81 | Q_INVOKABLE QPixmap pixmap() const; 82 | Q_INVOKABLE QWidget *widget() const; 83 | Q_INVOKABLE QObject *object() const; 84 | Q_INVOKABLE QPaintDevice *device() const; 85 | Q_INVOKABLE QPrinter *printer() const; 86 | Q_INVOKABLE QPainter *painter() const; 87 | Q_INVOKABLE QRect rect() const; 88 | Q_INVOKABLE QSize size() const; 89 | Q_INVOKABLE void close(); 90 | int width() const { return size().width(); } 91 | int height() const { return size().height(); } 92 | int depth() const; 93 | 94 | enum AngleUnit { Degrees, Radians }; 95 | 96 | // copy qpainter enums for moc! 97 | enum CompositionMode { 98 | SourceOver = QPainter::CompositionMode_SourceOver, 99 | DestinationOver = QPainter::CompositionMode_DestinationOver, 100 | Clear = QPainter::CompositionMode_Clear, 101 | Source = QPainter::CompositionMode_Source, 102 | Destination = QPainter::CompositionMode_Destination, 103 | SourceIn = QPainter::CompositionMode_SourceIn, 104 | DestinationIn = QPainter::CompositionMode_DestinationIn, 105 | SourceOut = QPainter::CompositionMode_SourceOut, 106 | DestinationOut = QPainter::CompositionMode_DestinationOut, 107 | SourceAtop = QPainter::CompositionMode_SourceAtop, 108 | DestinationAtop = QPainter::CompositionMode_DestinationAtop, 109 | Xor = QPainter::CompositionMode_Xor, 110 | Plus = QPainter::CompositionMode_Plus, 111 | Multiply = QPainter::CompositionMode_Multiply, 112 | Screen = QPainter::CompositionMode_Screen, 113 | Overlay = QPainter::CompositionMode_Overlay, 114 | Darken = QPainter::CompositionMode_Darken, 115 | Lighten = QPainter::CompositionMode_Lighten, 116 | ColorDodge = QPainter::CompositionMode_ColorDodge, 117 | ColorBurn = QPainter::CompositionMode_ColorBurn, 118 | HardLight = QPainter::CompositionMode_HardLight, 119 | SoftLight = QPainter::CompositionMode_SoftLight, 120 | Difference = QPainter::CompositionMode_Difference, 121 | Exclusion = QPainter::CompositionMode_Exclusion 122 | }; 123 | enum RenderHint { 124 | Antialiasing = QPainter::Antialiasing, 125 | TextAntialiasing = QPainter::TextAntialiasing, 126 | SmoothPixmapTransform = QPainter::SmoothPixmapTransform, 127 | HighQualityAntialiasing = QPainter::HighQualityAntialiasing, 128 | }; 129 | enum TextFlag { 130 | AlignLeft = Qt::AlignLeft, 131 | AlignRight = Qt::AlignRight, 132 | AlignHCenter = Qt::AlignHCenter, 133 | AlignJustify = Qt::AlignJustify, 134 | AlignTop = Qt::AlignTop, 135 | AlignBottom = Qt::AlignBottom, 136 | AlignVCenter = Qt::AlignVCenter, 137 | AlignCenter = Qt::AlignCenter, 138 | TextSingleLine =Qt::TextSingleLine, 139 | TextExpandTabs = Qt::TextExpandTabs, 140 | TextShowMnemonic = Qt::TextShowMnemonic, 141 | TextWordWrap = Qt::TextWordWrap, 142 | TextRich = (Qt::TextWordWrap|Qt::TextSingleLine), // magic 143 | RichText = TextRich // alias 144 | }; 145 | Q_DECLARE_FLAGS(RenderHints,RenderHint); 146 | Q_DECLARE_FLAGS(TextFlags,TextFlag); 147 | 148 | public slots: 149 | virtual void showpage(); 150 | void refresh(); 151 | 152 | public: 153 | // buffering 154 | void gbegin(); 155 | void gend(bool invalidate=false); 156 | // state 157 | QPen currentpen() const; 158 | QBrush currentbrush() const; 159 | QPointF currentpoint() const; 160 | QPainterPath currentpath() const; 161 | QPainterPath currentclip() const; 162 | QFont currentfont() const; 163 | QTransform currentmatrix() const; 164 | QBrush currentbackground() const; 165 | CompositionMode currentmode() const; 166 | RenderHints currenthints() const; 167 | AngleUnit currentangleunit() const; 168 | QString currentstylesheet() const; 169 | void setpen(QPen pen); 170 | void setbrush(QBrush brush); 171 | void setpoint(QPointF p); 172 | void setpath(QPainterPath p); 173 | void setclip(QPainterPath p); 174 | void setfont(QFont f); 175 | void setmatrix(QTransform m); 176 | void setbackground(QBrush brush); 177 | void setmode(CompositionMode m); 178 | void sethints(RenderHints h); 179 | void setangleunit(AngleUnit u); 180 | void setstylesheet(QString s); 181 | // postscript rendering 182 | void initclip(); 183 | void initmatrix(); 184 | void initgraphics(); 185 | void scale(qreal x, qreal y); 186 | void rotate(qreal x); 187 | void translate(qreal x, qreal y); 188 | void concat(QTransform m); 189 | void gsave(); 190 | void grestore(); 191 | void newpath(); 192 | void moveto(qreal x, qreal y); 193 | void lineto(qreal x, qreal y); 194 | void curveto(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3); 195 | void arc(qreal x, qreal y, qreal r, qreal a1, qreal a2); 196 | void arcn(qreal x, qreal y, qreal r, qreal a1, qreal a2); 197 | void arcto(qreal x1, qreal y1, qreal x2, qreal y2, qreal r); 198 | void rmoveto(qreal x, qreal y); 199 | void rlineto(qreal x, qreal y); 200 | void rcurveto(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3); 201 | void charpath(QString text); 202 | void closepath(); 203 | void stroke(bool resetpath=true); 204 | void fill(bool resetpath=true); 205 | void eofill(bool resetpath=true); 206 | void clip(bool resetpath=false); 207 | void eoclip(bool resetpath=false); 208 | void show(QString text); 209 | qreal stringwidth(QString text, qreal *pdx=0, qreal *pdy=0); 210 | // additional useful functions 211 | void rectangle(qreal x, qreal y, qreal w, qreal h); // non ps 212 | void image(QRectF drect, QImage i, QRectF srect); 213 | void image(QRectF drect, QPixmap p, QRectF srect); 214 | void image(QRectF drect, QtLuaPainter *p, QRectF srect); 215 | void show(QString text, qreal x, qreal y, qreal w, qreal h, int flags=0); 216 | QRectF stringrect(QString text); 217 | QRectF stringrect(QString text, qreal x, qreal y, qreal w, qreal h, int f=0); 218 | 219 | public: 220 | struct Private; 221 | struct Locker; 222 | struct State; 223 | protected: 224 | Private *d; 225 | }; 226 | 227 | 228 | 229 | #endif 230 | 231 | 232 | /* ------------------------------------------------------------- 233 | Local Variables: 234 | c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*" "qreal") 235 | End: 236 | ------------------------------------------------------------- */ 237 | 238 | 239 | --------------------------------------------------------------------------------