Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add qml_module to builder and create qmldir and QML module from build script options #434

Closed
3 tasks
Be-ing opened this issue Feb 9, 2023 · 3 comments
Closed
3 tasks
Labels
🔨 build system Issues related to integrating CXX-Qt into CMake/Cargo ⬆️ feature New feature or request
Milestone

Comments

@Be-ing
Copy link
Contributor

Be-ing commented Feb 9, 2023

Register the qml_module in the build script as we need to produce proper QML modules.

Note that we need to generate a qmldir, so for basic ones this will just include the plugin name etc, but if there are QML files included in that module they need to be listed in the qmldir too, so we need this to occur in the build script.

So

  • Add qml_module to CxxQtBuilder
  • Remove qml_uri and qml_version from qobject macro
  • Add qml_element to the qobject macro

This could then look like

#[cxx_qt::qobject(qml_element)
pub struct Thing;
.qml_module("com.foo.bar", 1, 0, |files| {
  files.rs("src/rust/thing.rs");
  files.qml("src/qml/main.qml");
})

Original description

It would be helpful to only need to specify the QML URI and version once in a central place, for example build.rs, to avoid repeating this information for multiple QObjects. QObjects exposed to QML could then be indicated with #[cxxqt::qobject(qml_element)].

#428 (comment)

@ahayzen
Copy link

ahayzen commented Feb 12, 2023

I wonder if we should require always specifying qml_element or qml_singleton (which implies a qml_element) 🤔

As when using this it was odd that specifying a uri and version magically made it an element too (and not obvious if that was then a singleton ?)

@ahayzen-kdab ahayzen-kdab added ⬆️ feature New feature or request 🙋 good first issue Good for newcomers labels Feb 13, 2023
@ahayzen-kdab ahayzen-kdab changed the title set default QML URI & version Add qml_module to builder and create qmldir and QML module from build script options Mar 9, 2023
@ahayzen-kdab ahayzen-kdab removed the 🙋 good first issue Good for newcomers label Mar 9, 2023
@ahayzen-kdab ahayzen-kdab added this to the 0.6 milestone Mar 9, 2023
@ahayzen-kdab
Copy link
Collaborator

ahayzen-kdab commented May 23, 2023

For non-QML related files and resources, eg QObjects or resources exposed to just C++, these would still need to use the old .file(...) and .qrc(...) methods outside of the qml_module(uri, version, |files| { ... }) callback.

This is fine and can be documented as such, we should just ensure that the API is the same, eg there is .rs(...) vs .file(...) currently for rust source files should be scanned for a #[cxx_qt::bridge]

@Be-ing Be-ing added the 🔨 build system Issues related to integrating CXX-Qt into CMake/Cargo label Jul 7, 2023
@ahayzen-kdab
Copy link
Collaborator

This was has been done and the API is the following...

        .qml_module(QmlModule {
            uri: "com.kdab.cxx_qt.demo",
            rust_files: &["src/cxxqt_object.rs"],
            qml_files: &["../qml/main.qml"],
            ..Default::default()
        })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 build system Issues related to integrating CXX-Qt into CMake/Cargo ⬆️ feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants