diff options
author | Jocelyn Turcotte <jturcotte@woboq.com> | 2016-01-07 19:56:14 +0300 |
---|---|---|
committer | Jocelyn Turcotte <jturcotte@woboq.com> | 2016-01-07 20:02:35 +0300 |
commit | ce6f90397a28b1703a762a9f7d43ec53c01d59f8 (patch) | |
tree | b2191cf1ef497b574bc295a1221e4f9f3ac9985a /src/gui/folderstatusdelegate.cpp | |
parent | bb6a50be022075715cd0b8a583906f79faa08c0e (diff) |
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.
Diffstat (limited to 'src/gui/folderstatusdelegate.cpp')
-rw-r--r-- | src/gui/folderstatusdelegate.cpp | 25 |
1 files 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) { |