Giter Club home page Giter Club logo

brig's Introduction

Brig

A user interface toolkit for Node.js, which is based on Qt for rendering. This project can be used to load and play QML file, make it possible to have a easy way to communicate between QML and Node.js for desktop application.

NPM

The JavaScript in QML is limited, so Brig

The JavaScript in QML is limited, which is used for QML components control only. If developer need more functions that something's like system calls(FileSystem, Socket, crypto ...etc) or using external libraries, C/C++ is the only way to make it.

In order to make QML application in pure JavaScript possible, Brig provides a way to use Node.js to extends QML without C/C++. That means developer can do more thing in QML with NPM modules and Node.js APIs.

Requirements

Ensure Qt 5+ tookits and Node.js 0.10+ are ready to go on your system.

For MacOSX user, no need to install Qt development environment for brig anymore. :-)

Known Issues

  • Failed to build brig for Qt 5.8+

Installation

Install module via NPM

npm install brig

Get Started

There is a simple way to go by loading existed QML file, so you can prepare a QML content like below:

Application.qml

import QtQuick 2.3
import QtQuick.Controls 1.0

ApplicationWindow {
	visible: true;
	color: 'black';
	title: 'Brig Demo';
	width: 640;
	height: 480;

	Text {
		anchors.centerIn: parent;
		text: 'Brig';
		font.family: 'Helvetica';
		font.bold: true;
		font.pointSize: 72;
		color: '#00ffcc';
		scale: 0;
		opacity: 0;

		Text {
			anchors.topMargin: 10;
			anchors.top: parent.bottom;
			anchors.horizontalCenter: parent.horizontalCenter;
			text: 'QML Application in Node.js';
			font.family: 'Helvetica';
			font.pointSize: 16;
			color: '#e6fffa';
		}

		Behavior on opacity {
			NumberAnimation {
				duration: 800;
				easing.type: Easing.OutCubic;
			}
		}

		Behavior on scale {
			NumberAnimation {
				duration: 1000;
				easing.type: Easing.OutBack;
			}
		}

		Component.onCompleted: {
			opacity = 1.0;
			scale = 1.0;
		}
	}
}

Then using Brig to load file in Node.js:

var Brig = require('brig');

var brig = new Brig();

brig.on('ready', function(brig) {

  // Loading QML file to play
  brig.open('Application.qml', function(err, window) {
    // window was opened
  });
});

Customized Type

(This is experimental feature, API might be changed in the next version)

You can create a customized type in order to expose some APIs or functionality from Node.js to QML, see below:

var myQmlType = brig.createType('MyItem', {
	property: {
		prop1: 123
	},
	method: {
		'readFile(a)': function(filename) {
			return require('fs').readFileSync(filename).toString();
		}
	},
	signal: [
		'test(a)'
	]
});

// Triggered when instance of customized type was created
myQmlType.on('instance-created', function(instance) {

	// Signals
	instance.on('test', function(a) {
		// test(a) signal was emitted
		console.log(a);
	});
});

In QML, we can import customized type with its type name and use it directly:

import Brig.MyItem 1.0

Usage:

MyItem {
	// attributes...
}

Examples

Some exmaples you can found which used brig:

Demonstration

Here is a great countdown timer with Brig for hackathon event to show off, you can click image to play YouTube video:

Countdown Timer (clicks to play video)

License

Licensed under the MIT License

Authors

Copyright(c) 2015-2017 Fred Chien <[email protected]>

brig's People

Contributors

cfsghost avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

brig's Issues

qt-darwin Causing Issues on Windows

Hi there!

When running the install script for qt-darwin, which is a dependency of brig, it errors due to being unable to extract the files using tar. I believe this could be remedied by making qt-darwin an optional dependency to only install on MacOS systems. Here is the npm output:

$ npm install brig

> [email protected] install D:\Matthew\Documents\Projects\QtTest\node_modules\qt-darwin
> tar -zxf library.node && rm -fr library.node

tar: Frameworks/Qt3DCore.framework/Qt3DCore: Cannot create symlink to ‘Versions/Current/Qt3DCore’: No such file or directory
tar: Frameworks/Qt3DCore.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/Qt3DQuick.framework/Qt3DQuick: Cannot create symlink to ‘Versions/Current/Qt3DQuick’: No such file or directory
tar: Frameworks/Qt3DQuick.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtBluetooth.framework/QtBluetooth: Cannot create symlink to ‘Versions/Current/QtBluetooth’: No such file or directory
tar: Frameworks/QtBluetooth.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtCharts.framework/QtCharts: Cannot create symlink to ‘Versions/Current/QtCharts’: No such file or directory
tar: Frameworks/QtCharts.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtConcurrent.framework/QtConcurrent: Cannot create symlink to ‘Versions/Current/QtConcurrent’: No such file or directory
tar: Frameworks/QtConcurrent.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtCore.framework/QtCore: Cannot create symlink to ‘Versions/Current/QtCore’: No such file or directory
tar: Frameworks/QtCore.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtDataVisualization.framework/QtDataVisualization: Cannot create symlink to ‘Versions/Current/QtDataVisualization’: No such file or directory
tar: Frameworks/QtDataVisualization.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtGui.framework/QtGui: Cannot create symlink to ‘Versions/Current/QtGui’: No such file or directory
tar: Frameworks/QtGui.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtMultimedia.framework/QtMultimedia: Cannot create symlink to ‘Versions/Current/QtMultimedia’: No such file or directory
tar: Frameworks/QtMultimedia.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtMultimediaQuick_p.framework/QtMultimediaQuick_p: Cannot create symlink to ‘Versions/Current/QtMultimediaQuick_p’: No such file or directory
tar: Frameworks/QtMultimediaQuick_p.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtMultimediaWidgets.framework/QtMultimediaWidgets: Cannot create symlink to ‘Versions/Current/QtMultimediaWidgets’: No such file or directory
tar: Frameworks/QtMultimediaWidgets.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtNetwork.framework/QtNetwork: Cannot create symlink to ‘Versions/Current/QtNetwork’: No such file or directory
tar: Frameworks/QtNetwork.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtOpenGL.framework/QtOpenGL: Cannot create symlink to ‘Versions/Current/QtOpenGL’: No such file or directory
tar: Frameworks/QtOpenGL.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtPositioning.framework/QtPositioning: Cannot create symlink to ‘Versions/Current/QtPositioning’: No such file or directory
tar: Frameworks/QtPositioning.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtPrintSupport.framework/QtPrintSupport: Cannot create symlink to ‘Versions/Current/QtPrintSupport’: No such file or directory
tar: Frameworks/QtPrintSupport.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtQml.framework/QtQml: Cannot create symlink to ‘Versions/Current/QtQml’: No such file or directory
tar: Frameworks/QtQml.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtQuick.framework/QtQuick: Cannot create symlink to ‘Versions/Current/QtQuick’: No such file or directory
tar: Frameworks/QtQuick.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtQuickControls2.framework/QtQuickControls2: Cannot create symlink to ‘Versions/Current/QtQuickControls2’: No such file or directory
tar: Frameworks/QtQuickControls2.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtQuickParticles.framework/QtQuickParticles: Cannot create symlink to ‘Versions/Current/QtQuickParticles’: No such file or directory
tar: Frameworks/QtQuickParticles.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtQuickTemplates2.framework/QtQuickTemplates2: Cannot create symlink to ‘Versions/Current/QtQuickTemplates2’: No such file or directory
tar: Frameworks/QtQuickTemplates2.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtSensors.framework/QtSensors: Cannot create symlink to ‘Versions/Current/QtSensors’: No such file or directory
tar: Frameworks/QtSensors.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtSql.framework/QtSql: Cannot create symlink to ‘Versions/Current/QtSql’: No such file or directory
tar: Frameworks/QtSql.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtWebChannel.framework/QtWebChannel: Cannot create symlink to ‘Versions/Current/QtWebChannel’: No such file or directory
tar: Frameworks/QtWebChannel.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtWebEngine.framework/QtWebEngine: Cannot create symlink to ‘Versions/Current/QtWebEngine’: No such file or directory
tar: Frameworks/QtWebEngine.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtWebEngineCore.framework/Helpers: Cannot create symlink to ‘Versions/Current/Helpers’: No such file or directory
tar: Frameworks/QtWebEngineCore.framework/Libraries: Cannot create symlink to ‘Versions/Current/Libraries’: No such file or directory
tar: Frameworks/QtWebEngineCore.framework/QtWebEngineCore: Cannot create symlink to ‘Versions/Current/QtWebEngineCore’: No such file or directory
tar: Frameworks/QtWebEngineCore.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtWebSockets.framework/QtWebSockets: Cannot create symlink to ‘Versions/Current/QtWebSockets’: No such file or directory
tar: Frameworks/QtWebSockets.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtWebView.framework/QtWebView: Cannot create symlink to ‘Versions/Current/QtWebView’: No such file or directory
tar: Frameworks/QtWebView.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtWidgets.framework/QtWidgets: Cannot create symlink to ‘Versions/Current/QtWidgets’: No such file or directory
tar: Frameworks/QtWidgets.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Frameworks/QtXmlPatterns.framework/QtXmlPatterns: Cannot create symlink to ‘Versions/Current/QtXmlPatterns’: No such file or directory
tar: Frameworks/QtXmlPatterns.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: No such file or directory
tar: Exiting with failure status due to previous errors

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] install: `tar -zxf library.node && rm -fr library.node`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Matthew\AppData\Roaming\npm-cache\_logs\2017-10-02T03_43_05_587Z-debug.log

Warning messages when starting application on MacOSX

Warning messages when starting application on MacOSX.

$ node app.js

objc[29593]: Class RunLoopModeTracker is implemented in both /Users/fred/Qt/5.7/clang_64/lib/QtCore.framework/Versions/5/QtCore and /Users/fred/projects/brig/native/node-v51-darwin-x64/brig.node. One of the two will be used. Which one is undefined.

Build error with QT 5.10

Here's what I get for npm brig install on my Mac

node-pre-gyp ERR! Tried to download(404): https://github.com/cfsghost/brig/releases/download/0.1.17/node-v59-darwin-x64.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v59 ABI) (falling back to source compile with node-gyp) 
  CXX(target) Release/obj.target/brig/build/src/moc_eventdispatcher.o
In file included from ../build/src/moc_eventdispatcher.cpp:9:
In file included from ../build/src/../../src/eventdispatcher/eventdispatcher.h:6:
In file included from /usr/local/Cellar/qt/5.10.0/lib/QtCore.framework/Versions/Current/Headers/QAbstractEventDispatcher:1:
/usr/local/Cellar/qt/5.10.0/lib/QtCore.framework/Versions/Current/Headers/qabstracteventdispatcher.h:43:10: fatal error: 'QtCore/qobject.h' file not found
#include <QtCore/qobject.h>
         ^~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/brig/build/src/moc_eventdispatcher.o] Error 1

Versions

Mac = 10.13.2.
QT = v5.10 via homebrew (I had to link moc and qmake myself).
NPM = 5.6.0

Mac users do/don't have to install QT via homebrew first?

First I homebrew uninstalled QT and checked the symlinks were gone from /use/local/bin/

Then, for npm install brig:

$ npm install brig
...
> [email protected] install /path/to/brig-example-app/node_modules/qt-darwin
> tar -zxf library.node && rm -fr library.node
> [email protected] install /path/to/brig-example-app/node_modules/brig
> node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! Tried to download(404): https://github.com/cfsghost/brig/releases/download/0.1.17/node-v59-darwin-x64.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v59 ABI) (falling back to source compile with node-gyp) 
tools/mac-config.sh: line 45: qmake: command not found
gyp: Call to 'tools/mac-config.sh --internal' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error 

So whatever it was doing with qt-darwin, didn't put qmake in the path :(

Fail to build on Qt 5.7.1 on linux arm

On raspberry pi 3

make: Entering directory '/home/pi/xxx/node_modules/brig/build'
  CXX(target) Release/obj.target/brig/build/src/moc_eventdispatcher.o
  CXX(target) Release/obj.target/brig/build/src/brig.o
In file include from ../src/brig.h:32:0,
                     from ../src/brig.cpp:2:
../src/DynamicQMetaObjectBuilder.h:6:43: fatal error: internal/qmetaobjectbuilder_p.h: No such file or directory
 #include <internal/qmetaobjectbuilder_p.h>

compilation terminalted.

qt 5.9.2

For being able to compile against Qt 5.9.2 I need to add

'-I/usr/include/qt/QtCore/5.9.2',
'-I/usr/include/qt/QtQuickControls2',

in binding.gyp "cflags" property. I'm using arch linux so basically is not possible for me to downgrade without lot of work. Is this an issue of brig or arch's. Thanks

N-API Support

N-API is available in Node.js v8.0 as experimental feature for native module. It provides a way to make native module be built once and run on all of versions of Node.js. That's great for Brig and it should be supported.

FTBFS: QApplication.cpp fatal error: QQuickStyle: No such file or directory

1st case:
Install/build with system Qt

ENV:
bluet@Titania:~/local/V-PlaySDK$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.2 LTS
Release:	16.04
Codename:	xenial
bluet@Titania:~/local/V-PlaySDK$ qmake -v
QMake version 3.0
Using Qt version 5.5.1 in /usr/lib/x86_64-linux-gnu
bluet@Titania:~/local/V-PlaySDK$ sudo apt install qt5-default qtquick1-5-dev qtquick1-5-dev-tools qtcreator qt5-qmake qtdeclarative5-dev qtquick1-5-dev qml-module-qtquick-controls qtmultimedia5-dev qtbase5-private-dev qml-module-qtquick-controls
bluet@Titania:~/workspace/brig-example-app$ npm install brig

Log:

npm-debug.log.txt

Support prebuilt binary for Windows

Brig can be installed on Mac OS X with prebuilt binary now in order to have a more easier way to prepare environment without Qt and Xcode.

This feature is being required on Windows as well.

Mac os M1

Please add support to mac os with arm64 ,. this wont work on mac with m1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.