From ce6f90397a28b1703a762a9f7d43ec53c01d59f8 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Thu, 7 Jan 2016 17:56:14 +0100 Subject: [PATCH] Fix the rendering of the red error box text QPainter::drawText uses the top of the font for the y position of its rect argument, but uses the baseline when using a point argument. Also use the margin variable that matches the font used instead of the aliasMargin and make sure that the margin is only added between the box and the text once. --- src/gui/folderstatusdelegate.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/gui/folderstatusdelegate.cpp b/src/gui/folderstatusdelegate.cpp index 7b5c35179..28e6b6080 100644 --- a/src/gui/folderstatusdelegate.cpp +++ b/src/gui/folderstatusdelegate.cpp @@ -244,12 +244,12 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem & int h = iconRect.bottom(); if( !errorTexts.isEmpty() ) { - h += aliasMargin; + h += margin; QRect errorRect = localPathRect; errorRect.setLeft( iconRect.left()); errorRect.setTop( h ); - errorRect.setHeight(errorTexts.count() * subFm.height()+aliasMargin); - errorRect.setRight( option.rect.right()-aliasMargin ); + errorRect.setHeight(errorTexts.count() * subFm.height() + 2 * margin); + errorRect.setRight( option.rect.right() - margin ); painter->setBrush( QColor(0xbb, 0x4d, 0x4d) ); painter->setPen( QColor(0xaa, 0xaa, 0xaa)); @@ -257,23 +257,20 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem & 4, 4); painter->setPen( Qt::white ); painter->setFont(errorFont); - QRect errorTextRect = errorRect; - errorTextRect.setLeft( errorTextRect.left()+aliasMargin ); - errorTextRect.setTop( errorTextRect.top()+aliasMargin/2 ); - - int x = errorTextRect.left(); - int y = errorTextRect.top()+aliasMargin/2 + subFm.height()/2; + QRect errorTextRect( errorRect.left() + margin, + errorRect.top() + margin, + errorRect.width() - 2 * margin, + subFm.height() ); foreach( QString eText, errorTexts ) { - QRect lineRect = QRect(x, y, errorTextRect.width(), subFm.height()); - painter->drawText(QStyle::visualRect(option.direction, option.rect, lineRect), textAlign, - subFm.elidedText( eText, Qt::ElideLeft, errorTextRect.width()-2*aliasMargin)); - y += lineRect.height(); + painter->drawText(QStyle::visualRect(option.direction, option.rect, errorTextRect), textAlign, + subFm.elidedText( eText, Qt::ElideLeft, errorTextRect.width())); + errorTextRect.translate(0, errorTextRect.height()); } h = errorRect.bottom(); } - h += aliasMargin; + h += margin; // Sync File Progress Bar: Show it if syncFile is not empty. if (showProgess) {