Improve rendering of icon theme descriptions when description is too long to fit

This commit is contained in:
Kovid Goyal 2025-06-29 09:30:38 +05:30
parent e008592fe7
commit 19632c98e6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -619,8 +619,8 @@ class Delegate(QStyledItemDelegate):
text = _('''\
<p><b><big>{title}</big></b><p>
<p>by <i>{author}</i> with <b>{number}</b> icons [{size}]</p>
<p>{description}</p>
<p>Version: {version} Number of users: {usage:n}</p>
<p>{description}</p>
<p><i>{visit}</i></p>
''').format(title=escape(theme.get('title') or _('Unknown')), author=escape(theme.get('author', _('Unknown'))),
number=theme.get('number', 0), description=escape(theme.get('description', '')),
@ -630,6 +630,8 @@ class Delegate(QStyledItemDelegate):
st = self.static_text_cache.get(text)
if st is None:
self.static_text_cache[text] = st = QStaticText(text)
st.setTextWidth(option.rect.width() - COVER_SIZE[0] - self.SPACING - 2)
painter.setClipRect(option.rect.adjusted(0, 0, 0, -2))
painter.drawStaticText(COVER_SIZE[0] + self.SPACING, option.rect.top() + self.SPACING, st)
painter.restore()