summary refs log tree commit diff
path: root/src/timeline/widgets
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
parentFix formatting issues (diff)
downloadnheko-4c0d4f35fecbd53f9bea12abe50a14fb74820435.tar.xz
Fix support for Qt versions < 5.11
Diffstat (limited to 'src/timeline/widgets')
-rw-r--r--src/timeline/widgets/AudioItem.cpp7
-rw-r--r--src/timeline/widgets/FileItem.cpp7
-rw-r--r--src/timeline/widgets/ImageItem.cpp7
3 files changed, 17 insertions, 4 deletions
diff --git a/src/timeline/widgets/AudioItem.cpp b/src/timeline/widgets/AudioItem.cpp
index 7ce9bf9a..5d6431ee 100644
--- a/src/timeline/widgets/AudioItem.cpp
+++ b/src/timeline/widgets/AudioItem.cpp
@@ -21,6 +21,7 @@
 #include <QFileDialog>
 #include <QPainter>
 #include <QPixmap>
+#include <QtGlobal>
 
 #include "Logging.h"
 #include "MatrixClient.h"
@@ -162,10 +163,14 @@ AudioItem::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();
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();
diff --git a/src/timeline/widgets/ImageItem.cpp b/src/timeline/widgets/ImageItem.cpp
index 79a66c4d..26c569d7 100644
--- a/src/timeline/widgets/ImageItem.cpp
+++ b/src/timeline/widgets/ImageItem.cpp
@@ -22,6 +22,7 @@
 #include <QPainter>
 #include <QPixmap>
 #include <QUuid>
+#include <QtGlobal>
 
 #include "Config.h"
 #include "ImageItem.h"
@@ -191,9 +192,11 @@ ImageItem::paintEvent(QPaintEvent *event)
 
         if (image_.isNull()) {
                 QString elidedText = metrics.elidedText(text_, Qt::ElideRight, max_width_ - 10);
-
+#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
+                setFixedSize(metrics.width(elidedText), fontHeight);
+#else
                 setFixedSize(metrics.horizontalAdvance(elidedText), fontHeight);
-
+#endif
                 painter.setFont(font);
                 painter.setPen(QPen(QColor(66, 133, 244)));
                 painter.drawText(QPoint(0, fontHeight / 2), elidedText);