summary refs log tree commit diff
path: root/src/RoomInfoListItem.cpp
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2019-07-04 22:58:06 -0400
committerJoseph Donofry <joedonofry@gmail.com>2019-07-04 22:58:56 -0400
commit4c0d4f35fecbd53f9bea12abe50a14fb74820435 (patch)
tree76b250c77bf8032bf60bba91f9d8823ec765421c /src/RoomInfoListItem.cpp
parentFix formatting issues (diff)
downloadnheko-4c0d4f35fecbd53f9bea12abe50a14fb74820435.tar.xz
Fix support for Qt versions < 5.11
Diffstat (limited to 'src/RoomInfoListItem.cpp')
-rw-r--r--src/RoomInfoListItem.cpp11
1 files changed, 9 insertions, 2 deletions
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 <QDebug>
 #include <QMouseEvent>
 #include <QPainter>
+#include <QtGlobal>
 
 #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