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

Respect configured workspace length unit in editors #684

merged 13 commits into from Apr 21, 2020


Copy link

@ubruhin ubruhin commented Apr 12, 2020


Until now, all number edit widgets in all editors always used Millimeters, no matter which unit was configured in workspace settings. Also it was not possible to enter values in other units by explicitly entering the unit, e.g. by writing "100mils". See also #362.


This PR heavily refactors these number input widgets in several ways:

  • Code refactoring: Add new base class LengthEditBase, based directly on QAbstractSpinBox
    instead of QDoubleSpinBox -> this way the actual value hold by the widget is Length instead of double.
  • By default, show the values in the unit configured in workspace settings.
  • Add context menu to switch unit:
  • Add support for entering mathematical expressions (using muparser), optionally including the unit:
    Peek 2020-04-12 22-57
  • Use automatic spinbox step value, determined from current value (for example if a multiple of 0.1mm is entered, the step is 0.1mm, but if a multiple of 10mils is entered, the step is 10mils):
    Peek 2020-04-12 23-05
  • Reduce number of displayed decimal places, depending on unit (converting values between different units can lead to very odd numbers with many decimal places, so for readability only a few decimal places are displayed).

Open Questions

See #362 (comment).

Copy link

dbrgn commented Apr 12, 2020

Very cool! 🎉

@ubruhin ubruhin force-pushed the 362-editors-use-workspace-length-unit branch 7 times, most recently from a25d9df to 30e870c Compare Apr 13, 2020
@ubruhin ubruhin force-pushed the 362-editors-use-workspace-length-unit branch 2 times, most recently from 6b0c45a to c36586c Compare Apr 19, 2020
@ubruhin ubruhin marked this pull request as ready for review Apr 20, 2020
@ubruhin ubruhin force-pushed the 362-editors-use-workspace-length-unit branch from c36586c to ec05424 Compare Apr 21, 2020
@ubruhin ubruhin merged commit a125ae6 into master Apr 21, 2020
11 checks passed
@ubruhin ubruhin deleted the 362-editors-use-workspace-length-unit branch Apr 21, 2020
ubruhin added a commit that referenced this issue Apr 22, 2020

Respect configured workspace length unit in editors
(cherry picked from commit a125ae6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Successfully merging this pull request may close these issues.

None yet

2 participants