-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
[GUI] QgsRasterBandComboBox: avoid oversized UI caused by too long band name & description #60675
[GUI] QgsRasterBandComboBox: avoid oversized UI caused by too long band name & description #60675
Conversation
🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. 🪟 Windows buildsDownload Windows builds of this PR for testing. |
@agiudiceandrea , there's a better fix than arbitrary clipping here, wait a sec. |
@agiudiceandrea , set the size adjust policy when constructing the raster band combobox:
That will allow for the combo box widget to have a width that is smaller than its content. |
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.
(see comment above, I should have added to this review :) )
Thanks @nirvn for the suggestion! I chose to elide the text in the middle because in some situation the colour interpretation of the band is put at the end, e.g. "Band 1: long description (Grey)", so it would be useful to maintain the beginning and the ending of the string which are usually the most important part. Video_2025-02-20_212934.mp4Using instead setSizeAdjustPolicy, when the description is too long, it may be impossible to read the band colour interpretation: Video_2025-02-20_213207.mp4Anyway, I'm not really satisfied with either implementation. I'm trying another approach using fontMetrics().elidedText(). I'll keep open this PR for another day and then I will close it if I don't find a proper way to totally fix the issue. |
@agiudiceandrea , the elidedText() function is a nice idea. I still think you [s/c]ould push the setSizeAdjustPolicy fix right now to at least fix the oversized UI a long band name & description is causing ATM. That's most welcome in any case. |
cfad177
to
7bfde7f
Compare
@agiudiceandrea , thanks! |
Description
EDIT: I abandoned the approach initially proposed by me (eliding the band's name in the middle with an ellipsis char if longer than 101 characters) in favour of setting the size adjust policy as suggested by @nirvn.
The raster band's name, displayed in Layer -> Properties -> Symbology and in the GUI of processing algorithms that use QgsProcessingParameterBand, may contain the band's description text: it may be very long, creating a GUI/UX issue.
This PR attempts to fix ##60642 in a simple way just avoiding to use raster band's name longer than 101 characters (arbitrary but IMHO reasonably chosen), eliding the band's name in the middle with an ellipsis char.
Fixes #60642.
Better approaches and improvement suggestions are welcome!