summary refs log tree commit diff
path: root/src/ui
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/ui
parentFix formatting issues (diff)
downloadnheko-4c0d4f35fecbd53f9bea12abe50a14fb74820435.tar.xz
Fix support for Qt versions < 5.11
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/InfoMessage.cpp16
-rw-r--r--src/ui/Painter.h7
2 files changed, 20 insertions, 3 deletions
diff --git a/src/ui/InfoMessage.cpp b/src/ui/InfoMessage.cpp

index b18a80c4..fa575d76 100644 --- a/src/ui/InfoMessage.cpp +++ b/src/ui/InfoMessage.cpp
@@ -4,6 +4,7 @@ #include <QDateTime> #include <QPainter> #include <QPen> +#include <QtGlobal> constexpr int VPadding = 6; constexpr int HPadding = 12; @@ -22,7 +23,13 @@ InfoMessage::InfoMessage(QString msg, QWidget *parent) initFont(); QFontMetrics fm{font()}; - width_ = fm.horizontalAdvance(msg_) + HPadding * 2; +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) + // width deprecated in 5.13 + width_ = fm.width(msg_) + HPadding * 2; +#else + width_ = fm.horizontalAdvance(msg_) + HPadding * 2; +#endif + height_ = fm.ascent() + 2 * VPadding; setFixedHeight(height_ + 2 * HMargin); @@ -64,7 +71,12 @@ DateSeparator::DateSeparator(QDateTime datetime, QWidget *parent) msg_ = datetime.toString(fmt); QFontMetrics fm{font()}; - width_ = fm.horizontalAdvance(msg_) + HPadding * 2; +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) + // width deprecated in 5.13 + width_ = fm.width(msg_) + HPadding * 2; +#else + width_ = fm.horizontalAdvance(msg_) + HPadding * 2; +#endif height_ = fm.ascent() + 2 * VPadding; setFixedHeight(height_ + 2 * HMargin); diff --git a/src/ui/Painter.h b/src/ui/Painter.h
index 8feed17b..1c1b17b0 100644 --- a/src/ui/Painter.h +++ b/src/ui/Painter.h
@@ -3,6 +3,7 @@ #include <QFontMetrics> #include <QPaintDevice> #include <QPainter> +#include <QtGlobal> class Painter : public QPainter { @@ -21,8 +22,12 @@ public: { QFontMetrics m(fontMetrics()); if (textWidth < 0) { - // deprecated in 5.13: textWidth = m.width(text); +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) + // deprecated in 5.13: + textWidth = m.width(text); +#else textWidth = m.horizontalAdvance(text); +#endif } drawText((outerw - x - textWidth), y + m.ascent(), text); }