Replace QLatin1String with operator _L1

This commit is contained in:
Jonas Kvinge
2024-09-07 04:24:14 +02:00
parent e3e6a22172
commit 4270b12cd1
185 changed files with 2429 additions and 2139 deletions

View File

@@ -65,6 +65,8 @@
#include "settings/settingsdialog.h"
#include "settings/spotifysettingspage.h"
using namespace Qt::StringLiterals;
const Song::Source SpotifyService::kSource = Song::Source::Spotify;
const char SpotifyService::kApiUrl[] = "https://api.spotify.com/v1";
@@ -273,7 +275,7 @@ void SpotifyService::Authenticate() {
code_verifier_ = Utilities::CryptographicRandomString(44);
code_challenge_ = QString::fromLatin1(QCryptographicHash::hash(code_verifier_.toUtf8(), QCryptographicHash::Sha256).toBase64(QByteArray::Base64UrlEncoding));
if (code_challenge_.lastIndexOf(QLatin1Char('=')) == code_challenge_.length() - 1) {
if (code_challenge_.lastIndexOf(u'=') == code_challenge_.length() - 1) {
code_challenge_.chop(1);
}
@@ -424,9 +426,9 @@ void SpotifyService::AccessTokenRequestFinished(QNetworkReply *reply) {
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
if (json_error.error == QJsonParseError::NoError && !json_doc.isEmpty() && json_doc.isObject()) {
QJsonObject json_obj = json_doc.object();
if (!json_obj.isEmpty() && json_obj.contains(QLatin1String("error")) && json_obj.contains(QLatin1String("error_description"))) {
QString error = json_obj[QLatin1String("error")].toString();
QString error_description = json_obj[QLatin1String("error_description")].toString();
if (!json_obj.isEmpty() && json_obj.contains("error"_L1) && json_obj.contains("error_description"_L1)) {
QString error = json_obj["error"_L1].toString();
QString error_description = json_obj["error_description"_L1].toString();
login_errors_ << QStringLiteral("Authentication failure: %1 (%2)").arg(error, error_description);
}
}
@@ -469,16 +471,16 @@ void SpotifyService::AccessTokenRequestFinished(QNetworkReply *reply) {
return;
}
if (!json_obj.contains(QLatin1String("access_token")) || !json_obj.contains(QLatin1String("expires_in"))) {
if (!json_obj.contains("access_token"_L1) || !json_obj.contains("expires_in"_L1)) {
LoginError(QStringLiteral("Authentication reply from server is missing access token or expires in."), json_obj);
return;
}
access_token_ = json_obj[QLatin1String("access_token")].toString();
if (json_obj.contains(QLatin1String("refresh_token"))) {
refresh_token_ = json_obj[QLatin1String("refresh_token")].toString();
access_token_ = json_obj["access_token"_L1].toString();
if (json_obj.contains("refresh_token"_L1)) {
refresh_token_ = json_obj["refresh_token"_L1].toString();
}
expires_in_ = json_obj[QLatin1String("expires_in")].toInt();
expires_in_ = json_obj["expires_in"_L1].toInt();
login_time_ = QDateTime::currentSecsSinceEpoch();
Settings s;
@@ -738,7 +740,7 @@ void SpotifyService::LoginError(const QString &error, const QVariant &debug) {
QString error_html;
for (const QString &e : std::as_const(login_errors_)) {
qLog(Error) << "Spotify:" << e;
error_html += e + QLatin1String("<br />");
error_html += e + "<br />"_L1;
}
if (debug.isValid()) qLog(Debug) << debug;