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: `FlagsEnum` is now `constexpr`. (#5510)
|
||||||
- Dev: Documented and added tests to RTL handling. (#5473)
|
- Dev: Documented and added tests to RTL handling. (#5473)
|
||||||
- Dev: Refactored a few `#define`s into `const(expr)` and cleaned includes. (#5527)
|
- 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
|
## 2.5.1
|
||||||
|
|
||||||
|
|
|
@ -72,22 +72,35 @@ QString possibleTypeToString(const PossibleType &possible);
|
||||||
|
|
||||||
bool isList(const PossibleType &possibleType);
|
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)
|
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);
|
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);
|
return variantIs(a, type) && variantIs(b, type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,9 +56,8 @@ QVariant BinaryOperation::execute(const ContextMap &context) const
|
||||||
switch (this->op_)
|
switch (this->op_)
|
||||||
{
|
{
|
||||||
case PLUS:
|
case PLUS:
|
||||||
if (static_cast<QMetaType::Type>(left.type()) ==
|
if (variantIs(left, QMetaType::QString) &&
|
||||||
QMetaType::QString &&
|
right.canConvert<QString>())
|
||||||
right.canConvert(QMetaType::QString))
|
|
||||||
{
|
{
|
||||||
return left.toString().append(right.toString());
|
return left.toString().append(right.toString());
|
||||||
}
|
}
|
||||||
|
@ -143,14 +142,14 @@ QVariant BinaryOperation::execute(const ContextMap &context) const
|
||||||
return false;
|
return false;
|
||||||
case CONTAINS:
|
case CONTAINS:
|
||||||
if (variantIs(left, QMetaType::QStringList) &&
|
if (variantIs(left, QMetaType::QStringList) &&
|
||||||
right.canConvert(QMetaType::QString))
|
right.canConvert<QString>())
|
||||||
{
|
{
|
||||||
return left.toStringList().contains(right.toString(),
|
return left.toStringList().contains(right.toString(),
|
||||||
Qt::CaseInsensitive);
|
Qt::CaseInsensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (variantIs(left, QMetaType::QVariantMap) &&
|
if (variantIs(left, QMetaType::QVariantMap) &&
|
||||||
right.canConvert(QMetaType::QString))
|
right.canConvert<QString>())
|
||||||
{
|
{
|
||||||
return left.toMap().contains(right.toString());
|
return left.toMap().contains(right.toString());
|
||||||
}
|
}
|
||||||
|
@ -160,8 +159,7 @@ QVariant BinaryOperation::execute(const ContextMap &context) const
|
||||||
return left.toList().contains(right);
|
return left.toList().contains(right);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (left.canConvert(QMetaType::QString) &&
|
if (left.canConvert<QString>() && right.canConvert<QString>())
|
||||||
right.canConvert(QMetaType::QString))
|
|
||||||
{
|
{
|
||||||
return left.toString().contains(right.toString(),
|
return left.toString().contains(right.toString(),
|
||||||
Qt::CaseInsensitive);
|
Qt::CaseInsensitive);
|
||||||
|
@ -170,7 +168,7 @@ QVariant BinaryOperation::execute(const ContextMap &context) const
|
||||||
return false;
|
return false;
|
||||||
case STARTS_WITH:
|
case STARTS_WITH:
|
||||||
if (variantIs(left, QMetaType::QStringList) &&
|
if (variantIs(left, QMetaType::QStringList) &&
|
||||||
right.canConvert(QMetaType::QString))
|
right.canConvert<QString>())
|
||||||
{
|
{
|
||||||
auto list = left.toStringList();
|
auto list = left.toStringList();
|
||||||
return !list.isEmpty() &&
|
return !list.isEmpty() &&
|
||||||
|
@ -183,8 +181,7 @@ QVariant BinaryOperation::execute(const ContextMap &context) const
|
||||||
return left.toList().startsWith(right);
|
return left.toList().startsWith(right);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (left.canConvert(QMetaType::QString) &&
|
if (left.canConvert<QString>() && right.canConvert<QString>())
|
||||||
right.canConvert(QMetaType::QString))
|
|
||||||
{
|
{
|
||||||
return left.toString().startsWith(right.toString(),
|
return left.toString().startsWith(right.toString(),
|
||||||
Qt::CaseInsensitive);
|
Qt::CaseInsensitive);
|
||||||
|
@ -194,7 +191,7 @@ QVariant BinaryOperation::execute(const ContextMap &context) const
|
||||||
|
|
||||||
case ENDS_WITH:
|
case ENDS_WITH:
|
||||||
if (variantIs(left, QMetaType::QStringList) &&
|
if (variantIs(left, QMetaType::QStringList) &&
|
||||||
right.canConvert(QMetaType::QString))
|
right.canConvert<QString>())
|
||||||
{
|
{
|
||||||
auto list = left.toStringList();
|
auto list = left.toStringList();
|
||||||
return !list.isEmpty() &&
|
return !list.isEmpty() &&
|
||||||
|
@ -207,8 +204,7 @@ QVariant BinaryOperation::execute(const ContextMap &context) const
|
||||||
return left.toList().endsWith(right);
|
return left.toList().endsWith(right);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (left.canConvert(QMetaType::QString) &&
|
if (left.canConvert<QString>() && right.canConvert<QString>())
|
||||||
right.canConvert(QMetaType::QString))
|
|
||||||
{
|
{
|
||||||
return left.toString().endsWith(right.toString(),
|
return left.toString().endsWith(right.toString(),
|
||||||
Qt::CaseInsensitive);
|
Qt::CaseInsensitive);
|
||||||
|
@ -216,14 +212,18 @@ QVariant BinaryOperation::execute(const ContextMap &context) const
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
case MATCH: {
|
case MATCH: {
|
||||||
if (!left.canConvert(QMetaType::QString))
|
if (!left.canConvert<QString>())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto matching = left.toString();
|
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()))
|
switch (static_cast<QMetaType::Type>(right.type()))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
case QMetaType::QRegularExpression: {
|
case QMetaType::QRegularExpression: {
|
||||||
return right.toRegularExpression()
|
return right.toRegularExpression()
|
||||||
|
|
|
@ -28,7 +28,7 @@ void parseEmoji(const std::shared_ptr<EmojiData> &emojiData,
|
||||||
const rapidjson::Value &unparsedEmoji,
|
const rapidjson::Value &unparsedEmoji,
|
||||||
const QString &shortCode = {})
|
const QString &shortCode = {})
|
||||||
{
|
{
|
||||||
std::vector<uint32_t> unicodeBytes{};
|
std::vector<char32_t> unicodeBytes{};
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool apple;
|
bool apple;
|
||||||
|
@ -82,7 +82,7 @@ void parseEmoji(const std::shared_ptr<EmojiData> &emojiData,
|
||||||
for (const QString &unicodeCharacter : unicodeCharacters)
|
for (const QString &unicodeCharacter : unicodeCharacters)
|
||||||
{
|
{
|
||||||
bool ok{false};
|
bool ok{false};
|
||||||
unicodeBytes.push_back(QString(unicodeCharacter).toUInt(&ok, 16));
|
unicodeBytes.push_back(unicodeCharacter.toUInt(&ok, 16));
|
||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
qCWarning(chatterinoEmoji)
|
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
|
// We can safely do a narrowing static cast since unicodeBytes will never be a large number
|
||||||
emojiData->value = QString::fromUcs4(unicodeBytes.data(),
|
emojiData->value =
|
||||||
static_cast<int>(unicodeBytes.size()));
|
QString::fromUcs4(unicodeBytes.data(),
|
||||||
|
static_cast<QString::size_type>(unicodeBytes.size()));
|
||||||
|
|
||||||
if (!emojiData->nonQualifiedCode.isEmpty())
|
if (!emojiData->nonQualifiedCode.isEmpty())
|
||||||
{
|
{
|
||||||
QStringList nonQualifiedCharacters =
|
QStringList nonQualifiedCharacters =
|
||||||
emojiData->nonQualifiedCode.toLower().split('-');
|
emojiData->nonQualifiedCode.toLower().split('-');
|
||||||
std::vector<uint32_t> nonQualifiedBytes{};
|
std::vector<char32_t> nonQualifiedBytes{};
|
||||||
for (const QString &unicodeCharacter : nonQualifiedCharacters)
|
for (const QString &unicodeCharacter : nonQualifiedCharacters)
|
||||||
{
|
{
|
||||||
bool ok{false};
|
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
|
// We can safely do a narrowing static cast since unicodeBytes will never be a large number
|
||||||
emojiData->nonQualified =
|
emojiData->nonQualified = QString::fromUcs4(
|
||||||
QString::fromUcs4(nonQualifiedBytes.data(),
|
nonQualifiedBytes.data(),
|
||||||
static_cast<int>(nonQualifiedBytes.size()));
|
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
|
// 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))
|
if (!existingEmoteSetKeys.contains(emoteSetKey))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1185,7 +1185,11 @@ void TwitchMessageBuilder::processIgnorePhrases(
|
||||||
QRegularExpression emoteregex(
|
QRegularExpression emoteregex(
|
||||||
"\\b" + emote.name.string + "\\b",
|
"\\b" + emote.name.string + "\\b",
|
||||||
QRegularExpression::UseUnicodePropertiesOption);
|
QRegularExpression::UseUnicodePropertiesOption);
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||||
|
auto match = emoteregex.matchView(midExtendedRef);
|
||||||
|
#else
|
||||||
auto match = emoteregex.match(midExtendedRef);
|
auto match = emoteregex.match(midExtendedRef);
|
||||||
|
#endif
|
||||||
if (match.hasMatch())
|
if (match.hasMatch())
|
||||||
{
|
{
|
||||||
emote.start = static_cast<int>(from + match.capturedStart());
|
emote.start = static_cast<int>(from + match.capturedStart());
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QTimeZone>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
|
|
||||||
|
@ -722,7 +723,7 @@ struct HelixShieldModeStatus {
|
||||||
, lastActivatedAt(QDateTime::fromString(
|
, lastActivatedAt(QDateTime::fromString(
|
||||||
json["last_activated_at"].toString(), Qt::ISODate))
|
json["last_activated_at"].toString(), Qt::ISODate))
|
||||||
{
|
{
|
||||||
this->lastActivatedAt.setTimeSpec(Qt::UTC);
|
this->lastActivatedAt.setTimeZone(QTimeZone::utc());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <IrcMessage>
|
#include <IrcMessage>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QTimeZone>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
@ -88,7 +89,7 @@ inline QDateTime calculateMessageTime(const Communi::IrcMessage *message)
|
||||||
QString timedate = message->tags().value("time").toString();
|
QString timedate = message->tags().value("time").toString();
|
||||||
|
|
||||||
auto date = QDateTime::fromString(timedate, Qt::ISODate);
|
auto date = QDateTime::fromString(timedate, Qt::ISODate);
|
||||||
date.setTimeSpec(Qt::TimeSpec::UTC);
|
date.setTimeZone(QTimeZone::utc());
|
||||||
return date.toLocalTime();
|
return date.toLocalTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,11 @@ void ColorItemDelegate::paint(QPainter *painter,
|
||||||
{
|
{
|
||||||
auto data = index.data(Qt::DecorationRole);
|
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)
|
if (data.type() != QVariant::Color)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
return QStyledItemDelegate::paint(painter, option, index);
|
return QStyledItemDelegate::paint(painter, option, index);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue