diff --git a/CHANGELOG.md b/CHANGELOG.md index d9abb6df1..f458677cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ - Dev: `FlagsEnum` is now `constexpr`. (#5510) - Dev: Documented and added tests to RTL handling. (#5473) - Dev: Refactored a few `#define`s into `const(expr)` and cleaned includes. (#5527) +- Dev: Prepared for Qt 6.8 by addressing some deprecations. (#5529) ## 2.5.1 diff --git a/src/controllers/filters/lang/Types.hpp b/src/controllers/filters/lang/Types.hpp index 8debaa697..737841090 100644 --- a/src/controllers/filters/lang/Types.hpp +++ b/src/controllers/filters/lang/Types.hpp @@ -72,22 +72,35 @@ QString possibleTypeToString(const PossibleType &possible); bool isList(const PossibleType &possibleType); -inline bool variantIs(const QVariant &a, QMetaType::Type type) +inline bool variantIs(const QVariant &a, int type) { - return static_cast(a.type()) == type; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + return a.typeId() == type; +#else + return a.type() == type; +#endif } -inline bool variantIsNot(const QVariant &a, QMetaType::Type type) +inline bool variantIsNot(const QVariant &a, int type) { - return static_cast(a.type()) != type; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + return a.typeId() != type; +#else + return a.type() != type; +#endif } inline bool convertVariantTypes(QVariant &a, QVariant &b, int type) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QMetaType ty(type); + return a.convert(ty) && b.convert(ty); +#else return a.convert(type) && b.convert(type); +#endif } -inline bool variantTypesMatch(QVariant &a, QVariant &b, QMetaType::Type type) +inline bool variantTypesMatch(QVariant &a, QVariant &b, int type) { return variantIs(a, type) && variantIs(b, type); } diff --git a/src/controllers/filters/lang/expressions/BinaryOperation.cpp b/src/controllers/filters/lang/expressions/BinaryOperation.cpp index 868ad23cd..acf21726b 100644 --- a/src/controllers/filters/lang/expressions/BinaryOperation.cpp +++ b/src/controllers/filters/lang/expressions/BinaryOperation.cpp @@ -56,9 +56,8 @@ QVariant BinaryOperation::execute(const ContextMap &context) const switch (this->op_) { case PLUS: - if (static_cast(left.type()) == - QMetaType::QString && - right.canConvert(QMetaType::QString)) + if (variantIs(left, QMetaType::QString) && + right.canConvert()) { return left.toString().append(right.toString()); } @@ -143,14 +142,14 @@ QVariant BinaryOperation::execute(const ContextMap &context) const return false; case CONTAINS: if (variantIs(left, QMetaType::QStringList) && - right.canConvert(QMetaType::QString)) + right.canConvert()) { return left.toStringList().contains(right.toString(), Qt::CaseInsensitive); } if (variantIs(left, QMetaType::QVariantMap) && - right.canConvert(QMetaType::QString)) + right.canConvert()) { return left.toMap().contains(right.toString()); } @@ -160,8 +159,7 @@ QVariant BinaryOperation::execute(const ContextMap &context) const return left.toList().contains(right); } - if (left.canConvert(QMetaType::QString) && - right.canConvert(QMetaType::QString)) + if (left.canConvert() && right.canConvert()) { return left.toString().contains(right.toString(), Qt::CaseInsensitive); @@ -170,7 +168,7 @@ QVariant BinaryOperation::execute(const ContextMap &context) const return false; case STARTS_WITH: if (variantIs(left, QMetaType::QStringList) && - right.canConvert(QMetaType::QString)) + right.canConvert()) { auto list = left.toStringList(); return !list.isEmpty() && @@ -183,8 +181,7 @@ QVariant BinaryOperation::execute(const ContextMap &context) const return left.toList().startsWith(right); } - if (left.canConvert(QMetaType::QString) && - right.canConvert(QMetaType::QString)) + if (left.canConvert() && right.canConvert()) { return left.toString().startsWith(right.toString(), Qt::CaseInsensitive); @@ -194,7 +191,7 @@ QVariant BinaryOperation::execute(const ContextMap &context) const case ENDS_WITH: if (variantIs(left, QMetaType::QStringList) && - right.canConvert(QMetaType::QString)) + right.canConvert()) { auto list = left.toStringList(); return !list.isEmpty() && @@ -207,8 +204,7 @@ QVariant BinaryOperation::execute(const ContextMap &context) const return left.toList().endsWith(right); } - if (left.canConvert(QMetaType::QString) && - right.canConvert(QMetaType::QString)) + if (left.canConvert() && right.canConvert()) { return left.toString().endsWith(right.toString(), Qt::CaseInsensitive); @@ -216,14 +212,18 @@ QVariant BinaryOperation::execute(const ContextMap &context) const return false; case MATCH: { - if (!left.canConvert(QMetaType::QString)) + if (!left.canConvert()) { return false; } auto matching = left.toString(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + switch (static_cast(right.typeId())) +#else switch (static_cast(right.type())) +#endif { case QMetaType::QRegularExpression: { return right.toRegularExpression() diff --git a/src/providers/emoji/Emojis.cpp b/src/providers/emoji/Emojis.cpp index b644df830..91da8b307 100644 --- a/src/providers/emoji/Emojis.cpp +++ b/src/providers/emoji/Emojis.cpp @@ -28,7 +28,7 @@ void parseEmoji(const std::shared_ptr &emojiData, const rapidjson::Value &unparsedEmoji, const QString &shortCode = {}) { - std::vector unicodeBytes{}; + std::vector unicodeBytes{}; struct { bool apple; @@ -82,7 +82,7 @@ void parseEmoji(const std::shared_ptr &emojiData, for (const QString &unicodeCharacter : unicodeCharacters) { bool ok{false}; - unicodeBytes.push_back(QString(unicodeCharacter).toUInt(&ok, 16)); + unicodeBytes.push_back(unicodeCharacter.toUInt(&ok, 16)); if (!ok) { qCWarning(chatterinoEmoji) @@ -92,14 +92,15 @@ void parseEmoji(const std::shared_ptr &emojiData, } // We can safely do a narrowing static cast since unicodeBytes will never be a large number - emojiData->value = QString::fromUcs4(unicodeBytes.data(), - static_cast(unicodeBytes.size())); + emojiData->value = + QString::fromUcs4(unicodeBytes.data(), + static_cast(unicodeBytes.size())); if (!emojiData->nonQualifiedCode.isEmpty()) { QStringList nonQualifiedCharacters = emojiData->nonQualifiedCode.toLower().split('-'); - std::vector nonQualifiedBytes{}; + std::vector nonQualifiedBytes{}; for (const QString &unicodeCharacter : nonQualifiedCharacters) { bool ok{false}; @@ -115,9 +116,9 @@ void parseEmoji(const std::shared_ptr &emojiData, } // We can safely do a narrowing static cast since unicodeBytes will never be a large number - emojiData->nonQualified = - QString::fromUcs4(nonQualifiedBytes.data(), - static_cast(nonQualifiedBytes.size())); + emojiData->nonQualified = QString::fromUcs4( + nonQualifiedBytes.data(), + static_cast(nonQualifiedBytes.size())); } } diff --git a/src/providers/twitch/TwitchAccount.cpp b/src/providers/twitch/TwitchAccount.cpp index eb07bd6ba..56cb52240 100644 --- a/src/providers/twitch/TwitchAccount.cpp +++ b/src/providers/twitch/TwitchAccount.cpp @@ -232,7 +232,7 @@ void TwitchAccount::loadUserstateEmotes(std::weak_ptr weakChannel) } // filter out emote sets from userstate message, which are not in fetched emote set list - for (const auto &emoteSetKey : qAsConst(this->userstateEmoteSets_)) + for (const auto &emoteSetKey : this->userstateEmoteSets_) { if (!existingEmoteSetKeys.contains(emoteSetKey)) { diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index 066ee9bca..02e469d23 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -1185,7 +1185,11 @@ void TwitchMessageBuilder::processIgnorePhrases( QRegularExpression emoteregex( "\\b" + emote.name.string + "\\b", QRegularExpression::UseUnicodePropertiesOption); +#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) + auto match = emoteregex.matchView(midExtendedRef); +#else auto match = emoteregex.match(midExtendedRef); +#endif if (match.hasMatch()) { emote.start = static_cast(from + match.capturedStart()); diff --git a/src/providers/twitch/api/Helix.hpp b/src/providers/twitch/api/Helix.hpp index aa95f1e32..9fab2648e 100644 --- a/src/providers/twitch/api/Helix.hpp +++ b/src/providers/twitch/api/Helix.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -722,7 +723,7 @@ struct HelixShieldModeStatus { , lastActivatedAt(QDateTime::fromString( json["last_activated_at"].toString(), Qt::ISODate)) { - this->lastActivatedAt.setTimeSpec(Qt::UTC); + this->lastActivatedAt.setTimeZone(QTimeZone::utc()); } }; diff --git a/src/util/IrcHelpers.hpp b/src/util/IrcHelpers.hpp index faa3fd71a..77e5c4ca6 100644 --- a/src/util/IrcHelpers.hpp +++ b/src/util/IrcHelpers.hpp @@ -2,6 +2,7 @@ #include #include +#include namespace chatterino { @@ -88,7 +89,7 @@ inline QDateTime calculateMessageTime(const Communi::IrcMessage *message) QString timedate = message->tags().value("time").toString(); auto date = QDateTime::fromString(timedate, Qt::ISODate); - date.setTimeSpec(Qt::TimeSpec::UTC); + date.setTimeZone(QTimeZone::utc()); return date.toLocalTime(); } diff --git a/src/widgets/helper/color/ColorItemDelegate.cpp b/src/widgets/helper/color/ColorItemDelegate.cpp index 5b67f68bc..0b5ad7c8c 100644 --- a/src/widgets/helper/color/ColorItemDelegate.cpp +++ b/src/widgets/helper/color/ColorItemDelegate.cpp @@ -15,7 +15,11 @@ void ColorItemDelegate::paint(QPainter *painter, { auto data = index.data(Qt::DecorationRole); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (data.typeId() != QMetaType::QColor) +#else if (data.type() != QVariant::Color) +#endif { return QStyledItemDelegate::paint(painter, option, index); }