Remove version checks for unsupported Qt versions

This commit is contained in:
Nicolas Werner 2021-07-26 13:55:51 +02:00
parent c8879e7c07
commit e8e48305c8
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
3 changed files with 3 additions and 22 deletions

View File

@ -295,12 +295,9 @@ operator<<(QDBusArgument &arg, const QImage &image)
int channels = i.isGrayscale() ? 1 : (i.hasAlphaChannel() ? 4 : 3); int channels = i.isGrayscale() ? 1 : (i.hasAlphaChannel() ? 4 : 3);
arg << i.depth() / channels; arg << i.depth() / channels;
arg << channels; arg << channels;
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
arg << QByteArray(reinterpret_cast<const char *>(i.bits()), i.byteCount());
#else
arg << QByteArray(reinterpret_cast<const char *>(i.bits()), i.sizeInBytes()); arg << QByteArray(reinterpret_cast<const char *>(i.bits()), i.sizeInBytes());
#endif
arg.endStructure(); arg.endStructure();
return arg; return arg;
} }

View File

@ -29,13 +29,7 @@ InfoMessage::InfoMessage(QString msg, QWidget *parent)
initFont(); initFont();
QFontMetrics fm{font()}; QFontMetrics fm{font()};
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) width_ = fm.horizontalAdvance(msg_) + HPadding * 2;
// width deprecated in 5.13
width_ = fm.width(msg_) + HPadding * 2;
#else
width_ = fm.horizontalAdvance(msg_) + HPadding * 2;
#endif
height_ = fm.ascent() + 2 * VPadding; height_ = fm.ascent() + 2 * VPadding;
setFixedHeight(height_ + 2 * HMargin); setFixedHeight(height_ + 2 * HMargin);
@ -77,12 +71,7 @@ DateSeparator::DateSeparator(QDateTime datetime, QWidget *parent)
msg_ = datetime.date().toString(fmt); msg_ = datetime.date().toString(fmt);
QFontMetrics fm{font()}; QFontMetrics fm{font()};
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) width_ = fm.horizontalAdvance(msg_) + HPadding * 2;
// width deprecated in 5.13
width_ = fm.width(msg_) + HPadding * 2;
#else
width_ = fm.horizontalAdvance(msg_) + HPadding * 2;
#endif
height_ = fm.ascent() + 2 * VPadding; height_ = fm.ascent() + 2 * VPadding;
setFixedHeight(height_ + 2 * HMargin); setFixedHeight(height_ + 2 * HMargin);

View File

@ -27,12 +27,7 @@ public:
{ {
QFontMetrics m(fontMetrics()); QFontMetrics m(fontMetrics());
if (textWidth < 0) { if (textWidth < 0) {
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
// deprecated in 5.13:
textWidth = m.width(text);
#else
textWidth = m.horizontalAdvance(text); textWidth = m.horizontalAdvance(text);
#endif
} }
drawText((outerw - x - textWidth), y + m.ascent(), text); drawText((outerw - x - textWidth), y + m.ascent(), text);
} }