[Merged] PR #4361: Add tooltip to f(x) when there is no expression

Post here if you have re-based and finalised code to integrate into master, which was discussed, agreed to and tested in other forums. You can also submit your PR directly on github.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
chennes
Veteran
Posts: 3906
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

[Merged] PR #4361: Add tooltip to f(x) when there is no expression

Post by chennes »

PR 4361

This PR comes from a suggestion by @luzpaz on Gitter, so there hasn't been any discussion of it here, as far as I am aware. There were several different ways this could have been implemented, so if you have any thoughts we can discuss it here.

At first it seemed very innocuous: just adding a tooltip to the little f(x) symbol where you click to access the formula. The old behavior was that there was no tooltip if there was no expression, and the expression itself as the tooltip if there was. This PR adds a tooltip ("Enter an expression...") when there is no expression, and adds "Expression: " to the beginning of the tip when there is one (that was suggested by @kisolre).

I say "at first" because it turns out that the code for displaying that symbol and handling the tooltip is duplicated in five different classes spread out over three files. I could not bring myself to hardcode those strings in everyplace they would be needed, considering that it's very possible that the wording will be changed either now or in the future. So instead I added a new function to the ExpressionLabel class that encapsulates the new behavior. Unfortunately, doing so means I had to litter the code with dynamic casts, because we are storing a QLabel*, not an ExpressionLabel*.

I think once we begin the 0.20 development cycle I'd like to revisit this and do some refactoring to eliminate all the duplicated code, and the dynamic casts, but I don't want to do that just to implement this otherwise very simple feature.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: PR #4361: Add tooltip to f(x) when there is no expression

Post by Kunda1 »

Thanks @chennes!
realthunder wrote: pinged by pinger macro
@realthunder does this PR conflict with your pending expression PR code at all?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
chrisb
Veteran
Posts: 54183
Joined: Tue Mar 17, 2015 9:14 am

Re: PR #4361: Add tooltip to f(x) when there is no expression

Post by chrisb »

Shouldn't this better be left completely out of 0.19?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
chennes
Veteran
Posts: 3906
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: PR #4361: Add tooltip to f(x) when there is no expression

Post by chennes »

chrisb wrote: Thu Feb 04, 2021 1:33 am Shouldn't this then be left completely out of 0.19?
Yes, probably, I didn't read about the feature freeze until after I submitted the PR. My bad, sorry!
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: PR #4361: Add tooltip to f(x) when there is no expression

Post by Kunda1 »

Not necessarily as this gray-area since it's part of the documentation of FC.
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: PR #4361: Add tooltip to f(x) when there is no expression

Post by realthunder »

chennes wrote: Thu Feb 04, 2021 1:33 am Yes, probably, I didn't read about the feature freeze until after I submitted the PR. My bad, sorry!
I kind of implemented similar feature in my branch recently. Maybe you can take a look (main commit here, and there are a few follow ups). Most of handling of that icon is integrated into ExpressionLabel.
expr-editor2.gif
expr-editor2.gif (183.72 KiB) Viewed 5686 times
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
chennes
Veteran
Posts: 3906
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: PR #4361: Add tooltip to f(x) when there is no expression

Post by chennes »

realthunder wrote: Thu Feb 04, 2021 2:14 am Most of handling of that icon is integrated into ExpressionLabel.
That's great, I think that was the long-term answer: I was just trying to put together a quick low-impact PR. But since I've missed the feature freeze anyway it probably doesn't matter anymore.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
chrisb
Veteran
Posts: 54183
Joined: Tue Mar 17, 2015 9:14 am

Re: PR #4361: Add tooltip to f(x) when there is no expression

Post by chrisb »

I prefer the way of showing the expression in the value: no need to hover with the mouse, and more than one expression visible at a time.
Attachments
Snip macro screenshot-c8b0bb.png
Snip macro screenshot-c8b0bb.png (6.49 KiB) Viewed 5633 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply