-
Notifications
You must be signed in to change notification settings - Fork 74
Replace QDoubleSpinBox by QLineEdit #1252
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
base: add-light-source
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## add-light-source #1252 +/- ##
=================================================
Coverage 72.75% 72.75%
=================================================
Files 308 308
Lines 26993 26993
=================================================
Hits 19638 19638
Misses 7355 7355
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
Hi, I tested it under Windows. I guess my opinion on the spinboxes shifted a little. This is extra code to maintain ourselves and as I understand it rewrites functionality the spinboxes already had, also, the write-in-the boxes behaviour didn't increase (As I see it, I hope I didn't miss anything you added?). Upside of the changes:
To sum up/the difference I see:
My conclusion: The current functional behaviour of the spinboxes is not perfect but now I don't think it's worse than a lineedit, but already implemented-> no extra code, no replacing code. |
|
I actually like the idea of replacing double spin boxes with LineEdit-like widgets. I am a little bit bothered by the arbitrary step sizes of the up and down buttons and the involuntary value changes when accidentally hovering a widget and using the mouse wheel. There is some extra code involved, but that is just the price one has to pay for customization. And the code can directly be re-used everywhere where we have widgets for entering doubles, which now is all over the place. @svengoldberg, we talked about it, but I forgot. What does the custom DoubleValidator do again? I played around a bit here: 3fb1afb. This is a version, where a user directly sees a difference in edit-mode and in view-mode and values are rounded in view-mode. It is actually a QLabel that gets replaced by a QLineEdit when the widget gets focus. When we enter edit mode, we see the whole unrounded value and the value is selected, so that typing replaces the current value. When pressing escape, edit mode exists without overwriting the value. When pressing enter or loosing focus (for instance by pressing tab), the value is accepted. If it is outside of the valid range, the value gets clamped. What do you think? |
I am confused about that. Wasn't it possible for you to add arbitrary many digits in the new user input field? This was the first intention we had at all that made us want to remove the Regarding the scrolling: Regarding default steps: Finally: I was not aware of that one can deactivate the "scrolling-issue". That was indeed one of the big downsides for me. Nevertheless, the user input becomes much more intuitive with the |
|
@joergbrech
From my point of view, the |
Yes, you're right, this is a big upside! And I didn't mention it. But: With blocking unfitting values, and no rule of how many decimal places get to be displayed, the experience just didn't feel so much better for me. How exactly is is specified how many decimal places get to be displayed and how many get to be used in the calculation? Didn't put this into words in my comment, sorry, for some reason I assumed this was a downside of QlineEdit, but @joergbrech just put it into code - though I must admit, I'm not quite sure about the number of decimal places of the internally (saved) values? Do they match? If they do: @joergbrech: 'tab' and 'enter' do not work equivalent, right? I really like a lot- and that also makes a huge difference- : That I can enter any high value, and it gets rounded to the upper boundary, and also displays zero decimals even if I didn't enter them. But I'm not completely convinced to replace ALL the spinboxes yet: The hovering funcionality is absolutely annoying, that's right. But coming from the specific point of view: If we'd prefer to keep the spin boxes, because they already bring a lot of functionality, and users would love them (which I don't know) what could we do?
|
|
Ok to sum up our discussion that we had on the phone today:
|
This is a draft PR, do not merge!
General information
This PR's base branch is branch that should be merged into main, as well. I started working there and did not see any advantage to move to another one for this example case...
Only one input field is changed, namely the "concentration" input of the
add-lightsource-dialog. The window can be found under "View->Display->Add a spotlight". Here, the direct contrast can be seen to the currently usedQDoubleSpinBox.Now, to the
Implementation:
This is a suggestion for the replacement of the
QDoubleSpinBoxby a customized version of theQLineEditfor every occurrence within the TiGLCreator. We discussed internally that we want to find another solution for user input of double valuesSince the
QLineEditis for text in general and not specified for number input, some restrictions and special calls are needed. For convenience, they are put into the derived classTIGLDoubleLineEdit. This allows easier access of this object when it is used for double input.Moreoever, the
QLineEdit(or its derived class) needs a validator object to only allow wanted input. This object, e.g., automatically blocks input that cannot be converted into adouble. For some reasons, the implemented value-range control did not work for me. So, I implemented a customizedvalidate()function. This is used by the Qt objectQDoubleValidator. In order to customize the function, I derived the classTIGLDoubleValidatorand overwrote the function to only allow string input that can be converted into double within a developer-defined value range.What do you all think about the suggestion @joergbrech @merakulix @ole-alb @AntonReiswich ?