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

[0.20] [GUI] Add tooltip to f(x) when there is no expression #4361

Merged
merged 1 commit into from Apr 2, 2021

Conversation

chennes
Copy link
Member

@chennes chennes commented Feb 4, 2021

As suggested by @luzpaz, this adds a tooltip to the f(x) icon of all of the widgets that use it: QuantitySpinBox, UIntSpinBox, IntSpinBox, DoubleSpinBox, and ExpLineEdit. These five classes are divided across three files, and all five classes duplicate the same basic code. In the existing code, no tooltip is shown if there is no expression. If there is an expression, it (alone) is used as the tooltip.

This commit modifies that behavior to have explanatory text as the tooltip when there is no expression, and when there is, to prepend a short string to the beginning.

To reduce further code duplication, this is implemented by adding a new function to ExpressionLabel allowing the text of the expression to be set. It checks that text and if it's empty, uses a preset default string as the tooltip. If there is expression text, it instead prepends another bit of text to the front and sets the entire expression+prefix as the tooltip.

TODO: In the future a lot of the preexisting code duplication could be removed by making the ExpressionLabel class do more internal management of the expression.

Thanks to @kisolre for the assistance tracking these down, and suggesting the default text used. Forum discussion topic: https://forum.freecadweb.org/viewtopic.php?f=17&t=55146


  • Branch rebased on latest master git pull --rebase upstream master
  • Unit tests confirmed to pass by running ./bin/FreeCAD --run-test 0
  • Commit message is well-written
  • No tracker ticket

@chennes chennes changed the title Add tooltip to f(x) when there is no expression [GUI] [0.20] Add tooltip to f(x) when there is no expression Feb 4, 2021
@wwmayer
Copy link
Contributor

wwmayer commented Feb 4, 2021

The calls of dynamic_cast should be replaced with static_cast. The reason is that most source analyzers will complain if a dynamic_cast is used but not checked if it returns a null pointer.

@abdullahtahiriyo abdullahtahiriyo changed the title [GUI] [0.20] Add tooltip to f(x) when there is no expression [0.20] [GUI] Add tooltip to f(x) when there is no expression Feb 4, 2021
As suggested by @luzpaz, this adds a tooltip to the f(x) icon of all
of the widgets that use it: QuantitySpinBox, UIntSpinBox, IntSpinBox,
DoubleSpinBox, and ExpLineEdit. These five classes are divided across
three files, and all five classes duplicate the same basic code. In the
existing code, no tooltip is shown if there is no expression. If there
is an expression, it (alone) is used as the tooltip.

This commit modifies that behavior to have explanatory text as the
tooltip when there is no expression, and when there is, to prepend a
short string to the beginning.

To reduce further code duplication, this is implemented by adding a new
function to ExpressionLabel allowing the text of the expression to be set.
It checks that text and if it's empty, uses a preset default string as the
tooltip. If there is expression text, it instead prepends another
bit of text to the front and sets the entire expression+prefix as the
tooltip.

TODO: In the future a lot of the preexisting code duplication could be
removed by making the ExpressionLabel class do more internal management
of the expression.

Thanks to @kisolre for the assistance tracking these down, and
suggesting the default text used.
@chennes
Copy link
Member Author

chennes commented Feb 4, 2021

The calls of dynamic_cast should be replaced with static_cast. The reason is that most source analyzers will complain if a dynamic_cast is used but not checked if it returns a null pointer.

Makes sense - change made.

@luzpaz luzpaz added enhancement Translation Translation and localization related labels Mar 5, 2021
@luzpaz
Copy link
Contributor

luzpaz commented Mar 10, 2021

@wmayer can we merge this before the next crowdin push ? (preferably after #4557 gets merged)

@wwmayer wwmayer merged commit 64fb634 into FreeCAD:master Apr 2, 2021
@chennes chennes deleted the addFxTooltipWhenNoFormula branch April 2, 2021 14:25
@wwmayer
Copy link
Contributor

wwmayer commented Apr 2, 2021

e151f19 avoids most code duplication of UIntSpinBox, IntSpinBox and DoubleSpinBox by implementing the class ExpressionSpinBox

@wwmayer
Copy link
Contributor

wwmayer commented Apr 2, 2021

5d49bf7 reduces code duplication of QuantitySpinBox

@luzpaz luzpaz added Feature FR for improvements or new features and removed enhancement labels Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature FR for improvements or new features Translation Translation and localization related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants