Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit b855cbf97a5a37b54bb7cffec078031a9c46aaaa @arturadib arturadib committed Apr 6, 2012
Showing 4,578 changed files with 405,384 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
@@ -0,0 +1,7 @@
+node_modules/
+build/
+bin/
+out/
+Release/
+npm-debug.log
+
@@ -0,0 +1,153 @@
+# Node-Qt
+
+Node-Qt provides native bindings to the [Qt library](http://developer.qt.nokia.com/doc/qt-4.8/) as a [Node.js addon](http://nodejs.org/docs/latest/api/addons.html). The focus is on graphics and audio bindings; there is no need to duplicate the functionality of the Node API and its modules.
+
+We try to follow [Qt's API](http://developer.qt.nokia.com/doc/qt-4.8/) as closely as possible, but sometimes quirks are inevitable (for example, virtual methods that handle events are translated into callback setters). See the header files in `src/` for a list of available bindings, and comments in `.cc` files for possible API differences.
+
+Supported platforms: **Mac OS X** | **Windows** | **Linux**
+
+
+#### Hello world
+
+```javascript
+var qt = require('node-qt'),
+ app = new qt.QApplication,
+ window = new qt.QWidget;
+
+// Prevent objects from being GC'd
+global.app = app;
+global.window = window;
+
+// Quirk: the virtual method paintEvent() is mapped into a callback setter
+window.paintEvent(function() {
+ var p = new qt.QPainter();
+ p.begin(window);
+ p.drawText(20, 30, 'hello node, hello qt');
+ p.end();
+});
+
+window.resize(300, 150);
+window.show();
+
+// Join Node's event loop
+setInterval(app.processEvents, 0);
+```
+
+
+
+
+
+
+
+
+
+
+
+# Getting started
+
+From your project directory, run (see below for requirements):
+
+```
+$ npm install node-qt
+```
+
+This will download and build the latest release of Node-Qt in `node_modules/`. Then create a new file, say `helloworld.js`, copy the example above and run Node as usual:
+
+```
+$ node helloworld
+```
+
+See the [examples/](https://github.com/arturadib/node-qt/tree/master/examples) directory for other simple use cases.
+
+
+
+
+
+
+
+
+
+
+
+# Requirements
+
+Node-Qt was designed to build seamlessly on a standard development box. The necessary platform-dependent Qt binaries are bundled with the module (due to heterogeneous dependencies, Linux is an exception).
+
++ **Mac:** Python, Make, and GCC.
++ **Windows:** Python and MSVC++ (either [free](http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express) or commercial).
++ **Linux:** Python, Make, GCC, and Qt 4.7+. To install Qt on Ubuntu: `$ sudo apt-get install pkg-config qt-sdk`.
+
+Node-Qt has been tested with Node 0.6.x.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Contributing
+
+
+
+## Building and testing
+
+To download and build the development version:
+
+```
+$ git clone git://github.com/arturadib/node-qt.git
+$ cd node-qt
+$ npm install
+```
+
+To run the unit tests:
+
+```
+$ node make test
+```
+
+(Ignore the image regression errors - they are based on snapshots that are platform- and backend-dependent).
+
+
+
+## Creating new bindings
+
+Please provide a test case for every new binding added. See `test/` for examples of unit tests.
+
+#### Binding to new classes
+
+1. Create your files (e.g. `qclass.h`, `qclass.cc`) from the provided templates `src/template.h`, `src/template.cc`
+2. `qclass.*`: search and replace all occurrences of `__Template__`, `__TEMPLATE__`, and `__template__` with the corresponding class name
+3. `node-qt.gyp`: Add qclass.cc to sources list
+4. `qt.cc`: Include `qclass.h`
+5. `qt.cc`: Add `QClass::Initialize()` to `Initialize()`
+
+#### Binding to new methods
+
+1. `qclass.h`: Declare static method as per `Example()` method in `template.h`
+2. `qclass.cc`: Implement method as per `Example()` in `template.cc`
+3. `qclass.cc`: Expose method to JavaScript via `tpl->PrototypeTemplate()` call in `Initialize()`. Again see template.cc.
+
+
+## Common errors
+
+This is a list of common errors when experimenting with Node addons, and their possible solutions:
+
+_"Out of memory"_
+
+`name` in `NODE_MODULE(name, ...)` does not match target name?
+
+_"Unable to load shared library"_
+
+`(v8 object)->Set()` called to register a method, but method implementation
+is missing?
+
+_"Segmentation fault"_
+
+Tough luck :) Did you forget to `new` a wrapped object?
@@ -0,0 +1,73 @@
+{
+ 'targets': [
+ {
+ 'target_name': 'qt',
+ 'sources': [
+ 'src/qt.cc',
+
+ 'src/QtCore/qsize.cc',
+ 'src/QtCore/qpointf.cc',
+
+ 'src/QtGui/qapplication.cc',
+ 'src/QtGui/qwidget.cc',
+ 'src/QtGui/qmouseevent.cc',
+ 'src/QtGui/qkeyevent.cc',
+ 'src/QtGui/qpixmap.cc',
+ 'src/QtGui/qpainter.cc',
+ 'src/QtGui/qcolor.cc',
+ 'src/QtGui/qbrush.cc',
+ 'src/QtGui/qpen.cc',
+ 'src/QtGui/qimage.cc',
+ 'src/QtGui/qpainterpath.cc',
+ 'src/QtGui/qfont.cc',
+ 'src/QtGui/qmatrix.cc',
+ 'src/QtGui/qsound.cc',
+ 'src/QtGui/qscrollarea.cc',
+ 'src/QtGui/qscrollbar.cc',
+
+ 'src/QtTest/qtesteventlist.cc'
+ ],
+ 'conditions': [
+ ['OS=="mac"', {
+ 'include_dirs': [
+ 'deps/qt-4.8.0/darwin/x64/include',
+ 'deps/qt-4.8.0/darwin/x64/include/QtCore',
+ 'deps/qt-4.8.0/darwin/x64/include/QtGui',
+ 'deps/qt-4.8.0/darwin/x64/include/QtTest'
+ ],
+ 'libraries': [
+ # TODO: fix node-gyp behavior that requires ../
+ '../deps/qt-4.8.0/darwin/x64/lib/QtCore.framework/QtCore',
+ '../deps/qt-4.8.0/darwin/x64/lib/QtGui.framework/QtGui',
+ '../deps/qt-4.8.0/darwin/x64/lib/QtTest.framework/QtTest'
+ ],
+ }],
+ ['OS=="linux"', {
+ 'cflags': [
+ '<!@(pkg-config --cflags QtCore QtGui QtTest)'
+ ],
+ 'ldflags': [
+ '<!@(pkg-config --libs-only-L --libs-only-other QtCore QtGui QtTest)'
+ ],
+ 'libraries': [
+ '<!@(pkg-config --libs-only-l QtCore QtGui QtTest)'
+ ]
+ }],
+ ['OS=="win"', {
+ 'include_dirs': [
+ 'deps/qt-4.8.0/win32/ia32/include',
+ 'deps/qt-4.8.0/win32/ia32/include/QtCore',
+ 'deps/qt-4.8.0/win32/ia32/include/QtGui',
+ 'deps/qt-4.8.0/win32/ia32/include/QtTest',
+ ],
+ 'libraries': [
+ # TODO: fix node-gyp behavior that requires ../
+ '../deps/qt-4.8.0/win32/ia32/lib/QtCore4.lib',
+ '../deps/qt-4.8.0/win32/ia32/lib/QtGui4.lib',
+ '../deps/qt-4.8.0/win32/ia32/lib/QtTest4.lib'
+ ]
+ }]
+ ]
+ }
+ ]
+}
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+#
+# Only repo maintainers should need to use this
+# Copies all necessary Qt frameworks into the current dir, and updates
+# the LD paths
+#
+
+# /Cellar assumes we've installed Qt via homebrew
+QT_PATH=/usr/local/Cellar/qt/4.8.0
+
+echo Removing existing copy
+rm -rf include lib
+mkdir include lib
+
+echo Importing copy from ${QT_PATH}
+cp -R ${QT_PATH}/lib/QtCore.framework \
+ ${QT_PATH}/lib/QtGui.framework \
+ ${QT_PATH}/lib/QtTest.framework \
+ lib
+
+# Avoid symbolic links by moving Version files around (npm doesn't like symlinks)
+find . -type l | xargs rm -f
+
+# Replace header symlinks with hardcopies
+mv -f lib/QtCore.framework/Versions/4/Headers include/QtCore
+mv -f lib/QtGui.framework/Versions/4/Headers include/QtGui
+mv -f lib/QtTest.framework/Versions/4/Headers include/QtTest
+
+# Replace lib symlinks with hardcopies
+mv -f lib/QtCore.framework/Versions/4/* lib/QtCore.framework
+mv -f lib/QtGui.framework/Versions/4/* lib/QtGui.framework
+mv -f lib/QtTest.framework/Versions/4/* lib/QtTest.framework
+
+chmod -R u+rw *
+
+# Update ids
+install_name_tool -id lib/QtCore.framework/QtCore lib/QtCore.framework/QtCore
+install_name_tool -id lib/QtGui.framework/QtGui lib/QtGui.framework/QtGui
+install_name_tool -id lib/QtTest.framework/QtTest lib/QtTest.framework/QtTest
+
+# Update internal refs (from old paths to new)
+install_name_tool -change ${QT_PATH}/lib/QtCore.framework/Versions/4/QtCore lib/QtCore.framework/QtCore lib/QtGui.framework/QtGui
+install_name_tool -change ${QT_PATH}/lib/QtCore.framework/Versions/4/QtCore lib/QtCore.framework/QtCore lib/QtTest.framework/QtTest
+
+# Break unncessary references to old path to avoid Qt's weird fallback
+# (find command only matches binary files like QtCore, not QtCore.prl)
+find lib -type f -name 'Qt*' ! -name '*.*' | xargs sed -i.bak -E 's/Cellar/______/g'
+find lib -name '*.bak' | xargs rm -f
@@ -0,0 +1 @@
+#include "qabstractanimation.h"
@@ -0,0 +1 @@
+#include "qstringbuilder.h"
@@ -0,0 +1 @@
+#include "qabstracteventdispatcher.h"
@@ -0,0 +1 @@
+#include "qabstractfileengine.h"
@@ -0,0 +1 @@
+#include "qabstractfileengine.h"
@@ -0,0 +1 @@
+#include "qabstractfileengine.h"
@@ -0,0 +1 @@
+#include "qabstractitemmodel.h"
@@ -0,0 +1 @@
+#include "qabstractitemmodel.h"
@@ -0,0 +1 @@
+#include "qabstractstate.h"
@@ -0,0 +1 @@
+#include "qabstractitemmodel.h"
@@ -0,0 +1 @@
+#include "qabstracttransition.h"
@@ -0,0 +1 @@
+#include "qabstractanimation.h"
@@ -0,0 +1 @@
+#include "qanimationgroup.h"
@@ -0,0 +1 @@
+#include "qobjectdefs.h"
@@ -0,0 +1 @@
+#include "qatomic.h"
@@ -0,0 +1 @@
+#include "qatomic.h"
@@ -0,0 +1 @@
+#include "qbasicatomic.h"
@@ -0,0 +1 @@
+#include "qbasicatomic.h"
@@ -0,0 +1 @@
+#include "qbasictimer.h"
@@ -0,0 +1 @@
+#include "qbitarray.h"
@@ -0,0 +1 @@
+#include "qbitarray.h"
@@ -0,0 +1 @@
+#include "qglobal.h"
@@ -0,0 +1 @@
+#include "qbuffer.h"
@@ -0,0 +1 @@
+#include "qbytearray.h"
@@ -0,0 +1 @@
+#include "qbytearraymatcher.h"
@@ -0,0 +1 @@
+#include "qbytearray.h"
@@ -0,0 +1 @@
+#include "qnamespace.h"
@@ -0,0 +1 @@
+#include "qcache.h"
@@ -0,0 +1 @@
+#include "qchar.h"
@@ -0,0 +1 @@
+#include "qstring.h"
@@ -0,0 +1 @@
+#include "qcoreevent.h"
@@ -0,0 +1 @@
+#include "qstringbuilder.h"
@@ -0,0 +1 @@
+#include "qstring.h"
@@ -0,0 +1 @@
+#include "qcontiguouscache.h"
@@ -0,0 +1 @@
+#include "qcontiguouscache.h"
@@ -0,0 +1 @@
+#include "qcontiguouscache.h"
@@ -0,0 +1 @@
+#include "qcoreapplication.h"
@@ -0,0 +1 @@
+#include "qcryptographichash.h"
@@ -0,0 +1 @@
+#include "qcoreevent.h"
@@ -0,0 +1 @@
+#include "qdatastream.h"
@@ -0,0 +1 @@
+#include "qdatetime.h"
@@ -0,0 +1 @@
+#include "qdatetime.h"
@@ -0,0 +1 @@
+#include "qdebug.h"
@@ -0,0 +1 @@
+#include "qdir.h"
@@ -0,0 +1 @@
+#include "qdiriterator.h"
@@ -0,0 +1 @@
+#include "qcoreevent.h"
@@ -0,0 +1 @@
+#include "qeasingcurve.h"
@@ -0,0 +1 @@
+#include "qelapsedtimer.h"
@@ -0,0 +1 @@
+#include "qcoreevent.h"
@@ -0,0 +1 @@
+#include "qeventloop.h"
@@ -0,0 +1 @@
+#include "qeventtransition.h"
@@ -0,0 +1 @@
+#include "qshareddata.h"
@@ -0,0 +1 @@
+#include "qfsfileengine.h"
@@ -0,0 +1 @@
+#include "qfactoryinterface.h"
@@ -0,0 +1 @@
+#include "qfile.h"
@@ -0,0 +1 @@
+#include "qfileinfo.h"
@@ -0,0 +1 @@
+#include "qfileinfo.h"
Oops, something went wrong. Retry.

0 comments on commit b855cbf

Please sign in to comment.