Fix small timestamp misalignment

This commit is contained in:
Konstantinos Sideris 2017-07-15 19:18:34 +03:00
parent 30fb46e25b
commit 3c1f9696df
2 changed files with 6 additions and 3 deletions

View File

@ -52,7 +52,7 @@ namespace timeline
static const int msgMargin = 11; static const int msgMargin = 11;
static const int avatarSize = 36; static const int avatarSize = 36;
static const int headerSpacing = 5; static const int headerSpacing = 5;
static const int headerLeftMargin = 12; static const int headerLeftMargin = 15;
namespace fonts namespace fonts
{ {

View File

@ -330,14 +330,17 @@ void TimelineItem::setupSimpleLayout()
QTextEdit htmlText(timestamp_->text()); QTextEdit htmlText(timestamp_->text());
QString plainText = htmlText.toPlainText(); QString plainText = htmlText.toPlainText();
timestamp_->adjustSize();
// Align the end of the avatar bubble with the end of the timestamp for // Align the end of the avatar bubble with the end of the timestamp for
// messages with and without avatar. Otherwise their bodies would not be aligned. // messages with and without avatar. Otherwise their bodies would not be aligned.
int offset = std::max(0, conf::timeline::avatarSize - timestamp_->fontMetrics().width(plainText)); int tsWidth = timestamp_->fontMetrics().width(plainText);
int offset = std::max(0, conf::timeline::avatarSize - tsWidth);
int defaultFontHeight = QFontMetrics(font_).ascent(); int defaultFontHeight = QFontMetrics(font_).ascent();
timestamp_->setAlignment(Qt::AlignTop); timestamp_->setAlignment(Qt::AlignTop);
timestamp_->setContentsMargins(offset, defaultFontHeight - timestamp_->fontMetrics().ascent(), 0, 0); timestamp_->setContentsMargins(offset + 1, defaultFontHeight - timestamp_->fontMetrics().ascent(), 0, 0);
topLayout_->setContentsMargins(conf::timeline::msgMargin, conf::timeline::msgMargin / 3, 0, 0); topLayout_->setContentsMargins(conf::timeline::msgMargin, conf::timeline::msgMargin / 3, 0, 0);
} }