Fix support for Qt versions < 5.11

This commit is contained in:
Joseph Donofry 2019-07-04 22:58:06 -04:00
parent 2484e0c118
commit 4c0d4f35fe
No known key found for this signature in database
GPG key ID: E8A1D78EF044B0CB
8 changed files with 56 additions and 12 deletions

View file

@ -2,6 +2,7 @@
#include <QPainter>
#include <QPoint>
#include <QShowEvent>
#include <QtGlobal>
#include "Config.h"
#include "TypingDisplay.h"
@ -69,9 +70,12 @@ TypingDisplay::paintEvent(QPaintEvent *)
text_ = fm.elidedText(text_, Qt::ElideRight, (double)(width() * 0.75));
QPainterPath path;
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
path.addRoundedRect(QRectF(0, 0, fm.width(text_) + 2 * LEFT_PADDING, height()), 3, 3);
#else
path.addRoundedRect(
QRectF(0, 0, fm.horizontalAdvance(text_) + 2 * LEFT_PADDING, height()), 3, 3);
#endif
p.fillPath(path, backgroundColor());
p.drawText(region, Qt::AlignVCenter, text_);
}