-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Make sure only powers of two are entered for the page size #1405
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
Make sure only powers of two are entered for the page size #1405
Conversation
|
Thanks @revolter, good thinking. 😄 |
989c1cc to
0afb750
Compare
src/PageSizeSpinBox.h
Outdated
| { | ||
| Q_OBJECT | ||
| public: | ||
| PageSizeSpinBox(QWidget* parent = Q_NULLPTR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer a nullptr here instead of the Qt specific macro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it added it like this by default, but I'm not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it does that. I think the default code snippets that are generated are made to work on all platforms and settings. But since our code only build with C++11 anyway we can use nullptr here.
|
@MKleusberg, Any idea how to fix the build? |
MKleusberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 😄 There are two problems to be fixed however.
-
The spinbox still allows you to enter invalid values manually. Maybe add a slot in PageSizeSpinBox here and connect it to the
valueChanged()signal, then check the new value there and fix it if it's invalid. Not sure if that's the best approach but it's the first one I could come up with 😉 -
The build still fails because Travis is using cmake. So you'll need to add the two new files to the CMakeLists.txt file, too 😄
|
Haha, you were faster than me here 😆 |
|
Could we somehow automate this required add of new files to the |
|
Hmmm, I don't think so. Qt Creator updates the I always did that manually so far because it doesn't take long at all. You'll just need to add |
Actually, it's not. If you deselect the input field, it jumps to the last valid value, and if you directly click OK it passes the same last valid value. But I can see how this could be confusing. |
cb8752c to
44727ca
Compare
😢 |
Having a QSpinBox didn't make too much sense when we only have 8 valid values. Forcing the user to type a valid value would have required a warning message too, along with translations. Having a QComboBox makes it clear (obviously) what values we are expecting, without any risk of invalid values or confusion.
|
That does look a lot better. 😄 |
|
Yep, looks good. 😄 |
|
And it also built without errors ❤️ |
|
Funny that we didn't think of this before - makes actually a lot more sense this way 😄 I'll go ahead and merge this then. Thanks, Iulian! |
|
Yeah, I know. I was thinking of better and better ways to validate the input when I found https://stackoverflow.com/questions/12616120/validation-in-qspinbox#comment41015189_20702720. |


No description provided.