Skip to content

Conversation

dfaure
Copy link
Contributor

@dfaure dfaure commented Aug 28, 2025

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.

  • The first search icon has icon-size: 40px and the icon is a SVG with a 22x22 viewbox (which required passing the icon size to qt_window::image_to_pixmap in qt_widgets/button.rs.
  • The second search icon tests what used to happen, without any icon-size set.
  • The big colorful reload icon is a 48x48 PNG, used with 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 than height 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.
Screenshot_20250829_001326

=====

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.

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
@dfaure dfaure force-pushed the work/dfaure/icon-size branch from a9f2c96 to 9d70984 Compare August 28, 2025 22:45
@dfaure
Copy link
Contributor Author

dfaure commented Sep 2, 2025

@ogoffart @tronical

Copy link
Member

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, I'm just back from vacation.

The implementation looks good.

I think the API is obvious enough.

Let's just wait until the 1.13 release is out to merge this.

@ogoffart ogoffart added this to the 1.14 milestone Sep 9, 2025
@ogoffart ogoffart merged commit 8c34ec0 into slint-ui:master Sep 11, 2025
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants