2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Replaced some qstr with u""_q literal.

This commit is contained in:
23rd
2022-11-27 00:20:17 +03:00
parent 22dc7023fc
commit 2acedca6b7
99 changed files with 477 additions and 480 deletions

View File

@@ -44,24 +44,24 @@ constexpr auto kShortPollTimeout = crl::time(3000);
constexpr auto kRememberCredentialsDelay = crl::time(1800 * 1000);
bool ForwardServiceErrorRequired(const QString &error) {
return (error == qstr("BOT_INVALID"))
|| (error == qstr("PUBLIC_KEY_REQUIRED"))
|| (error == qstr("PUBLIC_KEY_INVALID"))
|| (error == qstr("SCOPE_EMPTY"))
|| (error == qstr("PAYLOAD_EMPTY"));
return (error == u"BOT_INVALID"_q)
|| (error == u"PUBLIC_KEY_REQUIRED"_q)
|| (error == u"PUBLIC_KEY_INVALID"_q)
|| (error == u"SCOPE_EMPTY"_q)
|| (error == u"PAYLOAD_EMPTY"_q);
}
bool SaveErrorRequiresRestart(const QString &error) {
return (error == qstr("PASSWORD_REQUIRED"))
|| (error == qstr("SECURE_SECRET_REQUIRED"))
|| (error == qstr("SECURE_SECRET_INVALID"));
return (error == u"PASSWORD_REQUIRED"_q)
|| (error == u"SECURE_SECRET_REQUIRED"_q)
|| (error == u"SECURE_SECRET_INVALID"_q);
}
bool AcceptErrorRequiresRestart(const QString &error) {
return (error == qstr("PASSWORD_REQUIRED"))
|| (error == qstr("SECURE_SECRET_REQUIRED"))
|| (error == qstr("SECURE_VALUE_EMPTY"))
|| (error == qstr("SECURE_VALUE_HASH_INVALID"));
return (error == u"PASSWORD_REQUIRED"_q)
|| (error == u"SECURE_SECRET_REQUIRED"_q)
|| (error == u"SECURE_VALUE_EMPTY"_q)
|| (error == u"SECURE_VALUE_HASH_INVALID"_q);
}
std::map<QString, QString> GetTexts(const ValueMap &map) {
@@ -884,7 +884,7 @@ void FormController::submitPassword(
}
}).fail([=](const MTP::Error &error) {
_passwordCheckRequestId = 0;
if (error.type() == qstr("SRP_ID_INVALID")) {
if (error.type() == u"SRP_ID_INVALID"_q) {
handleSrpIdInvalid(_passwordCheckRequestId);
} else if (submitSaved) {
// Force reload and show form.
@@ -892,8 +892,8 @@ void FormController::submitPassword(
reloadPassword();
} else if (MTP::IsFloodError(error)) {
_passwordError.fire(tr::lng_flood_error(tr::now));
} else if (error.type() == qstr("PASSWORD_HASH_INVALID")
|| error.type() == qstr("SRP_PASSWORD_CHANGED")) {
} else if (error.type() == u"PASSWORD_HASH_INVALID"_q
|| error.type() == u"SRP_PASSWORD_CHANGED"_q) {
_passwordError.fire(tr::lng_passport_password_wrong(tr::now));
} else {
_passwordError.fire_copy(error.type());
@@ -963,7 +963,7 @@ void FormController::checkSavedPasswordSettings(
}
}).fail([=](const MTP::Error &error) {
_passwordCheckRequestId = 0;
if (error.type() != qstr("SRP_ID_INVALID")
if (error.type() != u"SRP_ID_INVALID"_q
|| !handleSrpIdInvalid(_passwordCheckRequestId)) {
} else {
session().data().forgetPassportCredentials();
@@ -1126,7 +1126,7 @@ void FormController::resetSecret(
generateSecret(password);
}).fail([=](const MTP::Error &error) {
_saveSecretRequestId = 0;
if (error.type() != qstr("SRP_ID_INVALID")
if (error.type() != u"SRP_ID_INVALID"_q
|| !handleSrpIdInvalid(_saveSecretRequestId)) {
formFail(error.type());
}
@@ -1709,7 +1709,7 @@ void FormController::verify(
clearValueVerification(nonconst);
}).fail([=](const MTP::Error &error) {
nonconst->verification.requestId = 0;
if (error.type() == qstr("PHONE_CODE_INVALID")) {
if (error.type() == u"PHONE_CODE_INVALID"_q) {
verificationError(
nonconst,
tr::lng_signin_wrong_code(tr::now));
@@ -1726,7 +1726,7 @@ void FormController::verify(
clearValueVerification(nonconst);
}).fail([=](const MTP::Error &error) {
nonconst->verification.requestId = 0;
if (error.type() == qstr("CODE_INVALID")) {
if (error.type() == u"CODE_INVALID"_q) {
verificationError(
nonconst,
tr::lng_signin_wrong_code(tr::now));
@@ -2107,24 +2107,24 @@ void FormController::sendSaveRequest(
value->saveRequestId = 0;
const auto code = error.type();
if (handleAppUpdateError(code)) {
} else if (code == qstr("PHONE_VERIFICATION_NEEDED")) {
} else if (code == u"PHONE_VERIFICATION_NEEDED"_q) {
if (value->type == Value::Type::Phone) {
startPhoneVerification(value);
return;
}
} else if (code == qstr("PHONE_NUMBER_INVALID")) {
} else if (code == u"PHONE_NUMBER_INVALID"_q) {
if (value->type == Value::Type::Phone) {
value->data.parsedInEdit.fields["value"].error
= tr::lng_bad_phone(tr::now);
valueSaveFailed(value);
return;
}
} else if (code == qstr("EMAIL_VERIFICATION_NEEDED")) {
} else if (code == u"EMAIL_VERIFICATION_NEEDED"_q) {
if (value->type == Value::Type::Email) {
startEmailVerification(value);
return;
}
} else if (code == qstr("EMAIL_INVALID")) {
} else if (code == u"EMAIL_INVALID"_q) {
if (value->type == Value::Type::Email) {
value->data.parsedInEdit.fields["value"].error
= tr::lng_cloud_password_bad_email(tr::now);
@@ -2325,7 +2325,7 @@ void FormController::saveSecret(
}
}).fail([=](const MTP::Error &error) {
_saveSecretRequestId = 0;
if (error.type() != qstr("SRP_ID_INVALID")
if (error.type() != u"SRP_ID_INVALID"_q
|| !handleSrpIdInvalid(_saveSecretRequestId)) {
suggestRestart();
}
@@ -2608,7 +2608,7 @@ void FormController::formFail(const QString &error) {
}
bool FormController::handleAppUpdateError(const QString &error) {
if (error == qstr("APP_VERSION_OUTDATED")) {
if (error == u"APP_VERSION_OUTDATED"_q) {
_view->showUpdateAppBox();
return true;
}

View File

@@ -128,9 +128,9 @@ EditDocumentScheme GetDocumentScheme(
return result.isEmpty() ? value : result;
};
const auto GenderFormat = [](const QString &value) {
if (value == qstr("male")) {
if (value == u"male"_q) {
return tr::lng_passport_gender_male(tr::now);
} else if (value == qstr("female")) {
} else if (value == u"female"_q) {
return tr::lng_passport_gender_female(tr::now);
}
return value;
@@ -179,7 +179,7 @@ EditDocumentScheme GetDocumentScheme(
return value.isEmpty() || DateValidateBoolean(value);
});
const auto GenderValidate = FromBoolean([](const QString &value) {
return value == qstr("male") || value == qstr("female");
return value == u"male"_q || value == u"female"_q;
});
const auto CountryValidate = FromBoolean([=](const QString &value) {
return !CountryFormat(value).isEmpty();

View File

@@ -885,9 +885,9 @@ std::unique_ptr<AbstractCheckView> GenderRow::createRadioView(
auto GenderRow::StringToGender(const QString &value)
-> std::optional<Gender> {
if (value == qstr("male")) {
if (value == u"male"_q) {
return Gender::Male;
} else if (value == qstr("female")) {
} else if (value == u"female"_q) {
return Gender::Female;
}
return std::nullopt;