summary refs log tree commit diff
path: root/src/timeline/widgets/FileItem.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/timeline/widgets/FileItem.cpp
parentFix formatting issues (diff)
downloadnheko-4c0d4f35fecbd53f9bea12abe50a14fb74820435.tar.xz
Fix support for Qt versions < 5.11
Diffstat (limited to 'src/timeline/widgets/FileItem.cpp')
-rw-r--r--src/timeline/widgets/FileItem.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/timeline/widgets/FileItem.cpp b/src/timeline/widgets/FileItem.cpp
index 3ae76913..1a555d1c 100644
--- a/src/timeline/widgets/FileItem.cpp
+++ b/src/timeline/widgets/FileItem.cpp
@@ -21,6 +21,7 @@
 #include <QFileDialog>
 #include <QPainter>
 #include <QPixmap>
+#include <QtGlobal>
 
 #include "Logging.h"
 #include "MatrixClient.h"
@@ -153,10 +154,14 @@ FileItem::resizeEvent(QResizeEvent *event)
         font.setWeight(QFont::Medium);
 
         QFontMetrics fm(font);
+#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
+        const int computedWidth = std::min(
+          fm.width(text_) + 2 * IconRadius + VerticalPadding * 2 + TextPadding, (double)MaxWidth);
+#else
         const int computedWidth =
           std::min(fm.horizontalAdvance(text_) + 2 * IconRadius + VerticalPadding * 2 + TextPadding,
                    (double)MaxWidth);
-
+#endif
         resize(computedWidth, Height);
 
         event->accept();