diff options
author | flow <flowlnlnln@gmail.com> | 2022-10-20 14:51:09 -0300 |
---|---|---|
committer | flow <flowlnlnln@gmail.com> | 2022-10-20 15:03:46 -0300 |
commit | 5d2763382128fb6ddbdc34ca803dc1b0f582d318 (patch) | |
tree | 3d491c84a2f8b400a83d8b783b69f310b774ef83 | |
parent | b46c4a81e0355189d90f33567b21ac07872fc2a4 (diff) | |
download | PrismLauncher-5d2763382128fb6ddbdc34ca803dc1b0f582d318.tar.gz PrismLauncher-5d2763382128fb6ddbdc34ca803dc1b0f582d318.tar.bz2 PrismLauncher-5d2763382128fb6ddbdc34ca803dc1b0f582d318.zip |
fix: show a single line in ProjectItem's desc. when there's no more space
Signed-off-by: flow <flowlnlnln@gmail.com>
-rw-r--r-- | launcher/ui/widgets/ProjectItem.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/launcher/ui/widgets/ProjectItem.cpp b/launcher/ui/widgets/ProjectItem.cpp index 49baf3e8..d1ff9dbc 100644 --- a/launcher/ui/widgets/ProjectItem.cpp +++ b/launcher/ui/widgets/ProjectItem.cpp @@ -89,13 +89,19 @@ void ProjectItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o auto num_lines = 1; // Get second line, elided if needed - 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); + if (cut_text.size() > 1) { + // 2.5x so because there should be some margin left from the 2x so things don't get too squishy. + if (rect.height() - title_height <= 2.5 * opt.fontMetrics.height()) { + // If there's not enough space, show only a single line, elided. + description = opt.fontMetrics.elidedText(description, opt.textElideMode, cut_text.at(0).first); } else { - description += cut_text.at(1).second; + if (cut_text.size() > 2) { + description += opt.fontMetrics.elidedText(cut_text.at(1).second, opt.textElideMode, cut_text.at(1).first); + } else { + description += cut_text.at(1).second; + } + num_lines += 1; } - num_lines += 1; } int description_x = rect.x(); |