1+ #include < QFileSystemWatcher>
12#include < QGuiApplication>
23#include < QLibraryInfo>
34#include < QPainter>
@@ -40,6 +41,9 @@ template<> struct SuperType<QTimer> { using type = QObject; };
4041template <> struct SuperType <qmlwrap::JuliaPaintedItem> { using type = QQuickItem; };
4142template <> struct SuperType <QAbstractItemModel> { using type = QObject; };
4243template <> struct SuperType <QAbstractTableModel> { using type = QAbstractItemModel; };
44+ template <> struct SuperType <QQuickItem> { using type = QObject; };
45+ template <> struct SuperType <QWindow> { using type = QObject; };
46+ template <> struct SuperType <QQuickWindow> { using type = QWindow; };
4347template <> struct SuperType <qmlwrap::JuliaItemModel> { using type = QAbstractTableModel; };
4448
4549}
@@ -321,7 +325,8 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& qml_module)
321325 qml_module.set_const (" Metal" , QSGRendererInterface::Metal);
322326 qml_module.set_const (" Null" , QSGRendererInterface::Null);
323327
324- qml_module.add_type <QObject>(" QObject" );
328+ qml_module.add_type <QObject>(" QObject" )
329+ .method (" deleteLater" , &QObject::deleteLater);
325330 qml_module.method (" connect_destroyed_signal" , [] (QObject& obj, jl_function_t * jl_f)
326331 {
327332 QObject::connect (&obj, &QObject::destroyed, [jl_f](QObject* o)
@@ -395,7 +400,7 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& qml_module)
395400 qml_module.add_type <QByteArrayView>(" QByteArrayView" );
396401
397402 qml_module.add_type <Parametric<TypeVar<1 >>>(" QList" , julia_type (" AbstractVector" ))
398- .apply <QVariantList, QList<QString>, QList<QUrl>, QList<QByteArray>, QList<int >>(qmlwrap::WrapQList ());
403+ .apply <QVariantList, QList<QString>, QList<QUrl>, QList<QByteArray>, QList<int >, QList<QObject*> >(qmlwrap::WrapQList ());
399404
400405 // QMap (= QVariantMap for the given type)
401406 qml_module.add_type <Parametric<TypeVar<1 >,TypeVar<2 >>>(" QMapIterator" )
@@ -450,13 +455,16 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& qml_module)
450455 .method (" context_object" , &QQmlContext::contextObject);
451456
452457 qml_module.add_type <QQmlEngine>(" QQmlEngine" , julia_base_type<QObject>())
458+ .method (" clearComponentCache" , &QQmlEngine::clearComponentCache)
459+ .method (" clearSingletons" , &QQmlEngine::clearSingletons)
453460 .method (" root_context" , &QQmlEngine::rootContext)
454461 .method (" quit" , &QQmlEngine::quit);
455462
456463 qqmlcontext_wrapper.method (" engine" , &QQmlContext::engine);
457464
458465 qml_module.add_type <QQmlApplicationEngine>(" QQmlApplicationEngine" , julia_base_type<QQmlEngine>())
459466 .constructor <QString>() // Construct with path to QML
467+ .method (" rootObjects" , &QQmlApplicationEngine::rootObjects)
460468 .method (" load_into_engine" , [] (QQmlApplicationEngine* e, const QString& qmlpath)
461469 {
462470 bool success = false ;
@@ -472,9 +480,11 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& qml_module)
472480
473481 qml_module.method (" qt_prefix_path" , []() { return QLibraryInfo::location (QLibraryInfo::PrefixPath); });
474482
475- auto qquickitem_type = qml_module.add_type <QQuickItem>(" QQuickItem" );
483+ auto qquickitem_type = qml_module.add_type <QQuickItem>(" QQuickItem" , julia_base_type<QObject>() );
476484
477- qml_module.add_type <QQuickWindow>(" QQuickWindow" )
485+ qml_module.add_type <QWindow>(" QWindow" , julia_base_type<QObject>())
486+ .method (" destroy" , &QWindow::destroy);
487+ qml_module.add_type <QQuickWindow>(" QQuickWindow" , julia_base_type<QWindow>())
478488 .method (" content_item" , &QQuickWindow::contentItem);
479489
480490 qquickitem_type.method (" window" , &QQuickItem::window);
@@ -631,4 +641,16 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& qml_module)
631641 var.setValue (val);
632642 return var;
633643 });
644+
645+ qml_module.add_type <QFileSystemWatcher>(" QFileSystemWatcher" )
646+ .constructor <QObject*>(jlcxx::finalize_policy::no)
647+ .method (" addPath" , &QFileSystemWatcher::addPath);
648+ qml_module.method (" connect_file_changed_signal" , [] (QFileSystemWatcher& watcher, jl_function_t * jl_f)
649+ {
650+ QObject::connect (&watcher, &QFileSystemWatcher::fileChanged, [jl_f](const QString& path)
651+ {
652+ static JuliaFunction f (jl_f);
653+ f (path);
654+ });
655+ });
634656}
0 commit comments