diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index 293277de2..5fb725936 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -21,6 +21,7 @@ #include "util/FormatTime.hpp" #include "util/Helpers.hpp" #include "util/IncognitoBrowser.hpp" +#include "util/Qt.hpp" #include "util/StreamLink.hpp" #include "util/Twitch.hpp" #include "widgets/Window.hpp" @@ -156,7 +157,7 @@ bool appendWhisperMessageWordsLocally(const QStringList &words) bool appendWhisperMessageStringLocally(const QString &textNoEmoji) { QString text = getApp()->emotes->emojis.replaceShortCodes(textNoEmoji); - QStringList words = text.split(' ', QString::SkipEmptyParts); + QStringList words = text.split(' ', Qt::SkipEmptyParts); if (words.length() == 0) { @@ -970,7 +971,7 @@ QString CommandController::execCommand(const QString &textNoEmoji, ChannelPtr channel, bool dryRun) { QString text = getApp()->emotes->emojis.replaceShortCodes(textNoEmoji); - QStringList words = text.split(' ', QString::SkipEmptyParts); + QStringList words = text.split(' ', Qt::SkipEmptyParts); if (words.length() == 0) { @@ -1007,7 +1008,7 @@ QString CommandController::execCommand(const QString &textNoEmoji, text = getApp()->emotes->emojis.replaceShortCodes( this->execCustomCommand(words, it.value(), dryRun, channel)); - words = text.split(' ', QString::SkipEmptyParts); + words = text.split(' ', Qt::SkipEmptyParts); if (words.length() == 0) { diff --git a/src/messages/search/AuthorPredicate.cpp b/src/messages/search/AuthorPredicate.cpp index 8e1b73280..77e02b296 100644 --- a/src/messages/search/AuthorPredicate.cpp +++ b/src/messages/search/AuthorPredicate.cpp @@ -1,5 +1,7 @@ #include "messages/search/AuthorPredicate.hpp" +#include "util/Qt.hpp" + namespace chatterino { AuthorPredicate::AuthorPredicate(const QStringList &authors) @@ -8,7 +10,7 @@ AuthorPredicate::AuthorPredicate(const QStringList &authors) // Check if any comma-seperated values were passed and transform those for (const auto &entry : authors) { - for (const auto &author : entry.split(',', QString::SkipEmptyParts)) + for (const auto &author : entry.split(',', Qt::SkipEmptyParts)) { this->authors_ << author; } diff --git a/src/messages/search/ChannelPredicate.cpp b/src/messages/search/ChannelPredicate.cpp index 0c1980c1f..798c2df52 100644 --- a/src/messages/search/ChannelPredicate.cpp +++ b/src/messages/search/ChannelPredicate.cpp @@ -1,5 +1,7 @@ #include "messages/search/ChannelPredicate.hpp" +#include "util/Qt.hpp" + namespace chatterino { ChannelPredicate::ChannelPredicate(const QStringList &channels) @@ -8,7 +10,7 @@ ChannelPredicate::ChannelPredicate(const QStringList &channels) // Check if any comma-seperated values were passed and transform those for (const auto &entry : channels) { - for (const auto &channel : entry.split(',', QString::SkipEmptyParts)) + for (const auto &channel : entry.split(',', Qt::SkipEmptyParts)) { this->channels_ << channel; } diff --git a/src/messages/search/LinkPredicate.cpp b/src/messages/search/LinkPredicate.cpp index 41fec567b..45860a236 100644 --- a/src/messages/search/LinkPredicate.cpp +++ b/src/messages/search/LinkPredicate.cpp @@ -1,5 +1,7 @@ #include "messages/search/LinkPredicate.hpp" + #include "common/LinkParser.hpp" +#include "util/Qt.hpp" namespace chatterino { @@ -9,8 +11,7 @@ LinkPredicate::LinkPredicate() bool LinkPredicate::appliesTo(const Message &message) { - for (const auto &word : - message.messageText.split(' ', QString::SkipEmptyParts)) + for (const auto &word : message.messageText.split(' ', Qt::SkipEmptyParts)) { if (LinkParser(word).hasMatch()) return true; diff --git a/src/messages/search/MessageFlagsPredicate.cpp b/src/messages/search/MessageFlagsPredicate.cpp index a1d2cbeeb..01a124020 100644 --- a/src/messages/search/MessageFlagsPredicate.cpp +++ b/src/messages/search/MessageFlagsPredicate.cpp @@ -1,12 +1,14 @@ #include "messages/search/MessageFlagsPredicate.hpp" +#include "util/Qt.hpp" + namespace chatterino { MessageFlagsPredicate::MessageFlagsPredicate(const QString &flags) : flags_() { // Check if any comma-seperated values were passed and transform those - for (const auto &flag : flags.split(',', QString::SkipEmptyParts)) + for (const auto &flag : flags.split(',', Qt::SkipEmptyParts)) { if (flag == "deleted" || flag == "disabled") { diff --git a/src/util/Qt.hpp b/src/util/Qt.hpp new file mode 100644 index 000000000..1187953d8 --- /dev/null +++ b/src/util/Qt.hpp @@ -0,0 +1,9 @@ +#pragma once + +#include + +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) +namespace Qt { +const QString::SplitBehavior SkipEmptyParts = QString::SkipEmptyParts; +} +#endif diff --git a/src/widgets/settingspages/CommandPage.cpp b/src/widgets/settingspages/CommandPage.cpp index 9533489d1..ea43105e1 100644 --- a/src/widgets/settingspages/CommandPage.cpp +++ b/src/widgets/settingspages/CommandPage.cpp @@ -15,6 +15,7 @@ #include "widgets/helper/EditableModelView.hpp" //#include "widgets/helper/ComboBoxItemDelegate.hpp" #include "util/CombinePath.hpp" +#include "util/Qt.hpp" #include #include @@ -59,9 +60,9 @@ CommandPage::CommandPage() QObject::connect(button, &QPushButton::clicked, this, [] { QFile c1settings = c1settingsPath(); c1settings.open(QIODevice::ReadOnly); - for (auto line : QString(c1settings.readAll()) - .split(QRegularExpression("[\r\n]"), - QString::SkipEmptyParts)) + for (auto line : + QString(c1settings.readAll()) + .split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts)) { if (int index = line.indexOf(' '); index != -1) {