Button: add property icon-size #9279
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It's nice that the default icon size comes from the style, but sometimes the user wants a big button with a big icon.
Tested in all 5 styles, with PNG and SVG, with and without icon-size set.
ChangeLog: Added
icon-size
property to Button====
This is what it looks like.
icon-size: 40px
and the icon is a SVG with a 22x22 viewbox (which required passing the icon size toqt_window::image_to_pixmap
inqt_widgets/button.rs
.icon-size
set.icon-size: 40px
. This testcase is the reason for setting min-height of the Image element in every style, otherwise the button wasn't high enough to accomodate for the icon. It also prevents users from shrinking windows vertically to the point of shrinking the buttons completely (pre-existing bug).I used
min-height
rather thanheight
because otherwise a small icon in a bigger button (e.g. for the second search icon, due to the lineedit in the hboxlayout) is top-aligned instead of vertically centered.=====
The remaining question is whether we're OK with square icon sizes, or we want it to be a size (like in Qt) rather than a length. Which requires adding support for
size
in the slint language, from what I can see, or going for icon-width and icon-height (not a big fan because, what happens if only one of them is set?). I don't remember ever setting a non-square icon size in my 25 years of Qt... but I'm raising the question because we won't be able to change it later.