From 4c0d4f35fecbd53f9bea12abe50a14fb74820435 Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Thu, 4 Jul 2019 22:58:06 -0400 Subject: Fix support for Qt versions < 5.11 --- src/RoomInfoListItem.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/RoomInfoListItem.cpp') diff --git a/src/RoomInfoListItem.cpp b/src/RoomInfoListItem.cpp index c8924bed..9bcce134 100644 --- a/src/RoomInfoListItem.cpp +++ b/src/RoomInfoListItem.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "Cache.h" #include "Config.h" @@ -182,9 +183,12 @@ RoomInfoListItem::paintEvent(QPaintEvent *event) QFont tsFont; tsFont.setPointSizeF(tsFont.pointSizeF() * 0.9); +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) + const int msgStampWidth = QFontMetrics(tsFont).width(lastMsgInfo_.timestamp) + 4; +#else const int msgStampWidth = QFontMetrics(tsFont).horizontalAdvance(lastMsgInfo_.timestamp) + 4; - +#endif // We use the full width of the widget if there is no unread msg bubble. const int bottomLineWidthLimit = (unreadMsgCount_ > 0) ? msgStampWidth : 0; @@ -212,8 +216,11 @@ RoomInfoListItem::paintEvent(QPaintEvent *event) p.setFont(QFont{}); p.drawText(QPoint(2 * wm.padding + wm.iconSize, bottom_y), userName); +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) + int nameWidth = QFontMetrics(QFont{}).width(userName); +#else int nameWidth = QFontMetrics(QFont{}).horizontalAdvance(userName); - +#endif p.setFont(QFont{}); // The limit is the space between the end of the username and the start of -- cgit 1.5.1