chore: remove old Qt 5.12 code, update docs and FreeBSD runner (#5396)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -124,15 +124,6 @@ LinkParser::LinkParser(const QString &unparsedString)
|
||||
QStringView remaining(unparsedString);
|
||||
QStringView protocol(remaining);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
QStringView wholeString(unparsedString);
|
||||
const auto refFromView = [&](QStringView view) {
|
||||
return QStringRef(&unparsedString,
|
||||
static_cast<int>(view.begin() - wholeString.begin()),
|
||||
static_cast<int>(view.size()));
|
||||
};
|
||||
#endif
|
||||
|
||||
// Check protocol for https?://
|
||||
if (remaining.startsWith(QStringLiteral("http"), Qt::CaseInsensitive) &&
|
||||
remaining.length() >= 4 + 3 + 1) // 'http' + '://' + [any]
|
||||
@@ -149,12 +140,7 @@ LinkParser::LinkParser(const QString &unparsedString)
|
||||
{
|
||||
// there's really a protocol => consume it
|
||||
remaining = withProto.mid(3);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
result.protocol = {protocol.begin(), remaining.begin()};
|
||||
#else
|
||||
result.protocol =
|
||||
refFromView({protocol.begin(), remaining.begin()});
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,13 +205,8 @@ LinkParser::LinkParser(const QString &unparsedString)
|
||||
if ((nDots == 3 && isValidIpv4(host)) ||
|
||||
isValidTld(host.mid(lastDotPos + 1)))
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
result.host = host;
|
||||
result.rest = rest;
|
||||
#else
|
||||
result.host = refFromView(host);
|
||||
result.rest = refFromView(rest);
|
||||
#endif
|
||||
result.source = unparsedString;
|
||||
this->result_ = std::move(result);
|
||||
}
|
||||
|
||||
@@ -7,28 +7,23 @@
|
||||
namespace chatterino {
|
||||
|
||||
struct ParsedLink {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
using StringView = QStringView;
|
||||
#else
|
||||
using StringView = QStringRef;
|
||||
#endif
|
||||
/// The parsed protocol of the link. Can be empty.
|
||||
///
|
||||
/// https://www.forsen.tv/commands
|
||||
/// ^------^
|
||||
StringView protocol;
|
||||
QStringView protocol;
|
||||
|
||||
/// The parsed host of the link. Can not be empty.
|
||||
///
|
||||
/// https://www.forsen.tv/commands
|
||||
/// ^-----------^
|
||||
StringView host;
|
||||
QStringView host;
|
||||
|
||||
/// The remainder of the link. Can be empty.
|
||||
///
|
||||
/// https://www.forsen.tv/commands
|
||||
/// ^-------^
|
||||
StringView rest;
|
||||
QStringView rest;
|
||||
|
||||
/// The original unparsed link.
|
||||
///
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include "singletons/Paths.hpp"
|
||||
#include "util/CombinePath.hpp"
|
||||
#include "util/QStringHash.hpp"
|
||||
#include "util/Qt.hpp"
|
||||
|
||||
#include <QString>
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "singletons/Resources.hpp"
|
||||
#include "singletons/Theme.hpp"
|
||||
#include "util/FormatTime.hpp"
|
||||
#include "util/Qt.hpp"
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include "singletons/StreamerMode.hpp"
|
||||
#include "singletons/WindowManager.hpp"
|
||||
#include "util/Helpers.hpp"
|
||||
#include "util/Qt.hpp"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "messages/search/AuthorPredicate.hpp"
|
||||
|
||||
#include "messages/Message.hpp"
|
||||
#include "util/Qt.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "messages/Message.hpp"
|
||||
#include "providers/twitch/TwitchBadge.hpp"
|
||||
#include "util/Qt.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "messages/search/ChannelPredicate.hpp"
|
||||
|
||||
#include "messages/Message.hpp"
|
||||
#include "util/Qt.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "common/LinkParser.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "util/Qt.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#include "messages/search/MessageFlagsPredicate.hpp"
|
||||
|
||||
#include "util/Qt.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
MessageFlagsPredicate::MessageFlagsPredicate(const QString &flags, bool negate)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "messages/Message.hpp"
|
||||
#include "providers/twitch/TwitchBadge.hpp"
|
||||
#include "util/Qt.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include "util/Helpers.hpp"
|
||||
#include "util/IrcHelpers.hpp"
|
||||
#include "util/QStringHash.hpp"
|
||||
#include "util/Qt.hpp"
|
||||
#include "widgets/Window.hpp"
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
@@ -382,13 +381,7 @@ namespace {
|
||||
dst.reserve(newLength);
|
||||
for (const QStringView &chunk : std::as_const(chunks))
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
|
||||
static_assert(sizeof(QChar) == sizeof(decltype(*chunk.utf16())));
|
||||
dst.append(reinterpret_cast<const QChar *>(chunk.utf16()),
|
||||
chunk.length());
|
||||
#else
|
||||
dst += chunk;
|
||||
#endif
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
@@ -1178,13 +1171,8 @@ void TwitchMessageBuilder::processIgnorePhrases(
|
||||
shiftIndicesAfter(static_cast<int>(from + length),
|
||||
static_cast<int>(replacement.length() - length));
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
auto midExtendedRef =
|
||||
QStringView{originalMessage}.mid(wordStart, wordEnd - wordStart);
|
||||
#else
|
||||
auto midExtendedRef =
|
||||
originalMessage.midRef(wordStart, wordEnd - wordStart);
|
||||
#endif
|
||||
|
||||
for (auto &emote : removedEmotes)
|
||||
{
|
||||
|
||||
@@ -85,11 +85,7 @@ void DebugCount::decrease(const QString &name, const int64_t &amount)
|
||||
|
||||
QString DebugCount::getDebugText()
|
||||
{
|
||||
#if QT_VERSION > QT_VERSION_CHECK(5, 13, 0)
|
||||
static const QLocale locale(QLocale::English);
|
||||
#else
|
||||
static QLocale locale(QLocale::English);
|
||||
#endif
|
||||
|
||||
auto counts = COUNTS.access();
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace chatterino {
|
||||
|
||||
namespace _helpers_internal {
|
||||
|
||||
SizeType skipSpace(StringView view, SizeType startPos)
|
||||
SizeType skipSpace(QStringView view, SizeType startPos)
|
||||
{
|
||||
while (startPos < view.length() && view.at(startPos).isSpace())
|
||||
{
|
||||
@@ -20,7 +20,7 @@ namespace _helpers_internal {
|
||||
return startPos - 1;
|
||||
}
|
||||
|
||||
bool matchesIgnorePlural(StringView word, const QString &expected)
|
||||
bool matchesIgnorePlural(QStringView word, const QString &expected)
|
||||
{
|
||||
if (!word.startsWith(expected))
|
||||
{
|
||||
@@ -34,7 +34,7 @@ namespace _helpers_internal {
|
||||
word.at(word.length() - 1).toLatin1() == 's';
|
||||
}
|
||||
|
||||
std::pair<uint64_t, bool> findUnitMultiplierToSec(StringView view,
|
||||
std::pair<uint64_t, bool> findUnitMultiplierToSec(QStringView view,
|
||||
SizeType &pos)
|
||||
{
|
||||
// Step 1. find end of unit
|
||||
@@ -207,11 +207,7 @@ int64_t parseDurationToSeconds(const QString &inputString,
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2)
|
||||
StringView input(inputString);
|
||||
#else
|
||||
StringView input(&inputString);
|
||||
#endif
|
||||
QStringView input(inputString);
|
||||
input = input.trimmed();
|
||||
|
||||
uint64_t currentValue = 0;
|
||||
|
||||
+4
-13
@@ -4,10 +4,6 @@
|
||||
#include <QLocale>
|
||||
#include <QString>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
|
||||
# include <QStringRef>
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
@@ -17,12 +13,7 @@ namespace chatterino {
|
||||
// only qualified for tests
|
||||
namespace _helpers_internal {
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2)
|
||||
using StringView = QStringView;
|
||||
#else
|
||||
using StringView = QStringRef;
|
||||
#endif
|
||||
using SizeType = StringView::size_type;
|
||||
using SizeType = QStringView::size_type;
|
||||
|
||||
/**
|
||||
* Skips all spaces.
|
||||
@@ -32,7 +23,7 @@ namespace _helpers_internal {
|
||||
* @param startPos The starting position (there must be a space in the view).
|
||||
* @return The position of the last space.
|
||||
*/
|
||||
SizeType skipSpace(StringView view, SizeType startPos);
|
||||
SizeType skipSpace(QStringView view, SizeType startPos);
|
||||
|
||||
/**
|
||||
* Checks if `word` equals `expected` (singular) or `expected` + 's' (plural).
|
||||
@@ -41,7 +32,7 @@ namespace _helpers_internal {
|
||||
* @param expected Singular of the expected word.
|
||||
* @return true if `word` is singular or plural of `expected`.
|
||||
*/
|
||||
bool matchesIgnorePlural(StringView word, const QString &expected);
|
||||
bool matchesIgnorePlural(QStringView word, const QString &expected);
|
||||
|
||||
/**
|
||||
* Tries to find the unit starting at `pos` and returns its multiplier so
|
||||
@@ -58,7 +49,7 @@ namespace _helpers_internal {
|
||||
* if it's a valid unit, undefined otherwise.
|
||||
* @return (multiplier, ok)
|
||||
*/
|
||||
std::pair<uint64_t, bool> findUnitMultiplierToSec(StringView view,
|
||||
std::pair<uint64_t, bool> findUnitMultiplierToSec(QStringView view,
|
||||
SizeType &pos);
|
||||
|
||||
} // namespace _helpers_internal
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include <QHash>
|
||||
#include <QString>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <>
|
||||
@@ -17,17 +15,3 @@ struct hash<QString> {
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
namespace std {
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
template <>
|
||||
struct hash<QString> {
|
||||
std::size_t operator()(const QString &s) const
|
||||
{
|
||||
return qHash(s);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace std
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
namespace Qt {
|
||||
const QString::SplitBehavior SkipEmptyParts = QString::SkipEmptyParts;
|
||||
}
|
||||
#endif
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "util/XDGDirectory.hpp"
|
||||
|
||||
#include "util/CombinePath.hpp"
|
||||
#include "util/Qt.hpp"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "common/Literals.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
#include "util/CombinePath.hpp"
|
||||
#include "util/Qt.hpp"
|
||||
#include "util/XDGDesktopFile.hpp"
|
||||
#include "util/XDGDirectory.hpp"
|
||||
|
||||
|
||||
@@ -77,11 +77,7 @@ QString ResizingTextEdit::textUnderCursor(bool *hadSpace) const
|
||||
|
||||
auto textUpToCursor = currentText.left(tc.selectionStart());
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
auto words = QStringView{textUpToCursor}.split(' ');
|
||||
#else
|
||||
auto words = textUpToCursor.splitRef(' ');
|
||||
#endif
|
||||
if (words.size() == 0)
|
||||
{
|
||||
return QString();
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "singletons/Settings.hpp"
|
||||
#include "util/CombinePath.hpp"
|
||||
#include "util/LayoutCreator.hpp"
|
||||
#include "util/Qt.hpp"
|
||||
#include "util/StandardItemHelper.hpp"
|
||||
#include "widgets/helper/EditableModelView.hpp"
|
||||
|
||||
|
||||
@@ -226,20 +226,16 @@ void SplitInput::themeChangedEvent()
|
||||
QPalette placeholderPalette;
|
||||
|
||||
palette.setColor(QPalette::WindowText, this->theme->splits.input.text);
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||
placeholderPalette.setColor(
|
||||
QPalette::PlaceholderText,
|
||||
this->theme->messages.textColors.chatPlaceholder);
|
||||
#endif
|
||||
|
||||
this->updateEmoteButton();
|
||||
this->updateCancelReplyButton();
|
||||
this->ui_.textEditLength->setPalette(palette);
|
||||
|
||||
this->ui_.textEdit->setStyleSheet(this->theme->splits.input.styleSheet);
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||
this->ui_.textEdit->setPalette(placeholderPalette);
|
||||
#endif
|
||||
auto marginPx = static_cast<int>(2.F * this->scale());
|
||||
this->ui_.vbox->setContentsMargins(marginPx, marginPx, marginPx, marginPx);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user