diff options
author | Sebastian Rueth <sebastian.rueth@protonmail.com> | 2022-10-20 08:02:05 +0200 |
---|---|---|
committer | Sebastian Rueth <sebastian.rueth@protonmail.com> | 2022-10-20 08:02:05 +0200 |
commit | b46c4a81e0355189d90f33567b21ac07872fc2a4 (patch) | |
tree | c5052df6255e3f65e7803db6c8cf243442f8b648 /launcher/ui/widgets | |
parent | d6479e133d340dcd5ed265b49149627d8cb4fe5b (diff) | |
download | PrismLauncher-b46c4a81e0355189d90f33567b21ac07872fc2a4.tar.gz PrismLauncher-b46c4a81e0355189d90f33567b21ac07872fc2a4.tar.bz2 PrismLauncher-b46c4a81e0355189d90f33567b21ac07872fc2a4.zip |
check space requirements of project description
if there isn't enough space for 2 lines of project description, only
draw one
Signed-off-by: Sebastian Rueth <sebastian.rueth@protonmail.com>
Diffstat (limited to 'launcher/ui/widgets')
-rw-r--r-- | launcher/ui/widgets/ProjectItem.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/launcher/ui/widgets/ProjectItem.cpp b/launcher/ui/widgets/ProjectItem.cpp index 1011d6e4..49baf3e8 100644 --- a/launcher/ui/widgets/ProjectItem.cpp +++ b/launcher/ui/widgets/ProjectItem.cpp @@ -86,20 +86,25 @@ void ProjectItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o // Get first line unconditionally description = cut_text.first().second; + auto num_lines = 1; + // Get second line, elided if needed - if (cut_text.size() > 1) { - if (cut_text.size() > 2) + if (cut_text.size() > 1 && rect.height() - title_height > opt.fontMetrics.height() * 2) { + if (cut_text.size() > 2) { description += opt.fontMetrics.elidedText(cut_text.at(1).second, opt.textElideMode, cut_text.at(1).first); - else + } else { description += cut_text.at(1).second; + } + num_lines += 1; } int description_x = rect.x(); + // Have the y-value be set based on the number of lines in the description, to centralize the // description text with the space between the base and the title. int description_y = rect.y() + title_height + (rect.height() - title_height) / 2; - if (cut_text.size() == 1) + if (num_lines == 1) description_y -= opt.fontMetrics.height() / 2; else description_y -= opt.fontMetrics.height(); |