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 <hello@camila.codes>
This commit is contained in:
Camila San 2018-07-30 19:59:04 +02:00
parent ee612bda3a
commit 156b4cf284
No known key found for this signature in database
GPG key ID: 7A4A6121E88E2AD4

View file

@ -110,9 +110,11 @@ void ActivityItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
// message text rect // message text rect
QRect messageTextBox = actionTextBox; QRect messageTextBox = actionTextBox;
int messageTextWidth = fm.width(messageText);
messageTextBox.setTop(option.rect.top() + fm.height() + margin); messageTextBox.setTop(option.rect.top() + fm.height() + margin);
messageTextBox.setHeight(actionTextBox.height()); messageTextBox.setHeight(fm.height());
messageTextBox.setBottom(messageTextBox.top() + fm.height()); messageTextBox.setBottom(messageTextBox.top() + fm.height());
messageTextBox.setRight(messageTextBox.left() + messageTextWidth + margin);
if(messageText.isEmpty()){ if(messageText.isEmpty()){
messageTextBox.setHeight(0); messageTextBox.setHeight(0);
messageTextBox.setBottom(messageTextBox.top()); messageTextBox.setBottom(messageTextBox.top());
@ -121,9 +123,13 @@ void ActivityItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
// time box rect // time box rect
QRect timeBox = messageTextBox; QRect timeBox = messageTextBox;
QString timeStr = tr("%1").arg(timeText); QString timeStr = tr("%1").arg(timeText);
timeBox.setTop(option.rect.top() + fm.height() + fm.height() + margin + offset/2); int timeTextWidth = fm.width(timeStr);
timeBox.setHeight(actionTextBox.height()); 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.setBottom(timeBox.top() + fm.height());
timeBox.setRight(timeBox.left() + timeTextWidth + margin);
// buttons - default values // buttons - default values
int rightMargin = margin; int rightMargin = margin;
@ -231,7 +237,7 @@ void ActivityItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
painter->setPen(option.palette.color(cg, QPalette::Text)); painter->setPen(option.palette.color(cg, QPalette::Text));
// calculate space for text - use the max possible before using the elipses // 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); (_primaryButtonWidth + _secondaryButtonWidth + _spaceBetweenButtons);
// draw the subject // draw the subject