Skip to content
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

Merged

Conversation

agiudiceandrea
Copy link
Member

@agiudiceandrea agiudiceandrea commented Feb 20, 2025

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.

image

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.

image

Fixes #60642.

Better approaches and improvement suggestions are welcome!

@github-actions github-actions bot added this to the 3.42.0 milestone Feb 20, 2025
@agiudiceandrea agiudiceandrea added GUI/UX Related to QGIS application GUI or User Experience Bug Either a bug report, or a bug fix. Let's hope for the latter! backport release-3_40 labels Feb 20, 2025
Copy link

github-actions bot commented Feb 20, 2025

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 7bfde7f)

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 7bfde7f)

@nirvn
Copy link
Contributor

nirvn commented Feb 20, 2025

@agiudiceandrea , there's a better fix than arbitrary clipping here, wait a sec.

@nirvn
Copy link
Contributor

nirvn commented Feb 20, 2025

@agiudiceandrea , set the size adjust policy when constructing the raster band combobox:

setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );

That will allow for the combo box widget to have a width that is smaller than its content.

Copy link
Contributor

@nirvn nirvn left a 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 :) )

@agiudiceandrea
Copy link
Member Author

agiudiceandrea commented Feb 20, 2025

Thanks @nirvn for the suggestion!
I've tried using setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );, but while it actually creates a more usable GUI, it doesn't totally fixes the issue.

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.
See the screencast where also for very long descriptions, the band colour interpretation is always visible

Video_2025-02-20_212934.mp4

Using instead setSizeAdjustPolicy, when the description is too long, it may be impossible to read the band colour interpretation:

Video_2025-02-20_213207.mp4

Anyway, 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.

@nirvn
Copy link
Contributor

nirvn commented Feb 21, 2025

@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.

@agiudiceandrea agiudiceandrea force-pushed the fix-60642-displaybandname-toolong branch from cfad177 to 7bfde7f Compare February 21, 2025 06:50
@agiudiceandrea agiudiceandrea changed the title [GUI] QgsRasterBandComboBox: avoid too long displayBandName() [GUI] QgsRasterBandComboBox: avoid oversized UI caused by too long band name & description Feb 21, 2025
@agiudiceandrea agiudiceandrea requested a review from nirvn February 21, 2025 06:57
@nirvn
Copy link
Contributor

nirvn commented Feb 21, 2025

@agiudiceandrea , thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport release-3_40 Bug Either a bug report, or a bug fix. Let's hope for the latter! GUI/UX Related to QGIS application GUI or User Experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Raster file metadata (NetCDF, GeoTIFF): long 'description' create issues in Layer properties dialog
2 participants