Merge pull request #17453 from Chocobo1/i18n

Fix empty string parameter was omitted
This commit is contained in:
Chocobo1
2022-07-30 14:30:12 +08:00
committed by GitHub
6 changed files with 173 additions and 56 deletions

View File

@@ -33,6 +33,7 @@
#include <QLocale>
#include <QRegularExpression>
#include <QStringList>
#include <QVector>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
@@ -76,6 +77,42 @@ QString Utils::String::wildcardToRegexPattern(const QString &pattern)
}
#endif
QStringList Utils::String::splitCommand(const QString &command)
{
QStringList ret;
ret.reserve(32);
bool inQuotes = false;
QString tmp;
for (const QChar c : command)
{
if (c == u' ')
{
if (!inQuotes)
{
if (!tmp.isEmpty())
{
ret.append(tmp);
tmp.clear();
}
continue;
}
}
else if (c == u'"')
{
inQuotes = !inQuotes;
}
tmp.append(c);
}
if (!tmp.isEmpty())
ret.append(tmp);
return ret;
}
std::optional<bool> Utils::String::parseBool(const QString &string)
{
if (string.compare(u"true", Qt::CaseInsensitive) == 0)

View File

@@ -61,6 +61,8 @@ namespace Utils::String
std::optional<int> parseInt(const QString &string);
std::optional<double> parseDouble(const QString &string);
QStringList splitCommand(const QString &command);
QString join(const QList<QStringView> &strings, QStringView separator);
QString fromDouble(double n, int precision);