mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
chore: silence some deprecation warnings in Qt 6.8 (#5529)
This commit is contained in:
parent
aed55ac1ba
commit
3257da1855
|
@ -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
|
||||
|
||||
|
|
|
@ -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<QMetaType::Type>(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<QMetaType::Type>(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);
|
||||
}
|
||||
|
|
|
@ -56,9 +56,8 @@ QVariant BinaryOperation::execute(const ContextMap &context) const
|
|||
switch (this->op_)
|
||||
{
|
||||
case PLUS:
|
||||
if (static_cast<QMetaType::Type>(left.type()) ==
|
||||
QMetaType::QString &&
|
||||
right.canConvert(QMetaType::QString))
|
||||
if (variantIs(left, QMetaType::QString) &&
|
||||
right.canConvert<QString>())
|
||||
{
|
||||
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<QString>())
|
||||
{
|
||||
return left.toStringList().contains(right.toString(),
|
||||
Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
if (variantIs(left, QMetaType::QVariantMap) &&
|
||||
right.canConvert(QMetaType::QString))
|
||||
right.canConvert<QString>())
|
||||
{
|
||||
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<QString>() && right.canConvert<QString>())
|
||||
{
|
||||
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<QString>())
|
||||
{
|
||||
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<QString>() && right.canConvert<QString>())
|
||||
{
|
||||
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<QString>())
|
||||
{
|
||||
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<QString>() && right.canConvert<QString>())
|
||||
{
|
||||
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<QString>())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
auto matching = left.toString();
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
switch (static_cast<QMetaType::Type>(right.typeId()))
|
||||
#else
|
||||
switch (static_cast<QMetaType::Type>(right.type()))
|
||||
#endif
|
||||
{
|
||||
case QMetaType::QRegularExpression: {
|
||||
return right.toRegularExpression()
|
||||
|
|
|
@ -28,7 +28,7 @@ void parseEmoji(const std::shared_ptr<EmojiData> &emojiData,
|
|||
const rapidjson::Value &unparsedEmoji,
|
||||
const QString &shortCode = {})
|
||||
{
|
||||
std::vector<uint32_t> unicodeBytes{};
|
||||
std::vector<char32_t> unicodeBytes{};
|
||||
|
||||
struct {
|
||||
bool apple;
|
||||
|
@ -82,7 +82,7 @@ void parseEmoji(const std::shared_ptr<EmojiData> &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> &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<int>(unicodeBytes.size()));
|
||||
emojiData->value =
|
||||
QString::fromUcs4(unicodeBytes.data(),
|
||||
static_cast<QString::size_type>(unicodeBytes.size()));
|
||||
|
||||
if (!emojiData->nonQualifiedCode.isEmpty())
|
||||
{
|
||||
QStringList nonQualifiedCharacters =
|
||||
emojiData->nonQualifiedCode.toLower().split('-');
|
||||
std::vector<uint32_t> nonQualifiedBytes{};
|
||||
std::vector<char32_t> nonQualifiedBytes{};
|
||||
for (const QString &unicodeCharacter : nonQualifiedCharacters)
|
||||
{
|
||||
bool ok{false};
|
||||
|
@ -115,9 +116,9 @@ void parseEmoji(const std::shared_ptr<EmojiData> &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<int>(nonQualifiedBytes.size()));
|
||||
emojiData->nonQualified = QString::fromUcs4(
|
||||
nonQualifiedBytes.data(),
|
||||
static_cast<QString::size_type>(nonQualifiedBytes.size()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -232,7 +232,7 @@ void TwitchAccount::loadUserstateEmotes(std::weak_ptr<Channel> 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))
|
||||
{
|
||||
|
|
|
@ -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<int>(from + match.capturedStart());
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QTimeZone>
|
||||
#include <QUrl>
|
||||
#include <QUrlQuery>
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <IrcMessage>
|
||||
#include <QString>
|
||||
#include <QTimeZone>
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue