Skip to content

Commit

Permalink
fix: file item name label display issue
Browse files Browse the repository at this point in the history
fix elidetextlayout line postion issue, replace linespace with line height in delegate.

Log: fix file name display issue
Bug: https://pms.uniontech.com/bug-view-217693.html
  • Loading branch information
Lighto-Ku authored and deepin-bot[bot] committed Oct 9, 2023
1 parent 195fcab commit 124ae20
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/dfm-base/utils/elidetextlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ QList<QRectF> ElideTextLayout::layout(const QRectF &rect, Qt::TextElideMode elid
QString curText = text();
auto processLine = [this, &ret, painter, &lastLineRect, background, textLineHeight, &curText, textLines](QTextLine &line) {
QRectF lRect = line.naturalTextRect();
lRect.setTop(lRect.top() - (textLineHeight - line.height()));
lRect.setHeight(textLineHeight);

ret.append(lRect);
Expand All @@ -91,7 +90,7 @@ QList<QRectF> ElideTextLayout::layout(const QRectF &rect, Qt::TextElideMode elid
while (line.isValid()) {
curHeight += textLineHeight;
line.setLineWidth(size.width());
line.setPosition(offset + QPointF(0, textLineHeight - line.height()));
line.setPosition(offset);

// check next line is out or not.
if (curHeight + textLineHeight > size.height()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void ExpandedItem::paintEvent(QPaintEvent *)
QString str = delegate->displayFileName(index);

QScopedPointer<ElideTextLayout> layout(ItemDelegateHelper::createTextLayout(str, QTextOption::WrapAtWordBoundaryOrAnywhere,
pa.fontMetrics().lineSpacing(), Qt::AlignCenter, &pa));
pa.fontMetrics().height(), Qt::AlignCenter, &pa));
layout->setAttribute(ElideTextLayout::kBackgroundRadius, kIconModeRectRadius);

const FileInfoPointer &info = delegate->parent()->parent()->model()->fileInfo(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ QList<QRect> IconItemDelegate::paintGeomertys(const QStyleOptionViewItem &option
void IconItemDelegate::updateItemSizeHint()
{
Q_D(IconItemDelegate);
d->textLineHeight = parent()->parent()->fontMetrics().lineSpacing();
d->textLineHeight = parent()->parent()->fontMetrics().height();

int width = parent()->parent()->iconSize().width() + 30;
#ifdef DTKWIDGET_CLASS_DSizeMode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void ListItemDelegate::updateItemSizeHint()
{
Q_D(ListItemDelegate);

d->textLineHeight = parent()->parent()->fontMetrics().lineSpacing();
d->textLineHeight = parent()->parent()->fontMetrics().height();
d->itemSizeHint = QSize(-1, qMax(int(parent()->parent()->iconSize().height() * 1.33), d->textLineHeight));
}

Expand Down

0 comments on commit 124ae20

Please sign in to comment.