X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fuisupport%2Fuistyle.h;h=888abcde4b5173cb64a7d472e3f1e0d716557476;hb=a8ab790b2218d6131f12b622b1373ba62958f3ef;hp=2b35c522b08f84eaa8c9ec9599e76b26ae680d4a;hpb=c1cf157116de7fc3da96203aa6f03c38c7ebb650;p=quassel.git diff --git a/src/uisupport/uistyle.h b/src/uisupport/uistyle.h index 2b35c522..888abcde 100644 --- a/src/uisupport/uistyle.h +++ b/src/uisupport/uistyle.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2018 by the Quassel Project * + * Copyright (C) 2005-2019 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -49,6 +49,28 @@ public: UiStyle(QObject* parent = nullptr); ~UiStyle() override; +// For backwards compatibility with Qt 5.5, the setFormats method was introduced +// in Qt 5.6, but the old setAdditionalFormats was deprecated in 5.6 as well. +// +// So we use the old one on Qt 5.5, and the new one everywhere else. +#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) + using FormatContainer = QVector; + static inline void setTextLayoutFormats(QTextLayout& layout, const FormatContainer& formats) { + layout.setFormats(formats); + } + static inline QVector containerToVector(const FormatContainer& container) { + return container; + } +#else + using FormatContainer = QList; + static inline void setTextLayoutFormats(QTextLayout& layout, const FormatContainer& formats) { + layout.setAdditionalFormats(formats); + } + static inline QVector containerToVector(const FormatContainer& container) { + return container.toVector(); + } +#endif + //! This enumerates the possible formats a text element may have. */ /** These formats are ordered on increasing importance, in cases where a given property is specified * by multiple active formats. @@ -275,7 +297,7 @@ public: QTextCharFormat format(const Format& format, MessageLabel messageLabel) const; QFontMetricsF* fontMetrics(FormatType formatType, MessageLabel messageLabel) const; - QList toTextLayoutList(const FormatList&, int textLength, MessageLabel messageLabel) const; + FormatContainer toTextLayoutList(const FormatList&, int textLength, MessageLabel messageLabel) const; inline const QBrush& brush(ColorRole role) const { return _uiStylePalette.at((int)role); } inline void setBrush(ColorRole role, const QBrush& brush) { _uiStylePalette[(int)role] = brush; }