diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a7d7ea..0477477 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ project(JlQML) cmake_minimum_required(VERSION 3.16.0) -set(JlQML_VERSION 0.5.4) +set(JlQML_VERSION 0.6.0) message(STATUS "Project version: v${JlQML_VERSION}") set(CMAKE_MACOSX_RPATH 1) diff --git a/wrap_qml.cpp b/wrap_qml.cpp index 9b525cf..4625702 100644 --- a/wrap_qml.cpp +++ b/wrap_qml.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -40,6 +41,9 @@ template<> struct SuperType { using type = QObject; }; template<> struct SuperType { using type = QQuickItem; }; template<> struct SuperType { using type = QObject; }; template<> struct SuperType { using type = QAbstractItemModel; }; +template<> struct SuperType { using type = QObject; }; +template<> struct SuperType { using type = QObject; }; +template<> struct SuperType { using type = QWindow; }; template<> struct SuperType { using type = QAbstractTableModel; }; } @@ -321,7 +325,8 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& qml_module) qml_module.set_const("Metal", QSGRendererInterface::Metal); qml_module.set_const("Null", QSGRendererInterface::Null); - qml_module.add_type("QObject"); + qml_module.add_type("QObject") + .method("deleteLater", &QObject::deleteLater); qml_module.method("connect_destroyed_signal", [] (QObject& obj, jl_function_t* jl_f) { QObject::connect(&obj, &QObject::destroyed, [jl_f](QObject* o) @@ -395,7 +400,7 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& qml_module) qml_module.add_type("QByteArrayView"); qml_module.add_type>>("QList", julia_type("AbstractVector")) - .apply, QList, QList, QList>(qmlwrap::WrapQList()); + .apply, QList, QList, QList, QList>(qmlwrap::WrapQList()); // QMap (= QVariantMap for the given type) qml_module.add_type,TypeVar<2>>>("QMapIterator") @@ -450,6 +455,8 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& qml_module) .method("context_object", &QQmlContext::contextObject); qml_module.add_type("QQmlEngine", julia_base_type()) + .method("clearComponentCache", &QQmlEngine::clearComponentCache) + .method("clearSingletons", &QQmlEngine::clearSingletons) .method("root_context", &QQmlEngine::rootContext) .method("quit", &QQmlEngine::quit); @@ -457,6 +464,7 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& qml_module) qml_module.add_type("QQmlApplicationEngine", julia_base_type()) .constructor() // Construct with path to QML + .method("rootObjects", &QQmlApplicationEngine::rootObjects) .method("load_into_engine", [] (QQmlApplicationEngine* e, const QString& qmlpath) { bool success = false; @@ -472,9 +480,11 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& qml_module) qml_module.method("qt_prefix_path", []() { return QLibraryInfo::location(QLibraryInfo::PrefixPath); }); - auto qquickitem_type = qml_module.add_type("QQuickItem"); + auto qquickitem_type = qml_module.add_type("QQuickItem", julia_base_type()); - qml_module.add_type("QQuickWindow") + qml_module.add_type("QWindow", julia_base_type()) + .method("destroy", &QWindow::destroy); + qml_module.add_type("QQuickWindow", julia_base_type()) .method("content_item", &QQuickWindow::contentItem); qquickitem_type.method("window", &QQuickItem::window); @@ -631,4 +641,16 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& qml_module) var.setValue(val); return var; }); + + qml_module.add_type("QFileSystemWatcher") + .constructor(jlcxx::finalize_policy::no) + .method("addPath", &QFileSystemWatcher::addPath); + qml_module.method("connect_file_changed_signal", [] (QFileSystemWatcher& watcher, jl_function_t* jl_f) + { + QObject::connect(&watcher, &QFileSystemWatcher::fileChanged, [jl_f](const QString& path) + { + static JuliaFunction f(jl_f); + f(path); + }); + }); }