mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-03 21:54:05 +02:00
Instantiate QRegularExpression instances statically
This commit is contained in:
parent
4b297bfa09
commit
e6b9a07163
18 changed files with 74 additions and 47 deletions
|
@ -113,7 +113,8 @@ Base64UrlInput::Base64UrlInput(
|
||||||
rpl::producer<QString> placeholder,
|
rpl::producer<QString> placeholder,
|
||||||
const QString &val)
|
const QString &val)
|
||||||
: MaskedInputField(parent, st, std::move(placeholder), val) {
|
: MaskedInputField(parent, st, std::move(placeholder), val) {
|
||||||
if (!QRegularExpression("^[a-zA-Z0-9_\\-]+$").match(val).hasMatch()) {
|
static const auto RegExp = QRegularExpression("^[a-zA-Z0-9_\\-]+$");
|
||||||
|
if (!RegExp.match(val).hasMatch()) {
|
||||||
setText(QString());
|
setText(QString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -831,8 +832,9 @@ void ProxyBox::prepare() {
|
||||||
connect(_host.data(), &HostInput::changed, [=] {
|
connect(_host.data(), &HostInput::changed, [=] {
|
||||||
Ui::PostponeCall(_host, [=] {
|
Ui::PostponeCall(_host, [=] {
|
||||||
const auto host = _host->getLastText().trimmed();
|
const auto host = _host->getLastText().trimmed();
|
||||||
static const auto mask = u"^\\d+\\.\\d+\\.\\d+\\.\\d+:(\\d*)$"_q;
|
static const auto mask = QRegularExpression(
|
||||||
const auto match = QRegularExpression(mask).match(host);
|
u"^\\d+\\.\\d+\\.\\d+\\.\\d+:(\\d*)$"_q);
|
||||||
|
const auto match = mask.match(host);
|
||||||
if (_host->cursorPosition() == host.size()
|
if (_host->cursorPosition() == host.size()
|
||||||
&& match.hasMatch()) {
|
&& match.hasMatch()) {
|
||||||
const auto port = match.captured(1);
|
const auto port = match.captured(1);
|
||||||
|
@ -1107,6 +1109,10 @@ void ProxiesBoxController::ShowApplyConfirmation(
|
||||||
proxy.password = fields.value(u"secret"_q);
|
proxy.password = fields.value(u"secret"_q);
|
||||||
}
|
}
|
||||||
if (proxy) {
|
if (proxy) {
|
||||||
|
static const auto UrlStartRegExp = QRegularExpression(
|
||||||
|
"^https://",
|
||||||
|
QRegularExpression::CaseInsensitiveOption);
|
||||||
|
static const auto UrlEndRegExp = QRegularExpression("/$");
|
||||||
const auto displayed = "https://" + server + "/";
|
const auto displayed = "https://" + server + "/";
|
||||||
const auto parsed = QUrl::fromUserInput(displayed);
|
const auto parsed = QUrl::fromUserInput(displayed);
|
||||||
const auto displayUrl = !UrlClickHandler::IsSuspicious(displayed)
|
const auto displayUrl = !UrlClickHandler::IsSuspicious(displayed)
|
||||||
|
@ -1117,11 +1123,9 @@ void ProxiesBoxController::ShowApplyConfirmation(
|
||||||
const auto displayServer = QString(
|
const auto displayServer = QString(
|
||||||
displayUrl
|
displayUrl
|
||||||
).replace(
|
).replace(
|
||||||
QRegularExpression(
|
UrlStartRegExp,
|
||||||
"^https://",
|
|
||||||
QRegularExpression::CaseInsensitiveOption),
|
|
||||||
QString()
|
QString()
|
||||||
).replace(QRegularExpression("/$"), QString());
|
).replace(UrlEndRegExp, QString());
|
||||||
const auto text = tr::lng_sure_enable_socks(
|
const auto text = tr::lng_sure_enable_socks(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_server,
|
lt_server,
|
||||||
|
|
|
@ -542,9 +542,13 @@ void Launcher::processArguments() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const auto RegExp = QRegularExpression("[^a-z0-9\\-_]");
|
||||||
gDebugMode = parseResult.contains("-debug");
|
gDebugMode = parseResult.contains("-debug");
|
||||||
gKeyFile = parseResult.value("-key", {}).join(QString()).toLower();
|
gKeyFile = parseResult
|
||||||
gKeyFile = gKeyFile.replace(QRegularExpression("[^a-z0-9\\-_]"), {});
|
.value("-key", {})
|
||||||
|
.join(QString())
|
||||||
|
.toLower()
|
||||||
|
.replace(RegExp, {});
|
||||||
gLaunchMode = parseResult.contains("-autostart") ? LaunchModeAutoStart
|
gLaunchMode = parseResult.contains("-autostart") ? LaunchModeAutoStart
|
||||||
: parseResult.contains("-fixprevious") ? LaunchModeFixPrevious
|
: parseResult.contains("-fixprevious") ? LaunchModeFixPrevious
|
||||||
: parseResult.contains("-cleanup") ? LaunchModeCleanup
|
: parseResult.contains("-cleanup") ? LaunchModeCleanup
|
||||||
|
|
|
@ -241,7 +241,7 @@ QString FindUpdateFile() {
|
||||||
}
|
}
|
||||||
const auto list = updates.entryInfoList(QDir::Files);
|
const auto list = updates.entryInfoList(QDir::Files);
|
||||||
for (const auto &info : list) {
|
for (const auto &info : list) {
|
||||||
if (QRegularExpression(
|
static const auto RegExp = QRegularExpression(
|
||||||
"^("
|
"^("
|
||||||
"tupdate|"
|
"tupdate|"
|
||||||
"tx64upd|"
|
"tx64upd|"
|
||||||
|
@ -250,7 +250,8 @@ QString FindUpdateFile() {
|
||||||
"tlinuxupd|"
|
"tlinuxupd|"
|
||||||
")\\d+(_[a-z\\d]+)?$",
|
")\\d+(_[a-z\\d]+)?$",
|
||||||
QRegularExpression::CaseInsensitiveOption
|
QRegularExpression::CaseInsensitiveOption
|
||||||
).match(info.fileName()).hasMatch()) {
|
);
|
||||||
|
if (RegExp.match(info.fileName()).hasMatch()) {
|
||||||
return info.absoluteFilePath();
|
return info.absoluteFilePath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,8 @@ void PhoneWidget::submit() {
|
||||||
|
|
||||||
// Check if such account is authorized already.
|
// Check if such account is authorized already.
|
||||||
const auto digitsOnly = [](QString value) {
|
const auto digitsOnly = [](QString value) {
|
||||||
return value.replace(QRegularExpression("[^0-9]"), QString());
|
static const auto RegExp = QRegularExpression("[^0-9]");
|
||||||
|
return value.replace(RegExp, QString());
|
||||||
};
|
};
|
||||||
const auto phoneDigits = digitsOnly(phone);
|
const auto phoneDigits = digitsOnly(phone);
|
||||||
for (const auto &[index, existing] : Core::App().domain().accounts()) {
|
for (const auto &[index, existing] : Core::App().domain().accounts()) {
|
||||||
|
|
|
@ -1354,8 +1354,11 @@ bool Instance::Private::onErrorDefault(
|
||||||
const auto &type = error.type();
|
const auto &type = error.type();
|
||||||
const auto code = error.code();
|
const auto code = error.code();
|
||||||
auto badGuestDc = (code == 400) && (type == u"FILE_ID_INVALID"_q);
|
auto badGuestDc = (code == 400) && (type == u"FILE_ID_INVALID"_q);
|
||||||
|
static const auto MigrateRegExp = QRegularExpression("^(FILE|PHONE|NETWORK|USER)_MIGRATE_(\\d+)$");
|
||||||
|
static const auto FloodWaitRegExp = QRegularExpression("^FLOOD_WAIT_(\\d+)$");
|
||||||
|
static const auto SlowmodeWaitRegExp = QRegularExpression("^SLOWMODE_WAIT_(\\d+)$");
|
||||||
QRegularExpressionMatch m1, m2;
|
QRegularExpressionMatch m1, m2;
|
||||||
if ((m1 = QRegularExpression("^(FILE|PHONE|NETWORK|USER)_MIGRATE_(\\d+)$").match(type)).hasMatch()) {
|
if ((m1 = MigrateRegExp.match(type)).hasMatch()) {
|
||||||
if (!requestId) return false;
|
if (!requestId) return false;
|
||||||
|
|
||||||
auto dcWithShift = ShiftedDcId(0);
|
auto dcWithShift = ShiftedDcId(0);
|
||||||
|
@ -1458,8 +1461,8 @@ bool Instance::Private::onErrorDefault(
|
||||||
return true;
|
return true;
|
||||||
} else if (code < 0
|
} else if (code < 0
|
||||||
|| code >= 500
|
|| code >= 500
|
||||||
|| (m1 = QRegularExpression("^FLOOD_WAIT_(\\d+)$").match(type)).hasMatch()
|
|| (m1 = FloodWaitRegExp.match(type)).hasMatch()
|
||||||
|| ((m2 = QRegularExpression("^SLOWMODE_WAIT_(\\d+)$").match(type)).hasMatch()
|
|| ((m2 = SlowmodeWaitRegExp.match(type)).hasMatch()
|
||||||
&& m2.captured(1).toInt() < 3)) {
|
&& m2.captured(1).toInt() < 3)) {
|
||||||
if (!requestId) return false;
|
if (!requestId) return false;
|
||||||
|
|
||||||
|
|
|
@ -757,8 +757,9 @@ bool DcOptions::loadFromFile(const QString &path) {
|
||||||
stream.setCodec("UTF-8");
|
stream.setCodec("UTF-8");
|
||||||
#endif // Qt < 6.0.0
|
#endif // Qt < 6.0.0
|
||||||
while (!stream.atEnd()) {
|
while (!stream.atEnd()) {
|
||||||
|
static const auto RegExp = QRegularExpression(R"(\s)");
|
||||||
auto line = stream.readLine();
|
auto line = stream.readLine();
|
||||||
auto components = line.split(QRegularExpression(R"(\s)"), Qt::SkipEmptyParts);
|
auto components = line.split(RegExp, Qt::SkipEmptyParts);
|
||||||
if (components.isEmpty() || components[0].startsWith('#')) {
|
if (components.isEmpty() || components[0].startsWith('#')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,11 +157,12 @@ bool ProxyData::supportsCalls() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProxyData::tryCustomResolve() const {
|
bool ProxyData::tryCustomResolve() const {
|
||||||
|
static const auto RegExp = QRegularExpression(
|
||||||
|
QStringLiteral("^\\d+\\.\\d+\\.\\d+\\.\\d+$")
|
||||||
|
);
|
||||||
return (type == Type::Socks5 || type == Type::Mtproto)
|
return (type == Type::Socks5 || type == Type::Mtproto)
|
||||||
&& !qthelp::is_ipv6(host)
|
&& !qthelp::is_ipv6(host)
|
||||||
&& !QRegularExpression(
|
&& !RegExp.match(host).hasMatch();
|
||||||
QStringLiteral("^\\d+\\.\\d+\\.\\d+\\.\\d+$")
|
|
||||||
).match(host).hasMatch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes::vector ProxyData::secretFromMtprotoPassword() const {
|
bytes::vector ProxyData::secretFromMtprotoPassword() const {
|
||||||
|
|
|
@ -25,11 +25,11 @@ namespace {
|
||||||
Error::Error(const MTPrpcError &error)
|
Error::Error(const MTPrpcError &error)
|
||||||
: _code(error.c_rpc_error().verror_code().v) {
|
: _code(error.c_rpc_error().verror_code().v) {
|
||||||
QString text = qs(error.c_rpc_error().verror_message());
|
QString text = qs(error.c_rpc_error().verror_message());
|
||||||
const auto expression = QRegularExpression(
|
static const auto Expression = QRegularExpression(
|
||||||
"^([A-Z0-9_]+)(: .*)?$",
|
"^([A-Z0-9_]+)(: .*)?$",
|
||||||
(QRegularExpression::DotMatchesEverythingOption
|
(QRegularExpression::DotMatchesEverythingOption
|
||||||
| QRegularExpression::MultilineOption));
|
| QRegularExpression::MultilineOption));
|
||||||
const auto match = expression.match(text);
|
const auto match = Expression.match(text);
|
||||||
if (match.hasMatch()) {
|
if (match.hasMatch()) {
|
||||||
_type = match.captured(1);
|
_type = match.captured(1);
|
||||||
_description = match.captured(2).mid(2);
|
_description = match.captured(2).mid(2);
|
||||||
|
|
|
@ -62,8 +62,9 @@ QString InstanceId() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckPhoneByPrefixesRules(const QString &phone, const QString &rules) {
|
bool CheckPhoneByPrefixesRules(const QString &phone, const QString &rules) {
|
||||||
|
static const auto RegExp = QRegularExpression("[^0-9]");
|
||||||
const auto check = QString(phone).replace(
|
const auto check = QString(phone).replace(
|
||||||
QRegularExpression("[^0-9]"),
|
RegExp,
|
||||||
QString());
|
QString());
|
||||||
auto result = false;
|
auto result = false;
|
||||||
for (const auto &prefix : rules.split(',')) {
|
for (const auto &prefix : rules.split(',')) {
|
||||||
|
|
|
@ -152,11 +152,12 @@ EditDocumentScheme GetDocumentScheme(
|
||||||
};
|
};
|
||||||
using Result = std::optional<QString>;
|
using Result = std::optional<QString>;
|
||||||
const auto NameValidate = [](const QString &value) -> Result {
|
const auto NameValidate = [](const QString &value) -> Result {
|
||||||
|
static const auto RegExp = QRegularExpression(
|
||||||
|
"^[a-zA-Z0-9\\.,/&\\-' ]+$"
|
||||||
|
);
|
||||||
if (value.isEmpty() || value.size() > kMaxNameSize) {
|
if (value.isEmpty() || value.size() > kMaxNameSize) {
|
||||||
return QString();
|
return QString();
|
||||||
} else if (!QRegularExpression(
|
} else if (!RegExp.match(value).hasMatch()) {
|
||||||
"^[a-zA-Z0-9\\.,/&\\-' ]+$"
|
|
||||||
).match(value).hasMatch()) {
|
|
||||||
return tr::lng_passport_bad_name(tr::now);
|
return tr::lng_passport_bad_name(tr::now);
|
||||||
}
|
}
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
@ -167,14 +168,16 @@ EditDocumentScheme GetDocumentScheme(
|
||||||
const auto StreetValidate = LimitedValidate(kMaxStreetSize);
|
const auto StreetValidate = LimitedValidate(kMaxStreetSize);
|
||||||
const auto CityValidate = LimitedValidate(kMaxCitySize, kMinCitySize);
|
const auto CityValidate = LimitedValidate(kMaxCitySize, kMinCitySize);
|
||||||
const auto PostcodeValidate = FromBoolean([](const QString &value) {
|
const auto PostcodeValidate = FromBoolean([](const QString &value) {
|
||||||
return QRegularExpression(
|
static const auto RegExp = QRegularExpression(
|
||||||
QString("^[a-zA-Z0-9\\-]{2,%1}$").arg(kMaxPostcodeSize)
|
QString("^[a-zA-Z0-9\\-]{2,%1}$").arg(kMaxPostcodeSize)
|
||||||
).match(value).hasMatch();
|
);
|
||||||
|
return RegExp.match(value).hasMatch();
|
||||||
});
|
});
|
||||||
const auto DateValidateBoolean = [](const QString &value) {
|
const auto DateValidateBoolean = [](const QString &value) {
|
||||||
return QRegularExpression(
|
static const auto RegExp = QRegularExpression(
|
||||||
"^\\d{2}\\.\\d{2}\\.\\d{4}$"
|
"^\\d{2}\\.\\d{2}\\.\\d{4}$"
|
||||||
).match(value).hasMatch();
|
);
|
||||||
|
return RegExp.match(value).hasMatch();
|
||||||
};
|
};
|
||||||
const auto DateValidate = FromBoolean(DateValidateBoolean);
|
const auto DateValidate = FromBoolean(DateValidateBoolean);
|
||||||
const auto DateOrEmptyValidate = FromBoolean([=](const QString &value) {
|
const auto DateOrEmptyValidate = FromBoolean([=](const QString &value) {
|
||||||
|
@ -479,9 +482,8 @@ EditContactScheme GetContactScheme(Scope::Type type) {
|
||||||
result.newHeader = tr::lng_passport_new_phone(tr::now);
|
result.newHeader = tr::lng_passport_new_phone(tr::now);
|
||||||
result.aboutNew = tr::lng_passport_new_phone_code(tr::now);
|
result.aboutNew = tr::lng_passport_new_phone_code(tr::now);
|
||||||
result.validate = [](const QString &value) {
|
result.validate = [](const QString &value) {
|
||||||
return QRegularExpression(
|
static const auto RegExp = QRegularExpression("^\\d{2,12}$");
|
||||||
"^\\d{2,12}$"
|
return RegExp.match(value).hasMatch();
|
||||||
).match(value).hasMatch();
|
|
||||||
};
|
};
|
||||||
result.format = [](const QString &value) {
|
result.format = [](const QString &value) {
|
||||||
return Ui::FormatPhone(value);
|
return Ui::FormatPhone(value);
|
||||||
|
|
|
@ -51,7 +51,8 @@ PostcodeInput::PostcodeInput(
|
||||||
rpl::producer<QString> placeholder,
|
rpl::producer<QString> placeholder,
|
||||||
const QString &val)
|
const QString &val)
|
||||||
: MaskedInputField(parent, st, std::move(placeholder), val) {
|
: MaskedInputField(parent, st, std::move(placeholder), val) {
|
||||||
if (!QRegularExpression("^[a-zA-Z0-9\\-]+$").match(val).hasMatch()) {
|
static const auto RegExp = QRegularExpression("^[a-zA-Z0-9\\-]+$");
|
||||||
|
if (!RegExp.match(val).hasMatch()) {
|
||||||
setText(QString());
|
setText(QString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -414,8 +415,9 @@ void CountryRow::chooseCountry() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QDate ValidateDate(const QString &value) {
|
QDate ValidateDate(const QString &value) {
|
||||||
const auto match = QRegularExpression(
|
static const auto RegExp = QRegularExpression(
|
||||||
"^([0-9]{2})\\.([0-9]{2})\\.([0-9]{4})$").match(value);
|
"^([0-9]{2})\\.([0-9]{2})\\.([0-9]{4})$");
|
||||||
|
const auto match = RegExp.match(value);
|
||||||
if (!match.hasMatch()) {
|
if (!match.hasMatch()) {
|
||||||
return QDate();
|
return QDate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,8 +54,9 @@ bool Card::empty() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Last4(const Card &card) {
|
QString Last4(const Card &card) {
|
||||||
|
static const auto RegExp = QRegularExpression("[^\\d]\\d*(\\d{4})$");
|
||||||
const auto masked = card.maskedNumber();
|
const auto masked = card.maskedNumber();
|
||||||
const auto m = QRegularExpression("[^\\d]\\d*(\\d{4})$").match(masked);
|
const auto m = RegExp.match(masked);
|
||||||
return m.hasMatch() ? m.captured(1) : QString();
|
return m.hasMatch() ? m.captured(1) : QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,11 +90,13 @@ struct BinRange {
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool IsNumeric(const QString &value) {
|
[[nodiscard]] bool IsNumeric(const QString &value) {
|
||||||
return QRegularExpression("^[0-9]*$").match(value).hasMatch();
|
static const auto RegExp = QRegularExpression("^[0-9]*$");
|
||||||
|
return RegExp.match(value).hasMatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] QString RemoveWhitespaces(QString value) {
|
[[nodiscard]] QString RemoveWhitespaces(QString value) {
|
||||||
return value.replace(QRegularExpression("\\s"), QString());
|
static const auto RegExp = QRegularExpression("\\s");
|
||||||
|
return value.replace(RegExp, QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] std::vector<BinRange> BinRangesForNumber(
|
[[nodiscard]] std::vector<BinRange> BinRangesForNumber(
|
||||||
|
|
|
@ -39,7 +39,8 @@ struct SimpleFieldState {
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] QString RemoveNonNumbers(QString value) {
|
[[nodiscard]] QString RemoveNonNumbers(QString value) {
|
||||||
return value.replace(QRegularExpression("[^0-9]"), QString());
|
static const auto RegExp = QRegularExpression("[^0-9]");
|
||||||
|
return value.replace(RegExp, QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] SimpleFieldState NumbersOnlyState(SimpleFieldState state) {
|
[[nodiscard]] SimpleFieldState NumbersOnlyState(SimpleFieldState state) {
|
||||||
|
|
|
@ -36,7 +36,8 @@ struct SimpleFieldState {
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] QString RemoveNonNumbers(QString value) {
|
[[nodiscard]] QString RemoveNonNumbers(QString value) {
|
||||||
return value.replace(QRegularExpression("[^0-9]"), QString());
|
static const auto RegExp = QRegularExpression("[^0-9]");
|
||||||
|
return value.replace(RegExp, QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] SimpleFieldState CleanMoneyState(
|
[[nodiscard]] SimpleFieldState CleanMoneyState(
|
||||||
|
@ -216,6 +217,7 @@ struct SimpleFieldState {
|
||||||
const FieldConfig &config,
|
const FieldConfig &config,
|
||||||
const QString &parsed,
|
const QString &parsed,
|
||||||
const QString &countryIso2) {
|
const QString &countryIso2) {
|
||||||
|
static const auto RegExp = QRegularExpression("[^0-9]\\.");
|
||||||
if (config.type == FieldType::Country) {
|
if (config.type == FieldType::Country) {
|
||||||
return countryIso2;
|
return countryIso2;
|
||||||
} else if (config.type == FieldType::Money) {
|
} else if (config.type == FieldType::Money) {
|
||||||
|
@ -227,16 +229,14 @@ struct SimpleFieldState {
|
||||||
QChar(','),
|
QChar(','),
|
||||||
QChar('.')
|
QChar('.')
|
||||||
).replace(
|
).replace(
|
||||||
QRegularExpression("[^0-9\\.]"),
|
RegExp,
|
||||||
QString()
|
QString()
|
||||||
).toDouble();
|
).toDouble();
|
||||||
return QString::number(
|
return QString::number(
|
||||||
int64(base::SafeRound(real * std::pow(10., rule.exponent))));
|
int64(base::SafeRound(real * std::pow(10., rule.exponent))));
|
||||||
} else if (config.type == FieldType::CardNumber
|
} else if (config.type == FieldType::CardNumber
|
||||||
|| config.type == FieldType::CardCVC) {
|
|| config.type == FieldType::CardCVC) {
|
||||||
return QString(parsed).replace(
|
return QString(parsed).replace(RegExp, QString());
|
||||||
QRegularExpression("[^0-9\\.]"),
|
|
||||||
QString());
|
|
||||||
}
|
}
|
||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,8 @@ Data::StatisticalChart StatisticalChartFromJSON(const QByteArray &json) {
|
||||||
for (auto &line : result.lines) {
|
for (auto &line : result.lines) {
|
||||||
const auto colorIt = colors.constFind(line.idString);
|
const auto colorIt = colors.constFind(line.idString);
|
||||||
if (colorIt != colors.constEnd() && (*colorIt).isString()) {
|
if (colorIt != colors.constEnd() && (*colorIt).isString()) {
|
||||||
const auto match = QRegularExpression(colorPattern).match(
|
static const auto RegExp = QRegularExpression(u"(.*)(#.*)"_q);
|
||||||
|
const auto match = RegExp.match(
|
||||||
colorIt->toString());
|
colorIt->toString());
|
||||||
if (match.hasMatch()) {
|
if (match.hasMatch()) {
|
||||||
line.colorKey = match.captured(1);
|
line.colorKey = match.captured(1);
|
||||||
|
|
|
@ -579,8 +579,9 @@ void writeAutoupdatePrefix(const QString &prefix) {
|
||||||
QString readAutoupdatePrefix() {
|
QString readAutoupdatePrefix() {
|
||||||
Expects(!Core::UpdaterDisabled());
|
Expects(!Core::UpdaterDisabled());
|
||||||
|
|
||||||
|
static const auto RegExp = QRegularExpression("/+$");
|
||||||
auto result = readAutoupdatePrefixRaw();
|
auto result = readAutoupdatePrefixRaw();
|
||||||
return result.replace(QRegularExpression("/+$"), QString());
|
return result.replace(RegExp, QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeBackground(const Data::WallPaper &paper, const QImage &image) {
|
void writeBackground(const Data::WallPaper &paper, const QImage &image) {
|
||||||
|
|
|
@ -234,13 +234,14 @@ void CountrySelectBox::Inner::init() {
|
||||||
}
|
}
|
||||||
auto index = 0;
|
auto index = 0;
|
||||||
for (const auto &info : _list) {
|
for (const auto &info : _list) {
|
||||||
|
static const auto RegExp = QRegularExpression("[\\s\\-]");
|
||||||
auto full = info.country
|
auto full = info.country
|
||||||
+ ' '
|
+ ' '
|
||||||
+ (!info.alternativeName.isEmpty()
|
+ (!info.alternativeName.isEmpty()
|
||||||
? info.alternativeName
|
? info.alternativeName
|
||||||
: QString());
|
: QString());
|
||||||
const auto namesList = std::move(full).toLower().split(
|
const auto namesList = std::move(full).toLower().split(
|
||||||
QRegularExpression("[\\s\\-]"),
|
RegExp,
|
||||||
Qt::SkipEmptyParts);
|
Qt::SkipEmptyParts);
|
||||||
auto &names = _namesList.emplace_back();
|
auto &names = _namesList.emplace_back();
|
||||||
names.reserve(namesList.size());
|
names.reserve(namesList.size());
|
||||||
|
|
Loading…
Add table
Reference in a new issue