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

[RFE] add support for appending to QML import path to sailfish-qml #15

Open
M4rtinK opened this issue Oct 13, 2014 · 1 comment
Open

Comments

@M4rtinK
Copy link

M4rtinK commented Oct 13, 2014

Unlike qmlscene, sailfish-qml does accept any command line arguments for appending to the QML import path. This basically prevents non-C++ QML programs from having QML only modules as they can't add their application qml folder to the QML import path.

Example:
Consider application "foo" that lives in /user/share/harbour-foo with qml files in /user/share/harbour-foo/qml, which has a QML-only module living in /user/share/harbour-foo/qml/Bar. Bar has a qmldir file and is a normal QML-only module.

With qmlscene it is possible to run the application like this:

qmlscene /usr/share/harbour-foo/harbour-foo.qml -I /usr/share/harbour-foo/qml

The application can use this for of importing the Bar module:

import Bar 1.0

This has multiple advantages:

  • independent on the location of the file importing the module
  • supports module versioning
  • it is possible to switch between different API-compatible modules by manipulating the import path at startup (for example API compatible Platform-specific components)
  • looks nice and clean

However, sailfish-qml does not support appending to the import path,
so the application can only directly import modules from the current working directory:

import "Bar"

This has multiple disadvantages:

  • looks ugly
  • file location dependent (some files might have "../Bar", "../../Bar", etc.)
  • no support for versioning
  • no support for module switching without direct source file mangling

Background usecase:

The modRana navigation system uses the Universal Components set, that abstracts platform differences by providing a unified API but uses the native component set on each platform, resulting in a native looking but multi-platform application with a single UI source code.

To achieve this, the application manipulates the QML import path by adding path to the UC module for the given platform. All the UC modules are API compatible - on desktop the application will add path to the directory with the UC module using QtQucik Controls as backend, on Sailfish OS it will add path to the directory where the UC module that uses the Sailfish Silica backend is located.

Unfortunately this is not possible at the moment as sailfish-qml does not support appending to the QML import path, so modRana needs to do some pretty ugly & fragile source code mangling during packaging.

@martyone
Copy link
Member

@M4rtinK Have you considered using QML2_IMPORT_PATH environment variable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants