Git Product home page Git Product logo

qmlcore's Introduction

PureQML::QMLCore: QML to Javascript translator

QmlCore is a simple set of tools we (a small team of QML advocates) use since years to simplify the development of HTML5 UIs for both mobile and desktop devices. It was designed with the original QML in mind, while it's not 100% compatible and improved in some aspects. The main concepts are the same though, so if you're familiar with original QML, you could start right away.

Usage

QmlCore provides a toolchain written in Python using python-future, allowing it to be run on top of both python versions. Normally you don't need to use them directly. build provides a convenient wrapper around them all.

Prerequisites

Any modern Python (2 or 3) will go well. Jinja2 is a different option for templating in case you want more than QML loader in your HTML file, while it's not required for small apps.

To install the requirements run:

$ pip install -r requirements.txt

Simple how-to

  • Create project directory, cd <project-dir>
  • Clone QmlCore to it: git clone [email protected]:pureqml/qmlcore.git
  • Run ./qmlcore/build --boilerplate
  • Look into ./src/app.qml
  • Run ./qmlcore/build Please find the resulting files in build.web/*

How it works

The QML compiler scans source directories for QML files and parses each one. Filename starting with uppercase letter considered component, lowercase instantiated. Project-wide options are stored in the .manifest file. The result of the compilation is a single Javascript file with minimum dependencies (modernizr only), ready to use in mobile and desktop environment and accompanied by sample .html launcher.

Manifest options

Manifest is a collection of project-wide hacks we used to botch various projects. Some of them may or may not be useful.

  • templater - template engine to use, only 'simple' and 'jinja2' are supported at the moment
  • web-prefix - see -p option below, specify css rules prefix
  • minify - false/true or compiler name as string, only 'gcc' and 'uglify-js' are supported. google closure compiler requires java to run.
  • platforms use additional platform/*/ files, default and only platform is 'web' for now
  • path - additional directories to search sources for

build tool command line options

  • -m, --minify minify with default option ('uglify-js')
  • -k, --keep keep original source after minification, useful for debugging minification warnings
  • -d, --devel development mode, keep running and wait for changes, requires inotify module
  • -p, --web-prefix web prefix, removed default CSS rules, adds 'qml-' prefix for them, allowing you to interchange HTML/QML.
  • -u, --update-translation update translation files, specified in manifest.languages
  • -j, --jobs run N jobs in parallel
  • --boilerplate initialises bare minimum for quicker kick-off in current directory.

Supported Platforms

We support many different platforms and video integration variants.

Most notable platforms are:

  • HTML5 Web Browser (Obviously) with different addons:
    • Shaka
    • Dash.js
    • Video.js Web Extension
  • ElectronJS
  • Android (Native engine and Cordova)
  • IOS (Cordova)
  • SmartTV Platorms:
    • Any Android TV via native Android support.
    • LG (Netcast and WebOS)
    • Samsung SmartTv (Orsay and Tizen)
    • OperaTV
  • Many STB platforms (privately)
  • Native C++ engine with minimal requirements (EGL or LinuxFB) (privately)

For the full list of supported platform see here and here. Or alternatively just ask us.

Native Android support

Main repo for Pureqml native Android implementation is https://github.com/pureqml/qmlcore-android.

In order to build native android app you need to:

  • Install Android SDK and set ANDROID_HOME environment variable
  • Run ./qmlcore/platform/pure.femto/build-android-native.sh script.

Localisation

QmlCore uses Qt-approach to localisation. You write the code in your default language, then generate/update (build -u) .ts translation files, translate them with qt linguist and compile your project. QmlCore recognizes tr, qsTr, qsTranslate function, as well as QT_TR_NOOP/QT_TRANSLATE_NOOP macros.

Controls library

QmlCore contains a bare minimum of platform controls: Images, texts, rectangles and model-view-delegate classes. Various controls that might be useful are in a separate repository. Just clone it via git clone [email protected]:pureqml/controls.git in your project and that's it!

QML differences

Grammar

We require a semicolon after each statement. This may be changed in future.

Focus

The biggest discrepancy with original QML is how focus is implemented. We're aiming to have "always-consistent" focus everywhere. You have to mark every focus-able component with focus: true; property, and the rest should work without tweaking. We provide several convenient properties to handle focus with ease:

  • activeFocus — this item has current focus and got any user input first
  • focused — this item has current focus in its parent, but not necessarily focused globally

Random customization notes

Adding modernizr features

Please use the following command to get the custom modernizr build page: head -n2 dist/modernizr-custom.js | tail -n1 or just the second line of modernizr-custom.js file

Thanks

Modernizr project

Modernizr tells you what HTML, CSS and JavaScript features the user’s browser has to offer. https://modernizr.com/

SDL Game Controller Database

A community sourced database of game controller mappings https://github.com/gabomdq/SDL_GameControllerDB

Apache Cordova project

Apache Cordova is an open-source mobile development framework. It allows you to use standard web technologies - HTML5, CSS3, and JavaScript for cross-platform development. https://cordova.apache.org

qmlcore's People

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  avatar  avatar  avatar  avatar

qmlcore's Issues

Add 'templates'

Add 'templates' property into manifest for customizing files to be templated

rowsChanged signal handler doesn't work

If you try to handle 'rowsChanged' signal in ListModel corresponded handler will be not called.
Example for reproducing:
ListModel {
onRowsChanged: { log("onRowsChanged") }
}

Suggestion:
I suppose it's all because of conflict with property changed signal, I mean that 'onRowsChanged' handler is treated as handler for property 'rows' changed signal instead of 'rowsChanged' signal

Docs: keep inherited stuff within the component

Add to documentation to particular component information about it's inheritance tree (e.g. WebItem->Rectangle->Item), so inherited properties and methods can be easily accessible.
Having kind of inheritance structure would be nice:
"interits": {
"name": "Rectangle",
"ref": "core/Ractangle",
"inherits": {
"name": "Item",
"ref": "core/Item",
"inherits": {
"name": "Object",
"ref": null,
"inherits": null
}
}
}

print filename with syntax error on compile time

parsing /home/lifeart/repositories/qml2js/app.qml ... qml2js.app
ERROR: not well-formed (invalid token): line 1, column 0
ERROR: command ./qmlcore/qml-compiler -o build.web ./qmlcore/core ./qmlcore/platform/web ./qmlcore/platform/html5 . -a app failed with code 1

uglify moar

add the most aggressive options:
"-m", "--mangle-props=2", protect with "-r navigator", test with "-b"

Simultaneous declaration of several properties

Consider the idea of having a number of typical properties in a single declaration.
Something like this:
property int x, y, z, width, height;
or more complicated:
property string text1: parent.text, text2: y, text3: "Blah-blah-blah " + parent.width;

Braces in comments and strings

Parser treat braces inside comment or string constant as scope brace.

Simple example for reproducing:
Item {
anchors.fill: context;

onCompleted: {
	var str = "olololo {"
}

}

Error message:
ERROR: Expected "}" (at char 77), (line:8, col:1)

Text shadow

Use 'Shadow' property instead of simple bool property.

Multi-line text

We must concatinate every line right now to write multi-line strings property values. It will be cool to write it like this:
text: "
foo
bar
";

doubled object discard

There are many warnings like this when model data drops
invalid removeListener(boxChanged, function () { [native code] }) invocation Error
at t.core.Text.t.core.EventEmitter.removeListener

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.