qml 0.0.7 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +3 -0
- data/.travis.yml +5 -9
- data/LICENSE.txt +1 -1
- data/README.md +84 -114
- data/changes.md +5 -0
- data/examples/fizzbuzz/fizzbuzz.rb +3 -4
- data/examples/todo_array/todo_array.rb +4 -4
- data/examples/todo_sequel/todo_sequel.rb +7 -7
- data/examples/twitter/twitter.rb +5 -3
- data/ext/qml/application.c +88 -0
- data/ext/qml/application.h +9 -0
- data/ext/qml/component.c +89 -0
- data/ext/qml/component.h +10 -0
- data/ext/qml/conversion.c +60 -0
- data/ext/qml/conversion.h +8 -0
- data/ext/qml/dispatcher.c +31 -0
- data/ext/qml/dispatcher.h +7 -0
- data/ext/qml/engine.c +135 -0
- data/ext/qml/engine.h +10 -0
- data/ext/qml/exporter.c +93 -0
- data/ext/qml/exporter.h +7 -0
- data/ext/qml/extconf.rb +38 -97
- data/ext/qml/interface.c +156 -0
- data/ext/qml/interface.h +11 -0
- data/ext/qml/js_array.c +47 -0
- data/ext/qml/js_array.h +7 -0
- data/ext/qml/js_function.c +109 -0
- data/ext/qml/js_function.h +7 -0
- data/ext/qml/js_object.c +284 -0
- data/ext/qml/js_object.h +19 -0
- data/ext/qml/js_wrapper.c +19 -0
- data/ext/qml/js_wrapper.h +7 -0
- data/ext/qml/lib/libqmlbind/.gitignore +38 -0
- data/ext/qml/lib/libqmlbind/.gitmodules +3 -0
- data/ext/qml/lib/libqmlbind/.travis.yml +14 -0
- data/ext/qml/lib/libqmlbind/LICENSE.txt +22 -0
- data/ext/qml/lib/libqmlbind/libqmlbind.pro +3 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind.h +14 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/application.h +18 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/component.h +21 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/engine.h +34 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/exporter.h +37 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/interface.h +16 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/iterator.h +19 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/metaobject.h +13 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/plugin.h +17 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/qmlbind_global.h +78 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/register.h +17 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/signal_emitter.h +15 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/string.h +15 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/value.h +100 -0
- data/ext/qml/lib/libqmlbind/qmlbind/qmlbind.pro +62 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_application.cpp +103 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_component.cpp +54 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_engine.cpp +65 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_exporter.cpp +52 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_interface.cpp +19 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_iterator.cpp +32 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_metaobject.cpp +19 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_plugin.cpp +27 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_register.cpp +17 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_signal_emitter.cpp +27 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_string.cpp +22 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_value.cpp +215 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/backref.cpp +54 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/backref.h +29 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/engine.cpp +32 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/engine.h +27 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/exporter.cpp +73 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/exporter.h +46 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/interface.cpp +75 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/interface.h +37 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/metaobject.cpp +101 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/metaobject.h +29 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/signalemitter.cpp +33 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/signalemitter.h +25 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/ticktimer.cpp +15 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/ticktimer.h +19 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/typeregisterer.cpp +112 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/typeregisterer.h +28 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/util.h +13 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/wrapper.cpp +23 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/wrapper.h +29 -0
- data/ext/qml/lib/libqmlbind/readme.md +14 -0
- data/ext/qml/lib/libqmlbind/test/api.c +1 -0
- data/ext/qml/lib/libqmlbind/test/application_test.cpp +16 -0
- data/ext/qml/lib/libqmlbind/test/component_test.cpp +57 -0
- data/ext/qml/lib/libqmlbind/test/engine_test.cpp +94 -0
- data/ext/qml/lib/libqmlbind/test/exporter_test.cpp +312 -0
- data/ext/qml/lib/libqmlbind/test/fixtures/emptyhandlers.cpp +36 -0
- data/ext/qml/lib/libqmlbind/test/fixtures/emptyhandlers.h +6 -0
- data/ext/qml/lib/libqmlbind/test/fixtures/test.qml +5 -0
- data/ext/qml/lib/libqmlbind/test/fixtures/testmodule/qmldir +2 -0
- data/ext/qml/lib/libqmlbind/test/fixtures/testmodule/test.qml +5 -0
- data/ext/qml/lib/libqmlbind/test/iterator_test.cpp +37 -0
- data/ext/qml/lib/libqmlbind/test/main.cpp +11 -0
- data/ext/qml/lib/libqmlbind/test/plugin_test.cpp +41 -0
- data/ext/qml/lib/libqmlbind/test/test.pro +26 -0
- data/ext/qml/lib/libqmlbind/test/test_helper.h +20 -0
- data/ext/qml/lib/libqmlbind/test/value_test.cpp +252 -0
- data/ext/qml/lib/libqmlbind/testplugin/testplugin.cpp +11 -0
- data/ext/qml/lib/libqmlbind/testplugin/testplugin.h +21 -0
- data/ext/qml/lib/libqmlbind/testplugin/testplugin.json +3 -0
- data/ext/qml/lib/libqmlbind/testplugin/testplugin.pro +21 -0
- data/ext/qml/meta_object.c +81 -0
- data/ext/qml/meta_object.h +8 -0
- data/ext/qml/plugin_loader.c +71 -0
- data/ext/qml/plugin_loader.h +7 -0
- data/ext/qml/qml.c +95 -0
- data/ext/qml/qml.h +10 -0
- data/ext/qml/rubyqml-plugin/listmodel.cpp +102 -0
- data/ext/qml/rubyqml-plugin/listmodel.h +37 -0
- data/ext/qml/rubyqml-plugin/rubyqml-plugin.pro +19 -0
- data/ext/qml/rubyqml-plugin/rubyqmlplugin.cpp +25 -0
- data/ext/qml/rubyqml-plugin/rubyqmlplugin.h +19 -0
- data/ext/qml/signal_emitter.c +71 -0
- data/ext/qml/signal_emitter.h +9 -0
- data/lib/qml.rb +11 -10
- data/lib/qml/access.rb +64 -86
- data/lib/qml/application.rb +20 -71
- data/lib/qml/component.rb +41 -33
- data/lib/qml/core_ext.rb +1 -0
- data/lib/qml/core_ext/to_qml.rb +70 -0
- data/lib/qml/data.rb +1 -0
- data/lib/qml/data/array_model.rb +99 -101
- data/lib/qml/data/list_model.rb +107 -131
- data/lib/qml/data/list_model_access.rb +44 -0
- data/lib/qml/data/query_model.rb +45 -47
- data/lib/qml/dispatcher.rb +5 -13
- data/lib/qml/engine.rb +9 -58
- data/lib/qml/errors.rb +0 -21
- data/lib/qml/interface.rb +21 -0
- data/lib/qml/js_array.rb +8 -0
- data/lib/qml/js_object.rb +69 -0
- data/lib/qml/js_util.rb +18 -0
- data/lib/qml/plugin_loader.rb +1 -13
- data/lib/qml/plugins.rb +3 -17
- data/lib/qml/proc_access.rb +28 -0
- data/lib/qml/qt.rb +21 -3
- data/lib/qml/reactive.rb +147 -8
- data/lib/qml/signal.rb +67 -0
- data/lib/qml/version.rb +1 -1
- data/qml.gemspec +8 -2
- data/spec/qml/access_spec.rb +33 -120
- data/spec/qml/application_spec.rb +11 -24
- data/spec/qml/component_spec.rb +4 -4
- data/spec/qml/data/array_model_spec.rb +2 -2
- data/spec/qml/data/list_model_spec.rb +2 -2
- data/spec/qml/data/query_model_spec.rb +4 -4
- data/spec/qml/engine_spec.rb +23 -21
- data/spec/qml/interface_spec.rb +20 -0
- data/spec/qml/js_array_spec.rb +29 -0
- data/spec/qml/js_function_spec.rb +32 -0
- data/spec/qml/js_object_spec.rb +113 -0
- data/spec/qml/plugin_loader_spec.rb +9 -11
- data/spec/qml/qt_spec.rb +9 -0
- data/spec/qml/reactive_spec.rb +37 -0
- data/spec/qml/signal_connect_spec.rb +27 -0
- data/spec/qml/signal_spec.rb +73 -0
- data/spec/qml/to_qml_spec.rb +76 -0
- data/spec/shared/qml/access_example.rb +21 -0
- data/spec/shared/qml/data/list_model.rb +12 -13
- data/spec/spec_helper.rb +2 -3
- metadata +141 -166
- data/examples/imageprovider/imageprovider.rb +0 -57
- data/examples/imageprovider/main.qml +0 -51
- data/ext/qml/accessclass.cpp +0 -65
- data/ext/qml/accessclass.h +0 -19
- data/ext/qml/accessobject.cpp +0 -30
- data/ext/qml/accessobject.h +0 -22
- data/ext/qml/common.h +0 -18
- data/ext/qml/conversionerror.h +0 -14
- data/ext/qml/ext_accesswrapperfactory.cpp +0 -75
- data/ext/qml/ext_accesswrapperfactory.h +0 -39
- data/ext/qml/ext_anywrapper.cpp +0 -34
- data/ext/qml/ext_anywrapper.h +0 -23
- data/ext/qml/ext_kernel.cpp +0 -81
- data/ext/qml/ext_kernel.h +0 -9
- data/ext/qml/ext_metaobject.cpp +0 -399
- data/ext/qml/ext_metaobject.h +0 -60
- data/ext/qml/ext_pluginloader.cpp +0 -53
- data/ext/qml/ext_pluginloader.h +0 -30
- data/ext/qml/ext_pointer.cpp +0 -132
- data/ext/qml/ext_pointer.h +0 -41
- data/ext/qml/ext_testutil.cpp +0 -40
- data/ext/qml/ext_testutil.h +0 -9
- data/ext/qml/foreignclass.cpp +0 -72
- data/ext/qml/foreignclass.h +0 -88
- data/ext/qml/foreignmetaobject.cpp +0 -345
- data/ext/qml/foreignmetaobject.h +0 -46
- data/ext/qml/foreignobject.cpp +0 -22
- data/ext/qml/foreignobject.h +0 -21
- data/ext/qml/functioninfo.h +0 -16
- data/ext/qml/init.cpp +0 -67
- data/ext/qml/kernel.cpp +0 -39
- data/ext/qml/kernel.h +0 -32
- data/ext/qml/listmodel.cpp +0 -137
- data/ext/qml/listmodel.h +0 -45
- data/ext/qml/markable.h +0 -12
- data/ext/qml/objectdata.cpp +0 -26
- data/ext/qml/objectdata.h +0 -20
- data/ext/qml/objectgc.cpp +0 -69
- data/ext/qml/objectgc.h +0 -28
- data/ext/qml/plugins/core/applicationextension.cpp +0 -29
- data/ext/qml/plugins/core/applicationextension.h +0 -25
- data/ext/qml/plugins/core/componentextension.cpp +0 -41
- data/ext/qml/plugins/core/componentextension.h +0 -28
- data/ext/qml/plugins/core/contextextension.cpp +0 -39
- data/ext/qml/plugins/core/contextextension.h +0 -29
- data/ext/qml/plugins/core/core.pro +0 -29
- data/ext/qml/plugins/core/coreplugin.cpp +0 -87
- data/ext/qml/plugins/core/coreplugin.h +0 -49
- data/ext/qml/plugins/core/engineextension.cpp +0 -43
- data/ext/qml/plugins/core/engineextension.h +0 -31
- data/ext/qml/plugins/core/imageprovider.cpp +0 -38
- data/ext/qml/plugins/core/imageprovider.h +0 -18
- data/ext/qml/plugins/core/imagerequestpromise.cpp +0 -19
- data/ext/qml/plugins/core/imagerequestpromise.h +0 -21
- data/ext/qml/plugins/core/qmlexception.cpp +0 -11
- data/ext/qml/plugins/core/qmlexception.h +0 -17
- data/ext/qml/plugins/testutil/imageprovidertest.cpp +0 -40
- data/ext/qml/plugins/testutil/imageprovidertest.h +0 -17
- data/ext/qml/plugins/testutil/objectlifechecker.cpp +0 -17
- data/ext/qml/plugins/testutil/objectlifechecker.h +0 -24
- data/ext/qml/plugins/testutil/ownershiptest.cpp +0 -26
- data/ext/qml/plugins/testutil/ownershiptest.h +0 -30
- data/ext/qml/plugins/testutil/testobject.cpp +0 -6
- data/ext/qml/plugins/testutil/testobject.h +0 -108
- data/ext/qml/plugins/testutil/testobjectsubclass.cpp +0 -10
- data/ext/qml/plugins/testutil/testobjectsubclass.h +0 -19
- data/ext/qml/plugins/testutil/testutil.pro +0 -22
- data/ext/qml/plugins/testutil/testutilplugin.cpp +0 -55
- data/ext/qml/plugins/testutil/testutilplugin.h +0 -36
- data/ext/qml/qmltyperegisterer.cpp +0 -74
- data/ext/qml/qmltyperegisterer.h +0 -30
- data/ext/qml/rubyclass.cpp +0 -82
- data/ext/qml/rubyclass.h +0 -230
- data/ext/qml/rubyvalue.cpp +0 -656
- data/ext/qml/rubyvalue.h +0 -224
- data/ext/qml/signalforwarder.cpp +0 -64
- data/ext/qml/signalforwarder.h +0 -29
- data/ext/qml/util.cpp +0 -112
- data/ext/qml/util.h +0 -82
- data/ext/qml/valuereference.cpp +0 -50
- data/ext/qml/valuereference.h +0 -22
- data/ext/qml/weakvaluereference.cpp +0 -51
- data/ext/qml/weakvaluereference.h +0 -21
- data/lib/qml/context.rb +0 -71
- data/lib/qml/data/error.rb +0 -5
- data/lib/qml/dispatchable.rb +0 -34
- data/lib/qml/error_converter.rb +0 -16
- data/lib/qml/geometry.rb +0 -3
- data/lib/qml/geometry/point.rb +0 -5
- data/lib/qml/geometry/rectangle.rb +0 -5
- data/lib/qml/geometry/size.rb +0 -5
- data/lib/qml/image_provider.rb +0 -87
- data/lib/qml/init.rb +0 -29
- data/lib/qml/meta_object.rb +0 -20
- data/lib/qml/models.rb +0 -1
- data/lib/qml/qt_classes.rb +0 -9
- data/lib/qml/qt_object_base.rb +0 -233
- data/lib/qml/reactive/bindable.rb +0 -79
- data/lib/qml/reactive/chained_signal.rb +0 -25
- data/lib/qml/reactive/error.rb +0 -5
- data/lib/qml/reactive/object.rb +0 -293
- data/lib/qml/reactive/property.rb +0 -19
- data/lib/qml/reactive/signal.rb +0 -115
- data/lib/qml/reactive/signal_spy.rb +0 -27
- data/lib/qml/reactive/signals/map_signal.rb +0 -21
- data/lib/qml/reactive/signals/merge_signal.rb +0 -21
- data/lib/qml/reactive/signals/select_signal.rb +0 -21
- data/lib/qml/reactive/simple_property.rb +0 -17
- data/lib/qml/reactive/unbound_property.rb +0 -42
- data/lib/qml/reactive/unbound_signal.rb +0 -51
- data/lib/qml/test_util.rb +0 -1
- data/lib/qml/test_util/object_life_checker.rb +0 -17
- data/lib/qml/wrappable.rb +0 -9
- data/spec/qml/context_spec.rb +0 -43
- data/spec/qml/conversion_spec.rb +0 -60
- data/spec/qml/dispatchable_spec.rb +0 -26
- data/spec/qml/dispatcher_spec.rb +0 -71
- data/spec/qml/geometry/point_spec.rb +0 -4
- data/spec/qml/geometry/rectangle_spec.rb +0 -4
- data/spec/qml/geometry/size_spec.rb +0 -4
- data/spec/qml/image_provider_spec.rb +0 -33
- data/spec/qml/qt_object_base_spec.rb +0 -119
- data/spec/qml/reactive/object_spec.rb +0 -249
- data/spec/qml/reactive/property_spec.rb +0 -70
- data/spec/qml/reactive/signal_spec.rb +0 -191
- data/spec/qml/reactive/signal_spy_spec.rb +0 -26
- data/spec/qml/reactive/unbound_property_spec.rb +0 -40
- data/spec/qml/reactive/unbound_signal_spec.rb +0 -70
- data/spec/qml/test_object_spec.rb +0 -186
- data/spec/qml/wrappable_spec.rb +0 -10
- data/spec/shared/qml/reactive/object.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3e17be31c7cb2d6c9530581484a9146c71718e1
|
4
|
+
data.tar.gz: 0fa4538a3960c37c4afe368986e0d1565ce401c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 643d0c001ba1f018b5784ab472cd789278be85721678c5b4c5dbd1edd9e89beb46b585fa273b12da771594b7d3f6ac147b28ea4e7f72ec4835babe125e08e836
|
7
|
+
data.tar.gz: 3fdc78678a5790c2123869b66905b40bc24613a6d47cfecbdf322be58ac403d3f60007e9d4856a44b15d64698639d4b6d95b6cc61844fa66610f2322e7fdcf16
|
data/.gitmodules
ADDED
data/.travis.yml
CHANGED
@@ -1,17 +1,13 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.2.
|
4
|
-
- 2.1.
|
5
|
-
- 2.0.0
|
6
|
-
- 1.9.3
|
3
|
+
- 2.2.2
|
4
|
+
- 2.1.6
|
7
5
|
before_install:
|
8
|
-
- sudo apt-add-repository -y ppa:beineri/opt-
|
9
|
-
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
6
|
+
- sudo apt-add-repository -y ppa:beineri/opt-qt541
|
10
7
|
- sudo apt-get update
|
11
|
-
- sudo apt-get install -y
|
12
|
-
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.7 90
|
8
|
+
- sudo apt-get install -y qt54base qt54declarative
|
13
9
|
before_script:
|
14
|
-
- source /opt/
|
10
|
+
- source /opt/qt54/bin/qt54-env.sh
|
15
11
|
- cd ext/qml
|
16
12
|
- bundle exec ruby extconf.rb
|
17
13
|
- make
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -15,7 +15,7 @@ It provides bindings between QML and Ruby and enables you to use Qt Quick-based
|
|
15
15
|
|
16
16
|
## What you can do with ruby-qml
|
17
17
|
|
18
|
-
* Develop desktop GUI applications only with Ruby and QML
|
18
|
+
* Develop desktop GUI applications only with Ruby and QML / JavaScript
|
19
19
|
* Easily combine codes written in C++ and Qt with your Ruby code
|
20
20
|
|
21
21
|
## Gallery
|
@@ -28,27 +28,24 @@ It provides bindings between QML and Ruby and enables you to use Qt Quick-based
|
|
28
28
|
|
29
29
|
### Requirements
|
30
30
|
|
31
|
-
* **Ruby 1
|
31
|
+
* **Ruby 2.1 or later**
|
32
32
|
* **OS X or Linux**
|
33
|
-
* pkg-config
|
34
|
-
* libffi
|
35
33
|
* Qt 5.2 or later
|
36
34
|
|
37
35
|
### OS X with Homebrew
|
38
36
|
|
39
37
|
To install ruby-qml on OS X with Homebrew, run the following commands:
|
40
38
|
|
41
|
-
$ brew install
|
42
|
-
$ gem install qml -- --with-
|
39
|
+
$ brew install qt5
|
40
|
+
$ gem install qml -- --with-qmake=$(brew --prefix qt5)/bin/qmake
|
43
41
|
|
44
42
|
Both libffi and Qt5 are keg-only in Homebrew, so you must specify their paths explicitly (or force linking).
|
45
43
|
|
46
44
|
If you use [official Qt installation](http://qt-project.org/downloads), for example:
|
47
45
|
|
48
|
-
$
|
49
|
-
$ gem install qml -- --with-libffi-dir=$(brew --prefix libffi) --with-qt-dir=$HOME/Qt/5.3/clang_64
|
46
|
+
$ gem install qml -- --with-qmake=$HOME/Qt/5.4/clang_64/bin/qmake
|
50
47
|
|
51
|
-
The Qt installation path (`$HOME/Qt/5.
|
48
|
+
The Qt installation path (`$HOME/Qt/5.4/clang_64` in this example) depends on your Qt installation configuration and Qt version.
|
52
49
|
|
53
50
|
### General (OSX and Linux)
|
54
51
|
|
@@ -56,10 +53,8 @@ The Qt installation path (`$HOME/Qt/5.3/clang_64` in this example) depends on yo
|
|
56
53
|
|
57
54
|
#### Options
|
58
55
|
|
59
|
-
* `--with-
|
60
|
-
*
|
61
|
-
* `--with-qt-dir=[dir]`
|
62
|
-
* Qt installation directory (optional).
|
56
|
+
* `--with-qmake=[dir]`
|
57
|
+
* Qt qmake executable path (optional).
|
63
58
|
|
64
59
|
### Use Gemfile
|
65
60
|
|
@@ -74,7 +69,7 @@ And then execute:
|
|
74
69
|
To pass build options, use `bundle config`.
|
75
70
|
For example:
|
76
71
|
|
77
|
-
$ bundle config build.qml --with-
|
72
|
+
$ bundle config build.qml --with-qmake=$(brew --prefix qt5)/bin/qmake
|
78
73
|
|
79
74
|
The configuration will be saved in `~/.bundle/config`.
|
80
75
|
|
@@ -122,8 +117,8 @@ class FizzBuzz
|
|
122
117
|
include QML::Access
|
123
118
|
register_to_qml under: "Example", version: "1.0"
|
124
119
|
|
125
|
-
property
|
126
|
-
property
|
120
|
+
property(:input) { '0' }
|
121
|
+
property(:result) { '' }
|
127
122
|
signal :inputWasFizzBuzz, []
|
128
123
|
|
129
124
|
on_changed :input do
|
@@ -204,32 +199,15 @@ module Example
|
|
204
199
|
end
|
205
200
|
```
|
206
201
|
|
207
|
-
If the Ruby object is singleton, you can use the root context to make it available to QML.
|
208
|
-
In this case, you don't have to use `register_to_qml`.
|
209
|
-
|
210
|
-
```ruby
|
211
|
-
class Foo
|
212
|
-
include QML::Access
|
213
|
-
def foo
|
214
|
-
puts "foo"
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
QML.run do |app|
|
219
|
-
app.context[:foo] = Foo.new
|
220
|
-
app.load_path Pathname(__FILE__) + '../main.qml'
|
221
|
-
end
|
222
|
-
```
|
223
|
-
|
224
202
|
### Pass data to QML ListModels
|
225
203
|
|
226
204
|
To bind list data between QML ListView and Ruby, you can use ListModels.
|
227
205
|
|
228
|
-
* `QML::
|
206
|
+
* `QML::ListModel` - the base class for ruby-qml list models.
|
229
207
|
|
230
|
-
* `QML::
|
208
|
+
* `QML::ArrayModel` - provides a simple list model implementation using Array.
|
231
209
|
|
232
|
-
* `QML::
|
210
|
+
* `QML::QueryModel` - for databases (like ActiveRecord, Sequel or something)
|
233
211
|
|
234
212
|
This example uses `ArrayModel` to provide list data for a QML ListView.
|
235
213
|
When the content of the ArrayModel is changed, the list view is also automatically updated.
|
@@ -244,7 +222,7 @@ class TodoController
|
|
244
222
|
include QML::Access
|
245
223
|
register_to_qml under: "Example", version: "1.0"
|
246
224
|
|
247
|
-
property
|
225
|
+
property(:model) { QML::ArrayModel.new(:title, :description, :due_date) }
|
248
226
|
|
249
227
|
def add(title, description, due_date)
|
250
228
|
# Items of list models must be "Hash-like" (have #[] method to get columns)
|
@@ -253,7 +231,6 @@ class TodoController
|
|
253
231
|
description: description,
|
254
232
|
due_date: due_date
|
255
233
|
}
|
256
|
-
p item
|
257
234
|
model << item
|
258
235
|
end
|
259
236
|
end
|
@@ -275,7 +252,7 @@ TodoController {
|
|
275
252
|
### Combile asynchronous operations
|
276
253
|
|
277
254
|
In QML, all UI-related operations are done synchronously in the event loop.
|
278
|
-
To set result of asynchronous operations to the UI, use `QML.
|
255
|
+
To set result of asynchronous operations to the UI, use `QML.next_tick`.
|
279
256
|
|
280
257
|
#### Examples
|
281
258
|
|
@@ -284,11 +261,10 @@ To set result of asynchronous operations to the UI, use `QML.later` or `QML::Dis
|
|
284
261
|
```ruby
|
285
262
|
# Ruby
|
286
263
|
class HeavyTaskController
|
287
|
-
# QML::Access includes QML::Dispathable
|
288
264
|
include QML::Access
|
289
265
|
register_to_qml under: "Example", version: "1.0"
|
290
266
|
|
291
|
-
property
|
267
|
+
property(:result) { '' }
|
292
268
|
|
293
269
|
def set_result(result)
|
294
270
|
self.result = result
|
@@ -296,9 +272,7 @@ class HeavyTaskController
|
|
296
272
|
|
297
273
|
def start_heavy_task
|
298
274
|
Thread.new do
|
299
|
-
|
300
|
-
# or
|
301
|
-
QML.later do
|
275
|
+
QML.next_tick do
|
302
276
|
set_result do_heavy_task()
|
303
277
|
end
|
304
278
|
end
|
@@ -320,64 +294,77 @@ HeavyTaskController {
|
|
320
294
|
}
|
321
295
|
```
|
322
296
|
|
323
|
-
###
|
297
|
+
### Value conversions between Ruby and QML JavaScript
|
298
|
+
|
299
|
+
|
300
|
+
#### Ruby to QML
|
301
|
+
|
302
|
+
|Ruby |QML/JavaScript |
|
303
|
+
|----------------|--------------------------------|
|
304
|
+
|nil |null |
|
305
|
+
|true/false |boolean |
|
306
|
+
|Numeric |number |
|
307
|
+
|String/Symbol |string |
|
308
|
+
|Array |Array |
|
309
|
+
|Hash |plain Object |
|
310
|
+
|Proc |Function |
|
311
|
+
|Time |Date |
|
312
|
+
|QML::Access |Object(QObject derived) |
|
313
|
+
|QML::ListModel |Object(QAbstractListModel) |
|
324
314
|
|
325
|
-
|
315
|
+
You can customize this by implementing `#to_qml` method.
|
326
316
|
|
327
|
-
|
317
|
+
#### QML to Ruby
|
328
318
|
|
329
|
-
|
330
|
-
|
331
|
-
|
319
|
+
|QML/JavaScript |Ruby |
|
320
|
+
|--------------------------------|----------------|
|
321
|
+
|null/undefined |nil |
|
322
|
+
|boolean |true/false |
|
323
|
+
|number |Float |
|
324
|
+
|string |String |
|
325
|
+
|Array |QML::JSArray |
|
326
|
+
|Function |QML::JSFunction |
|
327
|
+
|Object |QML::JSObject |
|
328
|
+
|Object wrapping QML::Access |QML::JSWrapper |
|
332
329
|
|
333
|
-
You
|
330
|
+
You can convert Objects further through QML::JSObject methods.
|
334
331
|
|
335
|
-
* Normal C++ member functions
|
336
332
|
|
337
|
-
|
333
|
+
### QML::JSObject usage
|
334
|
+
|
335
|
+
`QML::JSObject` is the wrapper class for JavaScript objects.
|
338
336
|
|
339
337
|
```ruby
|
340
|
-
|
341
|
-
|
338
|
+
obj = QML.engine.evaluate <<-JS
|
339
|
+
({
|
340
|
+
value: 1,
|
341
|
+
add: function(d) {
|
342
|
+
this.value += d;
|
343
|
+
}
|
344
|
+
})
|
345
|
+
JS
|
342
346
|
|
343
|
-
#
|
344
|
-
|
345
|
-
app.application_name = "Test" # aliased version
|
347
|
+
# Getter
|
348
|
+
obj.value #=> 1
|
346
349
|
|
347
|
-
#
|
348
|
-
|
349
|
-
|
350
|
-
end
|
350
|
+
# Setter
|
351
|
+
obj.value = 2
|
352
|
+
obj.vaue #=> 2
|
351
353
|
|
352
|
-
#
|
353
|
-
|
354
|
-
|
354
|
+
# Call method if the property is a function
|
355
|
+
obj.add(10)
|
356
|
+
obj.value #=> 11
|
355
357
|
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
* Integer
|
361
|
-
* Double
|
362
|
-
* String
|
363
|
-
* Time
|
364
|
-
* Date
|
365
|
-
* DateTime
|
366
|
-
* Array
|
367
|
-
* Hash
|
368
|
-
* QML::Geometry::Point (QPoint, QPointF)
|
369
|
-
* QML::Geometry::Size (QSize, QSizeF)
|
370
|
-
* QML::Geometry::Rectangle (QRect, QRectF)
|
371
|
-
* QML::QtObjectBase (Qt objects)
|
372
|
-
* QML::Access
|
373
|
-
* QML::Data::ListModel
|
358
|
+
# Subscription
|
359
|
+
obj[:value] #=> 11
|
360
|
+
obj[:add] #=> #<QML::JSFunction:...>
|
361
|
+
```
|
374
362
|
|
375
363
|
### Load and use Qt C++ plugins
|
376
364
|
|
377
365
|
`PluginLoader` loads Qt C++ plugins.
|
378
366
|
It enables you to use your Qt C++ codes from Ruby easily.
|
379
367
|
|
380
|
-
|
381
368
|
```c++
|
382
369
|
// C++ - plugin example
|
383
370
|
class MyPlugin : public QObject
|
@@ -398,42 +385,18 @@ public slots:
|
|
398
385
|
|
399
386
|
```ruby
|
400
387
|
# Ruby
|
388
|
+
|
389
|
+
# The instance will be a `QML::JSObject` which represents the plugin Qt object
|
401
390
|
plugin = QML::PluginLoader.new(directory, "myplugin").instance
|
402
391
|
|
403
|
-
|
392
|
+
# Connect to signal (see http://doc.qt.io/qt-5/qtqml-syntax-signals.html#connecting-signals-to-methods-and-signals)
|
393
|
+
plugin[:added].connect do |value|
|
404
394
|
puts "added value: #{value}"
|
405
395
|
end
|
406
396
|
|
407
397
|
plugin.add(1, 2) #=> 3
|
408
398
|
```
|
409
399
|
|
410
|
-
### Garbage collection
|
411
|
-
|
412
|
-
To support garbage collection of Qt objects used in ruby-qml,
|
413
|
-
`#managed?` attribute of each Qt object wrappr determines its memory management status.
|
414
|
-
|
415
|
-
#### Managed objects
|
416
|
-
|
417
|
-
*Manged objects* are managed by Ruby and QML and garbage collected when no longer reachable.
|
418
|
-
All objects created inside QML and objects returned from C++ methods will be *managed* by default.
|
419
|
-
|
420
|
-
#### Unmanaged objects
|
421
|
-
|
422
|
-
*Unmanaged* objects are not managed and never garbage collected.
|
423
|
-
Objects that have parents or that obtained from properties of other Qt objects will be *unmanaged* by default.
|
424
|
-
|
425
|
-
#### Specify management status explicitly
|
426
|
-
|
427
|
-
The `#managed?` method returns whether the object is managed or not.
|
428
|
-
The `#prefer_managed` methods sets management status safely
|
429
|
-
(e.g., objects that are created by QML will remain managed and objects that have parents will remain unmanaged).
|
430
|
-
|
431
|
-
```ruby
|
432
|
-
plugin = PluginLoader.new(path).instance
|
433
|
-
obj = plugin.create_object
|
434
|
-
obj.prefer_managed false
|
435
|
-
```
|
436
|
-
|
437
400
|
### Use with EventMachine
|
438
401
|
|
439
402
|
You can use [EventMachine](https://github.com/eventmachine/eventmachine) with ruby-qml.
|
@@ -464,7 +427,7 @@ require 'em-http-request'
|
|
464
427
|
|
465
428
|
class Controller
|
466
429
|
include QML::Access
|
467
|
-
property
|
430
|
+
property(:result) { '' }
|
468
431
|
|
469
432
|
def get
|
470
433
|
EM.synchrony do
|
@@ -489,6 +452,13 @@ end
|
|
489
452
|
|
490
453
|
## Contributing
|
491
454
|
|
455
|
+
### Init submodules
|
456
|
+
|
457
|
+
```
|
458
|
+
$ git submodule init
|
459
|
+
$ git submodule update
|
460
|
+
```
|
461
|
+
|
492
462
|
### Install dependencies
|
493
463
|
|
494
464
|
```
|
@@ -502,7 +472,7 @@ To build it, run the following commands:
|
|
502
472
|
|
503
473
|
```
|
504
474
|
$ cd ext/qml
|
505
|
-
$ bundle exec ruby extconf.rb --with-
|
475
|
+
$ bundle exec ruby extconf.rb --with-qmake=/path/to/qmake
|
506
476
|
$ make -j4
|
507
477
|
```
|
508
478
|
|
data/changes.md
CHANGED
@@ -8,9 +8,10 @@ module Examples
|
|
8
8
|
|
9
9
|
class FizzBuzz
|
10
10
|
include QML::Access
|
11
|
+
register_to_qml
|
11
12
|
|
12
|
-
property
|
13
|
-
property
|
13
|
+
property(:input) { '0' }
|
14
|
+
property(:result) { '' }
|
14
15
|
signal :inputWasFizzBuzz, []
|
15
16
|
|
16
17
|
on_changed :input do
|
@@ -32,8 +33,6 @@ module Examples
|
|
32
33
|
puts "quitting..."
|
33
34
|
QML.application.quit
|
34
35
|
end
|
35
|
-
|
36
|
-
register_to_qml
|
37
36
|
end
|
38
37
|
end
|
39
38
|
end
|
@@ -10,10 +10,10 @@ module Examples
|
|
10
10
|
include QML::Access
|
11
11
|
register_to_qml
|
12
12
|
|
13
|
-
property
|
14
|
-
property
|
15
|
-
property
|
16
|
-
property
|
13
|
+
property(:title) { '' }
|
14
|
+
property(:description) { '' }
|
15
|
+
property(:due_date) { '' }
|
16
|
+
property(:model) { QML::ArrayModel.new(:title, :description, :due_date) }
|
17
17
|
|
18
18
|
def add
|
19
19
|
item = {
|
@@ -12,10 +12,10 @@ module Examples
|
|
12
12
|
primary_key :id
|
13
13
|
String :title
|
14
14
|
String :description
|
15
|
-
|
15
|
+
Time :due_date
|
16
16
|
end
|
17
17
|
|
18
|
-
class SequelModel < QML::
|
18
|
+
class SequelModel < QML::QueryModel
|
19
19
|
attr_accessor :dataset
|
20
20
|
|
21
21
|
def initialize(dataset)
|
@@ -42,14 +42,14 @@ module Examples
|
|
42
42
|
self.model = SequelModel.new(@todo_dataset)
|
43
43
|
end
|
44
44
|
|
45
|
-
property
|
46
|
-
property
|
47
|
-
property
|
48
|
-
property
|
45
|
+
property(:title) { '' }
|
46
|
+
property(:description) { '' }
|
47
|
+
property(:due_date) { '' }
|
48
|
+
property(:order_by) { '' }
|
49
49
|
property :model
|
50
50
|
|
51
51
|
def add
|
52
|
-
@todo_dataset.insert(title: title, description: description, due_date: due_date)
|
52
|
+
@todo_dataset.insert(title: title, description: description, due_date: due_date.to_time)
|
53
53
|
model.update
|
54
54
|
end
|
55
55
|
|