From 156b4cf284ed2f19be687c2048add8332fa9f696 Mon Sep 17 00:00:00 2001 From: Camila San Date: Mon, 30 Jul 2018 19:59:04 +0200 Subject: [PATCH] Aligns time vertically on the bottom of the notification action text when there is no message. - Minor fix: gives less space for long text that needed ellipses which was not showing and set right margin because otherwise text was not painted correctly and completly. Signed-off-by: Camila San --- src/gui/activityitemdelegate.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gui/activityitemdelegate.cpp b/src/gui/activityitemdelegate.cpp index e18fde193..e068872ac 100644 --- a/src/gui/activityitemdelegate.cpp +++ b/src/gui/activityitemdelegate.cpp @@ -110,9 +110,11 @@ void ActivityItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem & // message text rect QRect messageTextBox = actionTextBox; + int messageTextWidth = fm.width(messageText); messageTextBox.setTop(option.rect.top() + fm.height() + margin); - messageTextBox.setHeight(actionTextBox.height()); + messageTextBox.setHeight(fm.height()); messageTextBox.setBottom(messageTextBox.top() + fm.height()); + messageTextBox.setRight(messageTextBox.left() + messageTextWidth + margin); if(messageText.isEmpty()){ messageTextBox.setHeight(0); messageTextBox.setBottom(messageTextBox.top()); @@ -121,9 +123,13 @@ void ActivityItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem & // time box rect QRect timeBox = messageTextBox; QString timeStr = tr("%1").arg(timeText); - timeBox.setTop(option.rect.top() + fm.height() + fm.height() + margin + offset/2); - timeBox.setHeight(actionTextBox.height()); + int timeTextWidth = fm.width(timeStr); + int timeTop = option.rect.top() + fm.height() + fm.height() + margin + offset/2; + if(messageText.isEmpty()) timeTop = option.rect.top() + fm.height() + margin; + timeBox.setTop(timeTop); + timeBox.setHeight(fm.height()); timeBox.setBottom(timeBox.top() + fm.height()); + timeBox.setRight(timeBox.left() + timeTextWidth + margin); // buttons - default values int rightMargin = margin; @@ -231,7 +237,7 @@ void ActivityItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem & painter->setPen(option.palette.color(cg, QPalette::Text)); // calculate space for text - use the max possible before using the elipses - int spaceLeftForText = option.rect.width() - (actionIconRect.width() + margin) - + int spaceLeftForText = option.rect.width() - (actionIconRect.width() + margin + rightMargin + leftMargin) - (_primaryButtonWidth + _secondaryButtonWidth + _spaceBetweenButtons); // draw the subject