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

Provide reusable QML components with common widgets #310

Closed
chapulina opened this issue Nov 4, 2021 · 3 comments · Fixed by #319
Closed

Provide reusable QML components with common widgets #310

chapulina opened this issue Nov 4, 2021 · 3 comments · Fixed by #319
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed OOBE 📦✨ Out-of-box experience

Comments

@chapulina
Copy link
Contributor

Widgets created with Ignition GUI often have duplicate code for interfaces to vectors, poses, colors, etc. It would be easier to construct various plugins if we offered these building blocks out of the box. It would also help users to write widgets that have the same look and feel.

Desired behavior

When I'm writing a plugin, I'd like to import Ignition GUI's resources and immediately include common components. For example:

...
import "qrc:/qml"
...
IgnPose3d {
  id: myPose
  xValue: posX
  ...
}

Alternatives considered

Keep using custom components for each plugin.

Implementation suggestion

See the implementation for IgnSpinBox, which is currently used in multiple plugins.

Additional context

Igntiion Gazebo's ComponentInspector plugin already implements a lot of these. The work should consist in porting them to ign-gui and making them as general as possible.

@chapulina chapulina added the enhancement New feature or request label Nov 4, 2021
@chapulina chapulina added the help wanted Extra attention is needed label Nov 12, 2021
@zflat
Copy link
Contributor

zflat commented Nov 22, 2021

I am pretty sure that if a qmldir file (https://doc.qt.io/archives/qt-6.0/qtqml-modules-qmldir.html) was added to the include/ignition/gui/qml directory and also added to the resources.qrc the qrc path to can be added to the QML load path. Then common components can be loaded with import statements as QML modules.

However, with QML modules, the name of the folder containing the qmldir is the name of the module so it would make sense to change QML files to be located at something like include/ignition/gui/qml/ignition_gui_common and put the qmldir file into the ignition_gui_common directory.

With the right setup, this wold be possible from QML:

import ignitiion_gui_common 1.0 as CommonComponents
Item {
  CommonComponents.SpinBox{
    //...
  }
  //...
}

Basically, use qmldir files to define importable QML modules.

@zflat
Copy link
Contributor

zflat commented Nov 24, 2021

@chapulina I just opened a draft pull request with changes like the ones I described in #310 (comment)

If this looks like the right approach, more files can be added to the QML module and import statements can be updated where the module will be used.

@chapulina
Copy link
Contributor Author

We got reusable vector, pose and color widgets. That's enough to close this ticket for now. As we develop more plugins, if we identify widgets that are being recreated multiple times, we should consider following the pattern of the new Gz widgets and create reusable components for them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed OOBE 📦✨ Out-of-box experience
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants