qml 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +46 -0
- data/.rspec +2 -0
- data/.travis.yml +15 -0
- data/.yardopts +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +351 -0
- data/Rakefile +6 -0
- data/examples/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/examples/fizzbuzz/fizzbuzz.rb +43 -0
- data/examples/fizzbuzz/main.qml +38 -0
- data/examples/imageprovider/imageprovider.rb +57 -0
- data/examples/imageprovider/main.qml +51 -0
- data/examples/todo/main.qml +70 -0
- data/examples/todo/todo.rb +36 -0
- data/examples/twitter/main.qml +36 -0
- data/examples/twitter/twitter.rb +55 -0
- data/ext/qml/accessclass.cpp +71 -0
- data/ext/qml/accessclass.h +19 -0
- data/ext/qml/accessobject.cpp +30 -0
- data/ext/qml/accessobject.h +22 -0
- data/ext/qml/application.cpp +54 -0
- data/ext/qml/application.h +17 -0
- data/ext/qml/common.h +18 -0
- data/ext/qml/ext_accesssupport.cpp +77 -0
- data/ext/qml/ext_accesssupport.h +42 -0
- data/ext/qml/ext_gcmarker.cpp +39 -0
- data/ext/qml/ext_gcmarker.h +27 -0
- data/ext/qml/ext_kernel.cpp +62 -0
- data/ext/qml/ext_kernel.h +11 -0
- data/ext/qml/ext_metaobject.cpp +410 -0
- data/ext/qml/ext_metaobject.h +62 -0
- data/ext/qml/ext_pluginloader.cpp +55 -0
- data/ext/qml/ext_pluginloader.h +32 -0
- data/ext/qml/ext_pointer.cpp +134 -0
- data/ext/qml/ext_pointer.h +43 -0
- data/ext/qml/ext_testutil.cpp +42 -0
- data/ext/qml/ext_testutil.h +11 -0
- data/ext/qml/extconf.rb +84 -0
- data/ext/qml/foreignclass.cpp +72 -0
- data/ext/qml/foreignclass.h +88 -0
- data/ext/qml/foreignmetaobject.cpp +345 -0
- data/ext/qml/foreignmetaobject.h +46 -0
- data/ext/qml/foreignobject.cpp +22 -0
- data/ext/qml/foreignobject.h +21 -0
- data/ext/qml/functioninfo.h +16 -0
- data/ext/qml/init.cpp +69 -0
- data/ext/qml/listmodel.cpp +112 -0
- data/ext/qml/listmodel.h +43 -0
- data/ext/qml/markable.h +12 -0
- data/ext/qml/objectdata.cpp +26 -0
- data/ext/qml/objectdata.h +20 -0
- data/ext/qml/objectgc.cpp +69 -0
- data/ext/qml/objectgc.h +28 -0
- data/ext/qml/plugins/core/applicationextension.cpp +34 -0
- data/ext/qml/plugins/core/applicationextension.h +28 -0
- data/ext/qml/plugins/core/componentextension.cpp +41 -0
- data/ext/qml/plugins/core/componentextension.h +28 -0
- data/ext/qml/plugins/core/contextextension.cpp +39 -0
- data/ext/qml/plugins/core/contextextension.h +29 -0
- data/ext/qml/plugins/core/core.pro +29 -0
- data/ext/qml/plugins/core/coreplugin.cpp +87 -0
- data/ext/qml/plugins/core/coreplugin.h +49 -0
- data/ext/qml/plugins/core/engineextension.cpp +27 -0
- data/ext/qml/plugins/core/engineextension.h +28 -0
- data/ext/qml/plugins/core/imageprovider.cpp +38 -0
- data/ext/qml/plugins/core/imageprovider.h +18 -0
- data/ext/qml/plugins/core/imagerequestpromise.cpp +19 -0
- data/ext/qml/plugins/core/imagerequestpromise.h +21 -0
- data/ext/qml/plugins/core/qmlexception.cpp +11 -0
- data/ext/qml/plugins/core/qmlexception.h +17 -0
- data/ext/qml/plugins/testutil/objectlifechecker.cpp +17 -0
- data/ext/qml/plugins/testutil/objectlifechecker.h +24 -0
- data/ext/qml/plugins/testutil/ownershiptest.cpp +26 -0
- data/ext/qml/plugins/testutil/ownershiptest.h +30 -0
- data/ext/qml/plugins/testutil/testobject.cpp +6 -0
- data/ext/qml/plugins/testutil/testobject.h +108 -0
- data/ext/qml/plugins/testutil/testobjectsubclass.cpp +10 -0
- data/ext/qml/plugins/testutil/testobjectsubclass.h +19 -0
- data/ext/qml/plugins/testutil/testutil.pro +20 -0
- data/ext/qml/plugins/testutil/testutilplugin.cpp +47 -0
- data/ext/qml/plugins/testutil/testutilplugin.h +32 -0
- data/ext/qml/qmltyperegisterer.cpp +74 -0
- data/ext/qml/qmltyperegisterer.h +30 -0
- data/ext/qml/rubyclass.cpp +94 -0
- data/ext/qml/rubyclass.h +234 -0
- data/ext/qml/rubyvalue.cpp +690 -0
- data/ext/qml/rubyvalue.h +256 -0
- data/ext/qml/signalforwarder.cpp +66 -0
- data/ext/qml/signalforwarder.h +29 -0
- data/ext/qml/util.cpp +120 -0
- data/ext/qml/util.h +101 -0
- data/ext/qml/valuereference.cpp +50 -0
- data/ext/qml/valuereference.h +22 -0
- data/ext/qml/weakvaluereference.cpp +27 -0
- data/ext/qml/weakvaluereference.h +19 -0
- data/lib/qml.rb +41 -0
- data/lib/qml/access.rb +137 -0
- data/lib/qml/application.rb +139 -0
- data/lib/qml/class_builder.rb +126 -0
- data/lib/qml/component.rb +53 -0
- data/lib/qml/context.rb +71 -0
- data/lib/qml/data.rb +2 -0
- data/lib/qml/data/array_model.rb +103 -0
- data/lib/qml/data/error.rb +5 -0
- data/lib/qml/data/list_model.rb +146 -0
- data/lib/qml/dispatchable.rb +34 -0
- data/lib/qml/dispatcher.rb +61 -0
- data/lib/qml/engine.rb +54 -0
- data/lib/qml/error_converter.rb +15 -0
- data/lib/qml/errors.rb +26 -0
- data/lib/qml/geometry.rb +3 -0
- data/lib/qml/geometry/point.rb +5 -0
- data/lib/qml/geometry/rectangle.rb +5 -0
- data/lib/qml/geometry/size.rb +5 -0
- data/lib/qml/image_provider.rb +87 -0
- data/lib/qml/meta_object.rb +20 -0
- data/lib/qml/models.rb +1 -0
- data/lib/qml/name_helper.rb +12 -0
- data/lib/qml/platform.rb +15 -0
- data/lib/qml/plugin_loader.rb +46 -0
- data/lib/qml/plugins.rb +26 -0
- data/lib/qml/qml.rb +1 -0
- data/lib/qml/qt.rb +6 -0
- data/lib/qml/qt_classes.rb +9 -0
- data/lib/qml/qt_object_base.rb +108 -0
- data/lib/qml/reactive.rb +8 -0
- data/lib/qml/reactive/bindable.rb +79 -0
- data/lib/qml/reactive/chained_signal.rb +25 -0
- data/lib/qml/reactive/error.rb +5 -0
- data/lib/qml/reactive/object.rb +278 -0
- data/lib/qml/reactive/property.rb +19 -0
- data/lib/qml/reactive/signal.rb +116 -0
- data/lib/qml/reactive/signal_spy.rb +27 -0
- data/lib/qml/reactive/signals/map_signal.rb +21 -0
- data/lib/qml/reactive/signals/merge_signal.rb +21 -0
- data/lib/qml/reactive/signals/select_signal.rb +21 -0
- data/lib/qml/reactive/simple_property.rb +17 -0
- data/lib/qml/reactive/unbound_property.rb +42 -0
- data/lib/qml/reactive/unbound_signal.rb +51 -0
- data/lib/qml/root_path.rb +3 -0
- data/lib/qml/test_util.rb +1 -0
- data/lib/qml/test_util/object_life_checker.rb +17 -0
- data/lib/qml/version.rb +3 -0
- data/lib/qml/wrappable.rb +9 -0
- data/qml.gemspec +28 -0
- data/spec/assets/testobj.qml +5 -0
- data/spec/qml/.access_spec.rb.swp +0 -0
- data/spec/qml/access_spec.rb +162 -0
- data/spec/qml/application_spec.rb +43 -0
- data/spec/qml/component_spec.rb +44 -0
- data/spec/qml/context_spec.rb +43 -0
- data/spec/qml/conversion_spec.rb +59 -0
- data/spec/qml/data/array_model_spec.rb +215 -0
- data/spec/qml/dispatchable_spec.rb +26 -0
- data/spec/qml/dispatcher_spec.rb +48 -0
- data/spec/qml/geometry/point_spec.rb +4 -0
- data/spec/qml/geometry/rectangle_spec.rb +4 -0
- data/spec/qml/geometry/size_spec.rb +4 -0
- data/spec/qml/plugin_loader_spec.rb +33 -0
- data/spec/qml/qt_object_base_spec.rb +119 -0
- data/spec/qml/reactive/object_spec.rb +273 -0
- data/spec/qml/reactive/property_spec.rb +70 -0
- data/spec/qml/reactive/signal_spec.rb +191 -0
- data/spec/qml/reactive/signal_spy_spec.rb +26 -0
- data/spec/qml/test_object_spec.rb +186 -0
- data/spec/qml_spec.rb +7 -0
- data/spec/spec_helper.rb +5 -0
- metadata +321 -0
data/ext/qml/objectgc.h
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include <QSet>
|
|
3
|
+
#include <QObject>
|
|
4
|
+
|
|
5
|
+
namespace RubyQml {
|
|
6
|
+
|
|
7
|
+
class ObjectGC : public QObject {
|
|
8
|
+
public:
|
|
9
|
+
|
|
10
|
+
void addObject(QObject *obj);
|
|
11
|
+
void markOwnedObject(QObject *obj);
|
|
12
|
+
void markNonOwnedObjects();
|
|
13
|
+
|
|
14
|
+
void setDebugMessageEnabled(bool enabled) { mDebugMessageEnabled = enabled; }
|
|
15
|
+
bool debugMessageEnabled() { return mDebugMessageEnabled; }
|
|
16
|
+
QDebug debug();
|
|
17
|
+
|
|
18
|
+
static ObjectGC *instance();
|
|
19
|
+
|
|
20
|
+
private:
|
|
21
|
+
ObjectGC() {}
|
|
22
|
+
void mark(QObject *obj, bool markOwned);
|
|
23
|
+
|
|
24
|
+
bool mDebugMessageEnabled = false;
|
|
25
|
+
QSet<QObject *> mObjects;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
} // namespace RubyQml
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#include "applicationextension.h"
|
|
2
|
+
#include <QApplication>
|
|
3
|
+
#include <QTimer>
|
|
4
|
+
#include <QDebug>
|
|
5
|
+
|
|
6
|
+
namespace RubyQml {
|
|
7
|
+
|
|
8
|
+
ApplicationExtension::ApplicationExtension(QApplication *app) :
|
|
9
|
+
mApp(app)
|
|
10
|
+
{
|
|
11
|
+
auto timer = new QTimer(this);
|
|
12
|
+
timer->setInterval(0);
|
|
13
|
+
timer->setSingleShot(false);
|
|
14
|
+
timer->start();
|
|
15
|
+
connect(timer, &QTimer::timeout, this, &ApplicationExtension::eventsProcessed);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
void ApplicationExtension::exec()
|
|
19
|
+
{
|
|
20
|
+
mApp->exec();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
void ApplicationExtension::processEvents()
|
|
24
|
+
{
|
|
25
|
+
QCoreApplication::processEvents();
|
|
26
|
+
forceDeferredDeletes();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
void ApplicationExtension::forceDeferredDeletes()
|
|
30
|
+
{
|
|
31
|
+
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
} // namespace RubyQml
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <QObject>
|
|
4
|
+
#include <QGuiApplication>
|
|
5
|
+
|
|
6
|
+
class QGuiApplication;
|
|
7
|
+
|
|
8
|
+
namespace RubyQml {
|
|
9
|
+
|
|
10
|
+
class ApplicationExtension : public QObject
|
|
11
|
+
{
|
|
12
|
+
Q_OBJECT
|
|
13
|
+
public:
|
|
14
|
+
explicit ApplicationExtension(QApplication *app);
|
|
15
|
+
|
|
16
|
+
signals:
|
|
17
|
+
void eventsProcessed();
|
|
18
|
+
|
|
19
|
+
public slots:
|
|
20
|
+
void exec();
|
|
21
|
+
void processEvents();
|
|
22
|
+
void forceDeferredDeletes();
|
|
23
|
+
|
|
24
|
+
private:
|
|
25
|
+
QApplication *mApp;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
} // namespace RubyQml
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#include "componentextension.h"
|
|
2
|
+
#include "qmlexception.h"
|
|
3
|
+
#include <QQmlComponent>
|
|
4
|
+
#include <QQmlEngine>
|
|
5
|
+
#include <QDebug>
|
|
6
|
+
|
|
7
|
+
namespace RubyQml {
|
|
8
|
+
|
|
9
|
+
ComponentExtension::ComponentExtension(QQmlComponent *component) :
|
|
10
|
+
mComponent(component)
|
|
11
|
+
{
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
void ComponentExtension::loadString(const QString &data, const QString &path)
|
|
15
|
+
{
|
|
16
|
+
mComponent->setData(data.toUtf8(), QUrl::fromLocalFile(path));
|
|
17
|
+
throwIfError();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
void ComponentExtension::loadFile(const QString &filePath)
|
|
21
|
+
{
|
|
22
|
+
mComponent->loadUrl(QUrl::fromLocalFile(filePath));
|
|
23
|
+
throwIfError();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
QObject *ComponentExtension::create(QQmlContext *context)
|
|
27
|
+
{
|
|
28
|
+
auto created = mComponent->create(context);
|
|
29
|
+
throwIfError();
|
|
30
|
+
QQmlEngine::setObjectOwnership(created, QQmlEngine::JavaScriptOwnership);
|
|
31
|
+
return created;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
void ComponentExtension::throwIfError()
|
|
35
|
+
{
|
|
36
|
+
if (mComponent->status() == QQmlComponent::Error) {
|
|
37
|
+
throw QmlException(mComponent->errorString());
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
} // namespace RubyQml
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <QObject>
|
|
4
|
+
#include <QQmlComponent>
|
|
5
|
+
|
|
6
|
+
class QQmlComponent;
|
|
7
|
+
|
|
8
|
+
namespace RubyQml {
|
|
9
|
+
|
|
10
|
+
class ComponentExtension : public QObject
|
|
11
|
+
{
|
|
12
|
+
Q_OBJECT
|
|
13
|
+
public:
|
|
14
|
+
explicit ComponentExtension(QQmlComponent *component);
|
|
15
|
+
|
|
16
|
+
public slots:
|
|
17
|
+
|
|
18
|
+
void loadString(const QString &data, const QString &path);
|
|
19
|
+
void loadFile(const QString &filePath);
|
|
20
|
+
QObject *create(QQmlContext *context);
|
|
21
|
+
|
|
22
|
+
private:
|
|
23
|
+
void throwIfError();
|
|
24
|
+
|
|
25
|
+
QQmlComponent *mComponent;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
} // namespace RubyQml
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#include "contextextension.h"
|
|
2
|
+
#include "qmlexception.h"
|
|
3
|
+
#include <QQmlContext>
|
|
4
|
+
#include <QQmlExpression>
|
|
5
|
+
|
|
6
|
+
namespace RubyQml {
|
|
7
|
+
|
|
8
|
+
ContextExtension::ContextExtension(QQmlContext *context) :
|
|
9
|
+
mContext(context)
|
|
10
|
+
{
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
QQmlEngine *ContextExtension::engine()
|
|
14
|
+
{
|
|
15
|
+
return mContext->engine();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
QVariant ContextExtension::evaluate(QObject *obj, const QString &str)
|
|
19
|
+
{
|
|
20
|
+
QQmlExpression expression(mContext, obj, str);
|
|
21
|
+
auto result = expression.evaluate();
|
|
22
|
+
if (expression.hasError()) {
|
|
23
|
+
throw QmlException(expression.error().toString());
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
void ContextExtension::setContextProperty(const QString &key, const QVariant &value)
|
|
29
|
+
{
|
|
30
|
+
mContext->setContextProperty(key, value);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
QVariant ContextExtension::contextProperty(const QString &key)
|
|
34
|
+
{
|
|
35
|
+
return mContext->contextProperty(key);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
} // namespace RubyQml
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <QObject>
|
|
4
|
+
#include <QVariant>
|
|
5
|
+
|
|
6
|
+
class QQmlContext;
|
|
7
|
+
class QQmlEngine;
|
|
8
|
+
|
|
9
|
+
namespace RubyQml {
|
|
10
|
+
|
|
11
|
+
class ContextExtension : public QObject
|
|
12
|
+
{
|
|
13
|
+
Q_OBJECT
|
|
14
|
+
Q_PROPERTY(QQmlEngine* engine READ engine)
|
|
15
|
+
public:
|
|
16
|
+
explicit ContextExtension(QQmlContext *context);
|
|
17
|
+
QQmlEngine *engine();
|
|
18
|
+
|
|
19
|
+
public slots:
|
|
20
|
+
|
|
21
|
+
QVariant evaluate(QObject *obj, const QString &str);
|
|
22
|
+
void setContextProperty(const QString &key, const QVariant &value);
|
|
23
|
+
QVariant contextProperty(const QString &key);
|
|
24
|
+
|
|
25
|
+
private:
|
|
26
|
+
QQmlContext *mContext;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
} // namespace RubyQml
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#-------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# Project created by QtCreator 2014-05-12T21:03:35
|
|
4
|
+
#
|
|
5
|
+
#-------------------------------------------------
|
|
6
|
+
|
|
7
|
+
QT += core gui qml quick widgets
|
|
8
|
+
|
|
9
|
+
TARGET = rubyqml-core
|
|
10
|
+
TEMPLATE = lib
|
|
11
|
+
CONFIG += plugin c++11
|
|
12
|
+
|
|
13
|
+
SOURCES += coreplugin.cpp \
|
|
14
|
+
qmlexception.cpp \
|
|
15
|
+
applicationextension.cpp \
|
|
16
|
+
componentextension.cpp \
|
|
17
|
+
contextextension.cpp \
|
|
18
|
+
engineextension.cpp \
|
|
19
|
+
imageprovider.cpp \
|
|
20
|
+
imagerequestpromise.cpp
|
|
21
|
+
|
|
22
|
+
HEADERS += coreplugin.h \
|
|
23
|
+
qmlexception.h \
|
|
24
|
+
applicationextension.h \
|
|
25
|
+
componentextension.h \
|
|
26
|
+
contextextension.h \
|
|
27
|
+
engineextension.h \
|
|
28
|
+
imageprovider.h \
|
|
29
|
+
imagerequestpromise.h
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#include "coreplugin.h"
|
|
2
|
+
#include "applicationextension.h"
|
|
3
|
+
#include "engineextension.h"
|
|
4
|
+
#include "componentextension.h"
|
|
5
|
+
#include "contextextension.h"
|
|
6
|
+
#include "imageprovider.h"
|
|
7
|
+
#include <QApplication>
|
|
8
|
+
#include <QQmlEngine>
|
|
9
|
+
#include <QQmlComponent>
|
|
10
|
+
#include <QQmlContext>
|
|
11
|
+
#include <stdexcept>
|
|
12
|
+
|
|
13
|
+
Q_DECLARE_METATYPE(const QMetaObject*)
|
|
14
|
+
|
|
15
|
+
namespace RubyQml {
|
|
16
|
+
|
|
17
|
+
CorePlugin::CorePlugin(QObject *parent) :
|
|
18
|
+
QObject(parent)
|
|
19
|
+
{
|
|
20
|
+
qRegisterMetaType<ApplicationExtension *>();
|
|
21
|
+
qRegisterMetaType<EngineExtension *>();
|
|
22
|
+
qRegisterMetaType<ComponentExtension *>();
|
|
23
|
+
qRegisterMetaType<ContextExtension *>();
|
|
24
|
+
qRegisterMetaType<ImageProvider *>();
|
|
25
|
+
qRegisterMetaType<QApplication *>();
|
|
26
|
+
qRegisterMetaType<QCoreApplication *>();
|
|
27
|
+
qRegisterMetaType<QQmlEngine *>();
|
|
28
|
+
qRegisterMetaType<QQmlComponent *>();
|
|
29
|
+
qRegisterMetaType<QQmlContext *>();
|
|
30
|
+
|
|
31
|
+
const QMetaObject *metaObjects[] = {
|
|
32
|
+
&staticQtMetaObject,
|
|
33
|
+
&QApplication::staticMetaObject,
|
|
34
|
+
&QQmlEngine::staticMetaObject,
|
|
35
|
+
&QQmlComponent::staticMetaObject,
|
|
36
|
+
&QQmlContext::staticMetaObject};
|
|
37
|
+
for (auto metaobj : metaObjects) {
|
|
38
|
+
mMetaObjects[metaobj->className()] = QVariant::fromValue(metaobj);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
QApplication *CorePlugin::applicationInstance()
|
|
43
|
+
{
|
|
44
|
+
return qApp;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
QQmlComponent *CorePlugin::createComponent(QQmlEngine *e)
|
|
48
|
+
{
|
|
49
|
+
return new QQmlComponent(e);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
QQmlContext *CorePlugin::createContext(QQmlEngine *engine)
|
|
53
|
+
{
|
|
54
|
+
return new QQmlContext(engine);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
ApplicationExtension *CorePlugin::createApplicationExtension(QApplication *app)
|
|
58
|
+
{
|
|
59
|
+
return new ApplicationExtension(app);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
EngineExtension *CorePlugin::createEngineExtension(QQmlEngine *engine)
|
|
63
|
+
{
|
|
64
|
+
return new EngineExtension(engine);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
ComponentExtension *CorePlugin::createComponentExtension(QQmlComponent *component)
|
|
68
|
+
{
|
|
69
|
+
return new ComponentExtension(component);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
ContextExtension *CorePlugin::createContextExtension(QQmlContext *context)
|
|
73
|
+
{
|
|
74
|
+
return new ContextExtension(context);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
QQmlContext *CorePlugin::contextForObject(QObject *object)
|
|
78
|
+
{
|
|
79
|
+
return QQmlEngine::contextForObject(object);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
ImageProvider *CorePlugin::createImageProvider(QObject *rubyCallback)
|
|
83
|
+
{
|
|
84
|
+
return new ImageProvider(rubyCallback);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
} // namespace RubyQml
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <QObject>
|
|
4
|
+
#include <QVariant>
|
|
5
|
+
|
|
6
|
+
class QApplication;
|
|
7
|
+
class QQmlEngine;
|
|
8
|
+
class QQmlComponent;
|
|
9
|
+
class QQmlContext;
|
|
10
|
+
|
|
11
|
+
namespace RubyQml {
|
|
12
|
+
|
|
13
|
+
class ApplicationExtension;
|
|
14
|
+
class ComponentExtension;
|
|
15
|
+
class EngineExtension;
|
|
16
|
+
class ContextExtension;
|
|
17
|
+
class ImageProvider;
|
|
18
|
+
|
|
19
|
+
class CorePlugin : public QObject
|
|
20
|
+
{
|
|
21
|
+
Q_OBJECT
|
|
22
|
+
Q_PLUGIN_METADATA(IID "org.ruby-qml.RubyQml.Core")
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
CorePlugin(QObject *parent = 0);
|
|
26
|
+
|
|
27
|
+
public slots:
|
|
28
|
+
QVariantHash metaObjects() { return mMetaObjects; }
|
|
29
|
+
|
|
30
|
+
QApplication *applicationInstance();
|
|
31
|
+
|
|
32
|
+
QQmlComponent *createComponent(QQmlEngine *engine);
|
|
33
|
+
QQmlContext *createContext(QQmlEngine *engine);
|
|
34
|
+
|
|
35
|
+
RubyQml::ApplicationExtension *createApplicationExtension(QApplication *app);
|
|
36
|
+
RubyQml::EngineExtension *createEngineExtension(QQmlEngine *engine);
|
|
37
|
+
RubyQml::ComponentExtension *createComponentExtension(QQmlComponent *component);
|
|
38
|
+
RubyQml::ContextExtension *createContextExtension(QQmlContext *context);
|
|
39
|
+
|
|
40
|
+
QQmlContext *contextForObject(QObject *object);
|
|
41
|
+
|
|
42
|
+
RubyQml::ImageProvider *createImageProvider(QObject *rubyCallback);
|
|
43
|
+
|
|
44
|
+
private:
|
|
45
|
+
QVariantHash mMetaObjects;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
} // namespace RubyQml
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#include "engineextension.h"
|
|
2
|
+
#include "imageprovider.h"
|
|
3
|
+
#include <QQmlEngine>
|
|
4
|
+
|
|
5
|
+
namespace RubyQml {
|
|
6
|
+
|
|
7
|
+
EngineExtension::EngineExtension(QQmlEngine *engine) :
|
|
8
|
+
mEngine(engine)
|
|
9
|
+
{
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
QQmlContext *EngineExtension::rootContext()
|
|
13
|
+
{
|
|
14
|
+
return mEngine->rootContext();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
void EngineExtension::addImageProvider(const QString &id, ImageProvider *provider)
|
|
18
|
+
{
|
|
19
|
+
mEngine->addImageProvider(id, provider);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
void EngineExtension::collectGarbage()
|
|
23
|
+
{
|
|
24
|
+
mEngine->collectGarbage();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
} // namespace RubyQml
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <QObject>
|
|
4
|
+
|
|
5
|
+
class QQmlEngine;
|
|
6
|
+
class QQmlContext;
|
|
7
|
+
|
|
8
|
+
namespace RubyQml {
|
|
9
|
+
|
|
10
|
+
class ImageProvider;
|
|
11
|
+
|
|
12
|
+
class EngineExtension : public QObject
|
|
13
|
+
{
|
|
14
|
+
Q_OBJECT
|
|
15
|
+
Q_PROPERTY(QQmlContext* rootContext READ rootContext)
|
|
16
|
+
public:
|
|
17
|
+
explicit EngineExtension(QQmlEngine *engine);
|
|
18
|
+
QQmlContext *rootContext();
|
|
19
|
+
|
|
20
|
+
public slots:
|
|
21
|
+
void addImageProvider(const QString &id, RubyQml::ImageProvider *provider);
|
|
22
|
+
void collectGarbage();
|
|
23
|
+
|
|
24
|
+
private:
|
|
25
|
+
QQmlEngine *mEngine;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
} // namespace RubyQml
|