Replace QLatin1String with operator _L1
This commit is contained in:
parent
e3e6a22172
commit
4270b12cd1
@ -61,6 +61,8 @@
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace logging {
|
||||
|
||||
static Level sDefaultLevel = Level_Debug;
|
||||
@ -159,7 +161,7 @@ static void MessageHandler(QtMsgType type, const QMessageLogContext&, const QStr
|
||||
break;
|
||||
}
|
||||
|
||||
const QStringList lines = message.split(QLatin1Char('\n'));
|
||||
const QStringList lines = message.split(u'\n');
|
||||
for (const QString &line : lines) {
|
||||
BufferedDebug d = CreateLogger<BufferedDebug>(level, QStringLiteral("unknown"), -1, nullptr);
|
||||
d << line.toLocal8Bit().constData();
|
||||
@ -196,9 +198,9 @@ void SetLevels(const QString &levels) {
|
||||
|
||||
if (!sClassLevels) return;
|
||||
|
||||
const QStringList items = levels.split(QLatin1Char(','));
|
||||
const QStringList items = levels.split(u',');
|
||||
for (const QString &item : items) {
|
||||
const QStringList class_level = item.split(QLatin1Char(':'));
|
||||
const QStringList class_level = item.split(u':');
|
||||
|
||||
QString class_name;
|
||||
bool ok = false;
|
||||
@ -216,7 +218,7 @@ void SetLevels(const QString &levels) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (class_name.isEmpty() || class_name == QLatin1Char('*')) {
|
||||
if (class_name.isEmpty() || class_name == u'*') {
|
||||
sDefaultLevel = static_cast<Level>(level);
|
||||
}
|
||||
else {
|
||||
@ -230,9 +232,9 @@ static QString ParsePrettyFunction(const char *pretty_function) {
|
||||
|
||||
// Get the class name out of the function name.
|
||||
QString class_name = QLatin1String(pretty_function);
|
||||
const qint64 paren = class_name.indexOf(QLatin1Char('('));
|
||||
const qint64 paren = class_name.indexOf(u'(');
|
||||
if (paren != -1) {
|
||||
const qint64 colons = class_name.lastIndexOf(QLatin1String("::"), paren);
|
||||
const qint64 colons = class_name.lastIndexOf("::"_L1, paren);
|
||||
if (colons != -1) {
|
||||
class_name = class_name.left(colons);
|
||||
}
|
||||
@ -241,7 +243,7 @@ static QString ParsePrettyFunction(const char *pretty_function) {
|
||||
}
|
||||
}
|
||||
|
||||
const qint64 space = class_name.lastIndexOf(QLatin1Char(' '));
|
||||
const qint64 space = class_name.lastIndexOf(u' ');
|
||||
if (space != -1) {
|
||||
class_name = class_name.mid(space + 1);
|
||||
}
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include "core/logging.h"
|
||||
#include "tagreaderbase.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
TagReaderBase::TagReaderBase() = default;
|
||||
TagReaderBase::~TagReaderBase() = default;
|
||||
|
||||
@ -142,11 +144,11 @@ TagReaderBase::Cover TagReaderBase::LoadCoverFromRequest(const QString &song_fil
|
||||
if (cover_mime_type.isEmpty()) {
|
||||
cover_mime_type = QMimeDatabase().mimeTypeForData(cover_data).name();
|
||||
}
|
||||
if (cover_mime_type == QLatin1String("image/jpeg")) {
|
||||
if (cover_mime_type == "image/jpeg"_L1) {
|
||||
qLog(Debug) << "Using cover from JPEG data for" << song_filename;
|
||||
return Cover(cover_data, cover_mime_type);
|
||||
}
|
||||
if (cover_mime_type == QLatin1String("image/png")) {
|
||||
if (cover_mime_type == "image/png"_L1) {
|
||||
qLog(Debug) << "Using cover from PNG data for" << song_filename;
|
||||
return Cover(cover_data, cover_mime_type);
|
||||
}
|
||||
|
@ -34,19 +34,21 @@
|
||||
#include "tagreaderbase.h"
|
||||
#include "tagreadertaglib.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
#undef TStringToQString
|
||||
#undef QStringToTString
|
||||
|
||||
bool GME::IsSupportedFormat(const QFileInfo &fileinfo) {
|
||||
return fileinfo.exists() && (fileinfo.completeSuffix().endsWith(QLatin1String("spc"), Qt::CaseInsensitive) || fileinfo.completeSuffix().endsWith(QLatin1String("vgm")), Qt::CaseInsensitive);
|
||||
return fileinfo.exists() && (fileinfo.completeSuffix().endsWith("spc"_L1, Qt::CaseInsensitive) || fileinfo.completeSuffix().endsWith("vgm"_L1), Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
TagReaderBase::Result GME::ReadFile(const QFileInfo &fileinfo, spb::tagreader::SongMetadata *song) {
|
||||
|
||||
if (fileinfo.completeSuffix().endsWith(QLatin1String("spc")), Qt::CaseInsensitive) {
|
||||
if (fileinfo.completeSuffix().endsWith("spc"_L1), Qt::CaseInsensitive) {
|
||||
return SPC::Read(fileinfo, song);
|
||||
}
|
||||
if (fileinfo.completeSuffix().endsWith(QLatin1String("vgm"), Qt::CaseInsensitive)) {
|
||||
if (fileinfo.completeSuffix().endsWith("vgm"_L1, Qt::CaseInsensitive)) {
|
||||
return VGM::Read(fileinfo, song);
|
||||
}
|
||||
|
||||
@ -239,7 +241,7 @@ TagReaderBase::Result GME::VGM::Read(const QFileInfo &fileinfo, spb::tagreader::
|
||||
QTextStream fileTagStream(gd3Data, QIODevice::ReadOnly);
|
||||
// Stored as 16 bit UTF string, two bytes per letter.
|
||||
fileTagStream.setEncoding(QStringConverter::Utf16);
|
||||
QStringList strings = fileTagStream.readLine(0).split(QLatin1Char('\0'));
|
||||
QStringList strings = fileTagStream.readLine(0).split(u'\0');
|
||||
if (strings.count() < 10) {
|
||||
return TagReaderBase::Result::ErrorCode::FileParseError;
|
||||
}
|
||||
|
@ -97,6 +97,8 @@
|
||||
#include "core/messagehandler.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
#undef TStringToQString
|
||||
#undef QStringToTString
|
||||
|
||||
@ -443,7 +445,7 @@ TagReaderBase::Result TagReaderTagLib::ReadFile(const QString &filename, spb::ta
|
||||
}
|
||||
|
||||
if (!disc.isEmpty()) {
|
||||
const qint64 i = disc.indexOf(QLatin1Char('/'));
|
||||
const qint64 i = disc.indexOf(u'/');
|
||||
if (i != -1) {
|
||||
// disc.right( i ).toInt() is total number of discs, we don't use this at the moment
|
||||
song->set_disc(disc.left(i).toInt());
|
||||
@ -457,7 +459,7 @@ TagReaderBase::Result TagReaderTagLib::ReadFile(const QString &filename, spb::ta
|
||||
// well, it wasn't set, but if the artist is VA assume it's a compilation
|
||||
const QString albumartist = QString::fromStdString(song->albumartist());
|
||||
const QString artist = QString::fromStdString(song->artist());
|
||||
if (artist.compare(QLatin1String("various artists")) == 0 || albumartist.compare(QLatin1String("various artists")) == 0) {
|
||||
if (artist.compare("various artists"_L1) == 0 || albumartist.compare("various artists"_L1) == 0) {
|
||||
song->set_compilation(true);
|
||||
}
|
||||
}
|
||||
@ -529,7 +531,7 @@ void TagReaderTagLib::ParseID3v2Tags(TagLib::ID3v2::Tag *tag, QString *disc, QSt
|
||||
for (uint i = 0; i < map[kID3v2_CommercialFrame].size(); ++i) {
|
||||
const TagLib::ID3v2::CommentsFrame *frame = dynamic_cast<const TagLib::ID3v2::CommentsFrame*>(map[kID3v2_CommercialFrame][i]);
|
||||
|
||||
if (frame && TagLibStringToQString(frame->description()) != QLatin1String("iTunNORM")) {
|
||||
if (frame && TagLibStringToQString(frame->description()) != "iTunNORM"_L1) {
|
||||
AssignTagLibStringToStdString(frame->text(), song->mutable_comment());
|
||||
break;
|
||||
}
|
||||
@ -937,7 +939,7 @@ TagReaderBase::Result TagReaderTagLib::WriteFile(const QString &filename, const
|
||||
save_tags_options << QStringLiteral("embedded cover");
|
||||
}
|
||||
|
||||
qLog(Debug) << "Saving" << save_tags_options.join(QLatin1String(", ")) << "to" << filename;
|
||||
qLog(Debug) << "Saving" << save_tags_options.join(", "_L1) << "to" << filename;
|
||||
|
||||
const Cover cover = LoadCoverFromRequest(filename, request);
|
||||
|
||||
@ -1501,10 +1503,10 @@ void TagReaderTagLib::SetEmbeddedArt(TagLib::MP4::File *aac_file, TagLib::MP4::T
|
||||
}
|
||||
else {
|
||||
TagLib::MP4::CoverArt::Format cover_format = TagLib::MP4::CoverArt::Format::JPEG;
|
||||
if (mime_type == QLatin1String("image/jpeg")) {
|
||||
if (mime_type == "image/jpeg"_L1) {
|
||||
cover_format = TagLib::MP4::CoverArt::Format::JPEG;
|
||||
}
|
||||
else if (mime_type == QLatin1String("image/png")) {
|
||||
else if (mime_type == "image/png"_L1) {
|
||||
cover_format = TagLib::MP4::CoverArt::Format::PNG;
|
||||
}
|
||||
else {
|
||||
|
@ -59,6 +59,8 @@
|
||||
#include "collectionquery.h"
|
||||
#include "collectiontask.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
CollectionBackend::CollectionBackend(QObject *parent)
|
||||
: CollectionBackendInterface(parent),
|
||||
db_(nullptr),
|
||||
@ -946,14 +948,14 @@ QStringList CollectionBackend::GetAllArtistsWithAlbums(const CollectionFilterOpt
|
||||
CollectionQuery query(db, songs_table_, opt);
|
||||
query.SetColumnSpec(QStringLiteral("DISTINCT albumartist"));
|
||||
query.AddCompilationRequirement(false);
|
||||
query.AddWhere(QStringLiteral("album"), QLatin1String(""), QStringLiteral("!="));
|
||||
query.AddWhere(QStringLiteral("album"), ""_L1, QStringLiteral("!="));
|
||||
|
||||
// Albums with no 'albumartist' (extract 'artist'):
|
||||
CollectionQuery query2(db, songs_table_, opt);
|
||||
query2.SetColumnSpec(QStringLiteral("DISTINCT artist"));
|
||||
query2.AddCompilationRequirement(false);
|
||||
query2.AddWhere(QStringLiteral("album"), QLatin1String(""), QStringLiteral("!="));
|
||||
query2.AddWhere(QStringLiteral("albumartist"), QLatin1String(""), QStringLiteral("="));
|
||||
query2.AddWhere(QStringLiteral("album"), ""_L1, QStringLiteral("!="));
|
||||
query2.AddWhere(QStringLiteral("albumartist"), ""_L1, QStringLiteral("="));
|
||||
|
||||
if (!query.Exec()) {
|
||||
ReportErrors(query);
|
||||
@ -1107,7 +1109,7 @@ SongList CollectionBackend::GetSongsByForeignId(const QStringList &ids, const QS
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
QString in = ids.join(QLatin1Char(','));
|
||||
QString in = ids.join(u',');
|
||||
|
||||
SqlQuery q(db);
|
||||
q.prepare(QStringLiteral("SELECT %3.ROWID, %2, %3.%4 FROM %3, %1 WHERE %3.%4 IN (in) AND %1.ROWID = %3.ROWID AND unavailable = 0").arg(songs_table_, Song::kColumnSpec, table, column, in));
|
||||
@ -1138,7 +1140,7 @@ Song CollectionBackend::GetSongById(const int id, QSqlDatabase &db) {
|
||||
|
||||
SongList CollectionBackend::GetSongsById(const QStringList &ids, QSqlDatabase &db) {
|
||||
|
||||
QString in = ids.join(QLatin1Char(','));
|
||||
QString in = ids.join(u',');
|
||||
|
||||
SqlQuery q(db);
|
||||
q.prepare(QStringLiteral("SELECT %1 FROM %2 WHERE ROWID IN (%3)").arg(Song::kRowIdColumnSpec, songs_table_, in));
|
||||
@ -1276,7 +1278,7 @@ SongList CollectionBackend::GetSongsBySongId(const QStringList &song_ids, QSqlDa
|
||||
for (const QString &song_id : song_ids) {
|
||||
song_ids2 << QLatin1Char('\'') + song_id + QLatin1Char('\'');
|
||||
}
|
||||
QString in = song_ids2.join(QLatin1Char(','));
|
||||
QString in = song_ids2.join(u',');
|
||||
|
||||
SqlQuery q(db);
|
||||
q.prepare(QStringLiteral("SELECT %1 FROM %2 WHERE SONG_ID IN (%3)").arg(Song::kRowIdColumnSpec, songs_table_, in));
|
||||
@ -1524,7 +1526,7 @@ CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist,
|
||||
key.append(album_info.album_artist);
|
||||
}
|
||||
if (!album_info.album.isEmpty()) {
|
||||
if (!key.isEmpty()) key.append(QLatin1Char('-'));
|
||||
if (!key.isEmpty()) key.append(u'-');
|
||||
key.append(album_info.album);
|
||||
}
|
||||
if (!filetype.isEmpty()) {
|
||||
@ -1640,7 +1642,7 @@ void CollectionBackend::UpdateManualAlbumArt(const QString &effective_albumartis
|
||||
{
|
||||
SqlQuery q(db);
|
||||
q.prepare(QStringLiteral("UPDATE %1 SET art_manual = :art_manual, art_unset = 0 WHERE effective_albumartist = :effective_albumartist AND album = :album AND unavailable = 0").arg(songs_table_));
|
||||
q.BindValue(QStringLiteral(":art_manual"), art_manual.isValid() ? art_manual.toString(QUrl::FullyEncoded) : QLatin1String(""));
|
||||
q.BindValue(QStringLiteral(":art_manual"), art_manual.isValid() ? art_manual.toString(QUrl::FullyEncoded) : ""_L1);
|
||||
q.BindValue(QStringLiteral(":effective_albumartist"), effective_albumartist);
|
||||
q.BindValue(QStringLiteral(":album"), album);
|
||||
if (!q.Exec()) {
|
||||
@ -1773,7 +1775,7 @@ void CollectionBackend::ForceCompilation(const QString &album, const QStringList
|
||||
|
||||
// Update the songs
|
||||
QString sql(QStringLiteral("UPDATE %1 SET compilation_on = :compilation_on, compilation_off = :compilation_off, compilation_effective = ((compilation OR compilation_detected OR :compilation_on) AND NOT :compilation_off) + 0 WHERE album = :album AND unavailable = 0").arg(songs_table_));
|
||||
if (!artist.isEmpty()) sql += QLatin1String(" AND artist = :artist");
|
||||
if (!artist.isEmpty()) sql += " AND artist = :artist"_L1;
|
||||
|
||||
SqlQuery q(db);
|
||||
q.prepare(sql);
|
||||
@ -1890,7 +1892,7 @@ bool CollectionBackend::ResetPlayStatistics(const QStringList &id_str_list) {
|
||||
|
||||
SqlQuery q(db);
|
||||
q.prepare(QStringLiteral("UPDATE %1 SET playcount = 0, skipcount = 0, lastplayed = -1 WHERE ROWID IN (:ids)").arg(songs_table_));
|
||||
q.BindValue(QStringLiteral(":ids"), id_str_list.join(QLatin1Char(',')));
|
||||
q.BindValue(QStringLiteral(":ids"), id_str_list.join(u','));
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
return false;
|
||||
@ -2068,7 +2070,7 @@ void CollectionBackend::UpdateSongsRating(const QList<int> &id_list, const float
|
||||
for (int i : id_list) {
|
||||
id_str_list << QString::number(i);
|
||||
}
|
||||
QString ids = id_str_list.join(QLatin1Char(','));
|
||||
QString ids = id_str_list.join(u',');
|
||||
SqlQuery q(db);
|
||||
q.prepare(QStringLiteral("UPDATE %1 SET rating = :rating WHERE ROWID IN (%2)").arg(songs_table_, ids));
|
||||
q.BindValue(QStringLiteral(":rating"), rating);
|
||||
|
@ -61,6 +61,8 @@
|
||||
#include "settings/collectionsettingspage.h"
|
||||
#include "settings/appearancesettingspage.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr int kFilterDelay = 500; // msec
|
||||
}
|
||||
@ -296,7 +298,7 @@ QActionGroup *CollectionFilterWidget::CreateGroupByActions(const QString &saved_
|
||||
if (version == 1) {
|
||||
QStringList saved = s.childKeys();
|
||||
for (int i = 0; i < saved.size(); ++i) {
|
||||
if (saved.at(i) == QLatin1String("version")) continue;
|
||||
if (saved.at(i) == "version"_L1) continue;
|
||||
QByteArray bytes = s.value(saved.at(i)).toByteArray();
|
||||
QDataStream ds(&bytes, QIODevice::ReadOnly);
|
||||
CollectionModel::Grouping g;
|
||||
@ -307,7 +309,7 @@ QActionGroup *CollectionFilterWidget::CreateGroupByActions(const QString &saved_
|
||||
else {
|
||||
QStringList saved = s.childKeys();
|
||||
for (int i = 0; i < saved.size(); ++i) {
|
||||
if (saved.at(i) == QLatin1String("version")) continue;
|
||||
if (saved.at(i) == "version"_L1) continue;
|
||||
s.remove(saved.at(i));
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,7 @@
|
||||
#include "settings/collectionsettingspage.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
const int CollectionModel::kPrettyCoverSize = 32;
|
||||
namespace {
|
||||
@ -119,7 +120,7 @@ CollectionModel::CollectionModel(SharedPtr<CollectionBackend> backend, Applicati
|
||||
|
||||
if (app_ && !sIconCache) {
|
||||
sIconCache = new QNetworkDiskCache(this);
|
||||
sIconCache->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QLatin1Char('/') + QLatin1String(kPixmapDiskCacheDir));
|
||||
sIconCache->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + u'/' + QLatin1String(kPixmapDiskCacheDir));
|
||||
QObject::connect(app_, &Application::ClearPixmapDiskCache, this, &CollectionModel::ClearDiskCache);
|
||||
}
|
||||
|
||||
@ -585,7 +586,7 @@ void CollectionModel::AddSongsInternal(const SongList &songs) {
|
||||
container_key = container->container_key;
|
||||
}
|
||||
else {
|
||||
if (!container_key.isEmpty()) container_key.append(QLatin1Char('-'));
|
||||
if (!container_key.isEmpty()) container_key.append(u'-');
|
||||
container_key.append(ContainerKey(group_by, song, has_unique_album_identifier));
|
||||
if (container_nodes_[i].contains(container_key)) {
|
||||
container = container_nodes_[i][container_key];
|
||||
@ -758,7 +759,7 @@ void CollectionModel::CreateDividerItem(const QString ÷r_key, const QStrin
|
||||
CollectionItem *divider = new CollectionItem(CollectionItem::Type::Divider, root_);
|
||||
divider->container_key = divider_key;
|
||||
divider->display_text = display_text;
|
||||
divider->sort_text = divider_key + QLatin1String(" ");
|
||||
divider->sort_text = divider_key + " "_L1;
|
||||
divider_nodes_[divider_key] = divider;
|
||||
|
||||
endInsertRows();
|
||||
@ -802,7 +803,7 @@ CollectionItem *CollectionModel::CreateCompilationArtistNode(CollectionItem *par
|
||||
if (parent != root_ && !parent->container_key.isEmpty()) parent->compilation_artist_node_->container_key.append(parent->container_key);
|
||||
parent->compilation_artist_node_->container_key.append(QLatin1String(kVariousArtists));
|
||||
parent->compilation_artist_node_->display_text = QLatin1String(kVariousArtists);
|
||||
parent->compilation_artist_node_->sort_text = QLatin1String(" various");
|
||||
parent->compilation_artist_node_->sort_text = " various"_L1;
|
||||
parent->compilation_artist_node_->container_level = parent->container_level + 1;
|
||||
|
||||
endInsertRows();
|
||||
@ -1056,14 +1057,14 @@ QString CollectionModel::TextOrUnknown(const QString &text) {
|
||||
QString CollectionModel::PrettyYearAlbum(const int year, const QString &album) {
|
||||
|
||||
if (year <= 0) return TextOrUnknown(album);
|
||||
return QString::number(year) + QLatin1String(" - ") + TextOrUnknown(album);
|
||||
return QString::number(year) + " - "_L1 + TextOrUnknown(album);
|
||||
|
||||
}
|
||||
|
||||
QString CollectionModel::PrettyAlbumDisc(const QString &album, const int disc) {
|
||||
|
||||
if (disc <= 0 || Song::AlbumContainsDisc(album)) return TextOrUnknown(album);
|
||||
return TextOrUnknown(album) + QLatin1String(" - (Disc ") + QString::number(disc) + QLatin1String(")");
|
||||
return TextOrUnknown(album) + " - (Disc "_L1 + QString::number(disc) + ")"_L1;
|
||||
|
||||
}
|
||||
|
||||
@ -1072,9 +1073,9 @@ QString CollectionModel::PrettyYearAlbumDisc(const int year, const QString &albu
|
||||
QString str;
|
||||
|
||||
if (year <= 0) str = TextOrUnknown(album);
|
||||
else str = QString::number(year) + QLatin1String(" - ") + TextOrUnknown(album);
|
||||
else str = QString::number(year) + " - "_L1 + TextOrUnknown(album);
|
||||
|
||||
if (!Song::AlbumContainsDisc(album) && disc > 0) str += QLatin1String(" - (Disc ") + QString::number(disc) + QLatin1String(")");
|
||||
if (!Song::AlbumContainsDisc(album) && disc > 0) str += " - (Disc "_L1 + QString::number(disc) + ")"_L1;
|
||||
|
||||
return str;
|
||||
|
||||
@ -1082,7 +1083,7 @@ QString CollectionModel::PrettyYearAlbumDisc(const int year, const QString &albu
|
||||
|
||||
QString CollectionModel::PrettyDisc(const int disc) {
|
||||
|
||||
return QLatin1String("Disc ") + QString::number(std::max(1, disc));
|
||||
return "Disc "_L1 + QString::number(std::max(1, disc));
|
||||
|
||||
}
|
||||
|
||||
@ -1159,7 +1160,7 @@ QString CollectionModel::SortText(const GroupBy group_by, const int container_le
|
||||
QString CollectionModel::SortText(QString text) {
|
||||
|
||||
if (text.isEmpty()) {
|
||||
text = QLatin1String(" unknown");
|
||||
text = " unknown"_L1;
|
||||
}
|
||||
else {
|
||||
text = text.toLower();
|
||||
@ -1179,7 +1180,7 @@ QString CollectionModel::SortTextForArtist(QString artist, const bool skip_artic
|
||||
for (const auto &i : Song::kArticles) {
|
||||
if (artist.startsWith(i)) {
|
||||
qint64 ilen = i.length();
|
||||
artist = artist.right(artist.length() - ilen) + QLatin1String(", ") + i.left(ilen - 1);
|
||||
artist = artist.right(artist.length() - ilen) + ", "_L1 + i.left(ilen - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1190,7 +1191,6 @@ QString CollectionModel::SortTextForArtist(QString artist, const bool skip_artic
|
||||
}
|
||||
|
||||
QString CollectionModel::SortTextForNumber(const int number) {
|
||||
|
||||
return QStringLiteral("%1").arg(number, 4, 10, QLatin1Char('0'));
|
||||
}
|
||||
|
||||
@ -1318,7 +1318,7 @@ QString CollectionModel::ContainerKey(const GroupBy group_by, const Song &song,
|
||||
|
||||
// Make sure we distinguish albums by different artists if the parent group by is not including artist.
|
||||
if (IsAlbumGroupBy(group_by) && !has_unique_album_identifier && !song.is_compilation() && !song.effective_albumartist().isEmpty()) {
|
||||
key.prepend(QLatin1Char('-'));
|
||||
key.prepend(u'-');
|
||||
key.prepend(TextOrUnknown(song.effective_albumartist()));
|
||||
has_unique_album_identifier = true;
|
||||
}
|
||||
@ -1348,7 +1348,7 @@ QString CollectionModel::DividerKey(const GroupBy group_by, const Song &song, co
|
||||
case GroupBy::FileType: {
|
||||
QChar c = sort_text[0];
|
||||
if (c.isDigit()) return QStringLiteral("0");
|
||||
if (c == QLatin1Char(' ')) return QString();
|
||||
if (c == u' ') return QString();
|
||||
if (c.decompositionTag() != QChar::NoDecomposition) {
|
||||
QString decomposition = c.decomposition();
|
||||
return QChar(decomposition[0]);
|
||||
@ -1397,25 +1397,25 @@ QString CollectionModel::DividerDisplayText(const GroupBy group_by, const QStrin
|
||||
case GroupBy::Genre:
|
||||
case GroupBy::FileType:
|
||||
case GroupBy::Format:
|
||||
if (key == QLatin1String("0")) return QStringLiteral("0-9");
|
||||
if (key == "0"_L1) return QStringLiteral("0-9");
|
||||
return key.toUpper();
|
||||
|
||||
case GroupBy::YearAlbum:
|
||||
case GroupBy::YearAlbumDisc:
|
||||
case GroupBy::OriginalYearAlbum:
|
||||
case GroupBy::OriginalYearAlbumDisc:
|
||||
if (key == QLatin1String("0000")) return tr("Unknown");
|
||||
if (key == "0000"_L1) return tr("Unknown");
|
||||
return key.toUpper();
|
||||
|
||||
case GroupBy::Year:
|
||||
case GroupBy::OriginalYear:
|
||||
if (key == QLatin1String("0000")) return tr("Unknown");
|
||||
if (key == "0000"_L1) return tr("Unknown");
|
||||
return QString::number(key.toInt()); // To remove leading 0s
|
||||
|
||||
case GroupBy::Samplerate:
|
||||
case GroupBy::Bitdepth:
|
||||
case GroupBy::Bitrate:
|
||||
if (key == QLatin1String("000")) return tr("Unknown");
|
||||
if (key == "000"_L1) return tr("Unknown");
|
||||
return QString::number(key.toInt()); // To remove leading 0s
|
||||
|
||||
case GroupBy::None:
|
||||
|
@ -38,6 +38,8 @@
|
||||
#include "collectionquery.h"
|
||||
#include "collectionfilteroptions.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
CollectionQuery::CollectionQuery(const QSqlDatabase &db, const QString &songs_table, const CollectionFilterOptions &filter_options)
|
||||
: SqlQuery(db),
|
||||
songs_table_(songs_table),
|
||||
@ -63,7 +65,7 @@ CollectionQuery::CollectionQuery(const QSqlDatabase &db, const QString &songs_ta
|
||||
void CollectionQuery::AddWhere(const QString &column, const QVariant &value, const QString &op) {
|
||||
|
||||
// Ignore 'literal' for IN
|
||||
if (op.compare(QLatin1String("IN"), Qt::CaseInsensitive) == 0) {
|
||||
if (op.compare("IN"_L1, Qt::CaseInsensitive) == 0) {
|
||||
const QStringList values = value.toStringList();
|
||||
QStringList final_values;
|
||||
final_values.reserve(values.count());
|
||||
@ -72,7 +74,7 @@ void CollectionQuery::AddWhere(const QString &column, const QVariant &value, con
|
||||
bound_values_ << single_value;
|
||||
}
|
||||
|
||||
where_clauses_ << QStringLiteral("%1 IN (%2)").arg(column, final_values.join(QLatin1Char(',')));
|
||||
where_clauses_ << QStringLiteral("%1 IN (%2)").arg(column, final_values.join(u','));
|
||||
}
|
||||
else {
|
||||
// Do integers inline - sqlite seems to get confused when you pass integers to bound parameters
|
||||
@ -81,7 +83,7 @@ void CollectionQuery::AddWhere(const QString &column, const QVariant &value, con
|
||||
}
|
||||
else if (value.metaType().id() == QMetaType::QString && value.toString().isNull()) {
|
||||
where_clauses_ << QStringLiteral("%1 %2 ?").arg(column, op);
|
||||
bound_values_ << QLatin1String("");
|
||||
bound_values_ << ""_L1;
|
||||
}
|
||||
else {
|
||||
where_clauses_ << QStringLiteral("%1 %2 ?").arg(column, op);
|
||||
@ -115,13 +117,13 @@ bool CollectionQuery::Exec() {
|
||||
where_clauses << QStringLiteral("unavailable = 0");
|
||||
}
|
||||
|
||||
if (!where_clauses.isEmpty()) sql += QLatin1String(" WHERE ") + where_clauses.join(QLatin1String(" AND "));
|
||||
if (!where_clauses.isEmpty()) sql += " WHERE "_L1 + where_clauses.join(" AND "_L1);
|
||||
|
||||
if (!order_by_.isEmpty()) sql += QLatin1String(" ORDER BY ") + order_by_;
|
||||
if (!order_by_.isEmpty()) sql += " ORDER BY "_L1 + order_by_;
|
||||
|
||||
if (limit_ != -1) sql += QLatin1String(" LIMIT ") + QString::number(limit_);
|
||||
if (limit_ != -1) sql += " LIMIT "_L1 + QString::number(limit_);
|
||||
|
||||
sql.replace(QLatin1String("%songs_table"), songs_table_);
|
||||
sql.replace("%songs_table"_L1, songs_table_);
|
||||
|
||||
if (!QSqlQuery::prepare(sql)) return false;
|
||||
|
||||
|
@ -71,6 +71,7 @@
|
||||
#endif
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
QStringList CollectionWatcher::sValidImages = QStringList() << QStringLiteral("jpg") << QStringLiteral("png") << QStringLiteral("gif") << QStringLiteral("jpeg");
|
||||
|
||||
@ -360,7 +361,7 @@ SongList CollectionWatcher::ScanTransaction::FindSongsInSubdirectory(const QStri
|
||||
if (cached_songs_dirty_) {
|
||||
const SongList songs = watcher_->backend_->FindSongsInDirectory(dir_);
|
||||
for (const Song &song : songs) {
|
||||
const QString p = song.url().toLocalFile().section(QLatin1Char('/'), 0, -2);
|
||||
const QString p = song.url().toLocalFile().section(u'/', 0, -2);
|
||||
cached_songs_.insert(p, song);
|
||||
}
|
||||
cached_songs_dirty_ = false;
|
||||
@ -379,7 +380,7 @@ bool CollectionWatcher::ScanTransaction::HasSongsWithMissingFingerprint(const QS
|
||||
if (cached_songs_missing_fingerprint_dirty_) {
|
||||
const SongList songs = watcher_->backend_->SongsWithMissingFingerprint(dir_);
|
||||
for (const Song &song : songs) {
|
||||
const QString p = song.url().toLocalFile().section(QLatin1Char('/'), 0, -2);
|
||||
const QString p = song.url().toLocalFile().section(u'/', 0, -2);
|
||||
cached_songs_missing_fingerprint_.insert(p, song);
|
||||
}
|
||||
cached_songs_missing_fingerprint_dirty_ = false;
|
||||
@ -394,7 +395,7 @@ bool CollectionWatcher::ScanTransaction::HasSongsWithMissingLoudnessCharacterist
|
||||
if (cached_songs_missing_loudness_characteristics_dirty_) {
|
||||
const SongList songs = watcher_->backend_->SongsWithMissingLoudnessCharacteristics(dir_);
|
||||
for (const Song &song : songs) {
|
||||
const QString p = song.url().toLocalFile().section(QLatin1Char('/'), 0, -2);
|
||||
const QString p = song.url().toLocalFile().section(u'/', 0, -2);
|
||||
cached_songs_missing_loudness_characteristics_.insert(p, song);
|
||||
}
|
||||
cached_songs_missing_loudness_characteristics_dirty_ = false;
|
||||
@ -559,7 +560,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const CollectionSu
|
||||
else {
|
||||
QString ext_part(ExtensionPart(child));
|
||||
QString dir_part(DirectoryPart(child));
|
||||
if (Song::kRejectedExtensions.contains(child_info.suffix(), Qt::CaseInsensitive) || child_info.baseName() == QLatin1String("qt_temp")) {
|
||||
if (Song::kRejectedExtensions.contains(child_info.suffix(), Qt::CaseInsensitive) || child_info.baseName() == "qt_temp"_L1) {
|
||||
t->AddToProgress(1);
|
||||
}
|
||||
else if (sValidImages.contains(ext_part)) {
|
||||
@ -661,7 +662,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const CollectionSu
|
||||
Chromaprinter chromaprinter(file);
|
||||
fingerprint = chromaprinter.CreateFingerprint();
|
||||
if (fingerprint.isEmpty()) {
|
||||
fingerprint = QLatin1String("NONE");
|
||||
fingerprint = "NONE"_L1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -688,11 +689,11 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const CollectionSu
|
||||
Chromaprinter chromaprinter(file);
|
||||
fingerprint = chromaprinter.CreateFingerprint();
|
||||
if (fingerprint.isEmpty()) {
|
||||
fingerprint = QLatin1String("NONE");
|
||||
fingerprint = "NONE"_L1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (song_tracking_ && !fingerprint.isEmpty() && fingerprint != QLatin1String("NONE") && FindSongsByFingerprint(file, fingerprint, &matching_songs)) {
|
||||
if (song_tracking_ && !fingerprint.isEmpty() && fingerprint != "NONE"_L1 && FindSongsByFingerprint(file, fingerprint, &matching_songs)) {
|
||||
|
||||
// The song is in the database and still on disk.
|
||||
// Check the mtime to see if it's been changed since it was added.
|
||||
@ -985,7 +986,7 @@ void CollectionWatcher::AddChangedSong(const QString &file, const Song &matching
|
||||
qLog(Debug) << "Song" << file << "unchanged.";
|
||||
}
|
||||
else {
|
||||
qLog(Debug) << "Song" << file << changes.join(QLatin1String(", ")) << "changed.";
|
||||
qLog(Debug) << "Song" << file << changes.join(", "_L1) << "changed.";
|
||||
}
|
||||
|
||||
}
|
||||
@ -1360,7 +1361,7 @@ void CollectionWatcher::RescanSongs(const SongList &songs) {
|
||||
QStringList scanned_paths;
|
||||
for (const Song &song : songs) {
|
||||
if (stop_or_abort_requested()) break;
|
||||
const QString song_path = song.url().toLocalFile().section(QLatin1Char('/'), 0, -2);
|
||||
const QString song_path = song.url().toLocalFile().section(u'/', 0, -2);
|
||||
if (scanned_paths.contains(song_path)) continue;
|
||||
ScanTransaction transaction(this, song.directory_id(), false, true, mark_songs_unavailable_);
|
||||
const CollectionSubdirectoryList subdirs = transaction.GetAllSubdirs();
|
||||
|
@ -47,6 +47,8 @@ class FileSystemWatcherInterface;
|
||||
class TaskManager;
|
||||
class CueParser;
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
class CollectionWatcher : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
@ -259,14 +261,14 @@ class CollectionWatcher : public QObject {
|
||||
};
|
||||
|
||||
inline QString CollectionWatcher::NoExtensionPart(const QString &fileName) {
|
||||
return fileName.contains(QLatin1Char('.')) ? fileName.section(QLatin1Char('.'), 0, -2) : QLatin1String("");
|
||||
return fileName.contains(u'.') ? fileName.section(u'.', 0, -2) : ""_L1;
|
||||
}
|
||||
// Thanks Amarok
|
||||
inline QString CollectionWatcher::ExtensionPart(const QString &fileName) {
|
||||
return fileName.contains(QLatin1Char('.')) ? fileName.mid(fileName.lastIndexOf(QLatin1Char('.')) + 1).toLower() : QLatin1String("");
|
||||
return fileName.contains(u'.') ? fileName.mid(fileName.lastIndexOf(u'.') + 1).toLower() : ""_L1;
|
||||
}
|
||||
inline QString CollectionWatcher::DirectoryPart(const QString &fileName) {
|
||||
return fileName.section(QLatin1Char('/'), 0, -2);
|
||||
return fileName.section(u'/', 0, -2);
|
||||
}
|
||||
|
||||
#endif // COLLECTIONWATCHER_H
|
||||
|
@ -44,6 +44,8 @@
|
||||
#include "savedgroupingmanager.h"
|
||||
#include "ui_savedgroupingmanager.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
const char *SavedGroupingManager::kSavedGroupingsSettingsGroup = "SavedGroupings";
|
||||
|
||||
SavedGroupingManager::SavedGroupingManager(const QString &saved_groupings_settings_group, QWidget *parent)
|
||||
@ -165,7 +167,7 @@ void SavedGroupingManager::UpdateModel() {
|
||||
if (version == 1) {
|
||||
QStringList saved = s.childKeys();
|
||||
for (int i = 0; i < saved.size(); ++i) {
|
||||
if (saved.at(i) == QLatin1String("version")) continue;
|
||||
if (saved.at(i) == "version"_L1) continue;
|
||||
QByteArray bytes = s.value(saved.at(i)).toByteArray();
|
||||
QDataStream ds(&bytes, QIODevice::ReadOnly);
|
||||
CollectionModel::Grouping g;
|
||||
@ -183,7 +185,7 @@ void SavedGroupingManager::UpdateModel() {
|
||||
else {
|
||||
QStringList saved = s.childKeys();
|
||||
for (int i = 0; i < saved.size(); ++i) {
|
||||
if (saved.at(i) == QLatin1String("version")) continue;
|
||||
if (saved.at(i) == "version"_L1) continue;
|
||||
s.remove(saved.at(i));
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +67,8 @@
|
||||
#include "contextview.h"
|
||||
#include "contextalbum.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr int kWidgetSpacing = 50;
|
||||
}
|
||||
@ -410,15 +412,15 @@ void ContextView::NoSong() {
|
||||
QString html;
|
||||
if (collectionview_->TotalSongs() == 1) html += tr("%1 song").arg(collectionview_->TotalSongs());
|
||||
else html += tr("%1 songs").arg(collectionview_->TotalSongs());
|
||||
html += QLatin1String("<br />");
|
||||
html += "<br />"_L1;
|
||||
|
||||
if (collectionview_->TotalArtists() == 1) html += tr("%1 artist").arg(collectionview_->TotalArtists());
|
||||
else html += tr("%1 artists").arg(collectionview_->TotalArtists());
|
||||
html += QLatin1String("<br />");
|
||||
html += "<br />"_L1;
|
||||
|
||||
if (collectionview_->TotalAlbums() == 1) html += tr("%1 album").arg(collectionview_->TotalAlbums());
|
||||
else html += tr("%1 albums").arg(collectionview_->TotalAlbums());
|
||||
html += QLatin1String("<br />");
|
||||
html += "<br />"_L1;
|
||||
|
||||
label_stop_summary_->setFont(font_normal_);
|
||||
label_stop_summary_->setText(html);
|
||||
@ -636,10 +638,10 @@ void ContextView::UpdateLyrics(const quint64 id, const QString &provider, const
|
||||
if (static_cast<qint64>(id) != lyrics_id_) return;
|
||||
|
||||
if (lyrics.isEmpty()) {
|
||||
lyrics_ = QLatin1String("No lyrics found.\n");
|
||||
lyrics_ = "No lyrics found.\n"_L1;
|
||||
}
|
||||
else {
|
||||
lyrics_ = lyrics + QLatin1String("\n\n(Lyrics from ") + provider + QLatin1String(")\n");
|
||||
lyrics_ = lyrics + "\n\n(Lyrics from "_L1 + provider + ")\n"_L1;
|
||||
}
|
||||
lyrics_id_ = -1;
|
||||
|
||||
|
@ -49,6 +49,8 @@
|
||||
#include "sqlquery.h"
|
||||
#include "scopedtransaction.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
const int Database::kSchemaVersion = 20;
|
||||
|
||||
namespace {
|
||||
@ -136,7 +138,7 @@ QSqlDatabase Database::Connect() {
|
||||
//qLog(Debug) << "Opened database with connection id" << connection_id;
|
||||
|
||||
if (injected_database_name_.isNull()) {
|
||||
db.setDatabaseName(directory_ + QLatin1Char('/') + QLatin1String(kDatabaseFilename));
|
||||
db.setDatabaseName(directory_ + u'/' + QLatin1String(kDatabaseFilename));
|
||||
}
|
||||
else {
|
||||
db.setDatabaseName(injected_database_name_);
|
||||
@ -352,7 +354,7 @@ void Database::UrlEncodeFilenameColumn(const QString &table, QSqlDatabase &db) {
|
||||
const int rowid = select.value(0).toInt();
|
||||
const QString filename = select.value(1).toString();
|
||||
|
||||
if (filename.isEmpty() || filename.contains(QLatin1String("://"))) {
|
||||
if (filename.isEmpty() || filename.contains("://"_L1)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -376,8 +378,8 @@ void Database::ExecSchemaCommandsFromFile(QSqlDatabase &db, const QString &filen
|
||||
}
|
||||
QByteArray data = schema_file.readAll();
|
||||
QString schema = QString::fromUtf8(data);
|
||||
if (schema.contains(QLatin1String("\r\n"))) {
|
||||
schema = schema.replace(QLatin1String("\r\n"), QLatin1String("\n"));
|
||||
if (schema.contains("\r\n"_L1)) {
|
||||
schema = schema.replace("\r\n"_L1, "\n"_L1);
|
||||
}
|
||||
schema_file.close();
|
||||
ExecSchemaCommands(db, schema, schema_version, in_transaction);
|
||||
@ -414,7 +416,7 @@ void Database::ExecSongTablesCommands(QSqlDatabase &db, const QStringList &song_
|
||||
if (command.contains(QLatin1String(kMagicAllSongsTables))) {
|
||||
for (const QString &table : song_tables) {
|
||||
// Another horrible hack: device songs tables don't have matching _fts tables, so if this command tries to touch one, ignore it.
|
||||
if (table.startsWith(QLatin1String("device_")) && command.contains(QLatin1String(kMagicAllSongsTables) + QLatin1String("_fts"))) {
|
||||
if (table.startsWith("device_"_L1) && command.contains(QLatin1String(kMagicAllSongsTables) + "_fts"_L1)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -450,7 +452,7 @@ QStringList Database::SongsTables(QSqlDatabase &db, const int schema_version) {
|
||||
// look for the tables in the main db
|
||||
const QStringList &tables = db.tables();
|
||||
for (const QString &table : tables) {
|
||||
if (table == QLatin1String("songs") || table.endsWith(QLatin1String("_songs"))) ret << table;
|
||||
if (table == "songs"_L1 || table.endsWith("_songs"_L1)) ret << table;
|
||||
}
|
||||
|
||||
// look for the tables in attached dbs
|
||||
@ -502,7 +504,7 @@ bool Database::IntegrityCheck(const QSqlDatabase &db) {
|
||||
QString message = q.value(0).toString();
|
||||
|
||||
// If no errors are found, a single row with the value "ok" is returned
|
||||
if (message == QLatin1String("ok")) {
|
||||
if (message == "ok"_L1) {
|
||||
ok = true;
|
||||
break;
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
namespace IconMapper {
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
struct IconProperties {
|
||||
explicit IconProperties() : min_size(0), max_size(0), allow_system_icon(true) {}
|
||||
IconProperties(const QStringList &_names, const int _min_size = 16, const int _max_size = 512, const bool _allow_system_icon = true) : names(_names), min_size(_min_size), max_size(_max_size), allow_system_icon(_allow_system_icon) {}
|
||||
@ -100,7 +102,7 @@ static const QMap<QString, IconProperties> iconmapper_ = { // clazy:exclude=non
|
||||
{ QStringLiteral("media-eject"), { {}} },
|
||||
{ QStringLiteral("media-playback-pause"), { {QStringLiteral("media-pause")}} },
|
||||
{ QStringLiteral("media-playlist-repeat"), { {}} },
|
||||
{ QStringLiteral("media-playlist-shuffle"), { {QLatin1String("")}} },
|
||||
{ QStringLiteral("media-playlist-shuffle"), { {""_L1}} },
|
||||
{ QStringLiteral("media-playback-start"), { {QStringLiteral("media-play"), QStringLiteral("media-playback-playing")}} },
|
||||
{ QStringLiteral("media-seek-backward"), { {}} },
|
||||
{ QStringLiteral("media-seek-forward"), { {}} },
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include <QDateTime>
|
||||
#include <QRandomGenerator>
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
LocalRedirectServer::LocalRedirectServer(QObject *parent)
|
||||
: QTcpServer(parent),
|
||||
port_(0),
|
||||
@ -86,7 +88,7 @@ void LocalRedirectServer::incomingConnection(qintptr socket_descriptor) {
|
||||
if (!tcp_socket->setSocketDescriptor(socket_descriptor)) {
|
||||
delete tcp_socket;
|
||||
close();
|
||||
error_ = QLatin1String("Unable to set socket descriptor");
|
||||
error_ = "Unable to set socket descriptor"_L1;
|
||||
Q_EMIT Finished();
|
||||
return;
|
||||
}
|
||||
@ -151,7 +153,7 @@ void LocalRedirectServer::WriteTemplate() const {
|
||||
.pixmap(16)
|
||||
.toImage()
|
||||
.save(&image_buffer, "PNG");
|
||||
page_data.replace(QLatin1String("@IMAGE_DATA@"), QString::fromUtf8(image_buffer.data().toBase64()));
|
||||
page_data.replace("@IMAGE_DATA@"_L1, QString::fromUtf8(image_buffer.data().toBase64()));
|
||||
image_buffer.close();
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,8 @@
|
||||
#include "core/logging.h"
|
||||
#include "scoped_nsobject.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
MacFSListener::MacFSListener(QObject *parent)
|
||||
: FileSystemWatcherInterface(parent),
|
||||
run_loop_(nullptr),
|
||||
@ -57,7 +59,7 @@ void MacFSListener::EventStreamCallback(ConstFSEventStreamRef stream, void *user
|
||||
for (size_t i = 0; i < num_events; ++i) {
|
||||
QString path = QString::fromUtf8(paths[i]);
|
||||
qLog(Debug) << "Something changed at:" << path;
|
||||
while (path.endsWith(QLatin1Char('/'))) {
|
||||
while (path.endsWith(u'/')) {
|
||||
path.chop(1);
|
||||
}
|
||||
Q_EMIT me->PathChanged(path);
|
||||
|
@ -223,6 +223,7 @@
|
||||
using std::make_unique;
|
||||
using std::make_shared;
|
||||
using namespace std::chrono_literals;
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
const char *MainWindow::kSettingsGroup = "MainWindow";
|
||||
const char *MainWindow::kAllFilesFilterSpec = QT_TR_NOOP("All Files (*)");
|
||||
@ -1268,7 +1269,7 @@ void MainWindow::ReloadAllSettings() {
|
||||
|
||||
void MainWindow::RefreshStyleSheet() {
|
||||
QString contents(styleSheet());
|
||||
setStyleSheet(QLatin1String(""));
|
||||
setStyleSheet(""_L1);
|
||||
setStyleSheet(contents);
|
||||
}
|
||||
|
||||
@ -2344,7 +2345,7 @@ void MainWindow::ShowInCollection() {
|
||||
}
|
||||
QString search;
|
||||
if (!songs.isEmpty()) {
|
||||
search = QLatin1String("artist:") + songs.first().artist() + QLatin1String(" album:") + songs.first().album();
|
||||
search = "artist:"_L1 + songs.first().artist() + " album:"_L1 + songs.first().album();
|
||||
}
|
||||
collection_view_->filter_widget()->ShowInCollection(search);
|
||||
|
||||
@ -2437,9 +2438,9 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
|
||||
break;
|
||||
|
||||
case CommandlineOptions::PlayerAction::ResizeWindow:{
|
||||
if (options.window_size().contains(QLatin1Char('x')) && options.window_size().length() >= 4) {
|
||||
QString str_w = options.window_size().left(options.window_size().indexOf(QLatin1Char('x')));
|
||||
QString str_h = options.window_size().right(options.window_size().length() - options.window_size().indexOf(QLatin1Char('x')) - 1);
|
||||
if (options.window_size().contains(u'x') && options.window_size().length() >= 4) {
|
||||
QString str_w = options.window_size().left(options.window_size().indexOf(u'x'));
|
||||
QString str_h = options.window_size().right(options.window_size().length() - options.window_size().indexOf(u'x') - 1);
|
||||
bool w_ok = false;
|
||||
bool h_ok = false;
|
||||
int w = str_w.toInt(&w_ok);
|
||||
@ -2479,7 +2480,7 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
|
||||
#ifdef HAVE_TIDAL
|
||||
const QList<QUrl> urls = options.urls();
|
||||
for (const QUrl &url : urls) {
|
||||
if (url.scheme() == QLatin1String("tidal") && url.host() == QLatin1String("login")) {
|
||||
if (url.scheme() == "tidal"_L1 && url.host() == "login"_L1) {
|
||||
Q_EMIT AuthorizationUrlReceived(url);
|
||||
return;
|
||||
}
|
||||
@ -2557,7 +2558,7 @@ bool MainWindow::LoadUrl(const QString &url) {
|
||||
return true;
|
||||
}
|
||||
#ifdef HAVE_TIDAL
|
||||
if (url.startsWith(QLatin1String("tidal://login"))) {
|
||||
if (url.startsWith("tidal://login"_L1)) {
|
||||
Q_EMIT AuthorizationUrlReceived(QUrl(url));
|
||||
return true;
|
||||
}
|
||||
@ -2927,9 +2928,9 @@ void MainWindow::CheckFullRescanRevisions() {
|
||||
if (!reasons.isEmpty()) {
|
||||
QString message = tr("The version of Strawberry you've just updated to requires a full collection rescan because of the new features listed below:") + QStringLiteral("<ul>");
|
||||
for (const QString &reason : reasons) {
|
||||
message += QLatin1String("<li>") + reason + QLatin1String("</li>");
|
||||
message += "<li>"_L1 + reason + "</li>"_L1;
|
||||
}
|
||||
message += QLatin1String("</ul>") + tr("Would you like to run a full rescan right now?");
|
||||
message += "</ul>"_L1 + tr("Would you like to run a full rescan right now?");
|
||||
if (QMessageBox::question(this, tr("Collection rescan notice"), message, QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
|
||||
app_->collection()->FullScan();
|
||||
}
|
||||
|
@ -64,6 +64,8 @@
|
||||
#include "mpris2_root.h"
|
||||
#include "mpris2_tracklist.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &arg, const MprisPlaylist &playlist) {
|
||||
arg.beginStructure();
|
||||
arg << playlist.id << playlist.name << playlist.icon;
|
||||
@ -132,13 +134,13 @@ Mpris2::Mpris2(Application *app, QObject *parent)
|
||||
|
||||
app_name_[0] = app_name_[0].toUpper();
|
||||
|
||||
QStringList data_dirs = QString::fromUtf8(qgetenv("XDG_DATA_DIRS")).split(QLatin1Char(':'));
|
||||
QStringList data_dirs = QString::fromUtf8(qgetenv("XDG_DATA_DIRS")).split(u':');
|
||||
|
||||
if (!data_dirs.contains(QLatin1String("/usr/local/share"))) {
|
||||
if (!data_dirs.contains("/usr/local/share"_L1)) {
|
||||
data_dirs.append(QStringLiteral("/usr/local/share"));
|
||||
}
|
||||
|
||||
if (!data_dirs.contains(QLatin1String("/usr/share"))) {
|
||||
if (!data_dirs.contains("/usr/share"_L1)) {
|
||||
data_dirs.append(QStringLiteral("/usr/share"));
|
||||
}
|
||||
|
||||
@ -208,18 +210,18 @@ void Mpris2::EmitNotification(const QString &name, const QVariant &value, const
|
||||
void Mpris2::EmitNotification(const QString &name) {
|
||||
|
||||
QVariant value;
|
||||
if (name == QLatin1String("PlaybackStatus")) value = PlaybackStatus();
|
||||
else if (name == QLatin1String("LoopStatus")) value = LoopStatus();
|
||||
else if (name == QLatin1String("Shuffle")) value = Shuffle();
|
||||
else if (name == QLatin1String("Metadata")) value = Metadata();
|
||||
else if (name == QLatin1String("Rating")) value = Rating();
|
||||
else if (name == QLatin1String("Volume")) value = Volume();
|
||||
else if (name == QLatin1String("Position")) value = Position();
|
||||
else if (name == QLatin1String("CanPlay")) value = CanPlay();
|
||||
else if (name == QLatin1String("CanPause")) value = CanPause();
|
||||
else if (name == QLatin1String("CanSeek")) value = CanSeek();
|
||||
else if (name == QLatin1String("CanGoNext")) value = CanGoNext();
|
||||
else if (name == QLatin1String("CanGoPrevious")) value = CanGoPrevious();
|
||||
if (name == "PlaybackStatus"_L1) value = PlaybackStatus();
|
||||
else if (name == "LoopStatus"_L1) value = LoopStatus();
|
||||
else if (name == "Shuffle"_L1) value = Shuffle();
|
||||
else if (name == "Metadata"_L1) value = Metadata();
|
||||
else if (name == "Rating"_L1) value = Rating();
|
||||
else if (name == "Volume"_L1) value = Volume();
|
||||
else if (name == "Position"_L1) value = Position();
|
||||
else if (name == "CanPlay"_L1) value = CanPlay();
|
||||
else if (name == "CanPause"_L1) value = CanPause();
|
||||
else if (name == "CanSeek"_L1) value = CanSeek();
|
||||
else if (name == "CanGoNext"_L1) value = CanGoNext();
|
||||
else if (name == "CanGoPrevious"_L1) value = CanGoPrevious();
|
||||
|
||||
if (value.isValid()) EmitNotification(name, value);
|
||||
|
||||
@ -326,13 +328,13 @@ void Mpris2::SetLoopStatus(const QString &value) {
|
||||
|
||||
PlaylistSequence::RepeatMode mode = PlaylistSequence::RepeatMode::Off;
|
||||
|
||||
if (value == QLatin1String("None")) {
|
||||
if (value == "None"_L1) {
|
||||
mode = PlaylistSequence::RepeatMode::Off;
|
||||
}
|
||||
else if (value == QLatin1String("Track")) {
|
||||
else if (value == "Track"_L1) {
|
||||
mode = PlaylistSequence::RepeatMode::Track;
|
||||
}
|
||||
else if (value == QLatin1String("Playlist")) {
|
||||
else if (value == "Playlist"_L1) {
|
||||
mode = PlaylistSequence::RepeatMode::Playlist;
|
||||
}
|
||||
|
||||
@ -461,7 +463,7 @@ bool Mpris2::CanPlay() const {
|
||||
|
||||
// This one's a bit different than MPRIS 1 - we want this to be true even when the song is already paused or stopped.
|
||||
bool Mpris2::CanPause() const {
|
||||
return (app_->player()->GetCurrentItem() && app_->player()->GetState() == EngineBase::State::Playing && !(app_->player()->GetCurrentItem()->options() & PlaylistItem::Option::PauseDisabled)) || PlaybackStatus() == QLatin1String("Paused") || PlaybackStatus() == QLatin1String("Stopped");
|
||||
return (app_->player()->GetCurrentItem() && app_->player()->GetState() == EngineBase::State::Playing && !(app_->player()->GetCurrentItem()->options() & PlaylistItem::Option::PauseDisabled)) || PlaybackStatus() == "Paused"_L1 || PlaybackStatus() == "Stopped"_L1;
|
||||
}
|
||||
|
||||
bool Mpris2::CanSeek() const { return CanSeek(app_->player()->GetState()); }
|
||||
@ -595,7 +597,7 @@ MaybePlaylist Mpris2::ActivePlaylist() const {
|
||||
|
||||
void Mpris2::ActivatePlaylist(const QDBusObjectPath &playlist_id) {
|
||||
|
||||
QStringList split_path = playlist_id.path().split(QLatin1Char('/'));
|
||||
QStringList split_path = playlist_id.path().split(u'/');
|
||||
qLog(Debug) << Q_FUNC_INFO << playlist_id.path() << split_path;
|
||||
if (split_path.isEmpty()) {
|
||||
return;
|
||||
@ -649,7 +651,7 @@ void Mpris2::PlaylistChangedSlot(Playlist *playlist) {
|
||||
|
||||
void Mpris2::PlaylistCollectionChanged(Playlist *playlist) {
|
||||
Q_UNUSED(playlist);
|
||||
EmitNotification(QStringLiteral("PlaylistCount"), QLatin1String(""), QStringLiteral("org.mpris.MediaPlayer2.Playlists"));
|
||||
EmitNotification(QStringLiteral("PlaylistCount"), ""_L1, QStringLiteral("org.mpris.MediaPlayer2.Playlists"));
|
||||
}
|
||||
|
||||
} // namespace mpris
|
||||
|
@ -32,6 +32,8 @@
|
||||
|
||||
namespace mpris {
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
inline void AddMetadata(const QString &key, const QString &metadata, QVariantMap *map) {
|
||||
if (!metadata.isEmpty()) (*map)[key] = metadata;
|
||||
}
|
||||
@ -61,7 +63,7 @@ inline void AddMetadata(const QString &key, const QDBusObjectPath &metadata, QVa
|
||||
}
|
||||
|
||||
inline QString AsMPRISDateTimeType(const qint64 time) {
|
||||
return time != -1 ? QDateTime::fromSecsSinceEpoch(time).toString(Qt::ISODate) : QLatin1String("");
|
||||
return time != -1 ? QDateTime::fromSecsSinceEpoch(time).toString(Qt::ISODate) : ""_L1;
|
||||
}
|
||||
|
||||
} // namespace mpris
|
||||
|
@ -32,6 +32,8 @@
|
||||
#include "core/settings.h"
|
||||
#include "networkproxyfactory.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
NetworkProxyFactory *NetworkProxyFactory::sInstance = nullptr;
|
||||
const char *NetworkProxyFactory::kSettingsGroup = "NetworkProxy";
|
||||
|
||||
@ -112,7 +114,7 @@ QList<QNetworkProxy> NetworkProxyFactory::queryProxy(const QNetworkProxyQuery &q
|
||||
ret.setPort(env_url_.port());
|
||||
ret.setUser(env_url_.userName());
|
||||
ret.setPassword(env_url_.password());
|
||||
if (env_url_.scheme().startsWith(QLatin1String("http"))) {
|
||||
if (env_url_.scheme().startsWith("http"_L1)) {
|
||||
ret.setType(QNetworkProxy::HttpProxy);
|
||||
}
|
||||
else {
|
||||
|
@ -70,7 +70,6 @@
|
||||
#include "settings/playlistsettingspage.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
const char *Player::kSettingsGroup = "Player";
|
||||
|
@ -63,6 +63,8 @@
|
||||
#endif
|
||||
#include "tagreadermessages.pb.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
const QStringList Song::kColumns = QStringList() << QStringLiteral("title")
|
||||
<< QStringLiteral("album")
|
||||
<< QStringLiteral("artist")
|
||||
@ -144,10 +146,10 @@ const QStringList Song::kColumns = QStringList() << QStringLiteral("title")
|
||||
|
||||
const QStringList Song::kRowIdColumns = QStringList() << QStringLiteral("ROWID") << kColumns;
|
||||
|
||||
const QString Song::kColumnSpec = kColumns.join(QLatin1String(", "));
|
||||
const QString Song::kRowIdColumnSpec = kRowIdColumns.join(QLatin1String(", "));
|
||||
const QString Song::kBindSpec = Utilities::Prepend(QStringLiteral(":"), kColumns).join(QLatin1String(", "));
|
||||
const QString Song::kUpdateSpec = Utilities::Updateify(kColumns).join(QLatin1String(", "));
|
||||
const QString Song::kColumnSpec = kColumns.join(", "_L1);
|
||||
const QString Song::kRowIdColumnSpec = kRowIdColumns.join(", "_L1);
|
||||
const QString Song::kBindSpec = Utilities::Prepend(QStringLiteral(":"), kColumns).join(", "_L1);
|
||||
const QString Song::kUpdateSpec = Utilities::Updateify(kColumns).join(", "_L1);
|
||||
|
||||
const QStringList Song::kTextSearchColumns = QStringList() << QStringLiteral("title")
|
||||
<< QStringLiteral("album")
|
||||
@ -421,9 +423,9 @@ const QString &Song::grouping() const { return d->grouping_; }
|
||||
const QString &Song::comment() const { return d->comment_; }
|
||||
const QString &Song::lyrics() const { return d->lyrics_; }
|
||||
|
||||
QString Song::artist_id() const { return d->artist_id_.isNull() ? QLatin1String("") : d->artist_id_; }
|
||||
QString Song::album_id() const { return d->album_id_.isNull() ? QLatin1String("") : d->album_id_; }
|
||||
QString Song::song_id() const { return d->song_id_.isNull() ? QLatin1String("") : d->song_id_; }
|
||||
QString Song::artist_id() const { return d->artist_id_.isNull() ? ""_L1 : d->artist_id_; }
|
||||
QString Song::album_id() const { return d->album_id_.isNull() ? ""_L1 : d->album_id_; }
|
||||
QString Song::song_id() const { return d->song_id_.isNull() ? ""_L1 : d->song_id_; }
|
||||
|
||||
qint64 Song::beginning_nanosec() const { return d->beginning_; }
|
||||
qint64 Song::end_nanosec() const { return d->end_; }
|
||||
@ -725,7 +727,7 @@ int Song::ColumnIndex(const QString &field) {
|
||||
}
|
||||
|
||||
QString Song::JoinSpec(const QString &table) {
|
||||
return Utilities::Prepend(table + QLatin1Char('.'), kRowIdColumns).join(QLatin1String(", "));
|
||||
return Utilities::Prepend(table + QLatin1Char('.'), kRowIdColumns).join(", "_L1);
|
||||
}
|
||||
|
||||
QString Song::PrettyTitle() const {
|
||||
@ -779,7 +781,7 @@ QString Song::TitleWithCompilationArtist() const {
|
||||
|
||||
if (title.isEmpty()) title = d->basefilename_;
|
||||
|
||||
if (is_compilation() && !d->artist_.isEmpty() && !d->artist_.contains(QLatin1String("various"), Qt::CaseInsensitive)) title = d->artist_ + QStringLiteral(" - ") + title;
|
||||
if (is_compilation() && !d->artist_.isEmpty() && !d->artist_.contains("various"_L1, Qt::CaseInsensitive)) title = d->artist_ + QStringLiteral(" - ") + title;
|
||||
|
||||
return title;
|
||||
|
||||
@ -787,7 +789,7 @@ QString Song::TitleWithCompilationArtist() const {
|
||||
|
||||
QString Song::SampleRateBitDepthToText() const {
|
||||
|
||||
if (d->samplerate_ == -1) return QLatin1String("");
|
||||
if (d->samplerate_ == -1) return ""_L1;
|
||||
if (d->bitdepth_ == -1) return QStringLiteral("%1 hz").arg(d->samplerate_);
|
||||
|
||||
return QStringLiteral("%1 hz / %2 bit").arg(d->samplerate_).arg(d->bitdepth_);
|
||||
@ -957,11 +959,11 @@ Song::Source Song::SourceFromURL(const QUrl &url) {
|
||||
if (url.scheme() == QStringLiteral("spotify")) return Source::Spotify;
|
||||
if (url.scheme() == QStringLiteral("qobuz")) return Source::Qobuz;
|
||||
if (url.scheme() == QStringLiteral("http") || url.scheme() == QStringLiteral("https") || url.scheme() == QStringLiteral("rtsp")) {
|
||||
if (url.host().endsWith(QLatin1String("tidal.com"), Qt::CaseInsensitive)) { return Source::Tidal; }
|
||||
if (url.host().endsWith(QLatin1String("spotify.com"), Qt::CaseInsensitive)) { return Source::Spotify; }
|
||||
if (url.host().endsWith(QLatin1String("qobuz.com"), Qt::CaseInsensitive)) { return Source::Qobuz; }
|
||||
if (url.host().endsWith(QLatin1String("somafm.com"), Qt::CaseInsensitive)) { return Source::SomaFM; }
|
||||
if (url.host().endsWith(QLatin1String("radioparadise.com"), Qt::CaseInsensitive)) { return Source::RadioParadise; }
|
||||
if (url.host().endsWith("tidal.com"_L1, Qt::CaseInsensitive)) { return Source::Tidal; }
|
||||
if (url.host().endsWith("spotify.com"_L1, Qt::CaseInsensitive)) { return Source::Spotify; }
|
||||
if (url.host().endsWith("qobuz.com"_L1, Qt::CaseInsensitive)) { return Source::Qobuz; }
|
||||
if (url.host().endsWith("somafm.com"_L1, Qt::CaseInsensitive)) { return Source::SomaFM; }
|
||||
if (url.host().endsWith("radioparadise.com"_L1, Qt::CaseInsensitive)) { return Source::RadioParadise; }
|
||||
return Source::Stream;
|
||||
}
|
||||
else return Source::Unknown;
|
||||
@ -1010,17 +1012,17 @@ QString Song::DescriptionForSource(const Source source) {
|
||||
|
||||
Song::Source Song::SourceFromText(const QString &source) {
|
||||
|
||||
if (source.compare(QLatin1String("file"), Qt::CaseInsensitive) == 0) return Source::LocalFile;
|
||||
if (source.compare(QLatin1String("collection"), Qt::CaseInsensitive) == 0) return Source::Collection;
|
||||
if (source.compare(QLatin1String("cd"), Qt::CaseInsensitive) == 0) return Source::CDDA;
|
||||
if (source.compare(QLatin1String("device"), Qt::CaseInsensitive) == 0) return Source::Device;
|
||||
if (source.compare(QLatin1String("stream"), Qt::CaseInsensitive) == 0) return Source::Stream;
|
||||
if (source.compare(QLatin1String("subsonic"), Qt::CaseInsensitive) == 0) return Source::Subsonic;
|
||||
if (source.compare(QLatin1String("tidal"), Qt::CaseInsensitive) == 0) return Source::Tidal;
|
||||
if (source.compare(QLatin1String("spotify"), Qt::CaseInsensitive) == 0) return Source::Spotify;
|
||||
if (source.compare(QLatin1String("qobuz"), Qt::CaseInsensitive) == 0) return Source::Qobuz;
|
||||
if (source.compare(QLatin1String("somafm"), Qt::CaseInsensitive) == 0) return Source::SomaFM;
|
||||
if (source.compare(QLatin1String("radioparadise"), Qt::CaseInsensitive) == 0) return Source::RadioParadise;
|
||||
if (source.compare("file"_L1, Qt::CaseInsensitive) == 0) return Source::LocalFile;
|
||||
if (source.compare("collection"_L1, Qt::CaseInsensitive) == 0) return Source::Collection;
|
||||
if (source.compare("cd"_L1, Qt::CaseInsensitive) == 0) return Source::CDDA;
|
||||
if (source.compare("device"_L1, Qt::CaseInsensitive) == 0) return Source::Device;
|
||||
if (source.compare("stream"_L1, Qt::CaseInsensitive) == 0) return Source::Stream;
|
||||
if (source.compare("subsonic"_L1, Qt::CaseInsensitive) == 0) return Source::Subsonic;
|
||||
if (source.compare("tidal"_L1, Qt::CaseInsensitive) == 0) return Source::Tidal;
|
||||
if (source.compare("spotify"_L1, Qt::CaseInsensitive) == 0) return Source::Spotify;
|
||||
if (source.compare("qobuz"_L1, Qt::CaseInsensitive) == 0) return Source::Qobuz;
|
||||
if (source.compare("somafm"_L1, Qt::CaseInsensitive) == 0) return Source::SomaFM;
|
||||
if (source.compare("radioparadise"_L1, Qt::CaseInsensitive) == 0) return Source::RadioParadise;
|
||||
|
||||
return Source::Unknown;
|
||||
|
||||
@ -1166,26 +1168,26 @@ bool Song::IsFileLossless() const {
|
||||
|
||||
Song::FileType Song::FiletypeByMimetype(const QString &mimetype) {
|
||||
|
||||
if (mimetype.compare(QLatin1String("audio/wav"), Qt::CaseInsensitive) == 0 || mimetype.compare(QLatin1String("audio/x-wav"), Qt::CaseInsensitive) == 0) return FileType::WAV;
|
||||
if (mimetype.compare(QLatin1String("audio/x-flac"), Qt::CaseInsensitive) == 0) return FileType::FLAC;
|
||||
if (mimetype.compare(QLatin1String("audio/x-wavpack"), Qt::CaseInsensitive) == 0) return FileType::WavPack;
|
||||
if (mimetype.compare(QLatin1String("audio/x-vorbis"), Qt::CaseInsensitive) == 0) return FileType::OggVorbis;
|
||||
if (mimetype.compare(QLatin1String("audio/x-opus"), Qt::CaseInsensitive) == 0) return FileType::OggOpus;
|
||||
if (mimetype.compare(QLatin1String("audio/x-speex"), Qt::CaseInsensitive) == 0) return FileType::OggSpeex;
|
||||
if (mimetype.compare("audio/wav"_L1, Qt::CaseInsensitive) == 0 || mimetype.compare("audio/x-wav"_L1, Qt::CaseInsensitive) == 0) return FileType::WAV;
|
||||
if (mimetype.compare("audio/x-flac"_L1, Qt::CaseInsensitive) == 0) return FileType::FLAC;
|
||||
if (mimetype.compare("audio/x-wavpack"_L1, Qt::CaseInsensitive) == 0) return FileType::WavPack;
|
||||
if (mimetype.compare("audio/x-vorbis"_L1, Qt::CaseInsensitive) == 0) return FileType::OggVorbis;
|
||||
if (mimetype.compare("audio/x-opus"_L1, Qt::CaseInsensitive) == 0) return FileType::OggOpus;
|
||||
if (mimetype.compare("audio/x-speex"_L1, Qt::CaseInsensitive) == 0) return FileType::OggSpeex;
|
||||
// Gstreamer returns audio/mpeg for both MP3 and MP4/AAC.
|
||||
// if (mimetype.compare("audio/mpeg", Qt::CaseInsensitive) == 0) return FileType::MPEG;
|
||||
if (mimetype.compare(QLatin1String("audio/aac"), Qt::CaseInsensitive) == 0) return FileType::MP4;
|
||||
if (mimetype.compare(QLatin1String("audio/x-wma"), Qt::CaseInsensitive) == 0) return FileType::ASF;
|
||||
if (mimetype.compare(QLatin1String("audio/aiff"), Qt::CaseInsensitive) == 0 || mimetype.compare(QLatin1String("audio/x-aiff"), Qt::CaseInsensitive) == 0) return FileType::AIFF;
|
||||
if (mimetype.compare(QLatin1String("audio/x-musepack"), Qt::CaseInsensitive) == 0) return FileType::MPC;
|
||||
if (mimetype.compare(QLatin1String("application/x-project"), Qt::CaseInsensitive) == 0) return FileType::MPC;
|
||||
if (mimetype.compare(QLatin1String("audio/x-dsf"), Qt::CaseInsensitive) == 0) return FileType::DSF;
|
||||
if (mimetype.compare(QLatin1String("audio/x-dsd"), Qt::CaseInsensitive) == 0) return FileType::DSDIFF;
|
||||
if (mimetype.compare(QLatin1String("audio/x-ape"), Qt::CaseInsensitive) == 0 || mimetype.compare(QLatin1String("application/x-ape"), Qt::CaseInsensitive) == 0 || mimetype.compare(QLatin1String("audio/x-ffmpeg-parsed-ape"), Qt::CaseInsensitive) == 0) return FileType::APE;
|
||||
if (mimetype.compare(QLatin1String("audio/x-mod"), Qt::CaseInsensitive) == 0) return FileType::MOD;
|
||||
if (mimetype.compare(QLatin1String("audio/x-s3m"), Qt::CaseInsensitive) == 0) return FileType::S3M;
|
||||
if (mimetype.compare(QLatin1String("audio/x-spc"), Qt::CaseInsensitive) == 0) return FileType::SPC;
|
||||
if (mimetype.compare(QLatin1String("audio/x-vgm"), Qt::CaseInsensitive) == 0) return FileType::VGM;
|
||||
if (mimetype.compare("audio/aac"_L1, Qt::CaseInsensitive) == 0) return FileType::MP4;
|
||||
if (mimetype.compare("audio/x-wma"_L1, Qt::CaseInsensitive) == 0) return FileType::ASF;
|
||||
if (mimetype.compare("audio/aiff"_L1, Qt::CaseInsensitive) == 0 || mimetype.compare("audio/x-aiff"_L1, Qt::CaseInsensitive) == 0) return FileType::AIFF;
|
||||
if (mimetype.compare("audio/x-musepack"_L1, Qt::CaseInsensitive) == 0) return FileType::MPC;
|
||||
if (mimetype.compare("application/x-project"_L1, Qt::CaseInsensitive) == 0) return FileType::MPC;
|
||||
if (mimetype.compare("audio/x-dsf"_L1, Qt::CaseInsensitive) == 0) return FileType::DSF;
|
||||
if (mimetype.compare("audio/x-dsd"_L1, Qt::CaseInsensitive) == 0) return FileType::DSDIFF;
|
||||
if (mimetype.compare("audio/x-ape"_L1, Qt::CaseInsensitive) == 0 || mimetype.compare("application/x-ape"_L1, Qt::CaseInsensitive) == 0 || mimetype.compare("audio/x-ffmpeg-parsed-ape"_L1, Qt::CaseInsensitive) == 0) return FileType::APE;
|
||||
if (mimetype.compare("audio/x-mod"_L1, Qt::CaseInsensitive) == 0) return FileType::MOD;
|
||||
if (mimetype.compare("audio/x-s3m"_L1, Qt::CaseInsensitive) == 0) return FileType::S3M;
|
||||
if (mimetype.compare("audio/x-spc"_L1, Qt::CaseInsensitive) == 0) return FileType::SPC;
|
||||
if (mimetype.compare("audio/x-vgm"_L1, Qt::CaseInsensitive) == 0) return FileType::VGM;
|
||||
|
||||
return FileType::Unknown;
|
||||
|
||||
@ -1193,26 +1195,26 @@ Song::FileType Song::FiletypeByMimetype(const QString &mimetype) {
|
||||
|
||||
Song::FileType Song::FiletypeByDescription(const QString &text) {
|
||||
|
||||
if (text.compare(QLatin1String("WAV"), Qt::CaseInsensitive) == 0) return FileType::WAV;
|
||||
if (text.compare(QLatin1String("Free Lossless Audio Codec (FLAC)"), Qt::CaseInsensitive) == 0) return FileType::FLAC;
|
||||
if (text.compare(QLatin1String("Wavpack"), Qt::CaseInsensitive) == 0) return FileType::WavPack;
|
||||
if (text.compare(QLatin1String("Vorbis"), Qt::CaseInsensitive) == 0) return FileType::OggVorbis;
|
||||
if (text.compare(QLatin1String("Opus"), Qt::CaseInsensitive) == 0) return FileType::OggOpus;
|
||||
if (text.compare(QLatin1String("Speex"), Qt::CaseInsensitive) == 0) return FileType::OggSpeex;
|
||||
if (text.compare(QLatin1String("MPEG-1 Layer 2 (MP2)"), Qt::CaseInsensitive) == 0) return FileType::MPEG;
|
||||
if (text.compare(QLatin1String("MPEG-1 Layer 3 (MP3)"), Qt::CaseInsensitive) == 0) return FileType::MPEG;
|
||||
if (text.compare(QLatin1String("MPEG-4 AAC"), Qt::CaseInsensitive) == 0) return FileType::MP4;
|
||||
if (text.compare(QLatin1String("WMA"), Qt::CaseInsensitive) == 0) return FileType::ASF;
|
||||
if (text.compare(QLatin1String("Audio Interchange File Format"), Qt::CaseInsensitive) == 0) return FileType::AIFF;
|
||||
if (text.compare(QLatin1String("MPC"), Qt::CaseInsensitive) == 0) return FileType::MPC;
|
||||
if (text.compare(QLatin1String("Musepack (MPC)"), Qt::CaseInsensitive) == 0) return FileType::MPC;
|
||||
if (text.compare(QLatin1String("audio/x-dsf"), Qt::CaseInsensitive) == 0) return FileType::DSF;
|
||||
if (text.compare(QLatin1String("audio/x-dsd"), Qt::CaseInsensitive) == 0) return FileType::DSDIFF;
|
||||
if (text.compare(QLatin1String("audio/x-ffmpeg-parsed-ape"), Qt::CaseInsensitive) == 0) return FileType::APE;
|
||||
if (text.compare(QLatin1String("Module Music Format (MOD)"), Qt::CaseInsensitive) == 0) return FileType::MOD;
|
||||
if (text.compare(QLatin1String("Module Music Format (MOD)"), Qt::CaseInsensitive) == 0) return FileType::S3M;
|
||||
if (text.compare(QLatin1String("SNES SPC700"), Qt::CaseInsensitive) == 0) return FileType::SPC;
|
||||
if (text.compare(QLatin1String("VGM"), Qt::CaseInsensitive) == 0) return FileType::VGM;
|
||||
if (text.compare("WAV"_L1, Qt::CaseInsensitive) == 0) return FileType::WAV;
|
||||
if (text.compare("Free Lossless Audio Codec (FLAC)"_L1, Qt::CaseInsensitive) == 0) return FileType::FLAC;
|
||||
if (text.compare("Wavpack"_L1, Qt::CaseInsensitive) == 0) return FileType::WavPack;
|
||||
if (text.compare("Vorbis"_L1, Qt::CaseInsensitive) == 0) return FileType::OggVorbis;
|
||||
if (text.compare("Opus"_L1, Qt::CaseInsensitive) == 0) return FileType::OggOpus;
|
||||
if (text.compare("Speex"_L1, Qt::CaseInsensitive) == 0) return FileType::OggSpeex;
|
||||
if (text.compare("MPEG-1 Layer 2 (MP2)"_L1, Qt::CaseInsensitive) == 0) return FileType::MPEG;
|
||||
if (text.compare("MPEG-1 Layer 3 (MP3)"_L1, Qt::CaseInsensitive) == 0) return FileType::MPEG;
|
||||
if (text.compare("MPEG-4 AAC"_L1, Qt::CaseInsensitive) == 0) return FileType::MP4;
|
||||
if (text.compare("WMA"_L1, Qt::CaseInsensitive) == 0) return FileType::ASF;
|
||||
if (text.compare("Audio Interchange File Format"_L1, Qt::CaseInsensitive) == 0) return FileType::AIFF;
|
||||
if (text.compare("MPC"_L1, Qt::CaseInsensitive) == 0) return FileType::MPC;
|
||||
if (text.compare("Musepack (MPC)"_L1, Qt::CaseInsensitive) == 0) return FileType::MPC;
|
||||
if (text.compare("audio/x-dsf"_L1, Qt::CaseInsensitive) == 0) return FileType::DSF;
|
||||
if (text.compare("audio/x-dsd"_L1, Qt::CaseInsensitive) == 0) return FileType::DSDIFF;
|
||||
if (text.compare("audio/x-ffmpeg-parsed-ape"_L1, Qt::CaseInsensitive) == 0) return FileType::APE;
|
||||
if (text.compare("Module Music Format (MOD)"_L1, Qt::CaseInsensitive) == 0) return FileType::MOD;
|
||||
if (text.compare("Module Music Format (MOD)"_L1, Qt::CaseInsensitive) == 0) return FileType::S3M;
|
||||
if (text.compare("SNES SPC700"_L1, Qt::CaseInsensitive) == 0) return FileType::SPC;
|
||||
if (text.compare("VGM"_L1, Qt::CaseInsensitive) == 0) return FileType::VGM;
|
||||
|
||||
return FileType::Unknown;
|
||||
|
||||
@ -1220,29 +1222,29 @@ Song::FileType Song::FiletypeByDescription(const QString &text) {
|
||||
|
||||
Song::FileType Song::FiletypeByExtension(const QString &ext) {
|
||||
|
||||
if (ext.compare(QLatin1String("wav"), Qt::CaseInsensitive) == 0 || ext.compare(QLatin1String("wave"), Qt::CaseInsensitive) == 0) return FileType::WAV;
|
||||
if (ext.compare(QLatin1String("flac"), Qt::CaseInsensitive) == 0) return FileType::FLAC;
|
||||
if (ext.compare(QLatin1String("wavpack"), Qt::CaseInsensitive) == 0 || ext.compare(QLatin1String("wv"), Qt::CaseInsensitive) == 0) return FileType::WavPack;
|
||||
if (ext.compare(QLatin1String("opus"), Qt::CaseInsensitive) == 0) return FileType::OggOpus;
|
||||
if (ext.compare(QLatin1String("speex"), Qt::CaseInsensitive) == 0 || ext.compare(QLatin1String("spx"), Qt::CaseInsensitive) == 0) return FileType::OggSpeex;
|
||||
if (ext.compare(QLatin1String("mp2"), Qt::CaseInsensitive) == 0) return FileType::MPEG;
|
||||
if (ext.compare(QLatin1String("mp3"), Qt::CaseInsensitive) == 0) return FileType::MPEG;
|
||||
if (ext.compare(QLatin1String("mp4"), Qt::CaseInsensitive) == 0 || ext.compare(QLatin1String("m4a"), Qt::CaseInsensitive) == 0 || ext.compare(QLatin1String("aac"), Qt::CaseInsensitive) == 0) return FileType::MP4;
|
||||
if (ext.compare(QLatin1String("asf"), Qt::CaseInsensitive) == 0 || ext.compare(QLatin1String("wma"), Qt::CaseInsensitive) == 0) return FileType::ASF;
|
||||
if (ext.compare(QLatin1String("aiff"), Qt::CaseInsensitive) == 0 || ext.compare(QLatin1String("aif"), Qt::CaseInsensitive) == 0 || ext.compare(QLatin1String("aifc"), Qt::CaseInsensitive) == 0) return FileType::AIFF;
|
||||
if (ext.compare(QLatin1String("mpc"), Qt::CaseInsensitive) == 0 || ext.compare(QLatin1String("mp+"), Qt::CaseInsensitive) == 0 || ext.compare(QLatin1String("mpp"), Qt::CaseInsensitive) == 0) return FileType::MPC;
|
||||
if (ext.compare(QLatin1String("dsf"), Qt::CaseInsensitive) == 0) return FileType::DSF;
|
||||
if (ext.compare(QLatin1String("dsd"), Qt::CaseInsensitive) == 0 || ext.compare(QLatin1String("dff"), Qt::CaseInsensitive) == 0) return FileType::DSDIFF;
|
||||
if (ext.compare(QLatin1String("ape"), Qt::CaseInsensitive) == 0) return FileType::APE;
|
||||
if (ext.compare(QLatin1String("mod"), Qt::CaseInsensitive) == 0 ||
|
||||
ext.compare(QLatin1String("module"), Qt::CaseInsensitive) == 0 ||
|
||||
ext.compare(QLatin1String("nst"), Qt::CaseInsensitive) == 0||
|
||||
ext.compare(QLatin1String("wow"), Qt::CaseInsensitive) == 0) return FileType::MOD;
|
||||
if (ext.compare(QLatin1String("s3m"), Qt::CaseInsensitive) == 0) return FileType::S3M;
|
||||
if (ext.compare(QLatin1String("xm"), Qt::CaseInsensitive) == 0) return FileType::XM;
|
||||
if (ext.compare(QLatin1String("it"), Qt::CaseInsensitive) == 0) return FileType::IT;
|
||||
if (ext.compare(QLatin1String("spc"), Qt::CaseInsensitive) == 0) return FileType::SPC;
|
||||
if (ext.compare(QLatin1String("vgm"), Qt::CaseInsensitive) == 0) return FileType::VGM;
|
||||
if (ext.compare("wav"_L1, Qt::CaseInsensitive) == 0 || ext.compare("wave"_L1, Qt::CaseInsensitive) == 0) return FileType::WAV;
|
||||
if (ext.compare("flac"_L1, Qt::CaseInsensitive) == 0) return FileType::FLAC;
|
||||
if (ext.compare("wavpack"_L1, Qt::CaseInsensitive) == 0 || ext.compare("wv"_L1, Qt::CaseInsensitive) == 0) return FileType::WavPack;
|
||||
if (ext.compare("opus"_L1, Qt::CaseInsensitive) == 0) return FileType::OggOpus;
|
||||
if (ext.compare("speex"_L1, Qt::CaseInsensitive) == 0 || ext.compare("spx"_L1, Qt::CaseInsensitive) == 0) return FileType::OggSpeex;
|
||||
if (ext.compare("mp2"_L1, Qt::CaseInsensitive) == 0) return FileType::MPEG;
|
||||
if (ext.compare("mp3"_L1, Qt::CaseInsensitive) == 0) return FileType::MPEG;
|
||||
if (ext.compare("mp4"_L1, Qt::CaseInsensitive) == 0 || ext.compare("m4a"_L1, Qt::CaseInsensitive) == 0 || ext.compare("aac"_L1, Qt::CaseInsensitive) == 0) return FileType::MP4;
|
||||
if (ext.compare("asf"_L1, Qt::CaseInsensitive) == 0 || ext.compare("wma"_L1, Qt::CaseInsensitive) == 0) return FileType::ASF;
|
||||
if (ext.compare("aiff"_L1, Qt::CaseInsensitive) == 0 || ext.compare("aif"_L1, Qt::CaseInsensitive) == 0 || ext.compare("aifc"_L1, Qt::CaseInsensitive) == 0) return FileType::AIFF;
|
||||
if (ext.compare("mpc"_L1, Qt::CaseInsensitive) == 0 || ext.compare("mp+"_L1, Qt::CaseInsensitive) == 0 || ext.compare("mpp"_L1, Qt::CaseInsensitive) == 0) return FileType::MPC;
|
||||
if (ext.compare("dsf"_L1, Qt::CaseInsensitive) == 0) return FileType::DSF;
|
||||
if (ext.compare("dsd"_L1, Qt::CaseInsensitive) == 0 || ext.compare("dff"_L1, Qt::CaseInsensitive) == 0) return FileType::DSDIFF;
|
||||
if (ext.compare("ape"_L1, Qt::CaseInsensitive) == 0) return FileType::APE;
|
||||
if (ext.compare("mod"_L1, Qt::CaseInsensitive) == 0 ||
|
||||
ext.compare("module"_L1, Qt::CaseInsensitive) == 0 ||
|
||||
ext.compare("nst"_L1, Qt::CaseInsensitive) == 0||
|
||||
ext.compare("wow"_L1, Qt::CaseInsensitive) == 0) return FileType::MOD;
|
||||
if (ext.compare("s3m"_L1, Qt::CaseInsensitive) == 0) return FileType::S3M;
|
||||
if (ext.compare("xm"_L1, Qt::CaseInsensitive) == 0) return FileType::XM;
|
||||
if (ext.compare("it"_L1, Qt::CaseInsensitive) == 0) return FileType::IT;
|
||||
if (ext.compare("spc"_L1, Qt::CaseInsensitive) == 0) return FileType::SPC;
|
||||
if (ext.compare("vgm"_L1, Qt::CaseInsensitive) == 0) return FileType::VGM;
|
||||
|
||||
return FileType::Unknown;
|
||||
|
||||
@ -1588,8 +1590,8 @@ void Song::InitFromItdb(Itdb_Track *track, const QString &prefix) {
|
||||
|
||||
d->source_ = Source::Device;
|
||||
QString filename = QString::fromLocal8Bit(track->ipod_path);
|
||||
filename.replace(QLatin1Char(':'), QLatin1Char('/'));
|
||||
if (prefix.contains(QLatin1String("://"))) {
|
||||
filename.replace(u':', u'/');
|
||||
if (prefix.contains("://"_L1)) {
|
||||
set_url(QUrl(prefix + filename));
|
||||
}
|
||||
else {
|
||||
@ -1935,7 +1937,7 @@ void Song::MergeUserSetData(const Song &other, const bool merge_playcount, const
|
||||
}
|
||||
|
||||
QString Song::AlbumKey() const {
|
||||
return QStringLiteral("%1|%2|%3").arg(is_compilation() ? QStringLiteral("_compilation") : effective_albumartist(), has_cue() ? cue_path() : QLatin1String(""), effective_album());
|
||||
return QStringLiteral("%1|%2|%3").arg(is_compilation() ? QStringLiteral("_compilation") : effective_albumartist(), has_cue() ? cue_path() : ""_L1, effective_album());
|
||||
}
|
||||
|
||||
size_t qHash(const Song &song) {
|
||||
|
@ -307,7 +307,7 @@ SongLoader::Result SongLoader::LoadLocalAsync(const QString &filename) {
|
||||
// It's a CUE - create virtual tracks
|
||||
QFile cue(matching_cue);
|
||||
if (cue.open(QIODevice::ReadOnly)) {
|
||||
const SongList songs = cue_parser_->Load(&cue, matching_cue, QDir(filename.section(QLatin1Char('/'), 0, -2)));
|
||||
const SongList songs = cue_parser_->Load(&cue, matching_cue, QDir(filename.section(u'/', 0, -2)));
|
||||
cue.close();
|
||||
for (const Song &song : songs) {
|
||||
if (song.is_valid()) songs_ << song;
|
||||
|
@ -26,6 +26,8 @@
|
||||
|
||||
#include "sqlquery.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
void SqlQuery::BindValue(const QString &placeholder, const QVariant &value) {
|
||||
|
||||
bound_values_.insert(placeholder, value);
|
||||
@ -36,13 +38,13 @@ void SqlQuery::BindValue(const QString &placeholder, const QVariant &value) {
|
||||
|
||||
void SqlQuery::BindStringValue(const QString &placeholder, const QString &value) {
|
||||
|
||||
BindValue(placeholder, value.isNull() ? QLatin1String("") : value);
|
||||
BindValue(placeholder, value.isNull() ? ""_L1 : value);
|
||||
|
||||
}
|
||||
|
||||
void SqlQuery::BindUrlValue(const QString &placeholder, const QUrl &value) {
|
||||
|
||||
BindValue(placeholder, value.isValid() ? value.toString(QUrl::FullyEncoded) : QLatin1String(""));
|
||||
BindValue(placeholder, value.isValid() ? value.toString(QUrl::FullyEncoded) : ""_L1);
|
||||
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,8 @@
|
||||
#include <QWindow>
|
||||
#include <qmath.h>
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
// Clamps float color values within (0, 255)
|
||||
static int clamp(float x) {
|
||||
const int val = x > 255 ? 255 : static_cast<int>(x);
|
||||
@ -461,7 +463,7 @@ QString StyleHelper::dpiSpecificImageFile(const QString &fileName) {
|
||||
QString StyleHelper::imageFileWithResolution(const QString &fileName, int dpr) {
|
||||
|
||||
const QFileInfo fi(fileName);
|
||||
return dpr == 1 ? fileName : fi.path() + QLatin1Char('/') + fi.completeBaseName() + QLatin1Char('@') + QString::number(dpr) + QLatin1String("x.") + fi.suffix();
|
||||
return dpr == 1 ? fileName : fi.path() + QLatin1Char('/') + fi.completeBaseName() + QLatin1Char('@') + QString::number(dpr) + "x."_L1 + fi.suffix();
|
||||
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include "core/logging.h"
|
||||
#include "stylesheetloader.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
StyleSheetLoader::StyleSheetLoader(QObject *parent) : QObject(parent) {}
|
||||
@ -90,7 +92,7 @@ void StyleSheetLoader::UpdateStyleSheet(QWidget *widget, SharedPtr<StyleSheetDat
|
||||
#else
|
||||
alt.setAlpha(130);
|
||||
#endif
|
||||
stylesheet.replace(QLatin1String("%palette-alternate-base"), QStringLiteral("rgba(%1,%2,%3,%4)").arg(alt.red()).arg(alt.green()).arg(alt.blue()).arg(alt.alpha()));
|
||||
stylesheet.replace("%palette-alternate-base"_L1, QStringLiteral("rgba(%1,%2,%3,%4)").arg(alt.red()).arg(alt.green()).arg(alt.blue()).arg(alt.alpha()));
|
||||
}
|
||||
|
||||
ReplaceColor(&stylesheet, QStringLiteral("Window"), p, QPalette::Window);
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include "song.h"
|
||||
#include "tagreaderclient.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kWorkerExecutableName[] = "strawberry-tagreader";
|
||||
}
|
||||
|
@ -30,6 +30,8 @@
|
||||
|
||||
#include "taskmanager.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
TaskManager::TaskManager(QObject *parent) : QObject(parent), next_task_id_(1) {
|
||||
|
||||
setObjectName(QLatin1String(metaObject()->className()));
|
||||
|
@ -61,7 +61,7 @@ QString TemporaryFile::GenerateFilename(const QString &filename_pattern) const {
|
||||
QString filename = filename_pattern;
|
||||
|
||||
Q_FOREVER {
|
||||
const int i = static_cast<int>(filename.indexOf(QLatin1Char('X')));
|
||||
const int i = static_cast<int>(filename.indexOf(u'X'));
|
||||
if (i == -1) break;
|
||||
const qint64 index = QRandomGenerator::global()->bounded(0, random_chars.length());
|
||||
const QChar random_char = random_chars.at(index);
|
||||
|
@ -79,6 +79,8 @@
|
||||
#include "coverfromurldialog.h"
|
||||
#include "currentalbumcoverloader.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
const char *AlbumCoverChoiceController::kLoadImageFileFilter = QT_TR_NOOP("Images (*.png *.jpg *.jpeg *.bmp *.gif *.xpm *.pbm *.pgm *.ppm *.xbm)");
|
||||
const char *AlbumCoverChoiceController::kSaveImageFileFilter = QT_TR_NOOP("Images (*.png *.jpg *.jpeg *.bmp *.xpm *.pbm *.ppm *.xbm)");
|
||||
const char *AlbumCoverChoiceController::kAllFilesFilter = QT_TR_NOOP("All files (*)");
|
||||
@ -233,12 +235,12 @@ QUrl AlbumCoverChoiceController::LoadCoverFromFile(Song *song) {
|
||||
|
||||
void AlbumCoverChoiceController::SaveCoverToFileManual(const Song &song, const AlbumCoverImageResult &result) {
|
||||
|
||||
QString initial_file_name = QLatin1String("/");
|
||||
QString initial_file_name = "/"_L1;
|
||||
|
||||
if (!song.effective_albumartist().isEmpty()) {
|
||||
initial_file_name = initial_file_name + song.effective_albumartist();
|
||||
}
|
||||
initial_file_name = initial_file_name + QLatin1Char('-') + (song.effective_album().isEmpty() ? tr("unknown") : song.effective_album()) + QLatin1String(".jpg");
|
||||
initial_file_name = initial_file_name + QLatin1Char('-') + (song.effective_album().isEmpty() ? tr("unknown") : song.effective_album()) + ".jpg"_L1;
|
||||
initial_file_name = initial_file_name.toLower();
|
||||
static const QRegularExpression regex_whitespaces(QStringLiteral("\\s"));
|
||||
initial_file_name.replace(regex_whitespaces, QStringLiteral("-"));
|
||||
@ -251,16 +253,16 @@ void AlbumCoverChoiceController::SaveCoverToFileManual(const Song &song, const A
|
||||
|
||||
QFileInfo fileinfo(save_filename);
|
||||
if (fileinfo.suffix().isEmpty()) {
|
||||
save_filename.append(QLatin1String(".jpg"));
|
||||
save_filename.append(".jpg"_L1);
|
||||
fileinfo.setFile(save_filename);
|
||||
}
|
||||
|
||||
if (!QImageWriter::supportedImageFormats().contains(fileinfo.completeSuffix().toUtf8().toLower())) {
|
||||
save_filename = Utilities::PathWithoutFilenameExtension(save_filename) + QLatin1String(".jpg");
|
||||
save_filename = Utilities::PathWithoutFilenameExtension(save_filename) + ".jpg"_L1;
|
||||
fileinfo.setFile(save_filename);
|
||||
}
|
||||
|
||||
if (result.is_jpeg() && fileinfo.completeSuffix().compare(QLatin1String("jpg"), Qt::CaseInsensitive) == 0) {
|
||||
if (result.is_jpeg() && fileinfo.completeSuffix().compare("jpg"_L1, Qt::CaseInsensitive) == 0) {
|
||||
QFile file(save_filename);
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
qLog(Error) << "Failed to open cover file" << save_filename << "for writing:" << file.errorString();
|
||||
@ -294,8 +296,8 @@ QString AlbumCoverChoiceController::GetInitialPathForFileDialog(const Song &song
|
||||
}
|
||||
|
||||
// If no automatic art, start in the song's folder
|
||||
if (!song.url().isEmpty() && song.url().isValid() && song.url().isLocalFile() && song.url().toLocalFile().contains(QLatin1Char('/'))) {
|
||||
return song.url().toLocalFile().section(QLatin1Char('/'), 0, -2) + filename;
|
||||
if (!song.url().isEmpty() && song.url().isValid() && song.url().isLocalFile() && song.url().toLocalFile().contains(u'/')) {
|
||||
return song.url().toLocalFile().section(u'/', 0, -2) + filename;
|
||||
}
|
||||
|
||||
return QDir::home().absolutePath() + filename;
|
||||
@ -478,13 +480,13 @@ void AlbumCoverChoiceController::ShowCover(const Song &song, const QPixmap &pixm
|
||||
|
||||
// Use Artist - Album as the window title
|
||||
QString title_text(song.effective_albumartist());
|
||||
if (!song.effective_album().isEmpty()) title_text += QLatin1String(" - ") + song.effective_album();
|
||||
if (!song.effective_album().isEmpty()) title_text += " - "_L1 + song.effective_album();
|
||||
|
||||
QLabel *label = new QLabel(dialog);
|
||||
label->setPixmap(pixmap);
|
||||
|
||||
// Add (WxHpx) to the title before possibly resizing
|
||||
title_text += QLatin1String(" (") + QString::number(pixmap.width()) + QLatin1Char('x') + QString::number(pixmap.height()) + QLatin1String("px)");
|
||||
title_text += QLatin1String(" (") + QString::number(pixmap.width()) + QLatin1Char('x') + QString::number(pixmap.height()) + "px)"_L1;
|
||||
|
||||
// If the cover is larger than the screen, resize the window 85% seems to be enough to account for title bar and taskbar etc.
|
||||
QScreen *screen = Utilities::GetScreen(this);
|
||||
@ -666,7 +668,7 @@ QUrl AlbumCoverChoiceController::SaveCoverToFileAutomatic(const Song::Source sou
|
||||
if (source == Song::Source::Collection && !cover_options_.cover_overwrite && !force_overwrite && get_save_album_cover_type() == CoverOptions::CoverType::Album && cover_options_.cover_filename == CoverOptions::CoverFilename::Pattern && file.exists()) {
|
||||
while (file.exists()) {
|
||||
QFileInfo fileinfo(file.fileName());
|
||||
file.setFileName(fileinfo.path() + QLatin1String("/0") + fileinfo.fileName());
|
||||
file.setFileName(fileinfo.path() + "/0"_L1 + fileinfo.fileName());
|
||||
}
|
||||
filepath = file.fileName();
|
||||
}
|
||||
|
@ -35,6 +35,8 @@
|
||||
|
||||
#include "core/settings.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
const char *AlbumCoverExport::kSettingsGroup = "AlbumCoverExport";
|
||||
|
||||
AlbumCoverExport::AlbumCoverExport(QWidget *parent) : QDialog(parent), ui_(new Ui_AlbumCoverExport) {
|
||||
@ -62,8 +64,8 @@ AlbumCoverExport::DialogResult AlbumCoverExport::Exec() {
|
||||
ui_->overwriteAll->setChecked(static_cast<OverwriteMode>(s.value("overwrite", static_cast<int>(OverwriteMode::All)).toInt()) == OverwriteMode::All);
|
||||
ui_->overwriteSmaller->setChecked(static_cast<OverwriteMode>(s.value("overwrite", static_cast<int>(OverwriteMode::Smaller)).toInt()) == OverwriteMode::Smaller);
|
||||
ui_->forceSize->setChecked(s.value("forceSize", false).toBool());
|
||||
ui_->width->setText(s.value("width", QLatin1String("")).toString());
|
||||
ui_->height->setText(s.value("height", QLatin1String("")).toString());
|
||||
ui_->width->setText(s.value("width", ""_L1).toString());
|
||||
ui_->height->setText(s.value("height", ""_L1).toString());
|
||||
ui_->export_downloaded->setChecked(s.value("export_downloaded", true).toBool());
|
||||
ui_->export_embedded->setChecked(s.value("export_embedded", false).toBool());
|
||||
|
||||
|
@ -48,6 +48,8 @@
|
||||
#include "coverproviders.h"
|
||||
#include "albumcoverimageresult.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr int kSearchTimeoutMs = 20000;
|
||||
constexpr int kImageLoadTimeoutMs = 6000;
|
||||
@ -86,7 +88,7 @@ void AlbumCoverFetcherSearch::TerminateSearch() {
|
||||
void AlbumCoverFetcherSearch::Start(SharedPtr<CoverProviders> cover_providers) {
|
||||
|
||||
// Ignore Radio Paradise "commercial" break.
|
||||
if (request_.artist.compare(QLatin1String("commercial-free"), Qt::CaseInsensitive) == 0 && request_.title.compare(QLatin1String("listener-supported"), Qt::CaseInsensitive) == 0) {
|
||||
if (request_.artist.compare("commercial-free"_L1, Qt::CaseInsensitive) == 0 && request_.title.compare("listener-supported"_L1, Qt::CaseInsensitive) == 0) {
|
||||
TerminateSearch();
|
||||
return;
|
||||
}
|
||||
@ -170,51 +172,51 @@ void AlbumCoverFetcherSearch::ProviderSearchResults(CoverProvider *provider, con
|
||||
// This is done since we can't match the album titles, and we want to prevent compilation or live albums from being picked before studio albums for streams.
|
||||
// TODO: Make these regular expressions.
|
||||
if (request_album.isEmpty() && (
|
||||
result_album.contains(QLatin1String("hits"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("greatest"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("best"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("collection"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("classics"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("singles"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("bootleg"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("live"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("concert"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("essential"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("ultimate"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("karaoke"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("mixtape"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("country rock"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("indie folk"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("soft rock"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("folk music"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("60's rock"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("60's romance"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("60s music"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("late 60s"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("the 60s"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("folk and blues"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("60 from the 60's"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("classic psychedelic"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("playlist: acoustic"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("90's rnb playlist"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("rock 80s"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("classic 80s"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("rock anthems"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("rock songs"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("rock 2019"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("guitar anthems"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("driving anthems"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("traffic jam jams"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("perfect background music"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("70's gold"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("rockfluence"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("acoustic dinner accompaniment"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("complete studio albums"), Qt::CaseInsensitive) ||
|
||||
result_album.contains(QLatin1String("mellow rock"), Qt::CaseInsensitive)
|
||||
result_album.contains("hits"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("greatest"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("best"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("collection"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("classics"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("singles"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("bootleg"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("live"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("concert"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("essential"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("ultimate"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("karaoke"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("mixtape"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("country rock"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("indie folk"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("soft rock"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("folk music"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("60's rock"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("60's romance"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("60s music"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("late 60s"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("the 60s"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("folk and blues"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("60 from the 60's"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("classic psychedelic"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("playlist: acoustic"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("90's rnb playlist"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("rock 80s"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("classic 80s"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("rock anthems"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("rock songs"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("rock 2019"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("guitar anthems"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("driving anthems"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("traffic jam jams"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("perfect background music"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("70's gold"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("rockfluence"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("acoustic dinner accompaniment"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("complete studio albums"_L1, Qt::CaseInsensitive) ||
|
||||
result_album.contains("mellow rock"_L1, Qt::CaseInsensitive)
|
||||
)) {
|
||||
results_copy[i].score_match -= 1;
|
||||
}
|
||||
else if (request_album.isEmpty() && result_album.contains(QLatin1String("soundtrack"), Qt::CaseInsensitive)) {
|
||||
else if (request_album.isEmpty() && result_album.contains("soundtrack"_L1, Qt::CaseInsensitive)) {
|
||||
results_copy[i].score_match -= 0.5;
|
||||
}
|
||||
|
||||
@ -323,8 +325,8 @@ void AlbumCoverFetcherSearch::ProviderCoverFetchFinished(QNetworkReply *reply) {
|
||||
}
|
||||
else {
|
||||
QString mimetype = reply->header(QNetworkRequest::ContentTypeHeader).toString();
|
||||
if (mimetype.contains(QLatin1Char(';'))) {
|
||||
mimetype = mimetype.left(mimetype.indexOf(QLatin1Char(';')));
|
||||
if (mimetype.contains(u';')) {
|
||||
mimetype = mimetype.left(mimetype.indexOf(u';'));
|
||||
}
|
||||
if (ImageUtils::SupportedImageMimeTypes().contains(mimetype, Qt::CaseInsensitive) || ImageUtils::SupportedImageFormats().contains(mimetype, Qt::CaseInsensitive)) {
|
||||
QByteArray image_data = reply->readAll();
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include "core/settings.h"
|
||||
#include "settings/coverssettingspage.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
AlbumCoverLoaderOptions::AlbumCoverLoaderOptions(const Options _options, const QSize _desired_scaled_size, const qreal _device_pixel_ratio, const Types &_types)
|
||||
: options(_options),
|
||||
desired_scaled_size(_desired_scaled_size),
|
||||
@ -39,16 +41,16 @@ AlbumCoverLoaderOptions::Types AlbumCoverLoaderOptions::LoadTypes() {
|
||||
const QStringList all_cover_types = QStringList() << QStringLiteral("art_unset") << QStringLiteral("art_embedded") << QStringLiteral("art_manual") << QStringLiteral("art_automatic");
|
||||
const QStringList cover_types_strlist = s.value(CoversSettingsPage::kTypes, all_cover_types).toStringList();
|
||||
for (const QString &cover_type_str : cover_types_strlist) {
|
||||
if (cover_type_str == QLatin1String("art_unset")) {
|
||||
if (cover_type_str == "art_unset"_L1) {
|
||||
cover_types << AlbumCoverLoaderOptions::Type::Unset;
|
||||
}
|
||||
else if (cover_type_str == QLatin1String("art_embedded")) {
|
||||
else if (cover_type_str == "art_embedded"_L1) {
|
||||
cover_types << AlbumCoverLoaderOptions::Type::Embedded;
|
||||
}
|
||||
else if (cover_type_str == QLatin1String("art_manual")) {
|
||||
else if (cover_type_str == "art_manual"_L1) {
|
||||
cover_types << AlbumCoverLoaderOptions::Type::Manual;
|
||||
}
|
||||
else if (cover_type_str == QLatin1String("art_automatic")) {
|
||||
else if (cover_type_str == "art_automatic"_L1) {
|
||||
cover_types << AlbumCoverLoaderOptions::Type::Automatic;
|
||||
}
|
||||
}
|
||||
|
@ -95,6 +95,7 @@
|
||||
#include "ui_albumcovermanager.h"
|
||||
|
||||
using namespace std::literals::chrono_literals;
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kSettingsGroup[] = "CoverManager";
|
||||
@ -289,10 +290,10 @@ void AlbumCoverManager::LoadGeometry() {
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
if (s.contains(QLatin1String("geometry"))) {
|
||||
if (s.contains("geometry"_L1)) {
|
||||
restoreGeometry(s.value("geometry").toByteArray());
|
||||
}
|
||||
if (s.contains(QLatin1String("splitter_state"))) {
|
||||
if (s.contains("splitter_state"_L1)) {
|
||||
ui_->splitter->restoreState(s.value("splitter_state").toByteArray());
|
||||
}
|
||||
else {
|
||||
@ -402,7 +403,7 @@ void AlbumCoverManager::ArtistChanged(QListWidgetItem *current) {
|
||||
display_text = album_info.album;
|
||||
}
|
||||
else {
|
||||
display_text = album_info.album_artist + QLatin1String(" - ") + album_info.album;
|
||||
display_text = album_info.album_artist + " - "_L1 + album_info.album;
|
||||
}
|
||||
|
||||
AlbumItem *album_item = new AlbumItem(icon_nocover_item_, display_text, ui_->albums);
|
||||
@ -418,7 +419,7 @@ void AlbumCoverManager::ArtistChanged(QListWidgetItem *current) {
|
||||
album_item->setToolTip(album_info.album);
|
||||
}
|
||||
else {
|
||||
album_item->setToolTip(album_info.album_artist + QLatin1String(" - ") + album_info.album);
|
||||
album_item->setToolTip(album_info.album_artist + " - "_L1 + album_info.album);
|
||||
}
|
||||
|
||||
album_item->setData(Role_ArtEmbedded, album_info.art_embedded);
|
||||
@ -536,7 +537,7 @@ bool AlbumCoverManager::ShouldHide(const AlbumItem &album_item, const QString &f
|
||||
return false;
|
||||
}
|
||||
|
||||
const QStringList query = filter.split(QLatin1Char(' '));
|
||||
const QStringList query = filter.split(u' ');
|
||||
for (const QString &s : query) {
|
||||
bool in_text = album_item.text().contains(s, Qt::CaseInsensitive);
|
||||
bool in_albumartist = album_item.data(Role_AlbumArtist).toString().contains(s, Qt::CaseInsensitive);
|
||||
@ -597,7 +598,7 @@ void AlbumCoverManager::UpdateStatusText() {
|
||||
.arg(fetch_statistics_.missing_images_);
|
||||
|
||||
if (fetch_statistics_.bytes_transferred_ > 0) {
|
||||
message += QLatin1String(", ") + tr("%1 transferred").arg(Utilities::PrettySize(fetch_statistics_.bytes_transferred_));
|
||||
message += ", "_L1 + tr("%1 transferred").arg(Utilities::PrettySize(fetch_statistics_.bytes_transferred_));
|
||||
}
|
||||
|
||||
statusBar()->showMessage(message);
|
||||
@ -671,7 +672,7 @@ Song AlbumCoverManager::AlbumItemAsSong(AlbumItem *album_item) {
|
||||
QString title = album_item->data(Role_Album).toString();
|
||||
QString artist_name = album_item->data(Role_AlbumArtist).toString();
|
||||
if (!artist_name.isEmpty()) {
|
||||
result.set_title(artist_name + QLatin1String(" - ") + title);
|
||||
result.set_title(artist_name + " - "_L1 + title);
|
||||
}
|
||||
else {
|
||||
result.set_title(title);
|
||||
|
@ -34,6 +34,8 @@
|
||||
#include "albumcoverexport.h"
|
||||
#include "coverexportrunnable.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
CoverExportRunnable::CoverExportRunnable(const AlbumCoverExport::DialogResult &dialog_result, const AlbumCoverLoaderOptions::Types &cover_types, const Song &song, QObject *parent)
|
||||
: QObject(parent),
|
||||
dialog_result_(dialog_result),
|
||||
@ -78,7 +80,7 @@ void CoverExportRunnable::ProcessAndExportCover() {
|
||||
if (song_.art_embedded() && dialog_result_.export_embedded_) {
|
||||
const TagReaderClient::Result result = TagReaderClient::Instance()->LoadEmbeddedArtAsImageBlocking(song_.url().toLocalFile(), image);
|
||||
if (result.success() && !image.isNull()) {
|
||||
extension = QLatin1String("jpg");
|
||||
extension = "jpg"_L1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -86,7 +88,7 @@ void CoverExportRunnable::ProcessAndExportCover() {
|
||||
if (dialog_result_.export_downloaded_ && song_.art_manual_is_valid()) {
|
||||
const QString cover_path = song_.art_manual().toLocalFile();
|
||||
if (image.load(cover_path)) {
|
||||
extension = cover_path.section(QLatin1Char('.'), -1);
|
||||
extension = cover_path.section(u'.', -1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -94,7 +96,7 @@ void CoverExportRunnable::ProcessAndExportCover() {
|
||||
if (dialog_result_.export_downloaded_ && song_.art_automatic_is_valid()) {
|
||||
const QString cover_path = song_.art_automatic().toLocalFile();
|
||||
if (image.load(cover_path)) {
|
||||
extension = cover_path.section(QLatin1Char('.'), -1);
|
||||
extension = cover_path.section(u'.', -1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -112,8 +114,8 @@ void CoverExportRunnable::ProcessAndExportCover() {
|
||||
image = image.scaled(QSize(dialog_result_.width_, dialog_result_.height_), Qt::IgnoreAspectRatio);
|
||||
}
|
||||
|
||||
QString cover_dir = song_.url().toLocalFile().section(QLatin1Char('/'), 0, -2);
|
||||
QString new_file = cover_dir + QLatin1Char('/') + dialog_result_.filename_ + QLatin1Char('.') + (song_.art_embedded() ? QLatin1String("jpg") : extension);
|
||||
QString cover_dir = song_.url().toLocalFile().section(u'/', 0, -2);
|
||||
QString new_file = cover_dir + QLatin1Char('/') + dialog_result_.filename_ + QLatin1Char('.') + (song_.art_embedded() ? "jpg"_L1 : extension);
|
||||
|
||||
// If the file exists, do not override!
|
||||
if (dialog_result_.overwrite_ == AlbumCoverExport::OverwriteMode::None && QFile::exists(new_file)) {
|
||||
@ -171,7 +173,7 @@ void CoverExportRunnable::ExportCover() {
|
||||
const TagReaderClient::Result result = TagReaderClient::Instance()->LoadEmbeddedArtAsImageBlocking(song_.url().toLocalFile(), image);
|
||||
if (result.success() && !image.isNull()) {
|
||||
embedded_cover = true;
|
||||
extension = QLatin1String("jpg");
|
||||
extension = "jpg"_L1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -179,7 +181,7 @@ void CoverExportRunnable::ExportCover() {
|
||||
if (dialog_result_.export_downloaded_ && song_.art_manual_is_valid()) {
|
||||
cover_path = song_.art_manual().toLocalFile();
|
||||
if (image.load(cover_path)) {
|
||||
extension = cover_path.section(QLatin1Char('.'), -1);
|
||||
extension = cover_path.section(u'.', -1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -187,7 +189,7 @@ void CoverExportRunnable::ExportCover() {
|
||||
if (dialog_result_.export_downloaded_ && song_.art_automatic_is_valid()) {
|
||||
cover_path = song_.art_automatic().toLocalFile();
|
||||
if (image.load(cover_path)) {
|
||||
extension = cover_path.section(QLatin1Char('.'), -1);
|
||||
extension = cover_path.section(u'.', -1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -200,7 +202,7 @@ void CoverExportRunnable::ExportCover() {
|
||||
return;
|
||||
}
|
||||
|
||||
QString cover_dir = song_.url().toLocalFile().section(QLatin1Char('/'), 0, -2);
|
||||
QString cover_dir = song_.url().toLocalFile().section(u'/', 0, -2);
|
||||
QString new_file = cover_dir + QLatin1Char('/') + dialog_result_.filename_ + QLatin1Char('.') + extension;
|
||||
|
||||
// If the file exists, do not override!
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include "coverfromurldialog.h"
|
||||
#include "ui_coverfromurldialog.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
CoverFromURLDialog::CoverFromURLDialog(SharedPtr<NetworkAccessManager> network, QWidget *parent)
|
||||
: QDialog(parent),
|
||||
network_(network),
|
||||
@ -56,7 +58,7 @@ CoverFromURLDialog::~CoverFromURLDialog() {
|
||||
AlbumCoverImageResult CoverFromURLDialog::Exec() {
|
||||
|
||||
// reset state
|
||||
ui_->url->setText(QLatin1String(""));
|
||||
ui_->url->setText(""_L1);
|
||||
last_album_cover_ = AlbumCoverImageResult();
|
||||
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
|
@ -48,6 +48,8 @@
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "deezercoverprovider.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kApiUrl[] = "https://api.deezer.com";
|
||||
constexpr int kLimit = 10;
|
||||
@ -74,14 +76,14 @@ bool DeezerCoverProvider::StartSearch(const QString &artist, const QString &albu
|
||||
QString resource;
|
||||
QString query = artist;
|
||||
if (album.isEmpty() && !title.isEmpty()) {
|
||||
resource = QLatin1String("search/track");
|
||||
if (!query.isEmpty()) query.append(QLatin1Char(' '));
|
||||
resource = "search/track"_L1;
|
||||
if (!query.isEmpty()) query.append(u' ');
|
||||
query.append(title);
|
||||
}
|
||||
else {
|
||||
resource = QLatin1String("search/album");
|
||||
resource = "search/album"_L1;
|
||||
if (!album.isEmpty()) {
|
||||
if (!query.isEmpty()) query.append(QLatin1Char(' '));
|
||||
if (!query.isEmpty()) query.append(u' ');
|
||||
query.append(album);
|
||||
}
|
||||
}
|
||||
@ -130,12 +132,12 @@ QByteArray DeezerCoverProvider::GetReplyData(QNetworkReply *reply) {
|
||||
QString error;
|
||||
if (json_error.error == QJsonParseError::NoError && !json_doc.isEmpty() && json_doc.isObject()) {
|
||||
QJsonObject json_obj = json_doc.object();
|
||||
if (json_obj.contains(QLatin1String("error"))) {
|
||||
QJsonValue value_error = json_obj[QLatin1String("error")];
|
||||
if (json_obj.contains("error"_L1)) {
|
||||
QJsonValue value_error = json_obj["error"_L1];
|
||||
if (value_error.isObject()) {
|
||||
QJsonObject obj_error = value_error.toObject();
|
||||
int code = obj_error[QLatin1String("code")].toInt();
|
||||
QString message = obj_error[QLatin1String("message")].toString();
|
||||
int code = obj_error["code"_L1].toInt();
|
||||
QString message = obj_error["message"_L1].toString();
|
||||
error = QStringLiteral("%1 (%2)").arg(message).arg(code);
|
||||
}
|
||||
}
|
||||
@ -162,27 +164,27 @@ QJsonValue DeezerCoverProvider::ExtractData(const QByteArray &data) {
|
||||
QJsonObject json_obj = ExtractJsonObj(data);
|
||||
if (json_obj.isEmpty()) return QJsonObject();
|
||||
|
||||
if (json_obj.contains(QLatin1String("error"))) {
|
||||
QJsonValue value_error = json_obj[QLatin1String("error")];
|
||||
if (json_obj.contains("error"_L1)) {
|
||||
QJsonValue value_error = json_obj["error"_L1];
|
||||
if (!value_error.isObject()) {
|
||||
Error(QStringLiteral("Error missing object"), json_obj);
|
||||
return QJsonValue();
|
||||
}
|
||||
QJsonObject obj_error = value_error.toObject();
|
||||
const int code = obj_error[QLatin1String("code")].toInt();
|
||||
QString message = obj_error[QLatin1String("message")].toString();
|
||||
const int code = obj_error["code"_L1].toInt();
|
||||
QString message = obj_error["message"_L1].toString();
|
||||
Error(QStringLiteral("%1 (%2)").arg(message).arg(code));
|
||||
return QJsonValue();
|
||||
}
|
||||
|
||||
if (!json_obj.contains(QLatin1String("data")) && !json_obj.contains(QLatin1String("DATA"))) {
|
||||
if (!json_obj.contains("data"_L1) && !json_obj.contains("DATA"_L1)) {
|
||||
Error(QStringLiteral("Json reply object is missing data."), json_obj);
|
||||
return QJsonValue();
|
||||
}
|
||||
|
||||
QJsonValue value_data;
|
||||
if (json_obj.contains(QLatin1String("data"))) value_data = json_obj[QLatin1String("data")];
|
||||
else value_data = json_obj[QLatin1String("DATA")];
|
||||
if (json_obj.contains("data"_L1)) value_data = json_obj["data"_L1];
|
||||
else value_data = json_obj["DATA"_L1];
|
||||
|
||||
return value_data;
|
||||
|
||||
@ -223,50 +225,50 @@ void DeezerCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
|
||||
}
|
||||
QJsonObject json_obj = json_value.toObject();
|
||||
QJsonObject obj_album;
|
||||
if (json_obj.contains(QLatin1String("album")) && json_obj[QLatin1String("album")].isObject()) { // Song search, so extract the album.
|
||||
obj_album = json_obj[QLatin1String("album")].toObject();
|
||||
if (json_obj.contains("album"_L1) && json_obj["album"_L1].isObject()) { // Song search, so extract the album.
|
||||
obj_album = json_obj["album"_L1].toObject();
|
||||
}
|
||||
else {
|
||||
obj_album = json_obj;
|
||||
}
|
||||
|
||||
if (!json_obj.contains(QLatin1String("id")) || !obj_album.contains(QLatin1String("id"))) {
|
||||
if (!json_obj.contains("id"_L1) || !obj_album.contains("id"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, data array value object is missing ID."), json_obj);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!obj_album.contains(QLatin1String("type"))) {
|
||||
if (!obj_album.contains("type"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, data array value album object is missing type."), obj_album);
|
||||
continue;
|
||||
}
|
||||
QString type = obj_album[QLatin1String("type")].toString();
|
||||
if (type != QLatin1String("album")) {
|
||||
QString type = obj_album["type"_L1].toString();
|
||||
if (type != "album"_L1) {
|
||||
Error(QStringLiteral("Invalid Json reply, data array value album object has incorrect type returned"), obj_album);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!json_obj.contains(QLatin1String("artist"))) {
|
||||
if (!json_obj.contains("artist"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, data array value object is missing artist."), json_obj);
|
||||
continue;
|
||||
}
|
||||
QJsonValue value_artist = json_obj[QLatin1String("artist")];
|
||||
QJsonValue value_artist = json_obj["artist"_L1];
|
||||
if (!value_artist.isObject()) {
|
||||
Error(QStringLiteral("Invalid Json reply, data array value artist is not a object."), value_artist);
|
||||
continue;
|
||||
}
|
||||
QJsonObject obj_artist = value_artist.toObject();
|
||||
|
||||
if (!obj_artist.contains(QLatin1String("name"))) {
|
||||
if (!obj_artist.contains("name"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, data array value artist object is missing name."), obj_artist);
|
||||
continue;
|
||||
}
|
||||
QString artist = obj_artist[QLatin1String("name")].toString();
|
||||
QString artist = obj_artist["name"_L1].toString();
|
||||
|
||||
if (!obj_album.contains(QLatin1String("title"))) {
|
||||
if (!obj_album.contains("title"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, data array value album object is missing title."), obj_album);
|
||||
continue;
|
||||
}
|
||||
QString album = obj_album[QLatin1String("title")].toString();
|
||||
QString album = obj_album["title"_L1].toString();
|
||||
|
||||
CoverProviderSearchResult cover_result;
|
||||
cover_result.artist = artist;
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "discogscoverprovider.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
using std::make_shared;
|
||||
|
||||
const char *DiscogsCoverProvider::kUrlSearch = "https://api.discogs.com/database/search";
|
||||
@ -163,7 +164,7 @@ QNetworkReply *DiscogsCoverProvider::CreateRequest(QUrl url, const ParamList &pa
|
||||
url.setQuery(url_query);
|
||||
|
||||
// Sign the request
|
||||
const QByteArray data_to_sign = QStringLiteral("GET\n%1\n%2\n%3").arg(url.host(), url.path(), query_items.join(QLatin1Char('&'))).toUtf8();
|
||||
const QByteArray data_to_sign = QStringLiteral("GET\n%1\n%2\n%3").arg(url.host(), url.path(), query_items.join(u'&')).toUtf8();
|
||||
const QByteArray signature(Utilities::HmacSha256(QByteArray::fromBase64(kSecretKeyB64), data_to_sign));
|
||||
|
||||
// Add the signature to the request
|
||||
@ -201,8 +202,8 @@ QByteArray DiscogsCoverProvider::GetReplyData(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.contains(QLatin1String("message"))) {
|
||||
error = json_obj[QLatin1String("message")].toString();
|
||||
if (json_obj.contains("message"_L1)) {
|
||||
error = json_obj["message"_L1].toString();
|
||||
}
|
||||
}
|
||||
if (error.isEmpty()) {
|
||||
@ -245,11 +246,11 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
|
||||
}
|
||||
|
||||
QJsonValue value_results;
|
||||
if (json_obj.contains(QLatin1String("results"))) {
|
||||
value_results = json_obj[QLatin1String("results")];
|
||||
if (json_obj.contains("results"_L1)) {
|
||||
value_results = json_obj["results"_L1];
|
||||
}
|
||||
else if (json_obj.contains(QLatin1String("message"))) {
|
||||
QString message = json_obj[QLatin1String("message")].toString();
|
||||
else if (json_obj.contains("message"_L1)) {
|
||||
QString message = json_obj["message"_L1].toString();
|
||||
Error(QStringLiteral("%1").arg(message));
|
||||
EndSearch(search);
|
||||
return;
|
||||
@ -274,15 +275,15 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
|
||||
continue;
|
||||
}
|
||||
QJsonObject obj_result = value_result.toObject();
|
||||
if (!obj_result.contains(QLatin1String("id")) || !obj_result.contains(QLatin1String("title")) || !obj_result.contains(QLatin1String("resource_url"))) {
|
||||
if (!obj_result.contains("id"_L1) || !obj_result.contains("title"_L1) || !obj_result.contains("resource_url"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, results value object is missing ID, title or resource_url."), obj_result);
|
||||
continue;
|
||||
}
|
||||
quint64 release_id = obj_result[QLatin1String("id")].toInt();
|
||||
QUrl resource_url(obj_result[QLatin1String("resource_url")].toString());
|
||||
QString title = obj_result[QLatin1String("title")].toString();
|
||||
quint64 release_id = obj_result["id"_L1].toInt();
|
||||
QUrl resource_url(obj_result["resource_url"_L1].toString());
|
||||
QString title = obj_result["title"_L1].toString();
|
||||
|
||||
if (title.contains(QLatin1String(" - "))) {
|
||||
if (title.contains(" - "_L1)) {
|
||||
QStringList title_splitted = title.split(QStringLiteral(" - "));
|
||||
if (title_splitted.count() == 2) {
|
||||
QString artist = title_splitted.first();
|
||||
@ -354,18 +355,18 @@ void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int se
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains(QLatin1String("artists")) || !json_obj.contains(QLatin1String("title"))) {
|
||||
if (!json_obj.contains("artists"_L1) || !json_obj.contains("title"_L1)) {
|
||||
Error(QStringLiteral("Json reply object is missing artists or title."), json_obj);
|
||||
EndSearch(search, release.id);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains(QLatin1String("images"))) {
|
||||
if (!json_obj.contains("images"_L1)) {
|
||||
EndSearch(search, release.id);
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonValue value_artists = json_obj[QLatin1String("artists")];
|
||||
QJsonValue value_artists = json_obj["artists"_L1];
|
||||
if (!value_artists.isArray()) {
|
||||
Error(QStringLiteral("Json reply object artists is not a array."), value_artists);
|
||||
EndSearch(search, release.id);
|
||||
@ -380,11 +381,11 @@ void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int se
|
||||
continue;
|
||||
}
|
||||
QJsonObject obj_artist = value_artist.toObject();
|
||||
if (!obj_artist.contains(QLatin1String("name"))) {
|
||||
if (!obj_artist.contains("name"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, artists array value object is missing name."), obj_artist);
|
||||
continue;
|
||||
}
|
||||
artist = obj_artist[QLatin1String("name")].toString();
|
||||
artist = obj_artist["name"_L1].toString();
|
||||
++i;
|
||||
if (artist == search->artist) break;
|
||||
}
|
||||
@ -393,15 +394,15 @@ void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int se
|
||||
EndSearch(search, release.id);
|
||||
return;
|
||||
}
|
||||
if (i > 1 && artist != search->artist) artist = QLatin1String("Various artists");
|
||||
if (i > 1 && artist != search->artist) artist = "Various artists"_L1;
|
||||
|
||||
QString album = json_obj[QLatin1String("title")].toString();
|
||||
QString album = json_obj["title"_L1].toString();
|
||||
if (artist != search->artist && album != search->album) {
|
||||
EndSearch(search, release.id);
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonValue value_images = json_obj[QLatin1String("images")];
|
||||
QJsonValue value_images = json_obj["images"_L1];
|
||||
if (!value_images.isArray()) {
|
||||
Error(QStringLiteral("Json images is not an array."));
|
||||
EndSearch(search, release.id);
|
||||
@ -422,23 +423,23 @@ void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int se
|
||||
continue;
|
||||
}
|
||||
QJsonObject obj_image = value_image.toObject();
|
||||
if (!obj_image.contains(QLatin1String("type")) || !obj_image.contains(QLatin1String("resource_url")) || !obj_image.contains(QLatin1String("width")) || !obj_image.contains(QLatin1String("height"))) {
|
||||
if (!obj_image.contains("type"_L1) || !obj_image.contains("resource_url"_L1) || !obj_image.contains("width"_L1) || !obj_image.contains("height"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, images array value object is missing type, resource_url, width or height."), obj_image);
|
||||
continue;
|
||||
}
|
||||
QString type = obj_image[QLatin1String("type")].toString();
|
||||
if (type != QLatin1String("primary")) {
|
||||
QString type = obj_image["type"_L1].toString();
|
||||
if (type != "primary"_L1) {
|
||||
continue;
|
||||
}
|
||||
int width = obj_image[QLatin1String("width")].toInt();
|
||||
int height = obj_image[QLatin1String("height")].toInt();
|
||||
int width = obj_image["width"_L1].toInt();
|
||||
int height = obj_image["height"_L1].toInt();
|
||||
if (width < 300 || height < 300) continue;
|
||||
const float aspect_score = static_cast<float>(1.0) - static_cast<float>(std::max(width, height) - std::min(width, height)) / static_cast<float>(std::max(height, width));
|
||||
if (aspect_score < 0.85) continue;
|
||||
CoverProviderSearchResult result;
|
||||
result.artist = artist;
|
||||
result.album = album;
|
||||
result.image_url = QUrl(obj_image[QLatin1String("resource_url")].toString());
|
||||
result.image_url = QUrl(obj_image["resource_url"_L1].toString());
|
||||
if (result.image_url.isEmpty()) continue;
|
||||
search->results.append(result);
|
||||
}
|
||||
|
@ -47,6 +47,8 @@
|
||||
#include "albumcoverfetcher.h"
|
||||
#include "lastfmcoverprovider.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kUrl[] = "https://ws.audioscrobbler.com/2.0/";
|
||||
constexpr char kApiKey[] = "211990b4c96782c05d1536e7219eb56e";
|
||||
@ -75,16 +77,16 @@ bool LastFmCoverProvider::StartSearch(const QString &artist, const QString &albu
|
||||
QString type;
|
||||
QString query = artist;
|
||||
if (album.isEmpty() && !title.isEmpty()) {
|
||||
method = QLatin1String("track.search");
|
||||
type = QLatin1String("track");
|
||||
if (!query.isEmpty()) query.append(QLatin1Char(' '));
|
||||
method = "track.search"_L1;
|
||||
type = "track"_L1;
|
||||
if (!query.isEmpty()) query.append(u' ');
|
||||
query.append(title);
|
||||
}
|
||||
else {
|
||||
method = QLatin1String("album.search");
|
||||
type = QLatin1String("album");
|
||||
method = "album.search"_L1;
|
||||
type = "album"_L1;
|
||||
if (!album.isEmpty()) {
|
||||
if (!query.isEmpty()) query.append(QLatin1Char(' '));
|
||||
if (!query.isEmpty()) query.append(u' ');
|
||||
query.append(album);
|
||||
}
|
||||
}
|
||||
@ -105,7 +107,7 @@ bool LastFmCoverProvider::StartSearch(const QString &artist, const QString &albu
|
||||
data_to_sign += QLatin1String(kSecret);
|
||||
|
||||
QByteArray const digest = QCryptographicHash::hash(data_to_sign.toUtf8(), QCryptographicHash::Md5);
|
||||
QString signature = QString::fromLatin1(digest.toHex()).rightJustified(32, QLatin1Char('0')).toLower();
|
||||
QString signature = QString::fromLatin1(digest.toHex()).rightJustified(32, u'0').toLower();
|
||||
|
||||
url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(QStringLiteral("api_sig"))), QString::fromLatin1(QUrl::toPercentEncoding(signature)));
|
||||
url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(QStringLiteral("format"))), QString::fromLatin1(QUrl::toPercentEncoding(QStringLiteral("json"))));
|
||||
@ -144,12 +146,12 @@ void LastFmCoverProvider::QueryFinished(QNetworkReply *reply, const int id, cons
|
||||
}
|
||||
|
||||
QJsonValue value_results;
|
||||
if (json_obj.contains(QLatin1String("results"))) {
|
||||
value_results = json_obj[QLatin1String("results")];
|
||||
if (json_obj.contains("results"_L1)) {
|
||||
value_results = json_obj["results"_L1];
|
||||
}
|
||||
else if (json_obj.contains(QLatin1String("error")) && json_obj.contains(QLatin1String("message"))) {
|
||||
int error = json_obj[QLatin1String("error")].toInt();
|
||||
QString message = json_obj[QLatin1String("message")].toString();
|
||||
else if (json_obj.contains("error"_L1) && json_obj.contains("message"_L1)) {
|
||||
int error = json_obj["error"_L1].toInt();
|
||||
QString message = json_obj["message"_L1].toString();
|
||||
Error(QStringLiteral("Error: %1: %2").arg(QString::number(error), message));
|
||||
Q_EMIT SearchFinished(id, results);
|
||||
return;
|
||||
@ -175,9 +177,9 @@ void LastFmCoverProvider::QueryFinished(QNetworkReply *reply, const int id, cons
|
||||
|
||||
QJsonValue value_matches;
|
||||
|
||||
if (type == QLatin1String("album")) {
|
||||
if (obj_results.contains(QLatin1String("albummatches"))) {
|
||||
value_matches = obj_results[QLatin1String("albummatches")];
|
||||
if (type == "album"_L1) {
|
||||
if (obj_results.contains("albummatches"_L1)) {
|
||||
value_matches = obj_results["albummatches"_L1];
|
||||
}
|
||||
else {
|
||||
Error(QStringLiteral("Json results object is missing albummatches."), obj_results);
|
||||
@ -185,9 +187,9 @@ void LastFmCoverProvider::QueryFinished(QNetworkReply *reply, const int id, cons
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (type == QLatin1String("track")) {
|
||||
if (obj_results.contains(QLatin1String("trackmatches"))) {
|
||||
value_matches = obj_results[QLatin1String("trackmatches")];
|
||||
else if (type == "track"_L1) {
|
||||
if (obj_results.contains("trackmatches"_L1)) {
|
||||
value_matches = obj_results["trackmatches"_L1];
|
||||
}
|
||||
else {
|
||||
Error(QStringLiteral("Json results object is missing trackmatches."), obj_results);
|
||||
@ -231,17 +233,17 @@ void LastFmCoverProvider::QueryFinished(QNetworkReply *reply, const int id, cons
|
||||
continue;
|
||||
}
|
||||
QJsonObject obj = value.toObject();
|
||||
if (!obj.contains(QLatin1String("artist")) || !obj.contains(QLatin1String("image")) || !obj.contains(QLatin1String("name"))) {
|
||||
if (!obj.contains("artist"_L1) || !obj.contains("image"_L1) || !obj.contains("name"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, album is missing artist, image or name."), obj);
|
||||
continue;
|
||||
}
|
||||
QString artist = obj[QLatin1String("artist")].toString();
|
||||
QString artist = obj["artist"_L1].toString();
|
||||
QString album;
|
||||
if (type == QLatin1String("album")) {
|
||||
album = obj[QLatin1String("name")].toString();
|
||||
if (type == "album"_L1) {
|
||||
album = obj["name"_L1].toString();
|
||||
}
|
||||
|
||||
QJsonValue json_image = obj[QLatin1String("image")];
|
||||
QJsonValue json_image = obj["image"_L1];
|
||||
if (!json_image.isArray()) {
|
||||
Error(QStringLiteral("Invalid Json reply, album image is not a array."), json_image);
|
||||
continue;
|
||||
@ -255,13 +257,13 @@ void LastFmCoverProvider::QueryFinished(QNetworkReply *reply, const int id, cons
|
||||
continue;
|
||||
}
|
||||
QJsonObject obj_image = value_image.toObject();
|
||||
if (!obj_image.contains(QLatin1String("#text")) || !obj_image.contains(QLatin1String("size"))) {
|
||||
if (!obj_image.contains("#text"_L1) || !obj_image.contains("size"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, album image value is missing #text or size."), obj_image);
|
||||
continue;
|
||||
}
|
||||
QString image_url = obj_image[QLatin1String("#text")].toString();
|
||||
QString image_url = obj_image["#text"_L1].toString();
|
||||
if (image_url.isEmpty()) continue;
|
||||
LastFmImageSize image_size = ImageSizeFromString(obj_image[QLatin1String("size")].toString().toLower());
|
||||
LastFmImageSize image_size = ImageSizeFromString(obj_image["size"_L1].toString().toLower());
|
||||
if (image_url_use.isEmpty() || image_size > image_size_use) {
|
||||
image_url_use = image_url;
|
||||
image_size_use = image_size;
|
||||
@ -271,8 +273,8 @@ void LastFmCoverProvider::QueryFinished(QNetworkReply *reply, const int id, cons
|
||||
if (image_url_use.isEmpty()) continue;
|
||||
|
||||
// Workaround for API limiting to 300x300 images.
|
||||
if (image_url_use.contains(QLatin1String("/300x300/"))) {
|
||||
image_url_use = image_url_use.replace(QLatin1String("/300x300/"), QLatin1String("/740x0/"));
|
||||
if (image_url_use.contains("/300x300/"_L1)) {
|
||||
image_url_use = image_url_use.replace("/300x300/"_L1, "/740x0/"_L1);
|
||||
}
|
||||
QUrl url(image_url_use);
|
||||
if (!url.isValid()) continue;
|
||||
@ -308,10 +310,10 @@ QByteArray LastFmCoverProvider::GetReplyData(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.contains(QLatin1String("error")) && json_obj.contains(QLatin1String("message"))) {
|
||||
int code = json_obj[QLatin1String("error")].toInt();
|
||||
QString message = json_obj[QLatin1String("message")].toString();
|
||||
error = QLatin1String("Error: ") + QString::number(code) + QLatin1String(": ") + message;
|
||||
if (json_obj.contains("error"_L1) && json_obj.contains("message"_L1)) {
|
||||
int code = json_obj["error"_L1].toInt();
|
||||
QString message = json_obj["message"_L1].toString();
|
||||
error = "Error: "_L1 + QString::number(code) + ": "_L1 + message;
|
||||
}
|
||||
}
|
||||
if (error.isEmpty()) {
|
||||
@ -340,10 +342,10 @@ void LastFmCoverProvider::Error(const QString &error, const QVariant &debug) {
|
||||
|
||||
LastFmCoverProvider::LastFmImageSize LastFmCoverProvider::ImageSizeFromString(const QString &size) {
|
||||
|
||||
if (size == QLatin1String("small")) return LastFmImageSize::Small;
|
||||
if (size == QLatin1String("medium")) return LastFmImageSize::Medium;
|
||||
if (size == QLatin1String("large")) return LastFmImageSize::Large;
|
||||
if (size == QLatin1String("extralarge")) return LastFmImageSize::ExtraLarge;
|
||||
if (size == "small"_L1) return LastFmImageSize::Small;
|
||||
if (size == "medium"_L1) return LastFmImageSize::Medium;
|
||||
if (size == "large"_L1) return LastFmImageSize::Large;
|
||||
if (size == "extralarge"_L1) return LastFmImageSize::ExtraLarge;
|
||||
|
||||
return LastFmImageSize::Unknown;
|
||||
|
||||
|
@ -44,6 +44,8 @@
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "musicbrainzcoverprovider.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kReleaseSearchUrl[] = "https://musicbrainz.org/ws/2/release/";
|
||||
constexpr char kAlbumCoverUrl[] = "https://coverartarchive.org/release/%1/front";
|
||||
@ -91,7 +93,7 @@ bool MusicbrainzCoverProvider::StartSearch(const QString &artist, const QString
|
||||
|
||||
void MusicbrainzCoverProvider::SendSearchRequest(const SearchRequest &request) {
|
||||
|
||||
QString query = QStringLiteral("release:\"%1\" AND artist:\"%2\"").arg(request.album.trimmed().replace(QLatin1Char('"'), QLatin1String("\\\"")), request.artist.trimmed().replace(QLatin1Char('"'), QLatin1String("\\\"")));
|
||||
QString query = QStringLiteral("release:\"%1\" AND artist:\"%2\"").arg(request.album.trimmed().replace(u'"', "\""_L1), request.artist.trimmed().replace(u'"', "\""_L1));
|
||||
|
||||
QUrlQuery url_query;
|
||||
url_query.addQueryItem(QStringLiteral("query"), query);
|
||||
@ -140,9 +142,9 @@ void MusicbrainzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains(QLatin1String("releases"))) {
|
||||
if (json_obj.contains(QLatin1String("error"))) {
|
||||
QString error = json_obj[QLatin1String("error")].toString();
|
||||
if (!json_obj.contains("releases"_L1)) {
|
||||
if (json_obj.contains("error"_L1)) {
|
||||
QString error = json_obj["error"_L1].toString();
|
||||
Error(error);
|
||||
}
|
||||
else {
|
||||
@ -151,7 +153,7 @@ void MusicbrainzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int
|
||||
Q_EMIT SearchFinished(search_id, results);
|
||||
return;
|
||||
}
|
||||
QJsonValue value_releases = json_obj[QLatin1String("releases")];
|
||||
QJsonValue value_releases = json_obj["releases"_L1];
|
||||
|
||||
if (!value_releases.isArray()) {
|
||||
Error(QStringLiteral("Json releases is not an array."), value_releases);
|
||||
@ -172,12 +174,12 @@ void MusicbrainzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int
|
||||
continue;
|
||||
}
|
||||
QJsonObject obj_release = value_release.toObject();
|
||||
if (!obj_release.contains(QLatin1String("id")) || !obj_release.contains(QLatin1String("artist-credit")) || !obj_release.contains(QLatin1String("title"))) {
|
||||
if (!obj_release.contains("id"_L1) || !obj_release.contains("artist-credit"_L1) || !obj_release.contains("title"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, releases array object is missing id, artist-credit or title."), obj_release);
|
||||
continue;
|
||||
}
|
||||
|
||||
QJsonValue json_artists = obj_release[QLatin1String("artist-credit")];
|
||||
QJsonValue json_artists = obj_release["artist-credit"_L1];
|
||||
if (!json_artists.isArray()) {
|
||||
Error(QStringLiteral("Invalid Json reply, artist-credit is not a array."), json_artists);
|
||||
continue;
|
||||
@ -192,28 +194,28 @@ void MusicbrainzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int
|
||||
}
|
||||
QJsonObject obj_artist = value_artist.toObject();
|
||||
|
||||
if (!obj_artist.contains(QLatin1String("artist"))) {
|
||||
if (!obj_artist.contains("artist"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, artist is missing."), obj_artist);
|
||||
continue;
|
||||
}
|
||||
QJsonValue value_artist2 = obj_artist[QLatin1String("artist")];
|
||||
QJsonValue value_artist2 = obj_artist["artist"_L1];
|
||||
if (!value_artist2.isObject()) {
|
||||
Error(QStringLiteral("Invalid Json reply, artist is not an object."), value_artist2);
|
||||
continue;
|
||||
}
|
||||
QJsonObject obj_artist2 = value_artist2.toObject();
|
||||
|
||||
if (!obj_artist2.contains(QLatin1String("name"))) {
|
||||
if (!obj_artist2.contains("name"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, artist is missing name."), value_artist2);
|
||||
continue;
|
||||
}
|
||||
artist = obj_artist2[QLatin1String("name")].toString();
|
||||
artist = obj_artist2["name"_L1].toString();
|
||||
++i;
|
||||
}
|
||||
if (i > 1) artist = QLatin1String("Various artists");
|
||||
if (i > 1) artist = "Various artists"_L1;
|
||||
|
||||
QString id = obj_release[QLatin1String("id")].toString();
|
||||
QString album = obj_release[QLatin1String("title")].toString();
|
||||
QString id = obj_release["id"_L1].toString();
|
||||
QString album = obj_release["title"_L1].toString();
|
||||
|
||||
CoverProviderSearchResult cover_result;
|
||||
QUrl url(QString::fromLatin1(kAlbumCoverUrl).arg(id));
|
||||
@ -247,8 +249,8 @@ QByteArray MusicbrainzCoverProvider::GetReplyData(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.contains(QLatin1String("error"))) {
|
||||
error = json_obj[QLatin1String("error")].toString();
|
||||
if (json_obj.contains("error"_L1)) {
|
||||
error = json_obj["error"_L1].toString();
|
||||
}
|
||||
}
|
||||
if (error.isEmpty()) {
|
||||
|
@ -40,6 +40,8 @@
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "musixmatchcoverprovider.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
MusixmatchCoverProvider::MusixmatchCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: JsonCoverProvider(QStringLiteral("Musixmatch"), true, false, 1.0, true, false, app, network, parent) {}
|
||||
|
||||
@ -107,8 +109,8 @@ void MusixmatchCoverProvider::HandleSearchReply(QNetworkReply *reply, const int
|
||||
return;
|
||||
}
|
||||
const QString content = QString::fromUtf8(data);
|
||||
const QString data_begin = QLatin1String("<script id=\"__NEXT_DATA__\" type=\"application/json\">");
|
||||
const QString data_end = QLatin1String("</script>");
|
||||
const QString data_begin = "<script id=\"__NEXT_DATA__\" type=\"application/json\">"_L1;
|
||||
const QString data_end = "</script>"_L1;
|
||||
if (!content.contains(data_begin) || !content.contains(data_end)) {
|
||||
Q_EMIT SearchFinished(id, results);
|
||||
return;
|
||||
@ -162,47 +164,47 @@ void MusixmatchCoverProvider::HandleSearchReply(QNetworkReply *reply, const int
|
||||
return;
|
||||
}
|
||||
|
||||
if (!obj_data.contains(QLatin1String("props")) || !obj_data[QLatin1String("props")].isObject()) {
|
||||
if (!obj_data.contains("props"_L1) || !obj_data["props"_L1].isObject()) {
|
||||
Error(QStringLiteral("Json reply is missing props."), obj_data);
|
||||
Q_EMIT SearchFinished(id, results);
|
||||
return;
|
||||
}
|
||||
obj_data = obj_data[QLatin1String("props")].toObject();
|
||||
obj_data = obj_data["props"_L1].toObject();
|
||||
|
||||
if (!obj_data.contains(QLatin1String("pageProps")) || !obj_data[QLatin1String("pageProps")].isObject()) {
|
||||
if (!obj_data.contains("pageProps"_L1) || !obj_data["pageProps"_L1].isObject()) {
|
||||
Error(QStringLiteral("Json props is missing pageProps."), obj_data);
|
||||
Q_EMIT SearchFinished(id, results);
|
||||
return;
|
||||
}
|
||||
obj_data = obj_data[QLatin1String("pageProps")].toObject();
|
||||
obj_data = obj_data["pageProps"_L1].toObject();
|
||||
|
||||
if (!obj_data.contains(QLatin1String("data")) || !obj_data[QLatin1String("data")].isObject()) {
|
||||
if (!obj_data.contains("data"_L1) || !obj_data["data"_L1].isObject()) {
|
||||
Error(QStringLiteral("Json pageProps is missing data."), obj_data);
|
||||
Q_EMIT SearchFinished(id, results);
|
||||
return;
|
||||
}
|
||||
obj_data = obj_data[QLatin1String("data")].toObject();
|
||||
obj_data = obj_data["data"_L1].toObject();
|
||||
|
||||
if (!obj_data.contains(QLatin1String("albumGet")) || !obj_data[QLatin1String("albumGet")].isObject()) {
|
||||
if (!obj_data.contains("albumGet"_L1) || !obj_data["albumGet"_L1].isObject()) {
|
||||
Error(QStringLiteral("Json data is missing albumGet."), obj_data);
|
||||
Q_EMIT SearchFinished(id, results);
|
||||
return;
|
||||
}
|
||||
obj_data = obj_data[QLatin1String("albumGet")].toObject();
|
||||
obj_data = obj_data["albumGet"_L1].toObject();
|
||||
|
||||
if (!obj_data.contains(QLatin1String("data")) || !obj_data[QLatin1String("data")].isObject()) {
|
||||
if (!obj_data.contains("data"_L1) || !obj_data["data"_L1].isObject()) {
|
||||
Error(QStringLiteral("Json albumGet reply is missing data."), obj_data);
|
||||
Q_EMIT SearchFinished(id, results);
|
||||
return;
|
||||
}
|
||||
obj_data = obj_data[QLatin1String("data")].toObject();
|
||||
obj_data = obj_data["data"_L1].toObject();
|
||||
|
||||
CoverProviderSearchResult result;
|
||||
if (obj_data.contains(QLatin1String("artistName")) && obj_data[QLatin1String("artistName")].isString()) {
|
||||
result.artist = obj_data[QLatin1String("artistName")].toString();
|
||||
if (obj_data.contains("artistName"_L1) && obj_data["artistName"_L1].isString()) {
|
||||
result.artist = obj_data["artistName"_L1].toString();
|
||||
}
|
||||
if (obj_data.contains(QLatin1String("name")) && obj_data[QLatin1String("name")].isString()) {
|
||||
result.album = obj_data[QLatin1String("name")].toString();
|
||||
if (obj_data.contains("name"_L1) && obj_data["name"_L1].isString()) {
|
||||
result.album = obj_data["name"_L1].toString();
|
||||
}
|
||||
|
||||
if (result.artist.compare(artist, Qt::CaseInsensitive) != 0 && result.album.compare(album, Qt::CaseInsensitive) != 0) {
|
||||
|
@ -47,6 +47,8 @@
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "opentidalcoverprovider.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kSettingsGroup[] = "OpenTidal";
|
||||
constexpr char kAuthUrl[] = "https://auth.tidal.com/v1/oauth2/token";
|
||||
@ -208,21 +210,21 @@ void OpenTidalCoverProvider::LoginFinished(QNetworkReply *reply) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains(QLatin1String("access_token")) ||
|
||||
!json_obj.contains(QLatin1String("token_type")) ||
|
||||
!json_obj.contains(QLatin1String("expires_in")) ||
|
||||
!json_obj[QLatin1String("access_token")].isString() ||
|
||||
!json_obj[QLatin1String("token_type")].isString()) {
|
||||
if (!json_obj.contains("access_token"_L1) ||
|
||||
!json_obj.contains("token_type"_L1) ||
|
||||
!json_obj.contains("expires_in"_L1) ||
|
||||
!json_obj["access_token"_L1].isString() ||
|
||||
!json_obj["token_type"_L1].isString()) {
|
||||
qLog(Error) << "OpenTidal: Invalid login reply.";
|
||||
FinishAllSearches();
|
||||
return;
|
||||
}
|
||||
|
||||
have_login_ = true;
|
||||
token_type_ = json_obj[QLatin1String("token_type")].toString();
|
||||
access_token_ = json_obj[QLatin1String("access_token")].toString();
|
||||
token_type_ = json_obj["token_type"_L1].toString();
|
||||
access_token_ = json_obj["access_token"_L1].toString();
|
||||
login_time_ = QDateTime::currentSecsSinceEpoch();
|
||||
expires_in_ = json_obj[QLatin1String("expires_in")].toInt();
|
||||
expires_in_ = json_obj["expires_in"_L1].toInt();
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
@ -285,21 +287,21 @@ QJsonObject OpenTidalCoverProvider::GetJsonObject(QNetworkReply *reply) {
|
||||
return QJsonObject();
|
||||
}
|
||||
QJsonObject json_obj = ExtractJsonObj(data);
|
||||
if (json_obj.contains(QLatin1String("errors")) && json_obj[QLatin1String("errors")].isArray()) {
|
||||
const QJsonArray array = json_obj[QLatin1String("errors")].toArray();
|
||||
if (json_obj.contains("errors"_L1) && json_obj["errors"_L1].isArray()) {
|
||||
const QJsonArray array = json_obj["errors"_L1].toArray();
|
||||
for (const QJsonValue &value : array) {
|
||||
if (!value.isObject()) continue;
|
||||
QJsonObject obj = value.toObject();
|
||||
if (!obj.contains(QLatin1String("category")) ||
|
||||
!obj.contains(QLatin1String("code")) ||
|
||||
!obj.contains(QLatin1String("detail"))) {
|
||||
if (!obj.contains("category"_L1) ||
|
||||
!obj.contains("code"_L1) ||
|
||||
!obj.contains("detail"_L1)) {
|
||||
continue;
|
||||
}
|
||||
QString category = obj[QLatin1String("category")].toString();
|
||||
QString code = obj[QLatin1String("code")].toString();
|
||||
QString detail = obj[QLatin1String("detail")].toString();
|
||||
QString category = obj["category"_L1].toString();
|
||||
QString code = obj["code"_L1].toString();
|
||||
QString detail = obj["detail"_L1].toString();
|
||||
qLog(Error) << "OpenTidal:" << category << code << detail;
|
||||
if (category == QLatin1String("AUTHENTICATION_ERROR")) {
|
||||
if (category == "AUTHENTICATION_ERROR"_L1) {
|
||||
LoginCheck();
|
||||
}
|
||||
}
|
||||
@ -320,11 +322,11 @@ void OpenTidalCoverProvider::SendSearchRequest(SearchRequestPtr search_request)
|
||||
|
||||
QString query = search_request->artist;
|
||||
if (!search_request->album.isEmpty()) {
|
||||
if (!query.isEmpty()) query.append(QLatin1Char(' '));
|
||||
if (!query.isEmpty()) query.append(u' ');
|
||||
query.append(search_request->album);
|
||||
}
|
||||
else if (!search_request->title.isEmpty()) {
|
||||
if (!query.isEmpty()) query.append(QLatin1Char(' '));
|
||||
if (!query.isEmpty()) query.append(u' ');
|
||||
query.append(search_request->title);
|
||||
}
|
||||
|
||||
@ -332,7 +334,7 @@ void OpenTidalCoverProvider::SendSearchRequest(SearchRequestPtr search_request)
|
||||
url_query.addQueryItem(QStringLiteral("query"), QString::fromUtf8(QUrl::toPercentEncoding(query)));
|
||||
url_query.addQueryItem(QStringLiteral("limit"), QString::number(kLimit));
|
||||
url_query.addQueryItem(QStringLiteral("countryCode"), QStringLiteral("US"));
|
||||
QUrl url(QLatin1String(kApiUrl) + QLatin1String("/search"));
|
||||
QUrl url(QLatin1String(kApiUrl) + "/search"_L1);
|
||||
url.setQuery(url_query);
|
||||
QNetworkRequest req(url);
|
||||
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||
@ -363,13 +365,13 @@ void OpenTidalCoverProvider::HandleSearchReply(QNetworkReply *reply, SearchReque
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains(QLatin1String("albums")) || !json_obj[QLatin1String("albums")].isArray()) {
|
||||
if (!json_obj.contains("albums"_L1) || !json_obj["albums"_L1].isArray()) {
|
||||
qLog(Debug) << "OpenTidal: Json object is missing albums.";
|
||||
Q_EMIT SearchFinished(search_request->id, CoverProviderSearchResults());
|
||||
return;
|
||||
}
|
||||
|
||||
const QJsonArray array_albums = json_obj[QLatin1String("albums")].toArray();
|
||||
const QJsonArray array_albums = json_obj["albums"_L1].toArray();
|
||||
if (array_albums.isEmpty()) {
|
||||
Q_EMIT SearchFinished(search_request->id, CoverProviderSearchResults());
|
||||
return;
|
||||
@ -385,55 +387,55 @@ void OpenTidalCoverProvider::HandleSearchReply(QNetworkReply *reply, SearchReque
|
||||
}
|
||||
QJsonObject obj_album = value_album.toObject();
|
||||
|
||||
if (!obj_album.contains(QLatin1String("resource")) || !obj_album[QLatin1String("resource")].isObject()) {
|
||||
if (!obj_album.contains("resource"_L1) || !obj_album["resource"_L1].isObject()) {
|
||||
qLog(Debug) << "OpenTidal: Invalid Json reply: Albums array album is missing resource object.";
|
||||
continue;
|
||||
}
|
||||
QJsonObject obj_resource = obj_album[QLatin1String("resource")].toObject();
|
||||
QJsonObject obj_resource = obj_album["resource"_L1].toObject();
|
||||
|
||||
if (!obj_resource.contains(QLatin1String("artists")) || !obj_resource[QLatin1String("artists")].isArray()) {
|
||||
if (!obj_resource.contains("artists"_L1) || !obj_resource["artists"_L1].isArray()) {
|
||||
qLog(Debug) << "OpenTidal: Invalid Json reply: Resource is missing artists array.";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!obj_resource.contains(QLatin1String("title")) || !obj_resource[QLatin1String("title")].isString()) {
|
||||
if (!obj_resource.contains("title"_L1) || !obj_resource["title"_L1].isString()) {
|
||||
qLog(Debug) << "OpenTidal: Invalid Json reply: Resource is missing title.";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!obj_resource.contains(QLatin1String("imageCover")) || !obj_resource[QLatin1String("imageCover")].isArray()) {
|
||||
if (!obj_resource.contains("imageCover"_L1) || !obj_resource["imageCover"_L1].isArray()) {
|
||||
qLog(Debug) << "OpenTidal: Invalid Json reply: Resource is missing imageCover array.";
|
||||
continue;
|
||||
}
|
||||
|
||||
QString artist;
|
||||
const QString album = obj_resource[QLatin1String("title")].toString();
|
||||
const QString album = obj_resource["title"_L1].toString();
|
||||
|
||||
const QJsonArray array_artists = obj_resource[QLatin1String("artists")].toArray();
|
||||
const QJsonArray array_artists = obj_resource["artists"_L1].toArray();
|
||||
for (const QJsonValue &value_artist : array_artists) {
|
||||
if (!value_artist.isObject()) {
|
||||
continue;
|
||||
}
|
||||
QJsonObject obj_artist = value_artist.toObject();
|
||||
if (!obj_artist.contains(QLatin1String("name"))) {
|
||||
if (!obj_artist.contains("name"_L1)) {
|
||||
continue;
|
||||
}
|
||||
artist = obj_artist[QLatin1String("name")].toString();
|
||||
artist = obj_artist["name"_L1].toString();
|
||||
break;
|
||||
}
|
||||
|
||||
const QJsonArray array_covers = obj_resource[QLatin1String("imageCover")].toArray();
|
||||
const QJsonArray array_covers = obj_resource["imageCover"_L1].toArray();
|
||||
for (const QJsonValue &value_cover : array_covers) {
|
||||
if (!value_cover.isObject()) {
|
||||
continue;
|
||||
}
|
||||
QJsonObject obj_cover = value_cover.toObject();
|
||||
if (!obj_cover.contains(QLatin1String("url")) || !obj_cover.contains(QLatin1String("width")) || !obj_cover.contains(QLatin1String("height"))) {
|
||||
if (!obj_cover.contains("url"_L1) || !obj_cover.contains("width"_L1) || !obj_cover.contains("height"_L1)) {
|
||||
continue;
|
||||
}
|
||||
const QUrl url(obj_cover[QLatin1String("url")].toString());
|
||||
const int width = obj_cover[QLatin1String("width")].toInt();
|
||||
const int height = obj_cover[QLatin1String("height")].toInt();
|
||||
const QUrl url(obj_cover["url"_L1].toString());
|
||||
const int width = obj_cover["width"_L1].toInt();
|
||||
const int height = obj_cover["height"_L1].toInt();
|
||||
if (!url.isValid()) continue;
|
||||
if (width < 640 || height < 640) continue;
|
||||
CoverProviderSearchResult cover_result;
|
||||
|
@ -47,6 +47,8 @@
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "qobuzcoverprovider.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr int kLimit = 10;
|
||||
}
|
||||
@ -73,14 +75,14 @@ bool QobuzCoverProvider::StartSearch(const QString &artist, const QString &album
|
||||
QString resource;
|
||||
QString query = artist;
|
||||
if (album.isEmpty() && !title.isEmpty()) {
|
||||
resource = QLatin1String("track/search");
|
||||
if (!query.isEmpty()) query.append(QLatin1Char(' '));
|
||||
resource = "track/search"_L1;
|
||||
if (!query.isEmpty()) query.append(u' ');
|
||||
query.append(title);
|
||||
}
|
||||
else {
|
||||
resource = QLatin1String("album/search");
|
||||
resource = "album/search"_L1;
|
||||
if (!album.isEmpty()) {
|
||||
if (!query.isEmpty()) query.append(QLatin1Char(' '));
|
||||
if (!query.isEmpty()) query.append(u' ');
|
||||
query.append(album);
|
||||
}
|
||||
}
|
||||
@ -134,9 +136,9 @@ QByteArray QobuzCoverProvider::GetReplyData(QNetworkReply *reply) {
|
||||
QJsonDocument json_doc = QJsonDocument::fromJson(data, &parse_error);
|
||||
if (parse_error.error == QJsonParseError::NoError && !json_doc.isEmpty() && json_doc.isObject()) {
|
||||
QJsonObject json_obj = json_doc.object();
|
||||
if (!json_obj.isEmpty() && json_obj.contains(QLatin1String("status")) && json_obj.contains(QLatin1String("code")) && json_obj.contains(QLatin1String("message"))) {
|
||||
int code = json_obj[QLatin1String("code")].toInt();
|
||||
QString message = json_obj[QLatin1String("message")].toString();
|
||||
if (!json_obj.isEmpty() && json_obj.contains("status"_L1) && json_obj.contains("code"_L1) && json_obj.contains("message"_L1)) {
|
||||
int code = json_obj["code"_L1].toInt();
|
||||
QString message = json_obj["message"_L1].toString();
|
||||
error = QStringLiteral("%1 (%2)").arg(message).arg(code);
|
||||
}
|
||||
}
|
||||
@ -179,11 +181,11 @@ void QobuzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) {
|
||||
}
|
||||
|
||||
QJsonValue value_type;
|
||||
if (json_obj.contains(QLatin1String("albums"))) {
|
||||
value_type = json_obj[QLatin1String("albums")];
|
||||
if (json_obj.contains("albums"_L1)) {
|
||||
value_type = json_obj["albums"_L1];
|
||||
}
|
||||
else if (json_obj.contains(QLatin1String("tracks"))) {
|
||||
value_type = json_obj[QLatin1String("tracks")];
|
||||
else if (json_obj.contains("tracks"_L1)) {
|
||||
value_type = json_obj["tracks"_L1];
|
||||
}
|
||||
else {
|
||||
Error(QStringLiteral("Json reply is missing albums and tracks object."), json_obj);
|
||||
@ -198,12 +200,12 @@ void QobuzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) {
|
||||
}
|
||||
QJsonObject obj_type = value_type.toObject();
|
||||
|
||||
if (!obj_type.contains(QLatin1String("items"))) {
|
||||
if (!obj_type.contains("items"_L1)) {
|
||||
Error(QStringLiteral("Json albums or tracks object does not contain items."), obj_type);
|
||||
Q_EMIT SearchFinished(id, results);
|
||||
return;
|
||||
}
|
||||
QJsonValue value_items = obj_type[QLatin1String("items")];
|
||||
QJsonValue value_items = obj_type["items"_L1];
|
||||
|
||||
if (!value_items.isArray()) {
|
||||
Error(QStringLiteral("Json albums or track object items is not a array."), value_items);
|
||||
@ -221,49 +223,49 @@ void QobuzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) {
|
||||
QJsonObject item_obj = value.toObject();
|
||||
|
||||
QJsonObject obj_album;
|
||||
if (item_obj.contains(QLatin1String("album"))) {
|
||||
if (!item_obj[QLatin1String("album")].isObject()) {
|
||||
if (item_obj.contains("album"_L1)) {
|
||||
if (!item_obj["album"_L1].isObject()) {
|
||||
Error(QStringLiteral("Invalid Json reply, items album is not a object."), item_obj);
|
||||
continue;
|
||||
}
|
||||
obj_album = item_obj[QLatin1String("album")].toObject();
|
||||
obj_album = item_obj["album"_L1].toObject();
|
||||
}
|
||||
else {
|
||||
obj_album = item_obj;
|
||||
}
|
||||
|
||||
if (!obj_album.contains(QLatin1String("artist")) || !obj_album.contains(QLatin1String("image")) || !obj_album.contains(QLatin1String("title"))) {
|
||||
if (!obj_album.contains("artist"_L1) || !obj_album.contains("image"_L1) || !obj_album.contains("title"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, item is missing artist, title or image."), obj_album);
|
||||
continue;
|
||||
}
|
||||
|
||||
QString album = obj_album[QLatin1String("title")].toString();
|
||||
QString album = obj_album["title"_L1].toString();
|
||||
|
||||
// Artist
|
||||
QJsonValue value_artist = obj_album[QLatin1String("artist")];
|
||||
QJsonValue value_artist = obj_album["artist"_L1];
|
||||
if (!value_artist.isObject()) {
|
||||
Error(QStringLiteral("Invalid Json reply, items (album) artist is not a object."), value_artist);
|
||||
continue;
|
||||
}
|
||||
QJsonObject obj_artist = value_artist.toObject();
|
||||
if (!obj_artist.contains(QLatin1String("name"))) {
|
||||
if (!obj_artist.contains("name"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, items (album) artist is missing name."), obj_artist);
|
||||
continue;
|
||||
}
|
||||
QString artist = obj_artist[QLatin1String("name")].toString();
|
||||
QString artist = obj_artist["name"_L1].toString();
|
||||
|
||||
// Image
|
||||
QJsonValue value_image = obj_album[QLatin1String("image")];
|
||||
QJsonValue value_image = obj_album["image"_L1];
|
||||
if (!value_image.isObject()) {
|
||||
Error(QStringLiteral("Invalid Json reply, items (album) image is not a object."), value_image);
|
||||
continue;
|
||||
}
|
||||
QJsonObject obj_image = value_image.toObject();
|
||||
if (!obj_image.contains(QLatin1String("large"))) {
|
||||
if (!obj_image.contains("large"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, items (album) image is missing large."), obj_image);
|
||||
continue;
|
||||
}
|
||||
QUrl cover_url(obj_image[QLatin1String("large")].toString());
|
||||
QUrl cover_url(obj_image["large"_L1].toString());
|
||||
|
||||
CoverProviderSearchResult cover_result;
|
||||
cover_result.artist = artist;
|
||||
|
@ -52,6 +52,8 @@
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "spotifycoverprovider.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kApiUrl[] = "https://api.spotify.com/v1";
|
||||
constexpr int kLimit = 10;
|
||||
@ -82,16 +84,16 @@ bool SpotifyCoverProvider::StartSearch(const QString &artist, const QString &alb
|
||||
QString extract;
|
||||
QString query = artist;
|
||||
if (album.isEmpty() && !title.isEmpty()) {
|
||||
type = QLatin1String("track");
|
||||
extract = QLatin1String("tracks");
|
||||
if (!query.isEmpty()) query.append(QLatin1Char(' '));
|
||||
type = "track"_L1;
|
||||
extract = "tracks"_L1;
|
||||
if (!query.isEmpty()) query.append(u' ');
|
||||
query.append(title);
|
||||
}
|
||||
else {
|
||||
type = QLatin1String("album");
|
||||
extract = QLatin1String("albums");
|
||||
type = "album"_L1;
|
||||
extract = "albums"_L1;
|
||||
if (!album.isEmpty()) {
|
||||
if (!query.isEmpty()) query.append(QLatin1Char(' '));
|
||||
if (!query.isEmpty()) query.append(u' ');
|
||||
query.append(album);
|
||||
}
|
||||
}
|
||||
@ -141,11 +143,11 @@ QByteArray SpotifyCoverProvider::GetReplyData(QNetworkReply *reply) {
|
||||
QString error;
|
||||
if (parse_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[QLatin1String("error")].isObject()) {
|
||||
QJsonObject obj_error = json_obj[QLatin1String("error")].toObject();
|
||||
if (obj_error.contains(QLatin1String("status")) && obj_error.contains(QLatin1String("message"))) {
|
||||
int status = obj_error[QLatin1String("status")].toInt();
|
||||
QString message = obj_error[QLatin1String("message")].toString();
|
||||
if (!json_obj.isEmpty() && json_obj.contains("error"_L1) && json_obj["error"_L1].isObject()) {
|
||||
QJsonObject obj_error = json_obj["error"_L1].toObject();
|
||||
if (obj_error.contains("status"_L1) && obj_error.contains("message"_L1)) {
|
||||
int status = obj_error["status"_L1].toInt();
|
||||
QString message = obj_error["message"_L1].toString();
|
||||
error = QStringLiteral("%1 (%2)").arg(message).arg(status);
|
||||
if (status == 401) Deauthenticate();
|
||||
}
|
||||
@ -195,13 +197,13 @@ void SpotifyCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id,
|
||||
}
|
||||
json_obj = json_obj[extract].toObject();
|
||||
|
||||
if (!json_obj.contains(QLatin1String("items")) || !json_obj[QLatin1String("items")].isArray()) {
|
||||
if (!json_obj.contains("items"_L1) || !json_obj["items"_L1].isArray()) {
|
||||
Error(QStringLiteral("%1 object is missing items array.").arg(extract), json_obj);
|
||||
Q_EMIT SearchFinished(id, CoverProviderSearchResults());
|
||||
return;
|
||||
}
|
||||
|
||||
const QJsonArray array_items = json_obj[QLatin1String("items")].toArray();
|
||||
const QJsonArray array_items = json_obj["items"_L1].toArray();
|
||||
if (array_items.isEmpty()) {
|
||||
Q_EMIT SearchFinished(id, CoverProviderSearchResults());
|
||||
return;
|
||||
@ -216,33 +218,33 @@ void SpotifyCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id,
|
||||
QJsonObject obj_item = value_item.toObject();
|
||||
|
||||
QJsonObject obj_album = obj_item;
|
||||
if (obj_item.contains(QLatin1String("album")) && obj_item[QLatin1String("album")].isObject()) {
|
||||
obj_album = obj_item[QLatin1String("album")].toObject();
|
||||
if (obj_item.contains("album"_L1) && obj_item["album"_L1].isObject()) {
|
||||
obj_album = obj_item["album"_L1].toObject();
|
||||
}
|
||||
|
||||
if (!obj_album.contains(QLatin1String("artists")) || !obj_album.contains(QLatin1String("name")) || !obj_album.contains(QLatin1String("images")) || !obj_album[QLatin1String("artists")].isArray() || !obj_album[QLatin1String("images")].isArray()) {
|
||||
if (!obj_album.contains("artists"_L1) || !obj_album.contains("name"_L1) || !obj_album.contains("images"_L1) || !obj_album["artists"_L1].isArray() || !obj_album["images"_L1].isArray()) {
|
||||
continue;
|
||||
}
|
||||
const QJsonArray array_artists = obj_album[QLatin1String("artists")].toArray();
|
||||
const QJsonArray array_images = obj_album[QLatin1String("images")].toArray();
|
||||
QString album = obj_album[QLatin1String("name")].toString();
|
||||
const QJsonArray array_artists = obj_album["artists"_L1].toArray();
|
||||
const QJsonArray array_images = obj_album["images"_L1].toArray();
|
||||
QString album = obj_album["name"_L1].toString();
|
||||
|
||||
QStringList artists;
|
||||
for (const QJsonValue &value_artist : array_artists) {
|
||||
if (!value_artist.isObject()) continue;
|
||||
QJsonObject obj_artist = value_artist.toObject();
|
||||
if (!obj_artist.contains(QLatin1String("name"))) continue;
|
||||
artists << obj_artist[QLatin1String("name")].toString();
|
||||
if (!obj_artist.contains("name"_L1)) continue;
|
||||
artists << obj_artist["name"_L1].toString();
|
||||
}
|
||||
|
||||
for (const QJsonValue &value_image : array_images) {
|
||||
if (!value_image.isObject()) continue;
|
||||
QJsonObject obj_image = value_image.toObject();
|
||||
if (!obj_image.contains(QLatin1String("url")) || !obj_image.contains(QLatin1String("width")) || !obj_image.contains(QLatin1String("height"))) continue;
|
||||
int width = obj_image[QLatin1String("width")].toInt();
|
||||
int height = obj_image[QLatin1String("height")].toInt();
|
||||
if (!obj_image.contains("url"_L1) || !obj_image.contains("width"_L1) || !obj_image.contains("height"_L1)) continue;
|
||||
int width = obj_image["width"_L1].toInt();
|
||||
int height = obj_image["height"_L1].toInt();
|
||||
if (width < 300 || height < 300) continue;
|
||||
QUrl url(obj_image[QLatin1String("url")].toString());
|
||||
QUrl url(obj_image["url"_L1].toString());
|
||||
CoverProviderSearchResult result;
|
||||
result.album = album;
|
||||
result.image_url = url;
|
||||
|
@ -45,6 +45,8 @@
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "tidalcoverprovider.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr int kLimit = 10;
|
||||
}
|
||||
@ -73,14 +75,14 @@ bool TidalCoverProvider::StartSearch(const QString &artist, const QString &album
|
||||
QString resource;
|
||||
QString query = artist;
|
||||
if (album.isEmpty() && !title.isEmpty()) {
|
||||
resource = QLatin1String("search/tracks");
|
||||
if (!query.isEmpty()) query.append(QLatin1Char(' '));
|
||||
resource = "search/tracks"_L1;
|
||||
if (!query.isEmpty()) query.append(u' ');
|
||||
query.append(title);
|
||||
}
|
||||
else {
|
||||
resource = QLatin1String("search/albums");
|
||||
resource = "search/albums"_L1;
|
||||
if (!album.isEmpty()) {
|
||||
if (!query.isEmpty()) query.append(QLatin1Char(' '));
|
||||
if (!query.isEmpty()) query.append(u' ');
|
||||
query.append(album);
|
||||
}
|
||||
}
|
||||
@ -134,10 +136,10 @@ QByteArray TidalCoverProvider::GetReplyData(QNetworkReply *reply) {
|
||||
QString error;
|
||||
if (parse_error.error == QJsonParseError::NoError && !json_doc.isEmpty() && json_doc.isObject()) {
|
||||
QJsonObject json_obj = json_doc.object();
|
||||
if (!json_obj.isEmpty() && json_obj.contains(QLatin1String("status")) && json_obj.contains(QLatin1String("userMessage"))) {
|
||||
status = json_obj[QLatin1String("status")].toInt();
|
||||
sub_status = json_obj[QLatin1String("subStatus")].toInt();
|
||||
QString user_message = json_obj[QLatin1String("userMessage")].toString();
|
||||
if (!json_obj.isEmpty() && json_obj.contains("status"_L1) && json_obj.contains("userMessage"_L1)) {
|
||||
status = json_obj["status"_L1].toInt();
|
||||
sub_status = json_obj["subStatus"_L1].toInt();
|
||||
QString user_message = json_obj["userMessage"_L1].toString();
|
||||
error = QStringLiteral("%1 (%2) (%3)").arg(user_message).arg(status).arg(sub_status);
|
||||
}
|
||||
}
|
||||
@ -180,12 +182,12 @@ void TidalCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains(QLatin1String("items"))) {
|
||||
if (!json_obj.contains("items"_L1)) {
|
||||
Error(QStringLiteral("Json object is missing items."), json_obj);
|
||||
Q_EMIT SearchFinished(id, CoverProviderSearchResults());
|
||||
return;
|
||||
}
|
||||
QJsonValue value_items = json_obj[QLatin1String("items")];
|
||||
QJsonValue value_items = json_obj["items"_L1];
|
||||
|
||||
if (!value_items.isArray()) {
|
||||
Q_EMIT SearchFinished(id, CoverProviderSearchResults());
|
||||
@ -207,25 +209,25 @@ void TidalCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) {
|
||||
}
|
||||
QJsonObject obj_item = value_item.toObject();
|
||||
|
||||
if (!obj_item.contains(QLatin1String("artist"))) {
|
||||
if (!obj_item.contains("artist"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, items array item is missing artist."), obj_item);
|
||||
continue;
|
||||
}
|
||||
QJsonValue value_artist = obj_item[QLatin1String("artist")];
|
||||
QJsonValue value_artist = obj_item["artist"_L1];
|
||||
if (!value_artist.isObject()) {
|
||||
Error(QStringLiteral("Invalid Json reply, items array item artist is not a object."), value_artist);
|
||||
continue;
|
||||
}
|
||||
QJsonObject obj_artist = value_artist.toObject();
|
||||
if (!obj_artist.contains(QLatin1String("name"))) {
|
||||
if (!obj_artist.contains("name"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, items array item artist is missing name."), obj_artist);
|
||||
continue;
|
||||
}
|
||||
QString artist = obj_artist[QLatin1String("name")].toString();
|
||||
QString artist = obj_artist["name"_L1].toString();
|
||||
|
||||
QJsonObject obj_album;
|
||||
if (obj_item.contains(QLatin1String("album"))) {
|
||||
QJsonValue value_album = obj_item[QLatin1String("album")];
|
||||
if (obj_item.contains("album"_L1)) {
|
||||
QJsonValue value_album = obj_item["album"_L1];
|
||||
if (value_album.isObject()) {
|
||||
obj_album = value_album.toObject();
|
||||
}
|
||||
@ -238,12 +240,12 @@ void TidalCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) {
|
||||
obj_album = obj_item;
|
||||
}
|
||||
|
||||
if (!obj_album.contains(QLatin1String("title")) || !obj_album.contains(QLatin1String("cover"))) {
|
||||
if (!obj_album.contains("title"_L1) || !obj_album.contains("cover"_L1)) {
|
||||
Error(QStringLiteral("Invalid Json reply, items array item album is missing title or cover."), obj_album);
|
||||
continue;
|
||||
}
|
||||
QString album = obj_album[QLatin1String("title")].toString();
|
||||
QString cover = obj_album[QLatin1String("cover")].toString().replace(QLatin1String("-"), QLatin1String("/"));
|
||||
QString album = obj_album["title"_L1].toString();
|
||||
QString cover = obj_album["cover"_L1].toString().replace("-"_L1, "/"_L1);
|
||||
|
||||
CoverProviderSearchResult cover_result;
|
||||
cover_result.artist = artist;
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "devicemanager.h"
|
||||
#include "deviceinfo.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
using std::make_shared;
|
||||
|
||||
ConnectedDevice::ConnectedDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent)
|
||||
@ -60,7 +61,7 @@ ConnectedDevice::ConnectedDevice(const QUrl &url, DeviceLister *lister, const QS
|
||||
backend_->moveToThread(app_->database()->thread());
|
||||
qLog(Debug) << &*backend_ << "for device" << unique_id_ << "moved to thread" << app_->database()->thread();
|
||||
|
||||
if (url_.scheme() != QLatin1String("cdda")) {
|
||||
if (url_.scheme() != "cdda"_L1) {
|
||||
QObject::connect(&*backend_, &CollectionBackend::TotalSongCountUpdated, this, &ConnectedDevice::BackendTotalSongCountUpdated);
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,8 @@
|
||||
#include "core/scopedtransaction.h"
|
||||
#include "devicedatabasebackend.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr int kDeviceSchemaVersion = 5;
|
||||
}
|
||||
@ -144,13 +146,13 @@ int DeviceDatabaseBackend::AddDevice(const Device &device) {
|
||||
int id = q.lastInsertId().toInt();
|
||||
|
||||
// Create the songs tables for the device
|
||||
QString filename(QLatin1String(":/schema/device-schema.sql"));
|
||||
QString filename(":/schema/device-schema.sql"_L1);
|
||||
QFile schema_file(filename);
|
||||
if (!schema_file.open(QIODevice::ReadOnly)) {
|
||||
qFatal("Couldn't open schema file %s: %s", filename.toUtf8().constData(), schema_file.errorString().toUtf8().constData());
|
||||
}
|
||||
QString schema = QString::fromUtf8(schema_file.readAll());
|
||||
schema.replace(QLatin1String("%deviceid"), QString::number(id));
|
||||
schema.replace("%deviceid"_L1, QString::number(id));
|
||||
|
||||
db_->ExecSchemaCommands(db, schema, 0, true);
|
||||
|
||||
|
@ -34,6 +34,8 @@
|
||||
#include "devicedatabasebackend.h"
|
||||
#include "deviceinfo.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
DeviceDatabaseBackend::Device DeviceInfo::SaveToDb() const {
|
||||
|
||||
DeviceDatabaseBackend::Device ret;
|
||||
@ -49,7 +51,7 @@ DeviceDatabaseBackend::Device DeviceInfo::SaveToDb() const {
|
||||
for (const Backend &backend : backends_) {
|
||||
unique_ids << backend.unique_id_;
|
||||
}
|
||||
ret.unique_id_ = unique_ids.join(QLatin1Char(','));
|
||||
ret.unique_id_ = unique_ids.join(u',');
|
||||
|
||||
return ret;
|
||||
|
||||
@ -64,7 +66,7 @@ void DeviceInfo::InitFromDb(const DeviceDatabaseBackend::Device &dev) {
|
||||
transcode_format_ = dev.transcode_format_;
|
||||
icon_name_ = dev.icon_name_;
|
||||
|
||||
const QStringList unique_ids = dev.unique_id_.split(QLatin1Char(','));
|
||||
const QStringList unique_ids = dev.unique_id_.split(u',');
|
||||
for (const QString &id : unique_ids) {
|
||||
backends_ << Backend(nullptr, id);
|
||||
}
|
||||
@ -90,7 +92,7 @@ const DeviceInfo::Backend *DeviceInfo::BestBackend() const {
|
||||
|
||||
void DeviceInfo::LoadIcon(const QVariantList &icons, const QString &name_hint) {
|
||||
|
||||
icon_name_ = QLatin1String("device");
|
||||
icon_name_ = "device"_L1;
|
||||
|
||||
if (icons.isEmpty()) {
|
||||
icon_ = IconLoader::Load(icon_name_);
|
||||
@ -121,10 +123,10 @@ void DeviceInfo::LoadIcon(const QVariantList &icons, const QString &name_hint) {
|
||||
QString icon_name = icon.toString();
|
||||
if (!icon_name.isEmpty()) {
|
||||
QString hint = icons.first().toString().toLower() + name_hint.toLower();
|
||||
if (hint.contains(QLatin1String("phone"))) icon_name_ = QLatin1String("device-phone");
|
||||
else if (hint.contains(QLatin1String("ipod")) || hint.contains(QLatin1String("apple"))) icon_name_ = QLatin1String("device-ipod");
|
||||
else if ((hint.contains(QLatin1String("usb"))) && (hint.contains(QLatin1String("reader")))) icon_name_ = QLatin1String("device-usb-flash");
|
||||
else if (hint.contains(QLatin1String("usb"))) icon_name_ = QLatin1String("device-usb-drive");
|
||||
if (hint.contains("phone"_L1)) icon_name_ = "device-phone"_L1;
|
||||
else if (hint.contains("ipod"_L1) || hint.contains("apple"_L1)) icon_name_ = "device-ipod"_L1;
|
||||
else if ((hint.contains("usb"_L1)) && (hint.contains("reader"_L1))) icon_name_ = "device-usb-flash"_L1;
|
||||
else if (hint.contains("usb"_L1)) icon_name_ = "device-usb-drive"_L1;
|
||||
icon_ = IconLoader::Load(icon_name_);
|
||||
if (!icon_.isNull()) {
|
||||
return;
|
||||
@ -133,7 +135,7 @@ void DeviceInfo::LoadIcon(const QVariantList &icons, const QString &name_hint) {
|
||||
}
|
||||
}
|
||||
|
||||
icon_name_ = QLatin1String("device");
|
||||
icon_name_ = "device"_L1;
|
||||
icon_ = IconLoader::Load(icon_name_);
|
||||
|
||||
}
|
||||
|
@ -37,6 +37,8 @@
|
||||
|
||||
#include "core/logging.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
DeviceLister::DeviceLister(QObject *parent)
|
||||
: QObject(parent),
|
||||
thread_(nullptr),
|
||||
@ -226,9 +228,9 @@ QUrl DeviceLister::MakeUrlFromLocalPath(const QString &path) const {
|
||||
}
|
||||
|
||||
bool DeviceLister::IsIpod(const QString &path) {
|
||||
return QFile::exists(path + QLatin1String("/iTunes_Control")) ||
|
||||
QFile::exists(path + QLatin1String("/iPod_Control")) ||
|
||||
QFile::exists(path + QLatin1String("/iTunes/iTunes_Control"));
|
||||
return QFile::exists(path + "/iTunes_Control"_L1) ||
|
||||
QFile::exists(path + "/iPod_Control"_L1) ||
|
||||
QFile::exists(path + "/iTunes/iTunes_Control"_L1);
|
||||
}
|
||||
|
||||
QVariantList DeviceLister::GuessIconForPath(const QString &path) {
|
||||
@ -277,7 +279,7 @@ QVariantList DeviceLister::GuessIconForPath(const QString &path) {
|
||||
QVariantList DeviceLister::GuessIconForModel(const QString &vendor, const QString &model) {
|
||||
|
||||
QVariantList ret;
|
||||
if (vendor.startsWith(QLatin1String("Google")) && model.contains(QLatin1String("Nexus"))) {
|
||||
if (vendor.startsWith("Google"_L1) && model.contains("Nexus"_L1)) {
|
||||
ret << QStringLiteral("phone-google-nexus-one");
|
||||
}
|
||||
return ret;
|
||||
|
@ -84,6 +84,7 @@
|
||||
# include "gpoddevice.h"
|
||||
#endif
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
using std::make_unique;
|
||||
|
||||
const int DeviceManager::kDeviceIconSize = 32;
|
||||
@ -244,7 +245,7 @@ void DeviceManager::LoadAllDevices() {
|
||||
|
||||
void DeviceManager::AddDeviceFromDB(DeviceInfo *info) {
|
||||
|
||||
const QStringList icon_names = info->icon_name_.split(QLatin1Char(','));
|
||||
const QStringList icon_names = info->icon_name_.split(u',');
|
||||
QVariantList icons;
|
||||
icons.reserve(icon_names.count());
|
||||
for (const QString &icon_name : icon_names) {
|
||||
@ -603,7 +604,7 @@ SharedPtr<ConnectedDevice> DeviceManager::Connect(DeviceInfo *info) {
|
||||
|
||||
// If we get here it means that this URL scheme wasn't supported.
|
||||
// If it was "ipod" or "mtp" then the user compiled out support and the device won't work properly.
|
||||
if (url.scheme() == QLatin1String("mtp") || url.scheme() == QLatin1String("gphoto2")) {
|
||||
if (url.scheme() == "mtp"_L1 || url.scheme() == "gphoto2"_L1) {
|
||||
if (QMessageBox::critical(nullptr, tr("This device will not work properly"),
|
||||
tr("This is an MTP device, but you compiled Strawberry without libmtp support.") + QStringLiteral(" ") +
|
||||
tr("If you continue, this device will work slowly and songs copied to it may not work."),
|
||||
@ -611,9 +612,9 @@ SharedPtr<ConnectedDevice> DeviceManager::Connect(DeviceInfo *info) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (url.scheme() == QLatin1String("ipod")) {
|
||||
if (url.scheme() == "ipod"_L1) {
|
||||
if (QMessageBox::critical(nullptr, tr("This device will not work properly"),
|
||||
tr("This is an iPod, but you compiled Strawberry without libgpod support.") + QLatin1String(" ") +
|
||||
tr("This is an iPod, but you compiled Strawberry without libgpod support.") + " "_L1 +
|
||||
tr("If you continue, this device will work slowly and songs copied to it may not work."),
|
||||
QMessageBox::Abort, QMessageBox::Ignore) == QMessageBox::Abort)
|
||||
return ret;
|
||||
@ -628,7 +629,7 @@ SharedPtr<ConnectedDevice> DeviceManager::Connect(DeviceInfo *info) {
|
||||
url_strings << url.toString();
|
||||
}
|
||||
|
||||
app_->AddError(tr("This type of device is not supported: %1").arg(url_strings.join(QLatin1String(", "))));
|
||||
app_->AddError(tr("This type of device is not supported: %1").arg(url_strings.join(", "_L1)));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,7 @@
|
||||
#include "deviceproperties.h"
|
||||
#include "deviceview.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
using std::make_unique;
|
||||
|
||||
const int DeviceItemDelegate::kIconPadding = 6;
|
||||
@ -143,7 +144,7 @@ void DeviceItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
||||
QVariant song_count = idx.data(DeviceManager::Role_SongCount);
|
||||
if (song_count.isValid()) {
|
||||
int count = song_count.toInt();
|
||||
status_text = tr("%1 song%2").arg(count).arg(count == 1 ? QLatin1String("") : QLatin1String("s"));
|
||||
status_text = tr("%1 song%2").arg(count).arg(count == 1 ? ""_L1 : "s"_L1);
|
||||
}
|
||||
else {
|
||||
status_text = idx.data(DeviceManager::Role_MountPath).toString();
|
||||
|
@ -47,6 +47,8 @@
|
||||
#include "devicelister.h"
|
||||
#include "giolister.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
QString GioLister::DeviceInfo::unique_id() const {
|
||||
|
||||
if (!volume_root_uri.isEmpty()) return volume_root_uri;
|
||||
@ -69,7 +71,7 @@ bool GioLister::DeviceInfo::is_suitable() const {
|
||||
|
||||
if (filesystem_type.isEmpty()) return true;
|
||||
|
||||
return filesystem_type != QLatin1String("udf") && filesystem_type != QLatin1String("smb") && filesystem_type != QLatin1String("cifs") && filesystem_type != QLatin1String("ssh") && filesystem_type != QLatin1String("isofs");
|
||||
return filesystem_type != "udf"_L1 && filesystem_type != "smb"_L1 && filesystem_type != "cifs"_L1 && filesystem_type != "ssh"_L1 && filesystem_type != "isofs"_L1;
|
||||
|
||||
}
|
||||
|
||||
@ -295,12 +297,12 @@ void GioLister::VolumeAdded(GVolume *volume) {
|
||||
|
||||
DeviceInfo info;
|
||||
info.ReadVolumeInfo(volume);
|
||||
if (info.volume_root_uri.startsWith(QLatin1String("afc://")) || info.volume_root_uri.startsWith(QLatin1String("gphoto2://"))) {
|
||||
if (info.volume_root_uri.startsWith("afc://"_L1) || info.volume_root_uri.startsWith("gphoto2://"_L1)) {
|
||||
// Handled by iLister.
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_AUDIOCD
|
||||
if (info.volume_root_uri.startsWith(QLatin1String("cdda"))) {
|
||||
if (info.volume_root_uri.startsWith("cdda"_L1)) {
|
||||
// Audio CD devices are already handled by CDDA lister
|
||||
return;
|
||||
}
|
||||
@ -339,12 +341,12 @@ void GioLister::MountAdded(GMount *mount) {
|
||||
|
||||
DeviceInfo info;
|
||||
info.ReadVolumeInfo(g_mount_get_volume(mount));
|
||||
if (info.volume_root_uri.startsWith(QLatin1String("afc://")) || info.volume_root_uri.startsWith(QLatin1String("gphoto2://"))) {
|
||||
if (info.volume_root_uri.startsWith("afc://"_L1) || info.volume_root_uri.startsWith("gphoto2://"_L1)) {
|
||||
// Handled by iLister.
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_AUDIOCD
|
||||
if (info.volume_root_uri.startsWith(QLatin1String("cdda"))) {
|
||||
if (info.volume_root_uri.startsWith("cdda"_L1)) {
|
||||
// Audio CD devices are already handled by CDDA lister
|
||||
return;
|
||||
}
|
||||
@ -506,7 +508,7 @@ void GioLister::DeviceInfo::ReadMountInfo(GMount *mount) {
|
||||
|
||||
// Query the file's info for a filesystem ID
|
||||
// Only afc devices (that I know of) give reliably unique IDs
|
||||
if (filesystem_type == QLatin1String("afc")) {
|
||||
if (filesystem_type == "afc"_L1) {
|
||||
error = nullptr;
|
||||
info = g_file_query_info(root, G_FILE_ATTRIBUTE_ID_FILESYSTEM, G_FILE_QUERY_INFO_NONE, nullptr, &error);
|
||||
if (error) {
|
||||
@ -580,7 +582,7 @@ void GioLister::UpdateDeviceFreeSpace(const QString &id) {
|
||||
|
||||
{
|
||||
QMutexLocker l(&mutex_);
|
||||
if (!devices_.contains(id) || !devices_[id].mount_ptr || devices_.value(id).volume_root_uri.startsWith(QLatin1String("mtp://"))) return;
|
||||
if (!devices_.contains(id) || !devices_[id].mount_ptr || devices_.value(id).volume_root_uri.startsWith("mtp://"_L1)) return;
|
||||
|
||||
GFile *root = g_mount_get_root(devices_.value(id).mount_ptr);
|
||||
|
||||
@ -605,7 +607,7 @@ void GioLister::UpdateDeviceFreeSpace(const QString &id) {
|
||||
bool GioLister::DeviceNeedsMount(const QString &id) {
|
||||
|
||||
QMutexLocker l(&mutex_);
|
||||
return devices_.contains(id) && !devices_[id].mount_ptr && !devices_[id].volume_root_uri.startsWith(QLatin1String("mtp://")) && !devices_[id].volume_root_uri.startsWith(QLatin1String("gphoto2://"));
|
||||
return devices_.contains(id) && !devices_[id].mount_ptr && !devices_[id].volume_root_uri.startsWith("mtp://"_L1) && !devices_[id].volume_root_uri.startsWith("gphoto2://"_L1);
|
||||
|
||||
}
|
||||
|
||||
@ -632,7 +634,7 @@ void GioLister::MountDevice(const QString &id, const int request_id) {
|
||||
void GioLister::UnmountDevice(const QString &id) {
|
||||
|
||||
QMutexLocker l(&mutex_);
|
||||
if (!devices_.contains(id) || !devices_[id].mount_ptr || devices_.value(id).volume_root_uri.startsWith(QLatin1String("mtp://"))) return;
|
||||
if (!devices_.contains(id) || !devices_[id].mount_ptr || devices_.value(id).volume_root_uri.startsWith("mtp://"_L1)) return;
|
||||
|
||||
const DeviceInfo device_info = devices_.value(id);
|
||||
|
||||
|
@ -325,10 +325,10 @@ bool GPodDevice::RemoveTrackFromITunesDb(const QString &path, const QString &rel
|
||||
|
||||
QString ipod_filename = path;
|
||||
if (!relative_to.isEmpty() && path.startsWith(relative_to)) {
|
||||
ipod_filename.remove(0, relative_to.length() + (relative_to.endsWith(QLatin1Char('/')) ? -1 : 0));
|
||||
ipod_filename.remove(0, relative_to.length() + (relative_to.endsWith(u'/') ? -1 : 0));
|
||||
}
|
||||
|
||||
ipod_filename.replace(QLatin1Char('/'), QLatin1Char(':'));
|
||||
ipod_filename.replace(u'/', u':');
|
||||
|
||||
// Find the track in the itdb, identify it by its filename
|
||||
Itdb_Track *track = nullptr;
|
||||
|
@ -53,6 +53,8 @@
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSURL.h>
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
#ifndef kUSBSerialNumberString
|
||||
#define kUSBSerialNumberString "USB Serial Number"
|
||||
#endif
|
||||
@ -134,9 +136,9 @@ bool MacOsDeviceLister::Init() {
|
||||
}
|
||||
|
||||
MTPDevice d;
|
||||
d.vendor = QLatin1String("SanDisk");
|
||||
d.vendor = "SanDisk"_L1;
|
||||
d.vendor_id = 0x781;
|
||||
d.product = QLatin1String("Sansa Clip+");
|
||||
d.product = "Sansa Clip+"_L1;
|
||||
d.product_id = 0x74d0;
|
||||
|
||||
d.quirks = 0x2 | 0x4 | 0x40 | 0x4000;
|
||||
@ -299,7 +301,7 @@ QString GetIconForDevice(io_object_t device) {
|
||||
scoped_nsobject<NSURL> bundle_url(reinterpret_cast<NSURL*>(KextManagerCreateURLForBundleIdentifier(kCFAllocatorDefault, reinterpret_cast<CFStringRef>(bundle))));
|
||||
|
||||
QString path = QString::fromUtf8([[bundle_url path] UTF8String]);
|
||||
path += QLatin1String("/Contents/Resources/");
|
||||
path += "/Contents/Resources/"_L1;
|
||||
path += QString::fromUtf8([file UTF8String]);
|
||||
return path;
|
||||
}
|
||||
@ -312,7 +314,7 @@ QString GetSerialForDevice(io_object_t device) {
|
||||
|
||||
const QString serial = GetUSBRegistryEntryString(device, CFSTR(kUSBSerialNumberString));
|
||||
if (!serial.isEmpty()) {
|
||||
return QLatin1String("USB/") + serial;
|
||||
return "USB/"_L1 + serial;
|
||||
}
|
||||
|
||||
return QString();
|
||||
@ -322,7 +324,7 @@ QString GetSerialForDevice(io_object_t device) {
|
||||
QString GetSerialForMTPDevice(io_object_t device) {
|
||||
|
||||
scoped_nsobject<NSString> serial(reinterpret_cast<NSString*>(GetPropertyForDevice(device, CFSTR(kUSBSerialNumberString))));
|
||||
return QLatin1String("MTP/") + QString::fromUtf8([serial UTF8String]);
|
||||
return "MTP/"_L1 + QString::fromUtf8([serial UTF8String]);
|
||||
|
||||
}
|
||||
|
||||
@ -596,14 +598,14 @@ void MacOsDeviceLister::USBDeviceAddedCallback(void *refcon, io_iterator_t it) {
|
||||
// Because this was designed by MS, the characters are in UTF-16 (LE?).
|
||||
QString str = QString::fromUtf16(reinterpret_cast<char16_t*>(data.data() + 2), (data.size() / 2) - 2);
|
||||
|
||||
if (str.startsWith(QLatin1String("MSFT100"))) {
|
||||
if (str.startsWith("MSFT100"_L1)) {
|
||||
// We got the OS descriptor!
|
||||
char vendor_code = data[16];
|
||||
ret = DeviceRequest(dev, kUSBIn, kUSBVendor, kUSBDevice, vendor_code, 0, 4, 256, &data);
|
||||
if (!ret || data.at(0) != 0x28)
|
||||
continue;
|
||||
|
||||
if (QString::fromLatin1(data.data() + 0x12, 3) != QLatin1String("MTP")) {
|
||||
if (QString::fromLatin1(data.data() + 0x12, 3) != "MTP"_L1) {
|
||||
// Not quite.
|
||||
continue;
|
||||
}
|
||||
@ -613,7 +615,7 @@ void MacOsDeviceLister::USBDeviceAddedCallback(void *refcon, io_iterator_t it) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (QString::fromLatin1(data.data() + 0x12, 3) != QLatin1String("MTP")) {
|
||||
if (QString::fromLatin1(data.data() + 0x12, 3) != "MTP"_L1) {
|
||||
// Not quite.
|
||||
continue;
|
||||
}
|
||||
@ -674,7 +676,7 @@ void MacOsDeviceLister::FoundMTPDevice(const MTPDevice &device, const QString &s
|
||||
|
||||
}
|
||||
|
||||
bool IsMTPSerial(const QString &serial) { return serial.startsWith(QLatin1String("MTP")); }
|
||||
bool IsMTPSerial(const QString &serial) { return serial.startsWith("MTP"_L1); }
|
||||
|
||||
bool MacOsDeviceLister::IsCDDevice(const QString &serial) const {
|
||||
return cd_devices_.contains(serial);
|
||||
|
@ -44,6 +44,8 @@
|
||||
#include "mtploader.h"
|
||||
#include "mtpconnection.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
class DeviceLister;
|
||||
class DeviceManager;
|
||||
|
||||
@ -187,7 +189,7 @@ bool MtpDevice::CopyToStorage(const CopyJob &job, QString &error_text) {
|
||||
metadata_on_device.InitFromMTP(&track, url_.host());
|
||||
metadata_on_device.set_directory_id(1);
|
||||
metadata_on_device.set_artist(metadata_on_device.effective_albumartist());
|
||||
metadata_on_device.set_albumartist(QLatin1String(""));
|
||||
metadata_on_device.set_albumartist(""_L1);
|
||||
songs_to_add_ << metadata_on_device;
|
||||
|
||||
// Remove the original if requested
|
||||
@ -226,7 +228,7 @@ bool MtpDevice::DeleteFromStorage(const DeleteJob &job) {
|
||||
|
||||
// Extract the ID from the song's URL
|
||||
QString filename = job.metadata_.url().path();
|
||||
filename.remove(QLatin1Char('/'));
|
||||
filename.remove(u'/');
|
||||
|
||||
bool ok = false;
|
||||
uint32_t id = filename.toUInt(&ok);
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include "udisks2filesystem.h"
|
||||
#include "udisks2job.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
using std::make_unique;
|
||||
using std::make_shared;
|
||||
|
||||
@ -83,7 +84,7 @@ QVariantList Udisks2Lister::DeviceIcons(const QString &id) {
|
||||
QString Udisks2Lister::DeviceManufacturer(const QString &id) {
|
||||
|
||||
QReadLocker locker(&device_data_lock_);
|
||||
if (!device_data_.contains(id)) return QLatin1String("");
|
||||
if (!device_data_.contains(id)) return ""_L1;
|
||||
return device_data_.value(id).vendor;
|
||||
|
||||
}
|
||||
@ -91,7 +92,7 @@ QString Udisks2Lister::DeviceManufacturer(const QString &id) {
|
||||
QString Udisks2Lister::DeviceModel(const QString &id) {
|
||||
|
||||
QReadLocker locker(&device_data_lock_);
|
||||
if (!device_data_.contains(id)) return QLatin1String("");
|
||||
if (!device_data_.contains(id)) return ""_L1;
|
||||
return device_data_.value(id).model;
|
||||
|
||||
}
|
||||
@ -122,7 +123,7 @@ QVariantMap Udisks2Lister::DeviceHardwareInfo(const QString &id) {
|
||||
const PartitionData data = device_data_.value(id);
|
||||
result[QStringLiteral(QT_TR_NOOP("D-Bus path"))] = data.dbus_path;
|
||||
result[QStringLiteral(QT_TR_NOOP("Serial number"))] = data.serial;
|
||||
result[QStringLiteral(QT_TR_NOOP("Mount points"))] = data.mount_paths.join(QLatin1String(", "));
|
||||
result[QStringLiteral(QT_TR_NOOP("Mount points"))] = data.mount_paths.join(", "_L1);
|
||||
result[QStringLiteral(QT_TR_NOOP("Partition label"))] = data.label;
|
||||
result[QStringLiteral(QT_TR_NOOP("UUID"))] = data.uuid;
|
||||
|
||||
@ -133,7 +134,7 @@ QVariantMap Udisks2Lister::DeviceHardwareInfo(const QString &id) {
|
||||
QString Udisks2Lister::MakeFriendlyName(const QString &id) {
|
||||
|
||||
QReadLocker locker(&device_data_lock_);
|
||||
if (!device_data_.contains(id)) return QLatin1String("");
|
||||
if (!device_data_.contains(id)) return ""_L1;
|
||||
return device_data_.value(id).friendly_name;
|
||||
|
||||
}
|
||||
@ -226,17 +227,17 @@ void Udisks2Lister::DBusInterfaceAdded(const QDBusObjectPath &path, const Interf
|
||||
|
||||
for (auto interface = interfaces.constBegin(); interface != interfaces.constEnd(); ++interface) {
|
||||
|
||||
if (interface.key() != QLatin1String("org.freedesktop.UDisks2.Job")) continue;
|
||||
if (interface.key() != "org.freedesktop.UDisks2.Job"_L1) continue;
|
||||
|
||||
SharedPtr<OrgFreedesktopUDisks2JobInterface> job = make_shared<OrgFreedesktopUDisks2JobInterface>(QLatin1String(kUDisks2Service), path.path(), QDBusConnection::systemBus());
|
||||
|
||||
if (!job->isValid()) continue;
|
||||
|
||||
bool is_mount_job = false;
|
||||
if (job->operation() == QLatin1String("filesystem-mount")) {
|
||||
if (job->operation() == "filesystem-mount"_L1) {
|
||||
is_mount_job = true;
|
||||
}
|
||||
else if (job->operation() == QLatin1String("filesystem-unmount")) {
|
||||
else if (job->operation() == "filesystem-unmount"_L1) {
|
||||
is_mount_job = false;
|
||||
}
|
||||
else {
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include "about.h"
|
||||
#include "ui_about.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
About::About(QWidget *parent) : QDialog(parent), ui_{} {
|
||||
|
||||
ui_.setupUi(this);
|
||||
@ -106,31 +108,31 @@ QString About::MainHtml() const {
|
||||
|
||||
QString ret;
|
||||
|
||||
ret += QLatin1String("<p>");
|
||||
ret += "<p>"_L1;
|
||||
ret += tr("Version %1").arg(QCoreApplication::applicationVersion());
|
||||
ret += QLatin1String("</p>");
|
||||
ret += "</p>"_L1;
|
||||
|
||||
ret += QLatin1String("<p>");
|
||||
ret += "<p>"_L1;
|
||||
ret += tr("Strawberry is a music player and music collection organizer.");
|
||||
ret += QLatin1String("<br />");
|
||||
ret += "<br />"_L1;
|
||||
ret += tr("It is a fork of Clementine released in 2018 aimed at music collectors and audiophiles.");
|
||||
ret += QLatin1String("</p>");
|
||||
ret += "</p>"_L1;
|
||||
|
||||
ret += QLatin1String("<p>");
|
||||
ret += "<p>"_L1;
|
||||
ret += tr("Strawberry is free software released under GPL. The source code is available on %1").arg(QStringLiteral("<a style=\"color:%1;\" href=\"https://github.com/strawberrymusicplayer/strawberry\">GitHub</a>.").arg(palette().text().color().name()));
|
||||
ret += QLatin1String("<br />");
|
||||
ret += "<br />"_L1;
|
||||
ret += tr("You should have received a copy of the GNU General Public License along with this program. If not, see %1").arg(QStringLiteral("<a style=\"color:%1;\" href=\"http://www.gnu.org/licenses/\">http://www.gnu.org/licenses/</a>").arg(palette().text().color().name()));
|
||||
ret += QLatin1String("</p>");
|
||||
ret += "</p>"_L1;
|
||||
|
||||
ret += QLatin1String("<p>");
|
||||
ret += "<p>"_L1;
|
||||
ret += tr("If you like Strawberry and can make use of it, consider sponsoring or donating.");
|
||||
ret += QLatin1String("<br />");
|
||||
ret += "<br />"_L1;
|
||||
ret += tr("You can sponsor the author on %1. You can also make a one-time payment through %2.").arg(
|
||||
QStringLiteral("<a style=\"color:%1;\" href=\"https://github.com/sponsors/jonaski\">GitHub sponsors</a>").arg(palette().text().color().name()),
|
||||
QStringLiteral("<a style=\"color:%1;\" href=\"https://paypal.me/jonaskvinge\">paypal.me/jonaskvinge</a>").arg(palette().text().color().name())
|
||||
);
|
||||
|
||||
ret += QLatin1String("</p>");
|
||||
ret += "</p>"_L1;
|
||||
|
||||
return ret;
|
||||
|
||||
@ -140,54 +142,54 @@ QString About::ContributorsHtml() const {
|
||||
|
||||
QString ret;
|
||||
|
||||
ret += QLatin1String("<p>");
|
||||
ret += QLatin1String("<b>");
|
||||
ret += "<p>"_L1;
|
||||
ret += "<b>"_L1;
|
||||
ret += tr("Author and maintainer");
|
||||
ret += QLatin1String("</b>");
|
||||
ret += "</b>"_L1;
|
||||
for (const Person &person : strawberry_authors_) {
|
||||
ret += QLatin1String("<br />") + PersonToHtml(person);
|
||||
ret += "<br />"_L1 + PersonToHtml(person);
|
||||
}
|
||||
ret += QLatin1String("</p>");
|
||||
ret += "</p>"_L1;
|
||||
|
||||
ret += QLatin1String("<p>");
|
||||
ret += QLatin1String("<b>");
|
||||
ret += "<p>"_L1;
|
||||
ret += "<b>"_L1;
|
||||
ret += tr("Contributors");
|
||||
ret += QLatin1String("</b>");
|
||||
ret += "</b>"_L1;
|
||||
for (const Person &person : strawberry_contributors_) {
|
||||
ret += QLatin1String("<br />") + PersonToHtml(person);
|
||||
ret += "<br />"_L1 + PersonToHtml(person);
|
||||
}
|
||||
ret += QLatin1String("</p>");
|
||||
ret += "</p>"_L1;
|
||||
|
||||
ret += QLatin1String("<p>");
|
||||
ret += QLatin1String("<b>");
|
||||
ret += "<p>"_L1;
|
||||
ret += "<b>"_L1;
|
||||
ret += tr("Clementine authors");
|
||||
ret += QLatin1String("</b>");
|
||||
ret += "</b>"_L1;
|
||||
for (const Person &person : clementine_authors_) {
|
||||
ret += QLatin1String("<br />") + PersonToHtml(person);
|
||||
ret += "<br />"_L1 + PersonToHtml(person);
|
||||
}
|
||||
ret += QLatin1String("</p>");
|
||||
ret += "</p>"_L1;
|
||||
|
||||
ret += QLatin1String("<p>");
|
||||
ret += QLatin1String("<b>");
|
||||
ret += "<p>"_L1;
|
||||
ret += "<b>"_L1;
|
||||
ret += tr("Clementine contributors");
|
||||
ret += QLatin1String("</b>");
|
||||
ret += "</b>"_L1;
|
||||
for (const Person &person : clementine_contributors_) {
|
||||
ret += QLatin1String("<br />") + PersonToHtml(person);
|
||||
ret += "<br />"_L1 + PersonToHtml(person);
|
||||
}
|
||||
ret += QLatin1String("</p>");
|
||||
ret += "</p>"_L1;
|
||||
|
||||
ret += QLatin1String("<p>");
|
||||
ret += QLatin1String("<b>");
|
||||
ret += "<p>"_L1;
|
||||
ret += "<b>"_L1;
|
||||
ret += tr("Thanks to");
|
||||
ret += QLatin1String("</b>");
|
||||
ret += "</b>"_L1;
|
||||
for (const Person &person : strawberry_thanks_) {
|
||||
ret += QLatin1String("<br />") + PersonToHtml(person);
|
||||
ret += "<br />"_L1 + PersonToHtml(person);
|
||||
}
|
||||
ret += QLatin1String("</p>");
|
||||
ret += "</p>"_L1;
|
||||
|
||||
ret += QLatin1String("<p>");
|
||||
ret += "<p>"_L1;
|
||||
ret += tr("Thanks to all the other Amarok and Clementine contributors.");
|
||||
ret += QLatin1String("</p>");
|
||||
ret += "</p>"_L1;
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ void Console::RunQuery() {
|
||||
values.append(record.value(i).toString());
|
||||
}
|
||||
|
||||
ui_.output->append(values.join(QLatin1Char('|')));
|
||||
ui_.output->append(values.join(u'|'));
|
||||
|
||||
}
|
||||
|
||||
|
@ -101,6 +101,8 @@
|
||||
#include "ui_edittagdialog.h"
|
||||
#include "tagreadermessages.pb.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kTagsDifferentHintText[] = QT_TR_NOOP("(different across multiple songs)");
|
||||
constexpr char kArtDifferentHintText[] = QT_TR_NOOP("Different art across multiple songs.");
|
||||
@ -476,21 +478,21 @@ void EditTagDialog::SetSongListVisibility(bool visible) {
|
||||
|
||||
QVariant EditTagDialog::Data::value(const Song &song, const QString &id) {
|
||||
|
||||
if (id == QLatin1String("title")) return song.title();
|
||||
if (id == QLatin1String("artist")) return song.artist();
|
||||
if (id == QLatin1String("album")) return song.album();
|
||||
if (id == QLatin1String("albumartist")) return song.albumartist();
|
||||
if (id == QLatin1String("composer")) return song.composer();
|
||||
if (id == QLatin1String("performer")) return song.performer();
|
||||
if (id == QLatin1String("grouping")) return song.grouping();
|
||||
if (id == QLatin1String("genre")) return song.genre();
|
||||
if (id == QLatin1String("comment")) return song.comment();
|
||||
if (id == QLatin1String("lyrics")) return song.lyrics();
|
||||
if (id == QLatin1String("track")) return song.track();
|
||||
if (id == QLatin1String("disc")) return song.disc();
|
||||
if (id == QLatin1String("year")) return song.year();
|
||||
if (id == QLatin1String("compilation")) return song.compilation();
|
||||
if (id == QLatin1String("rating")) { return song.rating(); }
|
||||
if (id == "title"_L1) return song.title();
|
||||
if (id == "artist"_L1) return song.artist();
|
||||
if (id == "album"_L1) return song.album();
|
||||
if (id == "albumartist"_L1) return song.albumartist();
|
||||
if (id == "composer"_L1) return song.composer();
|
||||
if (id == "performer"_L1) return song.performer();
|
||||
if (id == "grouping"_L1) return song.grouping();
|
||||
if (id == "genre"_L1) return song.genre();
|
||||
if (id == "comment"_L1) return song.comment();
|
||||
if (id == "lyrics"_L1) return song.lyrics();
|
||||
if (id == "track"_L1) return song.track();
|
||||
if (id == "disc"_L1) return song.disc();
|
||||
if (id == "year"_L1) return song.year();
|
||||
if (id == "compilation"_L1) return song.compilation();
|
||||
if (id == "rating"_L1) { return song.rating(); }
|
||||
qLog(Warning) << "Unknown ID" << id;
|
||||
return QVariant();
|
||||
|
||||
@ -498,21 +500,21 @@ QVariant EditTagDialog::Data::value(const Song &song, const QString &id) {
|
||||
|
||||
void EditTagDialog::Data::set_value(const QString &id, const QVariant &value) {
|
||||
|
||||
if (id == QLatin1String("title")) current_.set_title(value.toString());
|
||||
else if (id == QLatin1String("artist")) current_.set_artist(value.toString());
|
||||
else if (id == QLatin1String("album")) current_.set_album(value.toString());
|
||||
else if (id == QLatin1String("albumartist")) current_.set_albumartist(value.toString());
|
||||
else if (id == QLatin1String("composer")) current_.set_composer(value.toString());
|
||||
else if (id == QLatin1String("performer")) current_.set_performer(value.toString());
|
||||
else if (id == QLatin1String("grouping")) current_.set_grouping(value.toString());
|
||||
else if (id == QLatin1String("genre")) current_.set_genre(value.toString());
|
||||
else if (id == QLatin1String("comment")) current_.set_comment(value.toString());
|
||||
else if (id == QLatin1String("lyrics")) current_.set_lyrics(value.toString());
|
||||
else if (id == QLatin1String("track")) current_.set_track(value.toInt());
|
||||
else if (id == QLatin1String("disc")) current_.set_disc(value.toInt());
|
||||
else if (id == QLatin1String("year")) current_.set_year(value.toInt());
|
||||
else if (id == QLatin1String("compilation")) current_.set_compilation(value.toBool());
|
||||
else if (id == QLatin1String("rating")) { current_.set_rating(value.toFloat()); }
|
||||
if (id == "title"_L1) current_.set_title(value.toString());
|
||||
else if (id == "artist"_L1) current_.set_artist(value.toString());
|
||||
else if (id == "album"_L1) current_.set_album(value.toString());
|
||||
else if (id == "albumartist"_L1) current_.set_albumartist(value.toString());
|
||||
else if (id == "composer"_L1) current_.set_composer(value.toString());
|
||||
else if (id == "performer"_L1) current_.set_performer(value.toString());
|
||||
else if (id == "grouping"_L1) current_.set_grouping(value.toString());
|
||||
else if (id == "genre"_L1) current_.set_genre(value.toString());
|
||||
else if (id == "comment"_L1) current_.set_comment(value.toString());
|
||||
else if (id == "lyrics"_L1) current_.set_lyrics(value.toString());
|
||||
else if (id == "track"_L1) current_.set_track(value.toInt());
|
||||
else if (id == "disc"_L1) current_.set_disc(value.toInt());
|
||||
else if (id == "year"_L1) current_.set_year(value.toInt());
|
||||
else if (id == "compilation"_L1) current_.set_compilation(value.toBool());
|
||||
else if (id == "rating"_L1) { current_.set_rating(value.toFloat()); }
|
||||
else qLog(Warning) << "Unknown ID" << id;
|
||||
|
||||
}
|
||||
@ -692,12 +694,12 @@ void EditTagDialog::SelectionChanged() {
|
||||
|
||||
QString summary;
|
||||
if (indexes.count() == 1) {
|
||||
summary += QLatin1String("<p><b>") + first_song.PrettyTitleWithArtist().toHtmlEscaped() + QLatin1String("</b></p>");
|
||||
summary += "<p><b>"_L1 + first_song.PrettyTitleWithArtist().toHtmlEscaped() + "</b></p>"_L1;
|
||||
}
|
||||
else {
|
||||
summary += QLatin1String("<p><b>");
|
||||
summary += "<p><b>"_L1;
|
||||
summary += tr("%1 songs selected.").arg(indexes.count());
|
||||
summary += QLatin1String("</b></p>");
|
||||
summary += "</b></p>"_L1;
|
||||
}
|
||||
ui_->tags_summary->setText(summary);
|
||||
|
||||
@ -864,7 +866,7 @@ QString EditTagDialog::GetArtSummary(const Song &song, const AlbumCoverLoaderRes
|
||||
}
|
||||
|
||||
if (!song.is_collection_song()) {
|
||||
if (!summary.isEmpty()) summary += QLatin1String("<br />");
|
||||
if (!summary.isEmpty()) summary += "<br />"_L1;
|
||||
summary = tr("Album cover editing is only available for collection songs.");
|
||||
}
|
||||
|
||||
@ -911,8 +913,8 @@ void EditTagDialog::AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderRes
|
||||
if (ui_->song_list->selectionModel()->selectedIndexes().count() > 0) {
|
||||
const QModelIndex idx = ui_->song_list->selectionModel()->selectedIndexes().first();
|
||||
QString summary = ui_->summary->toPlainText();
|
||||
summary += QLatin1String("<br />");
|
||||
summary += QLatin1String("<br />");
|
||||
summary += "<br />"_L1;
|
||||
summary += "<br />"_L1;
|
||||
summary += GetArtSummary(data_[idx.row()].current_, result.type);
|
||||
ui_->summary->setText(summary);
|
||||
}
|
||||
@ -938,8 +940,8 @@ void EditTagDialog::AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderRes
|
||||
bool enable_change_art = false;
|
||||
if (first_song.is_valid()) {
|
||||
QString summary = ui_->tags_summary->toPlainText();
|
||||
summary += QLatin1String("<br />");
|
||||
summary += QLatin1String("<br />");
|
||||
summary += "<br />"_L1;
|
||||
summary += "<br />"_L1;
|
||||
if (cover_action == UpdateCoverAction::None) {
|
||||
summary += GetArtSummary(first_song, result.type);
|
||||
}
|
||||
|
@ -35,6 +35,8 @@
|
||||
#include "errordialog.h"
|
||||
#include "ui_errordialog.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
ErrorDialog::ErrorDialog(QWidget *parent)
|
||||
: QDialog(parent),
|
||||
ui_(new Ui_ErrorDialog) {
|
||||
@ -83,7 +85,7 @@ void ErrorDialog::UpdateContent() {
|
||||
QString html;
|
||||
for (const QString &message : std::as_const(current_messages_)) {
|
||||
if (!html.isEmpty()) {
|
||||
html += QLatin1String("<hr/>");
|
||||
html += "<hr/>"_L1;
|
||||
}
|
||||
html += message.toHtmlEscaped();
|
||||
}
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "snapdialog.h"
|
||||
#include "ui_messagedialog.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
SnapDialog::SnapDialog(QWidget *parent) : MessageDialog(parent) {
|
||||
|
||||
setWindowTitle(tr("Strawberry is running as a Snap"));
|
||||
@ -34,56 +36,56 @@ SnapDialog::SnapDialog(QWidget *parent) : MessageDialog(parent) {
|
||||
ui_->label_logo->setPixmap(pixmap);
|
||||
|
||||
QString text;
|
||||
text += QLatin1String("<p>");
|
||||
text += "<p>"_L1;
|
||||
text += tr("It is detected that Strawberry is running as a Snap");
|
||||
text += QLatin1String("</p>");
|
||||
text += "</p>"_L1;
|
||||
|
||||
text += QLatin1String("<p>");
|
||||
text += "<p>"_L1;
|
||||
text += tr("Strawberry is slower, and has restrictions when running as a Snap. Accessing the root filesystem (/) will not work. There also might be other restrictions such as accessing certain devices or network shares.");
|
||||
text += QLatin1String("</p>");
|
||||
text += "</p>"_L1;
|
||||
|
||||
text += QLatin1String("<p>");
|
||||
text += QLatin1String("Strawberry is available natively in the official package repositories for Fedora, openSUSE, Mageia, Arch, Manjaro, MX Linux and most other popular Linux distributions.");
|
||||
text += QLatin1String("</p>");
|
||||
text += "<p>"_L1;
|
||||
text += "Strawberry is available natively in the official package repositories for Fedora, openSUSE, Mageia, Arch, Manjaro, MX Linux and most other popular Linux distributions."_L1;
|
||||
text += "</p>"_L1;
|
||||
|
||||
text += QLatin1String("<p>");
|
||||
text += "<p>"_L1;
|
||||
text += tr("For Ubuntu there is an official PPA repository available at %1.").arg(QStringLiteral("<a style=\"color:%1;\" href=\"https://launchpad.net/~jonaski/+archive/ubuntu/strawberry\">https://launchpad.net/~jonaski/+archive/ubuntu/strawberry</a>").arg(palette().text().color().name()));
|
||||
text += QLatin1String("</p>");
|
||||
text += "</p>"_L1;
|
||||
|
||||
text += QLatin1String("<p>");
|
||||
text += "<p>"_L1;
|
||||
text += tr("Official releases are available for Debian and Ubuntu which also work on most of their derivatives. See %1 for more information.").arg(QStringLiteral("<a style=\"color:%1;\" href=\"https://www.strawberrymusicplayer.org/\">https://www.strawberrymusicplayer.org/</a>").arg(palette().text().color().name()));
|
||||
text += QLatin1String("</p>");
|
||||
text += "</p>"_L1;
|
||||
|
||||
text += QLatin1String("<p>");
|
||||
text += "<p>"_L1;
|
||||
text += tr("For a better experience please consider the other options above.");
|
||||
text += QLatin1String("</p>");
|
||||
text += "</p>"_L1;
|
||||
|
||||
text += QLatin1String("<p>");
|
||||
text += "<p>"_L1;
|
||||
text += tr("Copy your strawberry.conf and strawberry.db from your ~/snap directory to avoid losing configuration before you uninstall the snap:");
|
||||
text += QLatin1String("<br />");
|
||||
text += QLatin1String("cp ~/snap/strawberry/current/.config/strawberry/strawberry.conf ~/.config/strawberry/strawberry.conf<br />");
|
||||
text += QLatin1String("cp ~/snap/strawberry/current/.local/share/strawberry/strawberry/strawberry.db ~/.local/share/strawberry/strawberry/strawberry.db<br />");
|
||||
text += QLatin1String("</p>");
|
||||
text += QLatin1String("<p>");
|
||||
text += "<br />"_L1;
|
||||
text += "cp ~/snap/strawberry/current/.config/strawberry/strawberry.conf ~/.config/strawberry/strawberry.conf<br />"_L1;
|
||||
text += "cp ~/snap/strawberry/current/.local/share/strawberry/strawberry/strawberry.db ~/.local/share/strawberry/strawberry/strawberry.db<br />"_L1;
|
||||
text += "</p>"_L1;
|
||||
text += "<p>"_L1;
|
||||
text += tr("Uninstall the snap with:");
|
||||
text += QLatin1String("<br />");
|
||||
text += QLatin1String("snap remove strawberry");
|
||||
text += QLatin1String("</p>");
|
||||
text += QLatin1String("<p>");
|
||||
text += "<br />"_L1;
|
||||
text += "snap remove strawberry"_L1;
|
||||
text += "</p>"_L1;
|
||||
text += "<p>"_L1;
|
||||
text += tr("Install strawberry through PPA:");
|
||||
text += QLatin1String("<br />");
|
||||
text += QLatin1String("sudo add-apt-repository ppa:jonaski/strawberry<br />");
|
||||
text += QLatin1String("sudo apt-get update<br />");
|
||||
text += QLatin1String("sudo apt install strawberry");
|
||||
text += QLatin1String("</p>");
|
||||
text += QLatin1String("<p></p>");
|
||||
text += "<br />"_L1;
|
||||
text += "sudo add-apt-repository ppa:jonaski/strawberry<br />"_L1;
|
||||
text += "sudo apt-get update<br />"_L1;
|
||||
text += "sudo apt install strawberry"_L1;
|
||||
text += "</p>"_L1;
|
||||
text += "<p></p>"_L1;
|
||||
|
||||
ui_->label_text->setText(text);
|
||||
ui_->label_text->adjustSize();
|
||||
adjustSize();
|
||||
|
||||
settings_group_ = QLatin1String(MainWindow::kSettingsGroup);
|
||||
do_not_show_message_again_ = QLatin1String("ignore_snap");
|
||||
do_not_show_message_again_ = "ignore_snap"_L1;
|
||||
|
||||
if (parent) {
|
||||
Utilities::CenterWidgetOnScreen(Utilities::GetScreen(parent), this);
|
||||
|
@ -52,14 +52,14 @@ EngineDeviceList AlsaPCMDeviceFinder::ListDevices() {
|
||||
for (char *desc_i = hint_desc; desc_i && *desc_i != '\0'; ++desc_i) {
|
||||
if (*desc_i == '\n') {
|
||||
*desc_i = '\0';
|
||||
if (!description.isEmpty()) description.append(QLatin1Char(' '));
|
||||
if (!description.isEmpty()) description.append(u' ');
|
||||
description.append(QString::fromUtf8(desc_last));
|
||||
desc_last = desc_i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (desc_last) {
|
||||
if (!description.isEmpty()) description.append(QLatin1Char(' '));
|
||||
if (!description.isEmpty()) description.append(u' ');
|
||||
description.append(QString::fromUtf8(desc_last));
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,8 @@
|
||||
# endif // _MSC_VER
|
||||
#endif // Q_OS_WIN32
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
DeviceFinders::DeviceFinders(QObject *parent) : QObject(parent) {
|
||||
|
||||
setObjectName(QLatin1String(metaObject()->className()));
|
||||
|
@ -45,6 +45,7 @@
|
||||
|
||||
#include "ebur128analysis.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
using std::unique_ptr;
|
||||
|
||||
namespace {
|
||||
@ -216,16 +217,16 @@ FrameFormat::FrameFormat(GstCaps *caps) : channels(0), channel_mask(0), samplera
|
||||
channel_mask = gst_value_get_bitmask(value);
|
||||
}
|
||||
|
||||
if (format_str == QLatin1String("S16LE")) {
|
||||
if (format_str == "S16LE"_L1) {
|
||||
format = DataFormat::S16;
|
||||
}
|
||||
else if (format_str == QLatin1String("S32LE")) {
|
||||
else if (format_str == "S32LE"_L1) {
|
||||
format = DataFormat::S32;
|
||||
}
|
||||
else if (format_str == QLatin1String("F32LE")) {
|
||||
else if (format_str == "F32LE"_L1) {
|
||||
format = DataFormat::FP32;
|
||||
}
|
||||
else if (format_str == QLatin1String("F64LE")) {
|
||||
else if (format_str == "F64LE"_L1) {
|
||||
format = DataFormat::FP64;
|
||||
}
|
||||
else {
|
||||
|
@ -41,6 +41,8 @@
|
||||
# include "settings/spotifysettingspage.h"
|
||||
#endif
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
EngineBase::EngineBase(QObject *parent)
|
||||
: QObject(parent),
|
||||
exclusive_mode_(false),
|
||||
@ -83,8 +85,8 @@ EngineBase::~EngineBase() = default;
|
||||
|
||||
EngineBase::Type EngineBase::TypeFromName(const QString &name) {
|
||||
|
||||
if (name.compare(QLatin1String("gstreamer"), Qt::CaseInsensitive) == 0) return Type::GStreamer;
|
||||
if (name.compare(QLatin1String("vlc"), Qt::CaseInsensitive) == 0) return Type::VLC;
|
||||
if (name.compare("gstreamer"_L1, Qt::CaseInsensitive) == 0) return Type::GStreamer;
|
||||
if (name.compare("vlc"_L1, Qt::CaseInsensitive) == 0) return Type::VLC;
|
||||
|
||||
return Type::None;
|
||||
|
||||
@ -207,7 +209,7 @@ void EngineBase::ReloadSettings() {
|
||||
bool http2_enabled = s.value("http2", false).toBool();
|
||||
if (http2_enabled != http2_enabled_) {
|
||||
http2_enabled_ = http2_enabled;
|
||||
Utilities::SetEnv("SOUP_FORCE_HTTP1", http2_enabled_ ? QLatin1String("") : QStringLiteral("1"));
|
||||
Utilities::SetEnv("SOUP_FORCE_HTTP1", http2_enabled_ ? ""_L1 : QStringLiteral("1"));
|
||||
qLog(Debug) << "SOUP_FORCE_HTTP1:" << (http2_enabled_ ? "OFF" : "ON");
|
||||
}
|
||||
|
||||
|
@ -19,29 +19,31 @@
|
||||
|
||||
#include "enginedevice.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
EngineDevice::EngineDevice() : card(0), device(0) {}
|
||||
|
||||
QString EngineDevice::GuessIconName() const {
|
||||
|
||||
if (description.contains(QLatin1String("mcintosh"), Qt::CaseInsensitive)) {
|
||||
if (description.contains("mcintosh"_L1, Qt::CaseInsensitive)) {
|
||||
return QStringLiteral("mcintosh");
|
||||
}
|
||||
if (description.contains(QLatin1String("electrocompaniet"), Qt::CaseInsensitive)) {
|
||||
if (description.contains("electrocompaniet"_L1, Qt::CaseInsensitive)) {
|
||||
return QStringLiteral("electrocompaniet");
|
||||
}
|
||||
if (description.contains(QLatin1String("intel"), Qt::CaseInsensitive)) {
|
||||
if (description.contains("intel"_L1, Qt::CaseInsensitive)) {
|
||||
return QStringLiteral("intel");
|
||||
}
|
||||
if (description.contains(QLatin1String("realtek"), Qt::CaseInsensitive)) {
|
||||
if (description.contains("realtek"_L1, Qt::CaseInsensitive)) {
|
||||
return QStringLiteral("realtek");
|
||||
}
|
||||
if (description.contains(QLatin1String("nvidia"), Qt::CaseInsensitive)) {
|
||||
if (description.contains("nvidia"_L1, Qt::CaseInsensitive)) {
|
||||
return QStringLiteral("nvidia");
|
||||
}
|
||||
if (description.contains(QLatin1String("headset"), Qt::CaseInsensitive)) {
|
||||
if (description.contains("headset"_L1, Qt::CaseInsensitive)) {
|
||||
return QStringLiteral("headset");
|
||||
}
|
||||
if (description.contains(QLatin1String("pulseaudio"), Qt::CaseInsensitive)) {
|
||||
if (description.contains("pulseaudio"_L1, Qt::CaseInsensitive)) {
|
||||
return QStringLiteral("pulseaudio");
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@
|
||||
#include "gstbufferconsumer.h"
|
||||
#include "enginemetadata.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
using std::make_shared;
|
||||
|
||||
const char *GstEngine::kAutoSink = "autoaudiosink";
|
||||
@ -455,24 +456,24 @@ EngineBase::OutputDetailsList GstEngine::GetOutputsList() const {
|
||||
GstElementFactory *factory = GST_ELEMENT_FACTORY(future->data);
|
||||
const QString metadata = QString::fromUtf8(gst_element_factory_get_metadata(factory, GST_ELEMENT_METADATA_KLASS));
|
||||
const QString name = QString::fromUtf8(gst_plugin_feature_get_name(future->data));
|
||||
const QStringList classes = metadata.split(QLatin1Char('/'));
|
||||
if (classes.contains(QLatin1String("Audio"), Qt::CaseInsensitive) && (classes.contains(QLatin1String("Sink"), Qt::CaseInsensitive) || (classes.contains(QLatin1String("Source"), Qt::CaseInsensitive) && name.contains(QLatin1String("sink"))))) {
|
||||
const QStringList classes = metadata.split(u'/');
|
||||
if (classes.contains("Audio"_L1, Qt::CaseInsensitive) && (classes.contains("Sink"_L1, Qt::CaseInsensitive) || (classes.contains("Source"_L1, Qt::CaseInsensitive) && name.contains("sink"_L1)))) {
|
||||
QString description = QString::fromUtf8(gst_element_factory_get_metadata(factory, GST_ELEMENT_METADATA_DESCRIPTION));
|
||||
if (name == QLatin1String("wasapi2sink") && description == QLatin1String("Stream audio to an audio capture device through WASAPI")) {
|
||||
description.append(QLatin1Char('2'));
|
||||
if (name == "wasapi2sink"_L1 && description == "Stream audio to an audio capture device through WASAPI"_L1) {
|
||||
description.append(u'2');
|
||||
}
|
||||
else if (name == QLatin1String("pipewiresink") && description == QLatin1String("Send video to PipeWire")) {
|
||||
description = QLatin1String("Send audio to PipeWire");
|
||||
else if (name == "pipewiresink"_L1 && description == "Send video to PipeWire"_L1) {
|
||||
description = "Send audio to PipeWire"_L1;
|
||||
}
|
||||
OutputDetails output;
|
||||
output.name = name;
|
||||
output.description = description;
|
||||
if (output.name == QLatin1String(kAutoSink)) output.iconname = QLatin1String("soundcard");
|
||||
else if (output.name == QLatin1String(kALSASink) || output.name == QLatin1String(kOSS4Sink)) output.iconname = QLatin1String("alsa");
|
||||
else if (output.name == QLatin1String(kJackAudioSink)) output.iconname = QLatin1String("jack");
|
||||
else if (output.name == QLatin1String(kPulseSink)) output.iconname = QLatin1String("pulseaudio");
|
||||
else if (output.name == QLatin1String(kA2DPSink) || output.name == QLatin1String(kAVDTPSink)) output.iconname = QLatin1String("bluetooth");
|
||||
else output.iconname = QLatin1String("soundcard");
|
||||
if (output.name == QLatin1String(kAutoSink)) output.iconname = "soundcard"_L1;
|
||||
else if (output.name == QLatin1String(kALSASink) || output.name == QLatin1String(kOSS4Sink)) output.iconname = "alsa"_L1;
|
||||
else if (output.name == QLatin1String(kJackAudioSink)) output.iconname = "jack"_L1;
|
||||
else if (output.name == QLatin1String(kPulseSink)) output.iconname = "pulseaudio"_L1;
|
||||
else if (output.name == QLatin1String(kA2DPSink) || output.name == QLatin1String(kAVDTPSink)) output.iconname = "bluetooth"_L1;
|
||||
else output.iconname = "soundcard"_L1;
|
||||
outputs << output;
|
||||
}
|
||||
}
|
||||
@ -796,22 +797,22 @@ QByteArray GstEngine::FixupUrl(const QUrl &url) {
|
||||
// QUrl::fromLocalFile does this when given a \\host\share\file path on Windows.
|
||||
// Munge it back into a path that gstreamer will recognise.
|
||||
if (url.isLocalFile() && !url.host().isEmpty()) {
|
||||
QString str = QLatin1String("file:////") + url.host() + url.path();
|
||||
QString str = "file:////"_L1 + url.host() + url.path();
|
||||
uri = str.toUtf8();
|
||||
}
|
||||
else if (url.scheme() == QLatin1String("cdda")) {
|
||||
else if (url.scheme() == "cdda"_L1) {
|
||||
QString str;
|
||||
if (url.path().isEmpty()) {
|
||||
str = url.toString();
|
||||
str.remove(str.lastIndexOf(QLatin1Char('a')), 1);
|
||||
str.remove(str.lastIndexOf(u'a'), 1);
|
||||
}
|
||||
else {
|
||||
// Currently, Gstreamer can't handle input CD devices inside cdda URL.
|
||||
// So we handle them ourselves: we extract the track number and re-create a URL with only cdda:// + the track number (which can be handled by Gstreamer).
|
||||
// We keep the device in mind, and we will set it later using SourceSetupCallback
|
||||
QStringList path = url.path().split(QLatin1Char('/'));
|
||||
QStringList path = url.path().split(u'/');
|
||||
str = QStringLiteral("cdda://%1").arg(path.takeLast());
|
||||
QString device = path.join(QLatin1Char('/'));
|
||||
QString device = path.join(u'/');
|
||||
if (current_pipeline_) current_pipeline_->SetSourceDevice(device);
|
||||
}
|
||||
uri = str.toUtf8();
|
||||
@ -1030,12 +1031,12 @@ void GstEngine::UpdateScope(const int chunk_length) {
|
||||
|
||||
scope_chunk_++;
|
||||
|
||||
if (buffer_format_.startsWith(QLatin1String("S16LE")) ||
|
||||
buffer_format_.startsWith(QLatin1String("U16LE")) ||
|
||||
buffer_format_.startsWith(QLatin1String("S24LE")) ||
|
||||
buffer_format_.startsWith(QLatin1String("S24_32LE")) ||
|
||||
buffer_format_.startsWith(QLatin1String("S32LE")) ||
|
||||
buffer_format_.startsWith(QLatin1String("F32LE"))
|
||||
if (buffer_format_.startsWith("S16LE"_L1) ||
|
||||
buffer_format_.startsWith("U16LE"_L1) ||
|
||||
buffer_format_.startsWith("S24LE"_L1) ||
|
||||
buffer_format_.startsWith("S24_32LE"_L1) ||
|
||||
buffer_format_.startsWith("S32LE"_L1) ||
|
||||
buffer_format_.startsWith("F32LE"_L1)
|
||||
) {
|
||||
memcpy(dest, source, bytes);
|
||||
}
|
||||
@ -1102,7 +1103,7 @@ void GstEngine::StreamDiscovered(GstDiscoverer*, GstDiscovererInfo *info, GError
|
||||
GstStructure *gst_structure = gst_caps_get_structure(caps, i);
|
||||
if (!gst_structure) continue;
|
||||
QString mimetype = QString::fromUtf8(gst_structure_get_name(gst_structure));
|
||||
if (!mimetype.isEmpty() && mimetype != QLatin1String("audio/mpeg")) {
|
||||
if (!mimetype.isEmpty() && mimetype != "audio/mpeg"_L1) {
|
||||
engine_metadata.filetype = Song::FiletypeByMimetype(mimetype);
|
||||
if (engine_metadata.filetype == Song::FileType::Unknown) {
|
||||
qLog(Error) << "Unknown mimetype" << mimetype;
|
||||
|
@ -67,6 +67,8 @@
|
||||
#include "gstenginepipeline.h"
|
||||
#include "gstbufferconsumer.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr int GST_PLAY_FLAG_VIDEO = 0x00000001;
|
||||
@ -296,7 +298,7 @@ QString GstEnginePipeline::GstStateText(const GstState state) {
|
||||
|
||||
GstElement *GstEnginePipeline::CreateElement(const QString &factory_name, const QString &name, GstElement *bin, QString &error) const {
|
||||
|
||||
QString unique_name = QLatin1String("pipeline") + QLatin1Char('-') + QString::number(id()) + QLatin1Char('-') + (name.isEmpty() ? factory_name : name);
|
||||
QString unique_name = "pipeline"_L1 + u'-' + QString::number(id()) + u'-' + (name.isEmpty() ? factory_name : name);
|
||||
|
||||
GstElement *element = gst_element_factory_make(factory_name.toUtf8().constData(), unique_name.toUtf8().constData());
|
||||
if (!element) {
|
||||
@ -491,7 +493,7 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
||||
if (!device.isEmpty()) {
|
||||
qLog(Debug) << "Setting device" << device << "for" << output_;
|
||||
g_object_set(G_OBJECT(audiosink_), "device", device.toUtf8().constData(), nullptr);
|
||||
if (output_ == QLatin1String(GstEngine::kALSASink) && (device.startsWith(QLatin1String("hw:")) || device.startsWith(QLatin1String("plughw:")))) {
|
||||
if (output_ == QLatin1String(GstEngine::kALSASink) && (device.startsWith("hw:"_L1) || device.startsWith("plughw:"_L1))) {
|
||||
exclusive_mode_ = true;
|
||||
}
|
||||
}
|
||||
@ -783,7 +785,7 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
||||
// Link replaygain elements if enabled.
|
||||
if (rg_enabled_ && rgvolume && rglimiter && rgconverter) {
|
||||
if (!gst_element_link_many(element_link, rgvolume, rglimiter, rgconverter, nullptr)) {
|
||||
error = QLatin1String("Failed to link replaygain volume, limiter and converter elements.");
|
||||
error = "Failed to link replaygain volume, limiter and converter elements."_L1;
|
||||
return false;
|
||||
}
|
||||
element_link = rgconverter;
|
||||
@ -796,7 +798,7 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
||||
"format = (string) { F32LE, F64LE }");
|
||||
GstCaps *raw_fp_audio_caps = gst_static_caps_get(&static_raw_fp_audio_caps);
|
||||
if (!gst_element_link_filtered(element_link, volume_ebur128_, raw_fp_audio_caps)) {
|
||||
error = QLatin1String("Failed to link EBU R 128 volume element.");
|
||||
error = "Failed to link EBU R 128 volume element."_L1;
|
||||
return false;
|
||||
}
|
||||
gst_caps_unref(raw_fp_audio_caps);
|
||||
@ -806,7 +808,7 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
||||
// Link equalizer elements if enabled.
|
||||
if (eq_enabled_ && equalizer_ && equalizer_preamp_) {
|
||||
if (!gst_element_link_many(element_link, equalizer_preamp_, equalizer_, nullptr)) {
|
||||
error = QLatin1String("Failed to link equalizer and equalizer preamp elements.");
|
||||
error = "Failed to link equalizer and equalizer preamp elements."_L1;
|
||||
return false;
|
||||
}
|
||||
element_link = equalizer_;
|
||||
@ -815,7 +817,7 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
||||
// Link stereo balancer elements if enabled.
|
||||
if (stereo_balancer_enabled_ && audiopanorama_) {
|
||||
if (!gst_element_link(element_link, audiopanorama_)) {
|
||||
error = QLatin1String("Failed to link audio panorama (stereo balancer).");
|
||||
error = "Failed to link audio panorama (stereo balancer)."_L1;
|
||||
return false;
|
||||
}
|
||||
element_link = audiopanorama_;
|
||||
@ -824,7 +826,7 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
||||
// Link software volume element if enabled.
|
||||
if (volume_enabled_ && volume_sw_) {
|
||||
if (!gst_element_link(element_link, volume_sw_)) {
|
||||
error = QLatin1String("Failed to link software volume.");
|
||||
error = "Failed to link software volume."_L1;
|
||||
return false;
|
||||
}
|
||||
element_link = volume_sw_;
|
||||
@ -833,7 +835,7 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
||||
// Link fading volume element if enabled.
|
||||
if (fading_enabled_ && volume_fading_) {
|
||||
if (!gst_element_link(element_link, volume_fading_)) {
|
||||
error = QLatin1String("Failed to link fading volume.");
|
||||
error = "Failed to link fading volume."_L1;
|
||||
return false;
|
||||
}
|
||||
element_link = volume_fading_;
|
||||
@ -843,21 +845,21 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
||||
if (bs2b_enabled_ && bs2b) {
|
||||
qLog(Debug) << "Enabling bs2b";
|
||||
if (!gst_element_link(element_link, bs2b)) {
|
||||
error = QLatin1String("Failed to link bs2b.");
|
||||
error = "Failed to link bs2b."_L1;
|
||||
return false;
|
||||
}
|
||||
element_link = bs2b;
|
||||
}
|
||||
|
||||
if (!gst_element_link(element_link, audiosinkconverter)) {
|
||||
error = QLatin1String("Failed to link audio sink converter.");
|
||||
error = "Failed to link audio sink converter."_L1;
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
GstCaps *caps = gst_caps_new_empty_simple("audio/x-raw");
|
||||
if (!caps) {
|
||||
error = QLatin1String("Failed to create caps for raw audio.");
|
||||
error = "Failed to create caps for raw audio."_L1;
|
||||
return false;
|
||||
}
|
||||
if (channels_enabled_ && channels_ > 0) {
|
||||
@ -867,7 +869,7 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
||||
const bool link_filtered_result = gst_element_link_filtered(audiosinkconverter, audiosink_, caps);
|
||||
gst_caps_unref(caps);
|
||||
if (!link_filtered_result) {
|
||||
error = QLatin1String("Failed to link audio sink converter to audio sink with filter for ") + output_;
|
||||
error = "Failed to link audio sink converter to audio sink with filter for "_L1 + output_;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -960,7 +962,7 @@ void GstEnginePipeline::ElementAddedCallback(GstBin *bin, GstBin *sub_bin, GstEl
|
||||
const QString element_name = QString::fromUtf8(element_name_char);
|
||||
g_free(element_name_char);
|
||||
|
||||
if (bin != GST_BIN(instance->audiobin_) || element_name == QLatin1String("fake-audio-sink") || GST_ELEMENT(gst_element_get_parent(element)) != instance->audiosink_) return;
|
||||
if (bin != GST_BIN(instance->audiobin_) || element_name == "fake-audio-sink"_L1 || GST_ELEMENT(gst_element_get_parent(element)) != instance->audiosink_) return;
|
||||
|
||||
GstElement *volume = nullptr;
|
||||
if (GST_IS_STREAM_VOLUME(element)) {
|
||||
@ -1186,10 +1188,10 @@ GstPadProbeReturn GstEnginePipeline::BufferProbeCallback(GstPad *pad, GstPadProb
|
||||
quint64 duration = GST_BUFFER_DURATION(buf);
|
||||
qint64 end_time = static_cast<qint64>(start_time + duration);
|
||||
|
||||
if (format.startsWith(QLatin1String("S16LE"))) {
|
||||
if (format.startsWith("S16LE"_L1)) {
|
||||
instance->logged_unsupported_analyzer_format_ = false;
|
||||
}
|
||||
else if (format.startsWith(QLatin1String("S32LE"))) {
|
||||
else if (format.startsWith("S32LE"_L1)) {
|
||||
|
||||
GstMapInfo map_info;
|
||||
gst_buffer_map(buf, &map_info, GST_MAP_READ);
|
||||
@ -1210,7 +1212,7 @@ GstPadProbeReturn GstEnginePipeline::BufferProbeCallback(GstPad *pad, GstPadProb
|
||||
instance->logged_unsupported_analyzer_format_ = false;
|
||||
}
|
||||
|
||||
else if (format.startsWith(QLatin1String("F32LE"))) {
|
||||
else if (format.startsWith("F32LE"_L1)) {
|
||||
|
||||
GstMapInfo map_info;
|
||||
gst_buffer_map(buf, &map_info, GST_MAP_READ);
|
||||
@ -1231,7 +1233,7 @@ GstPadProbeReturn GstEnginePipeline::BufferProbeCallback(GstPad *pad, GstPadProb
|
||||
|
||||
instance->logged_unsupported_analyzer_format_ = false;
|
||||
}
|
||||
else if (format.startsWith(QLatin1String("S24LE"))) {
|
||||
else if (format.startsWith("S24LE"_L1)) {
|
||||
|
||||
GstMapInfo map_info;
|
||||
gst_buffer_map(buf, &map_info, GST_MAP_READ);
|
||||
@ -1254,7 +1256,7 @@ GstPadProbeReturn GstEnginePipeline::BufferProbeCallback(GstPad *pad, GstPadProb
|
||||
|
||||
instance->logged_unsupported_analyzer_format_ = false;
|
||||
}
|
||||
else if (format.startsWith(QLatin1String("S24_32LE"))) {
|
||||
else if (format.startsWith("S24_32LE"_L1)) {
|
||||
|
||||
GstMapInfo map_info;
|
||||
gst_buffer_map(buf, &map_info, GST_MAP_READ);
|
||||
@ -1526,7 +1528,7 @@ void GstEnginePipeline::ErrorMessageReceived(GstMessage *msg) {
|
||||
|
||||
{
|
||||
QMutexLocker l(&mutex_redirect_url_);
|
||||
if (!redirect_url_.isEmpty() && debugstr.contains(QLatin1String("A redirect message was posted on the bus and should have been handled by the application."))) {
|
||||
if (!redirect_url_.isEmpty() && debugstr.contains("A redirect message was posted on the bus and should have been handled by the application."_L1)) {
|
||||
// mmssrc posts a message on the bus *and* makes an error message when it wants to do a redirect.
|
||||
// We handle the message, but now we have to ignore the error too.
|
||||
return;
|
||||
@ -1567,11 +1569,11 @@ void GstEnginePipeline::TagMessageReceived(GstMessage *msg) {
|
||||
|
||||
if (!engine_metadata.title.isEmpty() && engine_metadata.artist.isEmpty() && engine_metadata.album.isEmpty()) {
|
||||
QStringList title_splitted;
|
||||
if (engine_metadata.title.contains(QLatin1String(" - "))) {
|
||||
if (engine_metadata.title.contains(" - "_L1)) {
|
||||
title_splitted = engine_metadata.title.split(QStringLiteral(" - "));
|
||||
}
|
||||
else if (engine_metadata.title.contains(QLatin1Char('~'))) {
|
||||
title_splitted = engine_metadata.title.split(QLatin1Char('~'));
|
||||
else if (engine_metadata.title.contains(u'~')) {
|
||||
title_splitted = engine_metadata.title.split(u'~');
|
||||
}
|
||||
if (!title_splitted.isEmpty() && title_splitted.count() >= 2) {
|
||||
int i = 0;
|
||||
|
@ -44,6 +44,8 @@
|
||||
|
||||
#include "gststartup.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
GThread *GstStartup::kGThread = nullptr;
|
||||
|
||||
gpointer GstStartup::GLibMainLoopThreadFunc(gpointer) {
|
||||
@ -115,28 +117,28 @@ void GstStartup::SetEnvironment() {
|
||||
// Set plugin root path
|
||||
QString plugin_root_path;
|
||||
# if defined(Q_OS_MACOS)
|
||||
plugin_root_path = QDir::cleanPath(app_path + QLatin1String("/../PlugIns"));
|
||||
plugin_root_path = QDir::cleanPath(app_path + "/../PlugIns"_L1);
|
||||
# elif defined(Q_OS_UNIX)
|
||||
plugin_root_path = QDir::cleanPath(app_path + QLatin1String("/../plugins"));
|
||||
plugin_root_path = QDir::cleanPath(app_path + "/../plugins"_L1);
|
||||
# elif defined(Q_OS_WIN32)
|
||||
plugin_root_path = app_path;
|
||||
# endif
|
||||
|
||||
// Set GIO module path
|
||||
const QString gio_module_path = plugin_root_path + QLatin1String("/gio-modules");
|
||||
const QString gio_module_path = plugin_root_path + "/gio-modules"_L1;
|
||||
|
||||
// Set GStreamer plugin scanner path
|
||||
QString gst_plugin_scanner;
|
||||
# if defined(Q_OS_UNIX)
|
||||
gst_plugin_scanner = plugin_root_path + QLatin1String("/gst-plugin-scanner");
|
||||
gst_plugin_scanner = plugin_root_path + "/gst-plugin-scanner"_L1;
|
||||
# endif
|
||||
|
||||
// Set GStreamer plugin path
|
||||
QString gst_plugin_path;
|
||||
# if defined(Q_OS_WIN32)
|
||||
gst_plugin_path = plugin_root_path + QLatin1String("/gstreamer-plugins");
|
||||
gst_plugin_path = plugin_root_path + "/gstreamer-plugins"_L1;
|
||||
# else
|
||||
gst_plugin_path = plugin_root_path + QLatin1String("/gstreamer");
|
||||
gst_plugin_path = plugin_root_path + "/gstreamer"_L1;
|
||||
# endif
|
||||
|
||||
if (!gio_module_path.isEmpty()) {
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include "macosdevicefinder.h"
|
||||
#include "enginedevice.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
namespace {
|
||||
|
||||
template<typename T>
|
||||
@ -107,7 +109,7 @@ EngineDeviceList MacOsDeviceFinder::ListDevices() {
|
||||
EngineDevice device;
|
||||
device.value = id;
|
||||
device.description = QString::fromUtf8(CFStringGetCStringPtr(*device_name, CFStringGetSystemEncoding()));
|
||||
if (device.description.isEmpty()) device.description = QLatin1String("Unknown device ") + device.value.toString();
|
||||
if (device.description.isEmpty()) device.description = "Unknown device "_L1 + device.value.toString();
|
||||
device.iconname = device.GuessIconName();
|
||||
device_list.append(device);
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ using namespace ABI::Windows::Foundation;
|
||||
using namespace ABI::Windows::Foundation::Collections;
|
||||
using namespace ABI::Windows::Devices::Enumeration;
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
UWPDeviceFinder::UWPDeviceFinder() : DeviceFinder(QStringLiteral("uwpdevice"), { QStringLiteral("wasapi2sink") }) {}
|
||||
|
||||
namespace {
|
||||
@ -107,7 +109,7 @@ EngineDeviceList UWPDeviceFinder::ListDevices() {
|
||||
|
||||
{
|
||||
EngineDevice default_device;
|
||||
default_device.description = QStringLiteral("Default device");
|
||||
default_device.description = "Default device"_L1;
|
||||
default_device.iconname = default_device.GuessIconName();
|
||||
devices.append(default_device);
|
||||
}
|
||||
|
@ -40,6 +40,8 @@
|
||||
#include "vlcengine.h"
|
||||
#include "vlcscopedref.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
VLCEngine::VLCEngine(SharedPtr<TaskManager> task_manager, QObject *parent)
|
||||
: EngineBase(parent),
|
||||
instance_(nullptr),
|
||||
@ -131,7 +133,7 @@ bool VLCEngine::Play(const bool pause, const quint64 offset_nanosec) {
|
||||
if (!Initialized()) return false;
|
||||
|
||||
// Set audio output
|
||||
if (!output_.isEmpty() && output_ != QLatin1String("auto")) {
|
||||
if (!output_.isEmpty() && output_ != "auto"_L1) {
|
||||
int result = libvlc_audio_output_set(player_, output_.toUtf8().constData());
|
||||
if (result != 0) qLog(Error) << "Failed to set output to" << output_;
|
||||
}
|
||||
@ -221,8 +223,8 @@ EngineBase::OutputDetailsList VLCEngine::GetOutputsList() const {
|
||||
|
||||
OutputDetailsList outputs;
|
||||
OutputDetails output_auto;
|
||||
output_auto.name = QLatin1String("auto");
|
||||
output_auto.description = QLatin1String("Automatically detected");
|
||||
output_auto.name = "auto"_L1;
|
||||
output_auto.description = "Automatically detected"_L1;
|
||||
outputs << output_auto;
|
||||
|
||||
libvlc_audio_output_t *audio_output_list = libvlc_audio_output_list_get(instance_);
|
||||
@ -230,12 +232,12 @@ EngineBase::OutputDetailsList VLCEngine::GetOutputsList() const {
|
||||
OutputDetails output;
|
||||
output.name = QString::fromUtf8(audio_output->psz_name);
|
||||
output.description = QString::fromUtf8(audio_output->psz_description);
|
||||
if (output.name == QLatin1String("auto")) output.iconname = QLatin1String("soundcard");
|
||||
else if ((output.name == QLatin1String("alsa"))||(output.name == QLatin1String("oss"))) output.iconname = QLatin1String("alsa");
|
||||
else if (output.name== QLatin1String("jack")) output.iconname = QLatin1String("jack");
|
||||
else if (output.name == QLatin1String("pulse")) output.iconname = QLatin1String("pulseaudio");
|
||||
else if (output.name == QLatin1String("afile")) output.iconname = QLatin1String("document-new");
|
||||
else output.iconname = QLatin1String("soundcard");
|
||||
if (output.name == "auto"_L1) output.iconname = "soundcard"_L1;
|
||||
else if ((output.name == "alsa"_L1)||(output.name == "oss"_L1)) output.iconname = "alsa"_L1;
|
||||
else if (output.name== "jack"_L1) output.iconname = "jack"_L1;
|
||||
else if (output.name == "pulse"_L1) output.iconname = "pulseaudio"_L1;
|
||||
else if (output.name == "afile"_L1) output.iconname = "document-new"_L1;
|
||||
else output.iconname = "soundcard"_L1;
|
||||
outputs << output;
|
||||
}
|
||||
libvlc_audio_output_list_release(audio_output_list);
|
||||
@ -252,11 +254,11 @@ bool VLCEngine::ValidOutput(const QString &output) {
|
||||
}
|
||||
|
||||
bool VLCEngine::CustomDeviceSupport(const QString &output) const {
|
||||
return output != QLatin1String("auto");
|
||||
return output != "auto"_L1;
|
||||
}
|
||||
|
||||
bool VLCEngine::ALSADeviceSupport(const QString &output) const {
|
||||
return output == QLatin1String("alsa");
|
||||
return output == "alsa"_L1;
|
||||
}
|
||||
|
||||
bool VLCEngine::ExclusiveModeSupport(const QString &output) const {
|
||||
|
@ -37,6 +37,8 @@
|
||||
|
||||
#include "enginebase.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
struct libvlc_event_t;
|
||||
|
||||
class TaskManager;
|
||||
@ -67,7 +69,7 @@ class VLCEngine : public EngineBase {
|
||||
|
||||
OutputDetailsList GetOutputsList() const override;
|
||||
bool ValidOutput(const QString &output) override;
|
||||
QString DefaultOutput() const override { return QLatin1String(""); }
|
||||
QString DefaultOutput() const override { return ""_L1; }
|
||||
bool CustomDeviceSupport(const QString &output) const override;
|
||||
bool ALSADeviceSupport(const QString &output) const override;
|
||||
bool ExclusiveModeSupport(const QString &output) const override;
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include "filtertree.h"
|
||||
#include "filterparsersearchcomparators.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
FilterParser::FilterParser(const QString &filter_string) : filter_string_(filter_string), iter_{}, end_{} {}
|
||||
|
||||
FilterTree *FilterParser::parse() {
|
||||
@ -73,7 +75,7 @@ FilterTree *FilterParser::parseAndGroup() {
|
||||
do {
|
||||
group->add(parseSearchExpression());
|
||||
advance();
|
||||
if (iter_ != end_ && *iter_ == QLatin1Char(')')) break;
|
||||
if (iter_ != end_ && *iter_ == u')') break;
|
||||
if (checkOr(false)) {
|
||||
break;
|
||||
}
|
||||
@ -87,16 +89,16 @@ FilterTree *FilterParser::parseAndGroup() {
|
||||
bool FilterParser::checkAnd() {
|
||||
|
||||
if (iter_ != end_) {
|
||||
if (*iter_ == QLatin1Char('A')) {
|
||||
if (*iter_ == u'A') {
|
||||
buf_ += *iter_;
|
||||
++iter_;
|
||||
if (iter_ != end_ && *iter_ == QLatin1Char('N')) {
|
||||
if (iter_ != end_ && *iter_ == u'N') {
|
||||
buf_ += *iter_;
|
||||
++iter_;
|
||||
if (iter_ != end_ && *iter_ == QLatin1Char('D')) {
|
||||
if (iter_ != end_ && *iter_ == u'D') {
|
||||
buf_ += *iter_;
|
||||
++iter_;
|
||||
if (iter_ != end_ && (iter_->isSpace() || *iter_ == QLatin1Char('-') || *iter_ == QLatin1Char('('))) {
|
||||
if (iter_ != end_ && (iter_->isSpace() || *iter_ == u'-' || *iter_ == u'(')) {
|
||||
advance();
|
||||
buf_.clear();
|
||||
return true;
|
||||
@ -113,7 +115,7 @@ bool FilterParser::checkAnd() {
|
||||
bool FilterParser::checkOr(const bool step_over) {
|
||||
|
||||
if (!buf_.isEmpty()) {
|
||||
if (buf_ == QLatin1String("OR")) {
|
||||
if (buf_ == "OR"_L1) {
|
||||
if (step_over) {
|
||||
buf_.clear();
|
||||
advance();
|
||||
@ -123,13 +125,13 @@ bool FilterParser::checkOr(const bool step_over) {
|
||||
}
|
||||
else {
|
||||
if (iter_ != end_) {
|
||||
if (*iter_ == QLatin1Char('O')) {
|
||||
if (*iter_ == u'O') {
|
||||
buf_ += *iter_;
|
||||
++iter_;
|
||||
if (iter_ != end_ && *iter_ == QLatin1Char('R')) {
|
||||
if (iter_ != end_ && *iter_ == u'R') {
|
||||
buf_ += *iter_;
|
||||
++iter_;
|
||||
if (iter_ != end_ && (iter_->isSpace() || *iter_ == QLatin1Char('-') || *iter_ == QLatin1Char('('))) {
|
||||
if (iter_ != end_ && (iter_->isSpace() || *iter_ == u'-' || *iter_ == u'(')) {
|
||||
if (step_over) {
|
||||
buf_.clear();
|
||||
advance();
|
||||
@ -149,19 +151,19 @@ FilterTree *FilterParser::parseSearchExpression() {
|
||||
|
||||
advance();
|
||||
if (iter_ == end_) return new NopFilter;
|
||||
if (*iter_ == QLatin1Char('(')) {
|
||||
if (*iter_ == u'(') {
|
||||
++iter_;
|
||||
advance();
|
||||
FilterTree *tree = parseOrGroup();
|
||||
advance();
|
||||
if (iter_ != end_) {
|
||||
if (*iter_ == QLatin1Char(')')) {
|
||||
if (*iter_ == u')') {
|
||||
++iter_;
|
||||
}
|
||||
}
|
||||
return tree;
|
||||
}
|
||||
else if (*iter_ == QLatin1Char('-')) {
|
||||
else if (*iter_ == u'-') {
|
||||
++iter_;
|
||||
FilterTree *tree = parseSearchExpression();
|
||||
if (tree->type() != FilterTree::FilterType::Nop) return new NotFilter(tree);
|
||||
@ -183,7 +185,7 @@ FilterTree *FilterParser::parseSearchTerm() {
|
||||
|
||||
for (; iter_ != end_; ++iter_) {
|
||||
if (in_quotes) {
|
||||
if (*iter_ == QLatin1Char('"')) {
|
||||
if (*iter_ == u'"') {
|
||||
in_quotes = false;
|
||||
}
|
||||
else {
|
||||
@ -191,23 +193,23 @@ FilterTree *FilterParser::parseSearchTerm() {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (*iter_ == QLatin1Char('"')) {
|
||||
if (*iter_ == u'"') {
|
||||
in_quotes = true;
|
||||
}
|
||||
else if (column.isEmpty() && *iter_ == QLatin1Char(':')) {
|
||||
else if (column.isEmpty() && *iter_ == u':') {
|
||||
column = buf_.toLower();
|
||||
buf_.clear();
|
||||
prefix.clear(); // Prefix isn't allowed here - let's ignore it
|
||||
}
|
||||
else if (iter_->isSpace() || *iter_ == QLatin1Char('(') || *iter_ == QLatin1Char(')') || *iter_ == QLatin1Char('-')) {
|
||||
else if (iter_->isSpace() || *iter_ == u'(' || *iter_ == u')' || *iter_ == u'-') {
|
||||
break;
|
||||
}
|
||||
else if (buf_.isEmpty()) {
|
||||
// We don't know whether there is a column part in this search term thus we assume the latter and just try and read a prefix
|
||||
if (prefix.isEmpty() && (*iter_ == QLatin1Char('>') || *iter_ == QLatin1Char('<') || *iter_ == QLatin1Char('=') || *iter_ == QLatin1Char('!'))) {
|
||||
if (prefix.isEmpty() && (*iter_ == u'>' || *iter_ == u'<' || *iter_ == u'=' || *iter_ == u'!')) {
|
||||
prefix += *iter_;
|
||||
}
|
||||
else if (prefix != QLatin1Char('=') && *iter_ == QLatin1Char('=')) {
|
||||
else if (prefix != u'=' && *iter_ == u'=') {
|
||||
prefix += *iter_;
|
||||
}
|
||||
else {
|
||||
@ -229,17 +231,17 @@ FilterTree *FilterParser::parseSearchTerm() {
|
||||
|
||||
FilterTree *FilterParser::createSearchTermTreeNode(const QString &column, const QString &prefix, const QString &value) const {
|
||||
|
||||
if (value.isEmpty() && prefix != QLatin1Char('=')) {
|
||||
if (value.isEmpty() && prefix != u'=') {
|
||||
return new NopFilter;
|
||||
}
|
||||
|
||||
FilterParserSearchTermComparator *cmp = nullptr;
|
||||
|
||||
if (Song::kTextSearchColumns.contains(column, Qt::CaseInsensitive)) {
|
||||
if (prefix == QLatin1Char('=') || prefix == QLatin1String("==")) {
|
||||
if (prefix == u'=' || prefix == "=="_L1) {
|
||||
cmp = new FilterParserTextEqComparator(value);
|
||||
}
|
||||
else if (prefix == QLatin1String("!=") || prefix == QLatin1String("<>")) {
|
||||
else if (prefix == "!="_L1 || prefix == "<>"_L1) {
|
||||
cmp = new FilterParserTextNeComparator(value);
|
||||
}
|
||||
else {
|
||||
@ -250,22 +252,22 @@ FilterTree *FilterParser::createSearchTermTreeNode(const QString &column, const
|
||||
bool ok = false;
|
||||
int number = value.toInt(&ok);
|
||||
if (ok) {
|
||||
if (prefix == QLatin1Char('=') || prefix == QLatin1String("==")) {
|
||||
if (prefix == u'=' || prefix == "=="_L1) {
|
||||
cmp = new FilterParserIntEqComparator(number);
|
||||
}
|
||||
else if (prefix == QLatin1String("!=") || prefix == QLatin1String("<>")) {
|
||||
else if (prefix == "!="_L1 || prefix == "<>"_L1) {
|
||||
cmp = new FilterParserIntNeComparator(number);
|
||||
}
|
||||
else if (prefix == QLatin1Char('>')) {
|
||||
else if (prefix == u'>') {
|
||||
cmp = new FilterParserIntGtComparator(number);
|
||||
}
|
||||
else if (prefix == QLatin1String(">=")) {
|
||||
else if (prefix == ">="_L1) {
|
||||
cmp = new FilterParserIntGeComparator(number);
|
||||
}
|
||||
else if (prefix == QLatin1Char('<')) {
|
||||
else if (prefix == u'<') {
|
||||
cmp = new FilterParserIntLtComparator(number);
|
||||
}
|
||||
else if (prefix == QLatin1String("<=")) {
|
||||
else if (prefix == "<="_L1) {
|
||||
cmp = new FilterParserIntLeComparator(number);
|
||||
}
|
||||
else {
|
||||
@ -277,22 +279,22 @@ FilterTree *FilterParser::createSearchTermTreeNode(const QString &column, const
|
||||
bool ok = false;
|
||||
uint number = value.toUInt(&ok);
|
||||
if (ok) {
|
||||
if (prefix == QLatin1Char('=') || prefix == QLatin1String("==")) {
|
||||
if (prefix == u'=' || prefix == "=="_L1) {
|
||||
cmp = new FilterParserUIntEqComparator(number);
|
||||
}
|
||||
else if (prefix == QLatin1String("!=") || prefix == QLatin1String("<>")) {
|
||||
else if (prefix == "!="_L1 || prefix == "<>"_L1) {
|
||||
cmp = new FilterParserUIntNeComparator(number);
|
||||
}
|
||||
else if (prefix == QLatin1Char('>')) {
|
||||
else if (prefix == u'>') {
|
||||
cmp = new FilterParserUIntGtComparator(number);
|
||||
}
|
||||
else if (prefix == QLatin1String(">=")) {
|
||||
else if (prefix == ">="_L1) {
|
||||
cmp = new FilterParserUIntGeComparator(number);
|
||||
}
|
||||
else if (prefix == QLatin1Char('<')) {
|
||||
else if (prefix == u'<') {
|
||||
cmp = new FilterParserUIntLtComparator(number);
|
||||
}
|
||||
else if (prefix == QLatin1String("<=")) {
|
||||
else if (prefix == "<="_L1) {
|
||||
cmp = new FilterParserUIntLeComparator(number);
|
||||
}
|
||||
else {
|
||||
@ -302,28 +304,28 @@ FilterTree *FilterParser::createSearchTermTreeNode(const QString &column, const
|
||||
}
|
||||
else if (Song::kInt64SearchColumns.contains(column, Qt::CaseInsensitive)) {
|
||||
qint64 number = 0;
|
||||
if (column == QLatin1String("length")) {
|
||||
if (column == "length"_L1) {
|
||||
number = ParseTime(value);
|
||||
}
|
||||
else {
|
||||
number = value.toLongLong();
|
||||
}
|
||||
if (prefix == QLatin1Char('=') || prefix == QLatin1String("==")) {
|
||||
if (prefix == u'=' || prefix == "=="_L1) {
|
||||
cmp = new FilterParserInt64EqComparator(number);
|
||||
}
|
||||
else if (prefix == QLatin1String("!=") || prefix == QLatin1String("<>")) {
|
||||
else if (prefix == "!="_L1 || prefix == "<>"_L1) {
|
||||
cmp = new FilterParserInt64NeComparator(number);
|
||||
}
|
||||
else if (prefix == QLatin1Char('>')) {
|
||||
else if (prefix == u'>') {
|
||||
cmp = new FilterParserInt64GtComparator(number);
|
||||
}
|
||||
else if (prefix == QLatin1String(">=")) {
|
||||
else if (prefix == ">="_L1) {
|
||||
cmp = new FilterParserInt64GeComparator(number);
|
||||
}
|
||||
else if (prefix == QLatin1Char('<')) {
|
||||
else if (prefix == u'<') {
|
||||
cmp = new FilterParserInt64LtComparator(number);
|
||||
}
|
||||
else if (prefix == QLatin1String("<=")) {
|
||||
else if (prefix == "<="_L1) {
|
||||
cmp = new FilterParserInt64LeComparator(number);
|
||||
}
|
||||
else {
|
||||
@ -332,22 +334,22 @@ FilterTree *FilterParser::createSearchTermTreeNode(const QString &column, const
|
||||
}
|
||||
else if (Song::kFloatSearchColumns.contains(column, Qt::CaseInsensitive)) {
|
||||
const float rating = ParseRating(value);
|
||||
if (prefix == QLatin1Char('=') || prefix == QLatin1String("==")) {
|
||||
if (prefix == u'=' || prefix == "=="_L1) {
|
||||
cmp = new FilterParserFloatEqComparator(rating);
|
||||
}
|
||||
else if (prefix == QLatin1String("!=") || prefix == QLatin1String("<>")) {
|
||||
else if (prefix == "!="_L1 || prefix == "<>"_L1) {
|
||||
cmp = new FilterParserFloatNeComparator(rating);
|
||||
}
|
||||
else if (prefix == QLatin1Char('>')) {
|
||||
else if (prefix == u'>') {
|
||||
cmp = new FilterParserFloatGtComparator(rating);
|
||||
}
|
||||
else if (prefix == QLatin1String(">=")) {
|
||||
else if (prefix == ">="_L1) {
|
||||
cmp = new FilterParserFloatGeComparator(rating);
|
||||
}
|
||||
else if (prefix == QLatin1Char('<')) {
|
||||
else if (prefix == u'<') {
|
||||
cmp = new FilterParserFloatLtComparator(rating);
|
||||
}
|
||||
else if (prefix == QLatin1String("<=")) {
|
||||
else if (prefix == "<="_L1) {
|
||||
cmp = new FilterParserFloatLeComparator(rating);
|
||||
}
|
||||
else {
|
||||
@ -385,7 +387,7 @@ qint64 FilterParser::ParseTime(const QString &time_str) {
|
||||
if (c.isDigit()) {
|
||||
accum = accum * 10LL + static_cast<qint64>(c.digitValue());
|
||||
}
|
||||
else if (c == QLatin1Char(':')) {
|
||||
else if (c == u':') {
|
||||
seconds = seconds * 60LL + accum;
|
||||
accum = 0LL;
|
||||
++colon_count;
|
||||
@ -419,15 +421,15 @@ float FilterParser::ParseRating(const QString &rating_str) {
|
||||
float rating = -1.0F;
|
||||
|
||||
// Check if the search is a float
|
||||
if (rating_str.contains(QLatin1Char('f'), Qt::CaseInsensitive)) {
|
||||
if (rating_str.count(QLatin1Char('f'), Qt::CaseInsensitive) > 1) {
|
||||
if (rating_str.contains(u'f', Qt::CaseInsensitive)) {
|
||||
if (rating_str.count(u'f', Qt::CaseInsensitive) > 1) {
|
||||
return rating;
|
||||
}
|
||||
QString rating_float_str = rating_str;
|
||||
if (rating_str.at(0) == QLatin1Char('f') || rating_str.at(0) == QLatin1Char('F')) {
|
||||
if (rating_str.at(0) == u'f' || rating_str.at(0) == u'F') {
|
||||
rating_float_str = rating_float_str.remove(0, 1);
|
||||
}
|
||||
if (rating_str.right(1) == QLatin1Char('f') || rating_str.right(1) == QLatin1Char('F')) {
|
||||
if (rating_str.right(1) == u'f' || rating_str.right(1) == u'F') {
|
||||
rating_float_str.chop(1);
|
||||
}
|
||||
bool ok = false;
|
||||
@ -459,29 +461,29 @@ QString FilterParser::ToolTip() {
|
||||
return QLatin1String("<html><head/><body><p>") +
|
||||
QObject::tr("Prefix a search term with a field name to limit the search to that field, e.g.:") +
|
||||
QLatin1Char(' ') +
|
||||
QLatin1String("<span style=\"font-weight:600;\">") +
|
||||
"<span style=\"font-weight:600;\">"_L1 +
|
||||
QObject::tr("artist") +
|
||||
QLatin1String(":</span><span style=\"font-style:italic;\">Strawbs</span> ") +
|
||||
QObject::tr("searches for all artists containing the word %1. ").arg(QLatin1String("Strawbs")) +
|
||||
QLatin1String("</p><p>") +
|
||||
":</span><span style=\"font-style:italic;\">Strawbs</span> "_L1 +
|
||||
QObject::tr("searches for all artists containing the word %1. ").arg("Strawbs"_L1) +
|
||||
"</p><p>"_L1 +
|
||||
|
||||
QObject::tr("Search terms for numerical fields can be prefixed with %1 or %2 to refine the search, e.g.: ")
|
||||
.arg(QLatin1String(" =, !=, <, >, <="), QLatin1String(">=")) +
|
||||
QLatin1String("<span style=\"font-weight:600;\">") +
|
||||
.arg(" =, !=, <, >, <="_L1, ">="_L1) +
|
||||
"<span style=\"font-weight:600;\">"_L1 +
|
||||
QObject::tr("rating") +
|
||||
QLatin1String("</span>") +
|
||||
QLatin1String(":>=") +
|
||||
QLatin1String("<span style=\"font-weight:italic;\">4</span>") +
|
||||
QLatin1String("</p><p>") +
|
||||
"</span>"_L1 +
|
||||
":>="_L1 +
|
||||
"<span style=\"font-weight:italic;\">4</span>"_L1 +
|
||||
"</p><p>"_L1 +
|
||||
|
||||
QObject::tr("Multiple search terms can also be combined with \"%1\" (default) and \"%2\", as well as grouped with parentheses. ")
|
||||
.arg(QLatin1String("AND"), QLatin1String("OR")) +
|
||||
.arg("AND"_L1, "OR"_L1) +
|
||||
|
||||
QLatin1String("</p><p><span style=\"font-weight:600;\">") +
|
||||
"</p><p><span style=\"font-weight:600;\">"_L1 +
|
||||
QObject::tr("Available fields") +
|
||||
QLatin1String(": ") + QLatin1String("</span><span style=\"font-style:italic;\">") +
|
||||
Song::kSearchColumns.join(QLatin1String(", ")) +
|
||||
QLatin1String("</span>.") +
|
||||
QLatin1String("</p></body></html>");
|
||||
": "_L1 + "</span><span style=\"font-style:italic;\">"_L1 +
|
||||
Song::kSearchColumns.join(", "_L1) +
|
||||
"</span>."_L1 +
|
||||
"</p></body></html>"_L1;
|
||||
|
||||
}
|
||||
|
@ -23,31 +23,33 @@
|
||||
|
||||
#include "filtertree.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
FilterTree::FilterTree() = default;
|
||||
FilterTree::~FilterTree() = default;
|
||||
|
||||
QVariant FilterTree::DataFromColumn(const QString &column, const Song &metadata) {
|
||||
|
||||
if (column == QLatin1String("albumartist")) return metadata.effective_albumartist();
|
||||
if (column == QLatin1String("artist")) return metadata.artist();
|
||||
if (column == QLatin1String("album")) return metadata.album();
|
||||
if (column == QLatin1String("title")) return metadata.PrettyTitle();
|
||||
if (column == QLatin1String("composer")) return metadata.composer();
|
||||
if (column == QLatin1String("performer")) return metadata.performer();
|
||||
if (column == QLatin1String("grouping")) return metadata.grouping();
|
||||
if (column == QLatin1String("genre")) return metadata.genre();
|
||||
if (column == QLatin1String("comment")) return metadata.comment();
|
||||
if (column == QLatin1String("track")) return metadata.track();
|
||||
if (column == QLatin1String("year")) return metadata.year();
|
||||
if (column == QLatin1String("length")) return metadata.length_nanosec();
|
||||
if (column == QLatin1String("samplerate")) return metadata.samplerate();
|
||||
if (column == QLatin1String("bitdepth")) return metadata.bitdepth();
|
||||
if (column == QLatin1String("bitrate")) return metadata.bitrate();
|
||||
if (column == QLatin1String("rating")) return metadata.rating();
|
||||
if (column == QLatin1String("playcount")) return metadata.playcount();
|
||||
if (column == QLatin1String("skipcount")) return metadata.skipcount();
|
||||
if (column == QLatin1String("filename")) return metadata.basefilename();
|
||||
if (column == QLatin1String("url")) return metadata.effective_stream_url().toString();
|
||||
if (column == "albumartist"_L1) return metadata.effective_albumartist();
|
||||
if (column == "artist"_L1) return metadata.artist();
|
||||
if (column == "album"_L1) return metadata.album();
|
||||
if (column == "title"_L1) return metadata.PrettyTitle();
|
||||
if (column == "composer"_L1) return metadata.composer();
|
||||
if (column == "performer"_L1) return metadata.performer();
|
||||
if (column == "grouping"_L1) return metadata.grouping();
|
||||
if (column == "genre"_L1) return metadata.genre();
|
||||
if (column == "comment"_L1) return metadata.comment();
|
||||
if (column == "track"_L1) return metadata.track();
|
||||
if (column == "year"_L1) return metadata.year();
|
||||
if (column == "length"_L1) return metadata.length_nanosec();
|
||||
if (column == "samplerate"_L1) return metadata.samplerate();
|
||||
if (column == "bitdepth"_L1) return metadata.bitdepth();
|
||||
if (column == "bitrate"_L1) return metadata.bitrate();
|
||||
if (column == "rating"_L1) return metadata.rating();
|
||||
if (column == "playcount"_L1) return metadata.playcount();
|
||||
if (column == "skipcount"_L1) return metadata.skipcount();
|
||||
if (column == "filename"_L1) return metadata.basefilename();
|
||||
if (column == "url"_L1) return metadata.effective_stream_url().toString();
|
||||
|
||||
return QVariant();
|
||||
|
||||
|
@ -34,6 +34,8 @@
|
||||
#include "globalshortcutgrabber.h"
|
||||
#include "ui_globalshortcutgrabber.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
GlobalShortcutGrabber::GlobalShortcutGrabber(QWidget *parent)
|
||||
: QDialog(parent),
|
||||
ui_(new Ui::GlobalShortcutGrabber),
|
||||
@ -110,7 +112,7 @@ bool GlobalShortcutGrabber::event(QEvent *e) {
|
||||
}
|
||||
|
||||
void GlobalShortcutGrabber::UpdateText() {
|
||||
ui_->label_key->setText(QLatin1String("<b>") + ret_.toString(QKeySequence::NativeText) + QLatin1String("</b>"));
|
||||
ui_->label_key->setText("<b>"_L1 + ret_.toString(QKeySequence::NativeText) + "</b>"_L1);
|
||||
}
|
||||
|
||||
void GlobalShortcutGrabber::Accepted() {
|
||||
|
@ -37,6 +37,8 @@
|
||||
|
||||
#include "gnomesettingsdaemon.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kService1[] = "org.gnome.SettingsDaemon.MediaKeys";
|
||||
constexpr char kService2[] = "org.gnome.SettingsDaemon";
|
||||
@ -118,9 +120,9 @@ void GlobalShortcutsBackendGnome::DoUnregister() {
|
||||
void GlobalShortcutsBackendGnome::GnomeMediaKeyPressed(const QString&, const QString &key) {
|
||||
|
||||
auto shortcuts = manager_->shortcuts();
|
||||
if (key == QLatin1String("Play")) shortcuts[QStringLiteral("play_pause")].action->trigger();
|
||||
if (key == QLatin1String("Stop")) shortcuts[QStringLiteral("stop")].action->trigger();
|
||||
if (key == QLatin1String("Next")) shortcuts[QStringLiteral("next_track")].action->trigger();
|
||||
if (key == QLatin1String("Previous")) shortcuts[QStringLiteral("prev_track")].action->trigger();
|
||||
if (key == "Play"_L1) shortcuts[QStringLiteral("play_pause")].action->trigger();
|
||||
if (key == "Stop"_L1) shortcuts[QStringLiteral("stop")].action->trigger();
|
||||
if (key == "Next"_L1) shortcuts[QStringLiteral("next_track")].action->trigger();
|
||||
if (key == "Previous"_L1) shortcuts[QStringLiteral("prev_track")].action->trigger();
|
||||
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ QStringList GlobalShortcutsBackendKDE::GetActionId(const QString &id, const QAct
|
||||
ret << QCoreApplication::applicationName();
|
||||
ret << id;
|
||||
ret << QCoreApplication::applicationName();
|
||||
ret << action->text().remove(QLatin1Char('&'));
|
||||
ret << action->text().remove(u'&');
|
||||
if (ret.back().isEmpty()) ret.back() = id;
|
||||
|
||||
return ret;
|
||||
|
@ -35,6 +35,8 @@
|
||||
|
||||
#include "matesettingsdaemon.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kService1[] = "org.mate.SettingsDaemon.MediaKeys";
|
||||
constexpr char kService2[] = "org.mate.SettingsDaemon";
|
||||
@ -118,9 +120,9 @@ void GlobalShortcutsBackendMate::DoUnregister() {
|
||||
void GlobalShortcutsBackendMate::MateMediaKeyPressed(const QString&, const QString &key) {
|
||||
|
||||
auto shortcuts = manager_->shortcuts();
|
||||
if (key == QLatin1String("Play")) shortcuts[QStringLiteral("play_pause")].action->trigger();
|
||||
if (key == QLatin1String("Stop")) shortcuts[QStringLiteral("stop")].action->trigger();
|
||||
if (key == QLatin1String("Next")) shortcuts[QStringLiteral("next_track")].action->trigger();
|
||||
if (key == QLatin1String("Previous")) shortcuts[QStringLiteral("prev_track")].action->trigger();
|
||||
if (key == "Play"_L1) shortcuts[QStringLiteral("play_pause")].action->trigger();
|
||||
if (key == "Stop"_L1) shortcuts[QStringLiteral("stop")].action->trigger();
|
||||
if (key == "Next"_L1) shortcuts[QStringLiteral("next_track")].action->trigger();
|
||||
if (key == "Previous"_L1) shortcuts[QStringLiteral("prev_track")].action->trigger();
|
||||
|
||||
}
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include "globalshortcutsbackend.h"
|
||||
#include "globalshortcut.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
GlobalShortcutsBackendX11::GlobalShortcutsBackendX11(GlobalShortcutsManager *manager, QObject *parent)
|
||||
: GlobalShortcutsBackend(manager, GlobalShortcutsBackend::Type::X11, parent),
|
||||
gshortcut_init_(nullptr) {}
|
||||
@ -45,7 +47,7 @@ bool GlobalShortcutsBackendX11::IsAvailable() const {
|
||||
|
||||
bool GlobalShortcutsBackendX11::IsX11Available() {
|
||||
|
||||
return QApplication::platformName() == QLatin1String("xcb");
|
||||
return QApplication::platformName() == "xcb"_L1;
|
||||
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,8 @@
|
||||
#include "lyricssearchresult.h"
|
||||
#include "chartlyricsprovider.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kUrlSearch[] = "http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect";
|
||||
}
|
||||
@ -100,21 +102,21 @@ void ChartLyricsProvider::HandleSearchReply(QNetworkReply *reply, const int id,
|
||||
QXmlStreamReader::TokenType type = reader.readNext();
|
||||
QString name = reader.name().toString();
|
||||
if (type == QXmlStreamReader::StartElement) {
|
||||
if (name == QLatin1String("GetLyricResult")) {
|
||||
if (name == "GetLyricResult"_L1) {
|
||||
result = LyricsSearchResult();
|
||||
}
|
||||
if (name == QLatin1String("LyricArtist")) {
|
||||
if (name == "LyricArtist"_L1) {
|
||||
result.artist = reader.readElementText();
|
||||
}
|
||||
else if (name == QLatin1String("LyricSong")) {
|
||||
else if (name == "LyricSong"_L1) {
|
||||
result.title = reader.readElementText();
|
||||
}
|
||||
else if (name == QLatin1String("Lyric")) {
|
||||
else if (name == "Lyric"_L1) {
|
||||
result.lyrics = reader.readElementText();
|
||||
}
|
||||
}
|
||||
else if (type == QXmlStreamReader::EndElement) {
|
||||
if (name == QLatin1String("GetLyricResult")) {
|
||||
if (name == "GetLyricResult"_L1) {
|
||||
if (!result.artist.isEmpty() && !result.title.isEmpty() && !result.lyrics.isEmpty() &&
|
||||
(result.artist.compare(request.albumartist, Qt::CaseInsensitive) == 0 ||
|
||||
result.artist.compare(request.artist, Qt::CaseInsensitive) == 0 ||
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include "lyricssearchrequest.h"
|
||||
#include "elyricsnetlyricsprovider.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kUrl[] = "https://www.elyrics.net/read/";
|
||||
constexpr char kStartTag[] = "<div[^>]*>";
|
||||
@ -41,7 +43,7 @@ ElyricsNetLyricsProvider::ElyricsNetLyricsProvider(SharedPtr<NetworkAccessManage
|
||||
|
||||
QUrl ElyricsNetLyricsProvider::Url(const LyricsSearchRequest &request) {
|
||||
|
||||
return QUrl(QLatin1String(kUrl) + request.artist[0].toLower() + QLatin1Char('/') + StringFixup(request.artist) + QLatin1String("-lyrics/") + StringFixup(request.title) + QLatin1String("-lyrics.html"));
|
||||
return QUrl(QLatin1String(kUrl) + request.artist[0].toLower() + QLatin1Char('/') + StringFixup(request.artist) + "-lyrics/"_L1 + StringFixup(request.title) + "-lyrics.html"_L1);
|
||||
|
||||
}
|
||||
|
||||
@ -56,7 +58,7 @@ QString ElyricsNetLyricsProvider::StringFixup(const QString &text) {
|
||||
.replace(regex_illegal_characters, QStringLiteral("_"))
|
||||
.replace(regex_duplicate_whitespaces, QStringLiteral(" "))
|
||||
.simplified()
|
||||
.replace(QLatin1Char(' '), QLatin1Char('-'))
|
||||
.replace(u' ', u'-')
|
||||
.toLower();
|
||||
|
||||
}
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include "htmllyricsprovider.h"
|
||||
#include "geniuslyricsprovider.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
using std::make_shared;
|
||||
|
||||
namespace {
|
||||
@ -128,7 +129,7 @@ void GeniusLyricsProvider::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);
|
||||
}
|
||||
|
||||
@ -250,9 +251,9 @@ void GeniusLyricsProvider::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);
|
||||
}
|
||||
}
|
||||
@ -295,12 +296,12 @@ void GeniusLyricsProvider::AccessTokenRequestFinished(QNetworkReply *reply) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains(QLatin1String("access_token"))) {
|
||||
if (!json_obj.contains("access_token"_L1)) {
|
||||
AuthError(QStringLiteral("Authentication reply from server is missing access token."), json_obj);
|
||||
return;
|
||||
}
|
||||
|
||||
const QString access_token = json_obj[QLatin1String("access_token")].toString();
|
||||
const QString access_token = json_obj["access_token"_L1].toString();
|
||||
|
||||
set_access_token(access_token);
|
||||
|
||||
@ -362,26 +363,26 @@ void GeniusLyricsProvider::HandleSearchReply(QNetworkReply *reply, const int id)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains(QLatin1String("meta"))) {
|
||||
if (!json_obj.contains("meta"_L1)) {
|
||||
Error(QStringLiteral("Json reply is missing meta object."), json_obj);
|
||||
EndSearch(search);
|
||||
return;
|
||||
}
|
||||
if (!json_obj[QLatin1String("meta")].isObject()) {
|
||||
if (!json_obj["meta"_L1].isObject()) {
|
||||
Error(QStringLiteral("Json reply meta is not an object."), json_obj);
|
||||
EndSearch(search);
|
||||
return;
|
||||
}
|
||||
QJsonObject obj_meta = json_obj[QLatin1String("meta")].toObject();
|
||||
if (!obj_meta.contains(QLatin1String("status"))) {
|
||||
QJsonObject obj_meta = json_obj["meta"_L1].toObject();
|
||||
if (!obj_meta.contains("status"_L1)) {
|
||||
Error(QStringLiteral("Json reply meta object is missing status."), obj_meta);
|
||||
EndSearch(search);
|
||||
return;
|
||||
}
|
||||
int status = obj_meta[QLatin1String("status")].toInt();
|
||||
int status = obj_meta["status"_L1].toInt();
|
||||
if (status != 200) {
|
||||
if (obj_meta.contains(QLatin1String("message"))) {
|
||||
Error(QStringLiteral("Received error %1: %2.").arg(status).arg(obj_meta[QLatin1String("message")].toString()));
|
||||
if (obj_meta.contains("message"_L1)) {
|
||||
Error(QStringLiteral("Received error %1: %2.").arg(status).arg(obj_meta["message"_L1].toString()));
|
||||
}
|
||||
else {
|
||||
Error(QStringLiteral("Received error %1.").arg(status));
|
||||
@ -390,50 +391,50 @@ void GeniusLyricsProvider::HandleSearchReply(QNetworkReply *reply, const int id)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains(QLatin1String("response"))) {
|
||||
if (!json_obj.contains("response"_L1)) {
|
||||
Error(QStringLiteral("Json reply is missing response."), json_obj);
|
||||
EndSearch(search);
|
||||
return;
|
||||
}
|
||||
if (!json_obj[QLatin1String("response")].isObject()) {
|
||||
if (!json_obj["response"_L1].isObject()) {
|
||||
Error(QStringLiteral("Json response is not an object."), json_obj);
|
||||
EndSearch(search);
|
||||
return;
|
||||
}
|
||||
QJsonObject obj_response = json_obj[QLatin1String("response")].toObject();
|
||||
if (!obj_response.contains(QLatin1String("hits"))) {
|
||||
QJsonObject obj_response = json_obj["response"_L1].toObject();
|
||||
if (!obj_response.contains("hits"_L1)) {
|
||||
Error(QStringLiteral("Json response is missing hits."), obj_response);
|
||||
EndSearch(search);
|
||||
return;
|
||||
}
|
||||
if (!obj_response[QLatin1String("hits")].isArray()) {
|
||||
if (!obj_response["hits"_L1].isArray()) {
|
||||
Error(QStringLiteral("Json hits is not an array."), obj_response);
|
||||
EndSearch(search);
|
||||
return;
|
||||
}
|
||||
const QJsonArray array_hits = obj_response[QLatin1String("hits")].toArray();
|
||||
const QJsonArray array_hits = obj_response["hits"_L1].toArray();
|
||||
|
||||
for (const QJsonValue &value_hit : array_hits) {
|
||||
if (!value_hit.isObject()) {
|
||||
continue;
|
||||
}
|
||||
QJsonObject obj_hit = value_hit.toObject();
|
||||
if (!obj_hit.contains(QLatin1String("result"))) {
|
||||
if (!obj_hit.contains("result"_L1)) {
|
||||
continue;
|
||||
}
|
||||
if (!obj_hit[QLatin1String("result")].isObject()) {
|
||||
if (!obj_hit["result"_L1].isObject()) {
|
||||
continue;
|
||||
}
|
||||
QJsonObject obj_result = obj_hit[QLatin1String("result")].toObject();
|
||||
if (!obj_result.contains(QLatin1String("title")) || !obj_result.contains(QLatin1String("primary_artist")) || !obj_result.contains(QLatin1String("url")) || !obj_result[QLatin1String("primary_artist")].isObject()) {
|
||||
QJsonObject obj_result = obj_hit["result"_L1].toObject();
|
||||
if (!obj_result.contains("title"_L1) || !obj_result.contains("primary_artist"_L1) || !obj_result.contains("url"_L1) || !obj_result["primary_artist"_L1].isObject()) {
|
||||
Error(QStringLiteral("Missing one or more values in result object"), obj_result);
|
||||
continue;
|
||||
}
|
||||
QJsonObject primary_artist = obj_result[QLatin1String("primary_artist")].toObject();
|
||||
if (!primary_artist.contains(QLatin1String("name"))) continue;
|
||||
QJsonObject primary_artist = obj_result["primary_artist"_L1].toObject();
|
||||
if (!primary_artist.contains("name"_L1)) continue;
|
||||
|
||||
QString artist = primary_artist[QLatin1String("name")].toString();
|
||||
QString title = obj_result[QLatin1String("title")].toString();
|
||||
QString artist = primary_artist["name"_L1].toString();
|
||||
QString title = obj_result["title"_L1].toString();
|
||||
|
||||
// Ignore results where both the artist and title don't match.
|
||||
if (!artist.startsWith(search->request.albumartist, Qt::CaseInsensitive) &&
|
||||
@ -442,7 +443,7 @@ void GeniusLyricsProvider::HandleSearchReply(QNetworkReply *reply, const int id)
|
||||
continue;
|
||||
}
|
||||
|
||||
QUrl url(obj_result[QLatin1String("url")].toString());
|
||||
QUrl url(obj_result["url"_L1].toString());
|
||||
if (!url.isValid()) continue;
|
||||
if (search->requests_lyric_.contains(url)) continue;
|
||||
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include "htmllyricsprovider.h"
|
||||
#include "lyricssearchrequest.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
HtmlLyricsProvider::HtmlLyricsProvider(const QString &name, const bool enabled, const QString &start_tag, const QString &end_tag, const QString &lyrics_start, const bool multiple, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: LyricsProvider(name, enabled, false, network, parent), start_tag_(start_tag), end_tag_(end_tag), lyrics_start_(lyrics_start), multiple_(multiple) {}
|
||||
|
||||
@ -110,7 +112,7 @@ void HtmlLyricsProvider::HandleLyricsReply(QNetworkReply *reply, const int id, c
|
||||
}
|
||||
|
||||
const QString lyrics = ParseLyricsFromHTML(QString::fromUtf8(data), QRegularExpression(start_tag_), QRegularExpression(end_tag_), QRegularExpression(lyrics_start_), multiple_);
|
||||
if (lyrics.isEmpty() || lyrics.contains(QLatin1String("we do not have the lyrics for"), Qt::CaseInsensitive)) {
|
||||
if (lyrics.isEmpty() || lyrics.contains("we do not have the lyrics for"_L1, Qt::CaseInsensitive)) {
|
||||
qLog(Debug) << name_ << "No lyrics for" << request.artist << request.album << request.title;
|
||||
Q_EMIT SearchFinished(id);
|
||||
return;
|
||||
@ -165,7 +167,7 @@ QString HtmlLyricsProvider::ParseLyricsFromHTML(const QString &content, const QR
|
||||
|
||||
if (end_lyrics_idx != -1 && start_lyrics_idx < end_lyrics_idx) {
|
||||
if (!lyrics.isEmpty()) {
|
||||
lyrics.append(QLatin1Char('\n'));
|
||||
lyrics.append(u'\n');
|
||||
}
|
||||
static const QRegularExpression regex_html_tag_a(QStringLiteral("<a [^>]*>[^<]*</a>"));
|
||||
static const QRegularExpression regex_html_tag_script(QStringLiteral("<script>[^>]*</script>"));
|
||||
@ -174,8 +176,8 @@ QString HtmlLyricsProvider::ParseLyricsFromHTML(const QString &content, const QR
|
||||
static const QRegularExpression regex_html_tag_p_close(QStringLiteral("</p>"));
|
||||
static const QRegularExpression regex_html_tags(QStringLiteral("<[^>]*>"));
|
||||
lyrics.append(content.mid(start_lyrics_idx, end_lyrics_idx - start_lyrics_idx)
|
||||
.remove(QLatin1Char('\r'))
|
||||
.remove(QLatin1Char('\n'))
|
||||
.remove(u'\r')
|
||||
.remove(u'\n')
|
||||
.remove(regex_html_tag_a)
|
||||
.remove(regex_html_tag_script)
|
||||
.remove(regex_html_tag_div)
|
||||
@ -191,7 +193,7 @@ QString HtmlLyricsProvider::ParseLyricsFromHTML(const QString &content, const QR
|
||||
}
|
||||
while (start_idx > 0 && multiple);
|
||||
|
||||
if (lyrics.length() > 6000 || lyrics.contains(QLatin1String("there are no lyrics to"), Qt::CaseInsensitive)) {
|
||||
if (lyrics.length() > 6000 || lyrics.contains("there are no lyrics to"_L1, Qt::CaseInsensitive)) {
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include "lyricssearchrequest.h"
|
||||
#include "letraslyricsprovider.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kUrl[] = "https://www.letras.mus.br/winamp.php";
|
||||
constexpr char kStartTag[] = "<div[^>]*>";
|
||||
@ -42,7 +44,7 @@ LetrasLyricsProvider::LetrasLyricsProvider(SharedPtr<NetworkAccessManager> netwo
|
||||
|
||||
QUrl LetrasLyricsProvider::Url(const LyricsSearchRequest &request) {
|
||||
|
||||
return QUrl(QLatin1String(kUrl) + QLatin1String("?musica=") + StringFixup(request.artist) + QLatin1String("&artista=") + StringFixup(request.title));
|
||||
return QUrl(QLatin1String(kUrl) + "?musica="_L1 + StringFixup(request.artist) + "&artista="_L1 + StringFixup(request.title));
|
||||
|
||||
}
|
||||
|
||||
@ -57,7 +59,7 @@ QString LetrasLyricsProvider::StringFixup(const QString &text) {
|
||||
.replace(regex_illegal_characters, QStringLiteral("_"))
|
||||
.replace(regex_multiple_whitespaces, QStringLiteral(" "))
|
||||
.simplified()
|
||||
.replace(QLatin1Char(' '), QLatin1Char('-'))
|
||||
.replace(u' ', u'-')
|
||||
.toLower()
|
||||
));
|
||||
|
||||
|
@ -38,6 +38,8 @@
|
||||
#include "lyricssearchresult.h"
|
||||
#include "lololyricsprovider.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kUrlSearch[] = "http://api.lololyrics.com/0.5/getLyric";
|
||||
}
|
||||
@ -104,15 +106,15 @@ void LoloLyricsProvider::HandleSearchReply(QNetworkReply *reply, const int id, c
|
||||
QXmlStreamReader::TokenType type = reader.readNext();
|
||||
QString name = reader.name().toString();
|
||||
if (type == QXmlStreamReader::StartElement) {
|
||||
if (name == QLatin1String("result")) {
|
||||
if (name == "result"_L1) {
|
||||
status.clear();
|
||||
result = LyricsSearchResult();
|
||||
}
|
||||
else if (name == QLatin1String("status")) {
|
||||
else if (name == "status"_L1) {
|
||||
status = reader.readElementText();
|
||||
}
|
||||
else if (name == QLatin1String("response")) {
|
||||
if (status == QLatin1String("OK")) {
|
||||
else if (name == "response"_L1) {
|
||||
if (status == "OK"_L1) {
|
||||
result.lyrics = reader.readElementText();
|
||||
}
|
||||
else {
|
||||
@ -122,7 +124,7 @@ void LoloLyricsProvider::HandleSearchReply(QNetworkReply *reply, const int id, c
|
||||
}
|
||||
}
|
||||
else if (type == QXmlStreamReader::EndElement) {
|
||||
if (name == QLatin1String("result")) {
|
||||
if (name == "result"_L1) {
|
||||
if (!result.lyrics.isEmpty()) {
|
||||
result.lyrics = Utilities::DecodeHtmlEntities(result.lyrics);
|
||||
results << result;
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include "utilities/transliterate.h"
|
||||
#include "lyricfindlyricsprovider.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kUrl[] = "https://lyrics.lyricfind.com/lyrics";
|
||||
constexpr char kLyricsStart[] = "<script id=\"__NEXT_DATA__\" type=\"application/json\">";
|
||||
@ -73,7 +75,7 @@ QString LyricFindLyricsProvider::StringFixup(const QString &text) {
|
||||
.remove(regex_illegal_characters)
|
||||
.replace(regex_multiple_whitespaces, QStringLiteral(" "))
|
||||
.simplified()
|
||||
.replace(QLatin1Char(' '), QLatin1Char('-'))
|
||||
.replace(u' ', u'-')
|
||||
.toLower();
|
||||
|
||||
}
|
||||
@ -151,48 +153,48 @@ void LyricFindLyricsProvider::HandleSearchReply(QNetworkReply *reply, const int
|
||||
if (obj.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!obj.contains(QLatin1String("props")) || !obj[QLatin1String("props")].isObject()) {
|
||||
if (!obj.contains("props"_L1) || !obj["props"_L1].isObject()) {
|
||||
Error(QStringLiteral("Missing props."));
|
||||
return;
|
||||
}
|
||||
obj = obj[QLatin1String("props")].toObject();
|
||||
if (!obj.contains(QLatin1String("pageProps")) || !obj[QLatin1String("pageProps")].isObject()) {
|
||||
obj = obj["props"_L1].toObject();
|
||||
if (!obj.contains("pageProps"_L1) || !obj["pageProps"_L1].isObject()) {
|
||||
Error(QStringLiteral("Missing pageProps."));
|
||||
return;
|
||||
}
|
||||
obj = obj[QLatin1String("pageProps")].toObject();
|
||||
if (!obj.contains(QLatin1String("songData")) || !obj[QLatin1String("songData")].isObject()) {
|
||||
obj = obj["pageProps"_L1].toObject();
|
||||
if (!obj.contains("songData"_L1) || !obj["songData"_L1].isObject()) {
|
||||
Error(QStringLiteral("Missing songData."));
|
||||
return;
|
||||
}
|
||||
obj = obj[QLatin1String("songData")].toObject();
|
||||
obj = obj["songData"_L1].toObject();
|
||||
|
||||
if (!obj.contains(QLatin1String("response")) || !obj[QLatin1String("response")].isObject()) {
|
||||
if (!obj.contains("response"_L1) || !obj["response"_L1].isObject()) {
|
||||
Error(QStringLiteral("Missing response."));
|
||||
return;
|
||||
}
|
||||
//const QJsonObject obj_response = obj[QLatin1String("response")].toObject();
|
||||
|
||||
if (!obj.contains(QLatin1String("track")) || !obj[QLatin1String("track")].isObject()) {
|
||||
if (!obj.contains("track"_L1) || !obj["track"_L1].isObject()) {
|
||||
Error(QStringLiteral("Missing track."));
|
||||
return;
|
||||
}
|
||||
const QJsonObject obj_track = obj[QLatin1String("track")].toObject();
|
||||
const QJsonObject obj_track = obj["track"_L1].toObject();
|
||||
|
||||
if (!obj_track.contains(QLatin1String("title")) ||
|
||||
!obj_track.contains(QLatin1String("lyrics"))) {
|
||||
if (!obj_track.contains("title"_L1) ||
|
||||
!obj_track.contains("lyrics"_L1)) {
|
||||
Error(QStringLiteral("Missing title or lyrics."));
|
||||
return;
|
||||
}
|
||||
|
||||
LyricsSearchResult result;
|
||||
|
||||
const QJsonObject obj_artist = obj[QLatin1String("artist")].toObject();
|
||||
if (obj_artist.contains(QLatin1String("name"))) {
|
||||
result.artist = obj_artist[QLatin1String("name")].toString();
|
||||
const QJsonObject obj_artist = obj["artist"_L1].toObject();
|
||||
if (obj_artist.contains("name"_L1)) {
|
||||
result.artist = obj_artist["name"_L1].toString();
|
||||
}
|
||||
result.title = obj_track[QLatin1String("title")].toString();
|
||||
result.lyrics = obj_track[QLatin1String("lyrics")].toString();
|
||||
result.title = obj_track["title"_L1].toString();
|
||||
result.lyrics = obj_track["lyrics"_L1].toString();
|
||||
results << result;
|
||||
|
||||
}
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include "lyricsprovider.h"
|
||||
#include "lyricsproviders.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr int kSearchTimeoutMs = 3000;
|
||||
constexpr int kGoodLyricsLength = 60;
|
||||
@ -62,7 +64,7 @@ void LyricsFetcherSearch::TerminateSearch() {
|
||||
void LyricsFetcherSearch::Start(SharedPtr<LyricsProviders> lyrics_providers) {
|
||||
|
||||
// Ignore Radio Paradise "commercial" break.
|
||||
if (request_.artist.compare(QLatin1String("commercial-free"), Qt::CaseInsensitive) == 0 && request_.title.compare(QLatin1String("listener-supported"), Qt::CaseInsensitive) == 0) {
|
||||
if (request_.artist.compare("commercial-free"_L1, Qt::CaseInsensitive) == 0 && request_.title.compare("listener-supported"_L1, Qt::CaseInsensitive) == 0) {
|
||||
TerminateSearch();
|
||||
return;
|
||||
}
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "musixmatchlyricsprovider.h"
|
||||
#include "providers/musixmatchprovider.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
using std::make_shared;
|
||||
|
||||
MusixmatchLyricsProvider::MusixmatchLyricsProvider(SharedPtr<NetworkAccessManager> network, QObject *parent) : JsonLyricsProvider(QStringLiteral("Musixmatch"), true, false, network, parent), use_api_(true) {}
|
||||
@ -140,31 +141,31 @@ void MusixmatchLyricsProvider::HandleSearchReply(QNetworkReply *reply, LyricsSea
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains(QLatin1String("message"))) {
|
||||
if (!json_obj.contains("message"_L1)) {
|
||||
Error(QStringLiteral("Json reply is missing message object."), json_obj);
|
||||
EndSearch(search);
|
||||
return;
|
||||
}
|
||||
if (!json_obj[QLatin1String("message")].isObject()) {
|
||||
if (!json_obj["message"_L1].isObject()) {
|
||||
Error(QStringLiteral("Json reply message is not an object."), json_obj);
|
||||
EndSearch(search);
|
||||
return;
|
||||
}
|
||||
QJsonObject obj_message = json_obj[QLatin1String("message")].toObject();
|
||||
QJsonObject obj_message = json_obj["message"_L1].toObject();
|
||||
|
||||
if (!obj_message.contains(QLatin1String("header"))) {
|
||||
if (!obj_message.contains("header"_L1)) {
|
||||
Error(QStringLiteral("Json reply message object is missing header."), obj_message);
|
||||
EndSearch(search);
|
||||
return;
|
||||
}
|
||||
if (!obj_message[QLatin1String("header")].isObject()) {
|
||||
if (!obj_message["header"_L1].isObject()) {
|
||||
Error(QStringLiteral("Json reply message header is not an object."), obj_message);
|
||||
EndSearch(search);
|
||||
return;
|
||||
}
|
||||
QJsonObject obj_header = obj_message[QLatin1String("header")].toObject();
|
||||
QJsonObject obj_header = obj_message["header"_L1].toObject();
|
||||
|
||||
int status_code = obj_header[QLatin1String("status_code")].toInt();
|
||||
int status_code = obj_header["status_code"_L1].toInt();
|
||||
if (status_code != 200) {
|
||||
Error(QStringLiteral("Received status code %1, switching to URL based lookup.").arg(status_code));
|
||||
use_api_ = false;
|
||||
@ -172,29 +173,29 @@ void MusixmatchLyricsProvider::HandleSearchReply(QNetworkReply *reply, LyricsSea
|
||||
return;
|
||||
}
|
||||
|
||||
if (!obj_message.contains(QLatin1String("body"))) {
|
||||
if (!obj_message.contains("body"_L1)) {
|
||||
Error(QStringLiteral("Json reply is missing body."), json_obj);
|
||||
EndSearch(search);
|
||||
return;
|
||||
}
|
||||
if (!obj_message[QLatin1String("body")].isObject()) {
|
||||
if (!obj_message["body"_L1].isObject()) {
|
||||
Error(QStringLiteral("Json body is not an object."), json_obj);
|
||||
EndSearch(search);
|
||||
return;
|
||||
}
|
||||
QJsonObject obj_body = obj_message[QLatin1String("body")].toObject();
|
||||
QJsonObject obj_body = obj_message["body"_L1].toObject();
|
||||
|
||||
if (!obj_body.contains(QLatin1String("track_list"))) {
|
||||
if (!obj_body.contains("track_list"_L1)) {
|
||||
Error(QStringLiteral("Json response is missing body."), obj_body);
|
||||
EndSearch(search);
|
||||
return;
|
||||
}
|
||||
if (!obj_body[QLatin1String("track_list")].isArray()) {
|
||||
if (!obj_body["track_list"_L1].isArray()) {
|
||||
Error(QStringLiteral("Json hits is not an array."), obj_body);
|
||||
EndSearch(search);
|
||||
return;
|
||||
}
|
||||
const QJsonArray array_tracklist = obj_body[QLatin1String("track_list")].toArray();
|
||||
const QJsonArray array_tracklist = obj_body["track_list"_L1].toArray();
|
||||
|
||||
for (const QJsonValue &value_track : array_tracklist) {
|
||||
if (!value_track.isObject()) {
|
||||
@ -202,23 +203,23 @@ void MusixmatchLyricsProvider::HandleSearchReply(QNetworkReply *reply, LyricsSea
|
||||
}
|
||||
QJsonObject obj_track = value_track.toObject();
|
||||
|
||||
if (!obj_track.contains(QLatin1String("track")) || !obj_track[QLatin1String("track")].isObject()) {
|
||||
if (!obj_track.contains("track"_L1) || !obj_track["track"_L1].isObject()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
obj_track = obj_track[QLatin1String("track")].toObject();
|
||||
if (!obj_track.contains(QLatin1String("artist_name")) ||
|
||||
!obj_track.contains(QLatin1String("album_name")) ||
|
||||
!obj_track.contains(QLatin1String("track_name")) ||
|
||||
!obj_track.contains(QLatin1String("track_share_url"))) {
|
||||
obj_track = obj_track["track"_L1].toObject();
|
||||
if (!obj_track.contains("artist_name"_L1) ||
|
||||
!obj_track.contains("album_name"_L1) ||
|
||||
!obj_track.contains("track_name"_L1) ||
|
||||
!obj_track.contains("track_share_url"_L1)) {
|
||||
Error(QStringLiteral("Missing one or more values in result object"), obj_track);
|
||||
continue;
|
||||
}
|
||||
|
||||
QString artist_name = obj_track[QLatin1String("artist_name")].toString();
|
||||
QString album_name = obj_track[QLatin1String("album_name")].toString();
|
||||
QString track_name = obj_track[QLatin1String("track_name")].toString();
|
||||
QUrl track_share_url(obj_track[QLatin1String("track_share_url")].toString());
|
||||
QString artist_name = obj_track["artist_name"_L1].toString();
|
||||
QString album_name = obj_track["album_name"_L1].toString();
|
||||
QString track_name = obj_track["track_name"_L1].toString();
|
||||
QUrl track_share_url(obj_track["track_share_url"_L1].toString());
|
||||
|
||||
// Ignore results where both the artist, album and title don't match.
|
||||
if (use_api_ &&
|
||||
@ -304,8 +305,8 @@ void MusixmatchLyricsProvider::HandleLyricsReply(QNetworkReply *reply, LyricsSea
|
||||
}
|
||||
|
||||
const QString content = QString::fromUtf8(data);
|
||||
const QString data_begin = QLatin1String("<script id=\"__NEXT_DATA__\" type=\"application/json\">");
|
||||
const QString data_end = QLatin1String("</script>");
|
||||
const QString data_begin = "<script id=\"__NEXT_DATA__\" type=\"application/json\">"_L1;
|
||||
const QString data_end = "</script>"_L1;
|
||||
qint64 begin_idx = content.indexOf(data_begin);
|
||||
QString content_json;
|
||||
if (begin_idx > 0) {
|
||||
@ -333,86 +334,86 @@ void MusixmatchLyricsProvider::HandleLyricsReply(QNetworkReply *reply, LyricsSea
|
||||
return;
|
||||
}
|
||||
|
||||
if (!obj_data.contains(QLatin1String("props")) || !obj_data[QLatin1String("props")].isObject()) {
|
||||
if (!obj_data.contains("props"_L1) || !obj_data["props"_L1].isObject()) {
|
||||
Error(QStringLiteral("Json reply is missing props."), obj_data);
|
||||
EndSearch(search, url);
|
||||
return;
|
||||
}
|
||||
obj_data = obj_data[QLatin1String("props")].toObject();
|
||||
obj_data = obj_data["props"_L1].toObject();
|
||||
|
||||
if (!obj_data.contains(QLatin1String("pageProps")) || !obj_data[QLatin1String("pageProps")].isObject()) {
|
||||
if (!obj_data.contains("pageProps"_L1) || !obj_data["pageProps"_L1].isObject()) {
|
||||
Error(QStringLiteral("Json props is missing pageProps."), obj_data);
|
||||
EndSearch(search, url);
|
||||
return;
|
||||
}
|
||||
obj_data = obj_data[QLatin1String("pageProps")].toObject();
|
||||
obj_data = obj_data["pageProps"_L1].toObject();
|
||||
|
||||
if (!obj_data.contains(QLatin1String("data")) || !obj_data[QLatin1String("data")].isObject()) {
|
||||
if (!obj_data.contains("data"_L1) || !obj_data["data"_L1].isObject()) {
|
||||
Error(QStringLiteral("Json pageProps is missing data."), obj_data);
|
||||
EndSearch(search, url);
|
||||
return;
|
||||
}
|
||||
obj_data = obj_data[QLatin1String("data")].toObject();
|
||||
obj_data = obj_data["data"_L1].toObject();
|
||||
|
||||
|
||||
if (!obj_data.contains(QLatin1String("trackInfo")) || !obj_data[QLatin1String("trackInfo")].isObject()) {
|
||||
if (!obj_data.contains("trackInfo"_L1) || !obj_data["trackInfo"_L1].isObject()) {
|
||||
Error(QStringLiteral("Json data is missing trackInfo."), obj_data);
|
||||
EndSearch(search, url);
|
||||
return;
|
||||
}
|
||||
obj_data = obj_data[QLatin1String("trackInfo")].toObject();
|
||||
obj_data = obj_data["trackInfo"_L1].toObject();
|
||||
|
||||
if (!obj_data.contains(QLatin1String("data")) || !obj_data[QLatin1String("data")].isObject()) {
|
||||
if (!obj_data.contains("data"_L1) || !obj_data["data"_L1].isObject()) {
|
||||
Error(QStringLiteral("Json trackInfo reply is missing data."), obj_data);
|
||||
EndSearch(search, url);
|
||||
return;
|
||||
}
|
||||
obj_data = obj_data[QLatin1String("data")].toObject();
|
||||
obj_data = obj_data["data"_L1].toObject();
|
||||
|
||||
if (!obj_data.contains(QLatin1String("track")) || !obj_data[QLatin1String("track")].isObject()) {
|
||||
if (!obj_data.contains("track"_L1) || !obj_data["track"_L1].isObject()) {
|
||||
Error(QStringLiteral("Json data is missing track."), obj_data);
|
||||
EndSearch(search, url);
|
||||
return;
|
||||
}
|
||||
|
||||
const QJsonObject obj_track = obj_data[QLatin1String("track")].toObject();
|
||||
const QJsonObject obj_track = obj_data["track"_L1].toObject();
|
||||
|
||||
if (!obj_track.contains(QLatin1String("hasLyrics")) || !obj_track[QLatin1String("hasLyrics")].isBool()) {
|
||||
if (!obj_track.contains("hasLyrics"_L1) || !obj_track["hasLyrics"_L1].isBool()) {
|
||||
Error(QStringLiteral("Json track is missing hasLyrics."), obj_track);
|
||||
EndSearch(search, url);
|
||||
return;
|
||||
}
|
||||
|
||||
const bool has_lyrics = obj_track[QLatin1String("hasLyrics")].toBool();
|
||||
const bool has_lyrics = obj_track["hasLyrics"_L1].toBool();
|
||||
if (!has_lyrics) {
|
||||
EndSearch(search, url);
|
||||
return;
|
||||
}
|
||||
|
||||
LyricsSearchResult result;
|
||||
if (obj_track.contains(QLatin1String("artistName")) && obj_track[QLatin1String("artistName")].isString()) {
|
||||
result.artist = obj_track[QLatin1String("artistName")].toString();
|
||||
if (obj_track.contains("artistName"_L1) && obj_track["artistName"_L1].isString()) {
|
||||
result.artist = obj_track["artistName"_L1].toString();
|
||||
}
|
||||
if (obj_track.contains(QLatin1String("albumName")) && obj_track[QLatin1String("albumName")].isString()) {
|
||||
result.album = obj_track[QLatin1String("albumName")].toString();
|
||||
if (obj_track.contains("albumName"_L1) && obj_track["albumName"_L1].isString()) {
|
||||
result.album = obj_track["albumName"_L1].toString();
|
||||
}
|
||||
if (obj_track.contains(QLatin1String("name")) && obj_track[QLatin1String("name")].isString()) {
|
||||
result.title = obj_track[QLatin1String("name")].toString();
|
||||
if (obj_track.contains("name"_L1) && obj_track["name"_L1].isString()) {
|
||||
result.title = obj_track["name"_L1].toString();
|
||||
}
|
||||
|
||||
if (!obj_data.contains(QLatin1String("lyrics")) || !obj_data[QLatin1String("lyrics")].isObject()) {
|
||||
if (!obj_data.contains("lyrics"_L1) || !obj_data["lyrics"_L1].isObject()) {
|
||||
Error(QStringLiteral("Json data is missing lyrics."), obj_data);
|
||||
EndSearch(search, url);
|
||||
return;
|
||||
}
|
||||
QJsonObject obj_lyrics = obj_data[QLatin1String("lyrics")].toObject();
|
||||
QJsonObject obj_lyrics = obj_data["lyrics"_L1].toObject();
|
||||
|
||||
if (!obj_lyrics.contains(QLatin1String("body")) || !obj_lyrics[QLatin1String("body")].isString()) {
|
||||
if (!obj_lyrics.contains("body"_L1) || !obj_lyrics["body"_L1].isString()) {
|
||||
Error(QStringLiteral("Json lyrics reply is missing body."), obj_lyrics);
|
||||
EndSearch(search, url);
|
||||
return;
|
||||
}
|
||||
result.lyrics = obj_lyrics[QLatin1String("body")].toString();
|
||||
result.lyrics = obj_lyrics["body"_L1].toString();
|
||||
|
||||
if (!result.lyrics.isEmpty()) {
|
||||
result.lyrics = Utilities::DecodeHtmlEntities(result.lyrics);
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include "jsonlyricsprovider.h"
|
||||
#include "ovhlyricsprovider.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kUrlSearch[] = "https://api.lyrics.ovh/v1/";
|
||||
}
|
||||
@ -80,20 +82,20 @@ void OVHLyricsProvider::HandleSearchReply(QNetworkReply *reply, const int id, co
|
||||
return;
|
||||
}
|
||||
|
||||
if (json_obj.contains(QLatin1String("error"))) {
|
||||
Error(json_obj[QLatin1String("error")].toString());
|
||||
if (json_obj.contains("error"_L1)) {
|
||||
Error(json_obj["error"_L1].toString());
|
||||
qLog(Debug) << "OVHLyrics: No lyrics for" << request.artist << request.title;
|
||||
Q_EMIT SearchFinished(id);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains(QLatin1String("lyrics"))) {
|
||||
if (!json_obj.contains("lyrics"_L1)) {
|
||||
Q_EMIT SearchFinished(id);
|
||||
return;
|
||||
}
|
||||
|
||||
LyricsSearchResult result;
|
||||
result.lyrics = json_obj[QLatin1String("lyrics")].toString();
|
||||
result.lyrics = json_obj["lyrics"_L1].toString();
|
||||
|
||||
if (result.lyrics.isEmpty()) {
|
||||
qLog(Debug) << "OVHLyrics: No lyrics for" << request.artist << request.title;
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include "lyricssearchrequest.h"
|
||||
#include "songlyricscomlyricsprovider.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kUrl[] = "https://www.songlyrics.com/";
|
||||
constexpr char kStartTag[] = "<p[^>]*>";
|
||||
@ -40,7 +42,7 @@ SongLyricsComLyricsProvider::SongLyricsComLyricsProvider(SharedPtr<NetworkAccess
|
||||
|
||||
QUrl SongLyricsComLyricsProvider::Url(const LyricsSearchRequest &request) {
|
||||
|
||||
return QUrl(QLatin1String(kUrl) + StringFixup(request.artist) + QLatin1Char('/') + StringFixup(request.title) + QLatin1String("-lyrics/"));
|
||||
return QUrl(QLatin1String(kUrl) + StringFixup(request.artist) + QLatin1Char('/') + StringFixup(request.title) + "-lyrics/"_L1);
|
||||
|
||||
}
|
||||
|
||||
@ -52,12 +54,12 @@ QString SongLyricsComLyricsProvider::StringFixup(QString text) {
|
||||
static const QRegularExpression regex_multiple_whitespaces(QStringLiteral(" {2,}"));
|
||||
static const QRegularExpression regex_multiple_dashes(QStringLiteral("(-)\\1+"));
|
||||
|
||||
return text.replace(QLatin1Char('/'), QLatin1Char('-'))
|
||||
.replace(QLatin1Char('\''), QLatin1Char('-'))
|
||||
return text.replace(u'/', u'-')
|
||||
.replace(u'\'', u'-')
|
||||
.remove(regex_illegal_characters)
|
||||
.replace(regex_multiple_whitespaces, QStringLiteral(" "))
|
||||
.simplified()
|
||||
.replace(QLatin1Char(' '), QLatin1Char('-'))
|
||||
.replace(u' ', u'-')
|
||||
.replace(regex_multiple_dashes, QStringLiteral("-"))
|
||||
.toLower();
|
||||
|
||||
|
@ -112,6 +112,7 @@
|
||||
# include "osd/osdbase.h"
|
||||
#endif
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
using std::make_shared;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
@ -212,11 +213,11 @@ int main(int argc, char *argv[]) {
|
||||
s.beginGroup(AppearanceSettingsPage::kSettingsGroup);
|
||||
QString style = s.value(AppearanceSettingsPage::kStyle).toString();
|
||||
if (style.isEmpty()) {
|
||||
style = QLatin1String("default");
|
||||
style = "default"_L1;
|
||||
s.setValue(AppearanceSettingsPage::kStyle, style);
|
||||
}
|
||||
s.endGroup();
|
||||
if (style != QLatin1String("default")) {
|
||||
if (style != "default"_L1) {
|
||||
QApplication::setStyle(style);
|
||||
}
|
||||
if (QApplication::style()) qLog(Debug) << "Style:" << QApplication::style()->objectName();
|
||||
@ -258,7 +259,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
QString system_language = QLocale::system().uiLanguages().empty() ? QLocale::system().name() : QLocale::system().uiLanguages().first();
|
||||
// uiLanguages returns strings with "-" as separators for language/region; however QTranslator needs "_" separators
|
||||
system_language.replace(QLatin1Char('-'), QLatin1Char('_'));
|
||||
system_language.replace(u'-', u'_');
|
||||
|
||||
const QString language = override_language.isEmpty() ? system_language : override_language;
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
#include "ext/gstmoodbar/gstfastspectrum.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
using std::make_unique;
|
||||
|
||||
namespace {
|
||||
@ -73,7 +74,7 @@ GstElement *MoodbarPipeline::CreateElement(const QString &factory_name) {
|
||||
QByteArray MoodbarPipeline::ToGstUrl(const QUrl &url) {
|
||||
|
||||
if (url.isLocalFile() && !url.host().isEmpty()) {
|
||||
QString str = QLatin1String("file:////") + url.host() + url.path();
|
||||
QString str = "file:////"_L1 + url.host() + url.path();
|
||||
return str.toUtf8();
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,8 @@
|
||||
|
||||
#include "acoustidclient.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kClientId[] = "0qjUoxbowg";
|
||||
constexpr char kUrl[] = "https://api.acoustid.org/v2/lookup";
|
||||
@ -151,8 +153,8 @@ void AcoustidClient::RequestFinished(QNetworkReply *reply, const int request_id)
|
||||
|
||||
QJsonObject json_object = json_document.object();
|
||||
|
||||
QString status = json_object[QLatin1String("status")].toString();
|
||||
if (status != QLatin1String("ok")) {
|
||||
QString status = json_object["status"_L1].toString();
|
||||
if (status != "ok"_L1) {
|
||||
Q_EMIT Finished(request_id, QStringList(), status);
|
||||
return;
|
||||
}
|
||||
@ -162,19 +164,19 @@ void AcoustidClient::RequestFinished(QNetworkReply *reply, const int request_id)
|
||||
// -then sort results by number of sources (the results are originally
|
||||
// unsorted but results with more sources are likely to be more accurate)
|
||||
// -keep only the ids, as sources where useful only to sort the results
|
||||
const QJsonArray json_results = json_object[QLatin1String("results")].toArray();
|
||||
const QJsonArray json_results = json_object["results"_L1].toArray();
|
||||
|
||||
// List of <id, nb of sources> pairs
|
||||
QList<IdSource> id_source_list;
|
||||
|
||||
for (const QJsonValue &v : json_results) {
|
||||
QJsonObject r = v.toObject();
|
||||
if (!r[QLatin1String("recordings")].isUndefined()) {
|
||||
const QJsonArray json_recordings = r[QLatin1String("recordings")].toArray();
|
||||
if (!r["recordings"_L1].isUndefined()) {
|
||||
const QJsonArray json_recordings = r["recordings"_L1].toArray();
|
||||
for (const QJsonValue &recording : json_recordings) {
|
||||
QJsonObject o = recording.toObject();
|
||||
if (!o[QLatin1String("id")].isUndefined()) {
|
||||
id_source_list << IdSource(o[QLatin1String("id")].toString(), o[QLatin1String("sources")].toInt());
|
||||
if (!o["id"_L1].isUndefined()) {
|
||||
id_source_list << IdSource(o["id"_L1].toString(), o["sources"_L1].toInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,8 @@
|
||||
#include "utilities/xmlutils.h"
|
||||
#include "musicbrainzclient.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
constexpr char kTrackUrl[] = "https://musicbrainz.org/ws/2/recording/";
|
||||
constexpr char kDiscUrl[] = "https://musicbrainz.org/ws/2/discid/";
|
||||
@ -96,8 +98,8 @@ QByteArray MusicBrainzClient::GetReplyData(QNetworkReply *reply, QString &error)
|
||||
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
|
||||
if (json_error.error == QJsonParseError::NoError && json_doc.isObject()) {
|
||||
QJsonObject json_obj = json_doc.object();
|
||||
if (!json_obj.isEmpty() && json_obj.contains(QLatin1String("error"))) {
|
||||
error = json_obj[QLatin1String("error")].toString();
|
||||
if (!json_obj.isEmpty() && json_obj.contains("error"_L1)) {
|
||||
error = json_obj["error"_L1].toString();
|
||||
}
|
||||
}
|
||||
if (error.isEmpty()) {
|
||||
@ -213,7 +215,7 @@ void MusicBrainzClient::RequestFinished(QNetworkReply *reply, const int id, cons
|
||||
QXmlStreamReader reader(data);
|
||||
ResultList res;
|
||||
while (!reader.atEnd()) {
|
||||
if (reader.readNext() == QXmlStreamReader::StartElement && reader.name().toString() == QLatin1String("recording")) {
|
||||
if (reader.readNext() == QXmlStreamReader::StartElement && reader.name().toString() == "recording"_L1) {
|
||||
const ResultList tracks = ParseTrack(&reader);
|
||||
for (const Result &track : tracks) {
|
||||
if (!track.title_.isEmpty()) {
|
||||
@ -268,20 +270,20 @@ void MusicBrainzClient::DiscIdRequestFinished(const QString &discid, QNetworkRep
|
||||
QXmlStreamReader::TokenType type = reader.readNext();
|
||||
if (type == QXmlStreamReader::StartElement) {
|
||||
QString name = reader.name().toString();
|
||||
if (name == QLatin1String("title")) {
|
||||
if (name == "title"_L1) {
|
||||
album = reader.readElementText();
|
||||
}
|
||||
else if (name == QLatin1String("date")) {
|
||||
else if (name == "date"_L1) {
|
||||
QRegularExpression regex(QString::fromLatin1(kDateRegex));
|
||||
QRegularExpressionMatch re_match = regex.match(reader.readElementText());
|
||||
if (re_match.capturedStart() == 0) {
|
||||
year = re_match.captured(0).toInt();
|
||||
}
|
||||
}
|
||||
else if (name == QLatin1String("artist-credit")) {
|
||||
else if (name == "artist-credit"_L1) {
|
||||
ParseArtist(&reader, &artist);
|
||||
}
|
||||
else if (name == QLatin1String("medium-list")) {
|
||||
else if (name == "medium-list"_L1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -290,7 +292,7 @@ void MusicBrainzClient::DiscIdRequestFinished(const QString &discid, QNetworkRep
|
||||
while (!reader.atEnd()) {
|
||||
QXmlStreamReader::TokenType token = reader.readNext();
|
||||
QString name = reader.name().toString();
|
||||
if (token == QXmlStreamReader::StartElement && name == QLatin1String("medium")) {
|
||||
if (token == QXmlStreamReader::StartElement && name == "medium"_L1) {
|
||||
// Get the medium with a matching discid.
|
||||
if (MediumHasDiscid(discid, &reader)) {
|
||||
const ResultList tracks = ParseMedium(&reader);
|
||||
@ -304,7 +306,7 @@ void MusicBrainzClient::DiscIdRequestFinished(const QString &discid, QNetworkRep
|
||||
Utilities::ConsumeCurrentElement(&reader);
|
||||
}
|
||||
}
|
||||
else if (token == QXmlStreamReader::EndElement && name == QLatin1String("medium-list")) {
|
||||
else if (token == QXmlStreamReader::EndElement && name == "medium-list"_L1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -326,10 +328,10 @@ bool MusicBrainzClient::MediumHasDiscid(const QString &discid, QXmlStreamReader
|
||||
QXmlStreamReader::TokenType type = reader->readNext();
|
||||
QString name = reader->name().toString();
|
||||
|
||||
if (type == QXmlStreamReader::StartElement && name == QLatin1String("disc") && reader->attributes().value(QLatin1String("id")).toString() == discid) {
|
||||
if (type == QXmlStreamReader::StartElement && name == "disc"_L1 && reader->attributes().value("id"_L1).toString() == discid) {
|
||||
return true;
|
||||
}
|
||||
if (type == QXmlStreamReader::EndElement && name == QLatin1String("disc-list")) {
|
||||
if (type == QXmlStreamReader::EndElement && name == "disc-list"_L1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -346,14 +348,14 @@ MusicBrainzClient::ResultList MusicBrainzClient::ParseMedium(QXmlStreamReader *r
|
||||
QString name = reader->name().toString();
|
||||
|
||||
if (type == QXmlStreamReader::StartElement) {
|
||||
if (name == QLatin1String("track")) {
|
||||
if (name == "track"_L1) {
|
||||
Result result;
|
||||
result = ParseTrackFromDisc(reader);
|
||||
ret << result;
|
||||
}
|
||||
}
|
||||
|
||||
if (type == QXmlStreamReader::EndElement && name == QLatin1String("track-list")) {
|
||||
if (type == QXmlStreamReader::EndElement && name == "track-list"_L1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -371,18 +373,18 @@ MusicBrainzClient::Result MusicBrainzClient::ParseTrackFromDisc(QXmlStreamReader
|
||||
QString name = reader->name().toString();
|
||||
|
||||
if (type == QXmlStreamReader::StartElement) {
|
||||
if (name == QLatin1String("position")) {
|
||||
if (name == "position"_L1) {
|
||||
result.track_ = reader->readElementText().toInt();
|
||||
}
|
||||
else if (name == QLatin1String("length")) {
|
||||
else if (name == "length"_L1) {
|
||||
result.duration_msec_ = reader->readElementText().toInt();
|
||||
}
|
||||
else if (name == QLatin1String("title")) {
|
||||
else if (name == "title"_L1) {
|
||||
result.title_ = reader->readElementText();
|
||||
}
|
||||
}
|
||||
|
||||
if (type == QXmlStreamReader::EndElement && name == QLatin1String("track")) {
|
||||
if (type == QXmlStreamReader::EndElement && name == "track"_L1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -402,21 +404,21 @@ MusicBrainzClient::ResultList MusicBrainzClient::ParseTrack(QXmlStreamReader *re
|
||||
|
||||
if (type == QXmlStreamReader::StartElement) {
|
||||
|
||||
if (name == QLatin1String("title")) {
|
||||
if (name == "title"_L1) {
|
||||
result.title_ = reader->readElementText();
|
||||
}
|
||||
else if (name == QLatin1String("length")) {
|
||||
else if (name == "length"_L1) {
|
||||
result.duration_msec_ = reader->readElementText().toInt();
|
||||
}
|
||||
else if (name == QLatin1String("artist-credit")) {
|
||||
else if (name == "artist-credit"_L1) {
|
||||
ParseArtist(reader, &result.artist_);
|
||||
}
|
||||
else if (name == QLatin1String("release")) {
|
||||
else if (name == "release"_L1) {
|
||||
releases << ParseRelease(reader);
|
||||
}
|
||||
}
|
||||
|
||||
if (type == QXmlStreamReader::EndElement && name == QLatin1String("recording")) {
|
||||
if (type == QXmlStreamReader::EndElement && name == "recording"_L1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -445,15 +447,15 @@ void MusicBrainzClient::ParseArtist(QXmlStreamReader *reader, QString *artist) {
|
||||
while (!reader->atEnd()) {
|
||||
QXmlStreamReader::TokenType type = reader->readNext();
|
||||
QString name = reader->name().toString();
|
||||
if (type == QXmlStreamReader::StartElement && name == QLatin1String("name-credit")) {
|
||||
join_phrase = reader->attributes().value(QLatin1String("joinphrase")).toString();
|
||||
if (type == QXmlStreamReader::StartElement && name == "name-credit"_L1) {
|
||||
join_phrase = reader->attributes().value("joinphrase"_L1).toString();
|
||||
}
|
||||
|
||||
if (type == QXmlStreamReader::StartElement && name == QLatin1String("name")) {
|
||||
if (type == QXmlStreamReader::StartElement && name == "name"_L1) {
|
||||
*artist += reader->readElementText() + join_phrase;
|
||||
}
|
||||
|
||||
if (type == QXmlStreamReader::EndElement && name == QLatin1String("artist-credit")) {
|
||||
if (type == QXmlStreamReader::EndElement && name == "artist-credit"_L1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -468,26 +470,26 @@ MusicBrainzClient::Release MusicBrainzClient::ParseRelease(QXmlStreamReader *rea
|
||||
QString name = reader->name().toString();
|
||||
|
||||
if (type == QXmlStreamReader::StartElement) {
|
||||
if (name == QLatin1String("title")) {
|
||||
if (name == "title"_L1) {
|
||||
ret.album_ = reader->readElementText();
|
||||
}
|
||||
else if (name == QLatin1String("status")) {
|
||||
else if (name == "status"_L1) {
|
||||
ret.SetStatusFromString(reader->readElementText());
|
||||
}
|
||||
else if (name == QLatin1String("date")) {
|
||||
else if (name == "date"_L1) {
|
||||
QRegularExpression regex(QString::fromLatin1(kDateRegex));
|
||||
QRegularExpressionMatch re_match = regex.match(reader->readElementText());
|
||||
if (re_match.capturedStart() == 0) {
|
||||
ret.year_ = re_match.captured(0).toInt();
|
||||
}
|
||||
}
|
||||
else if (name == QLatin1String("track-list")) {
|
||||
ret.track_ = reader->attributes().value(QLatin1String("offset")).toString().toInt() + 1;
|
||||
else if (name == "track-list"_L1) {
|
||||
ret.track_ = reader->attributes().value("offset"_L1).toString().toInt() + 1;
|
||||
Utilities::ConsumeCurrentElement(reader);
|
||||
}
|
||||
}
|
||||
|
||||
if (type == QXmlStreamReader::EndElement && name == QLatin1String("release")) {
|
||||
if (type == QXmlStreamReader::EndElement && name == "release"_L1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,8 @@
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
class QNetworkReply;
|
||||
class QTimer;
|
||||
class QXmlStreamReader;
|
||||
@ -152,16 +154,16 @@ class MusicBrainzClient : public QObject {
|
||||
}
|
||||
|
||||
void SetStatusFromString(const QString &s) {
|
||||
if (s.compare(QLatin1String("Official"), Qt::CaseInsensitive) == 0) {
|
||||
if (s.compare("Official"_L1, Qt::CaseInsensitive) == 0) {
|
||||
status_ = Status::Official;
|
||||
}
|
||||
else if (s.compare(QLatin1String("Promotion"), Qt::CaseInsensitive) == 0) {
|
||||
else if (s.compare("Promotion"_L1, Qt::CaseInsensitive) == 0) {
|
||||
status_ = Status::Promotional;
|
||||
}
|
||||
else if (s.compare(QLatin1String("Bootleg"), Qt::CaseInsensitive) == 0) {
|
||||
else if (s.compare("Bootleg"_L1, Qt::CaseInsensitive) == 0) {
|
||||
status_ = Status::Bootleg;
|
||||
}
|
||||
else if (s.compare(QLatin1String("Pseudo-release"), Qt::CaseInsensitive) == 0) {
|
||||
else if (s.compare("Pseudo-release"_L1, Qt::CaseInsensitive) == 0) {
|
||||
status_ = Status::PseudoRelease;
|
||||
}
|
||||
else {
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include "organizeformat.h"
|
||||
#include "organizeformatvalidator.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
const char OrganizeFormat::kBlockPattern[] = "\\{([^{}]+)\\}";
|
||||
const char OrganizeFormat::kTagPattern[] = "\\%([a-zA-Z]*)";
|
||||
|
||||
@ -73,7 +75,7 @@ OrganizeFormat::OrganizeFormat(const QString &format)
|
||||
|
||||
void OrganizeFormat::set_format(const QString &v) {
|
||||
format_ = v;
|
||||
format_.replace(QLatin1Char('\\'), QLatin1Char('/'));
|
||||
format_.replace(u'\\', u'/');
|
||||
}
|
||||
|
||||
bool OrganizeFormat::IsValid() const {
|
||||
@ -104,15 +106,15 @@ OrganizeFormat::GetFilenameForSongResult OrganizeFormat::GetFilenameForSong(cons
|
||||
filepath.clear();
|
||||
if (!path.isEmpty()) {
|
||||
filepath.append(path);
|
||||
if (path.right(1) != QLatin1Char('/')) {
|
||||
filepath.append(QLatin1Char('/'));
|
||||
if (path.right(1) != u'/') {
|
||||
filepath.append(u'/');
|
||||
}
|
||||
}
|
||||
filepath.append(song.basefilename());
|
||||
}
|
||||
}
|
||||
|
||||
if (filepath.isEmpty() || (filepath.contains(QLatin1Char('/')) && (filepath.section(QLatin1Char('/'), 0, -2).isEmpty() || filepath.section(QLatin1Char('/'), 0, -2).isEmpty()))) {
|
||||
if (filepath.isEmpty() || (filepath.contains(u'/') && (filepath.section(u'/', 0, -2).isEmpty() || filepath.section(u'/', 0, -2).isEmpty()))) {
|
||||
return GetFilenameForSongResult();
|
||||
}
|
||||
|
||||
@ -159,14 +161,14 @@ OrganizeFormat::GetFilenameForSongResult OrganizeFormat::GetFilenameForSong(cons
|
||||
extension = info.suffix();
|
||||
}
|
||||
}
|
||||
if (!info.path().isEmpty() && info.path() != QLatin1Char('.')) {
|
||||
if (!info.path().isEmpty() && info.path() != u'.') {
|
||||
filepath.append(info.path());
|
||||
filepath.append(QLatin1Char('/'));
|
||||
filepath.append(u'/');
|
||||
}
|
||||
filepath.append(info.completeBaseName());
|
||||
|
||||
// Fix any parts of the path that start with dots.
|
||||
QStringList parts_old = filepath.split(QLatin1Char('/'));
|
||||
QStringList parts_old = filepath.split(u'/');
|
||||
QStringList parts_new;
|
||||
for (int i = 0; i < parts_old.count(); ++i) {
|
||||
QString part = parts_old[i];
|
||||
@ -179,7 +181,7 @@ OrganizeFormat::GetFilenameForSongResult OrganizeFormat::GetFilenameForSong(cons
|
||||
part = part.trimmed();
|
||||
parts_new.append(part);
|
||||
}
|
||||
filepath = parts_new.join(QLatin1Char('/'));
|
||||
filepath = parts_new.join(u'/');
|
||||
|
||||
if (replace_spaces_) {
|
||||
static const QRegularExpression regex_whitespaces(QStringLiteral("\\s"));
|
||||
@ -205,7 +207,7 @@ QString OrganizeFormat::ParseBlock(QString block, const Song &song, bool *have_t
|
||||
// Recursively parse the block
|
||||
bool empty = false;
|
||||
QString value = ParseBlock(re_match.captured(1), song, have_tagdata, &empty);
|
||||
if (empty) value = QLatin1String("");
|
||||
if (empty) value = ""_L1;
|
||||
|
||||
// Replace the block's value
|
||||
block.replace(pos, re_match.capturedLength(), value);
|
||||
@ -243,61 +245,61 @@ QString OrganizeFormat::TagValue(const QString &tag, const Song &song) const {
|
||||
|
||||
QString value;
|
||||
|
||||
if (tag == QLatin1String("title")) {
|
||||
if (tag == "title"_L1) {
|
||||
value = song.title();
|
||||
}
|
||||
else if (tag == QLatin1String("album")) {
|
||||
else if (tag == "album"_L1) {
|
||||
value = song.album();
|
||||
}
|
||||
else if (tag == QLatin1String("artist")) {
|
||||
else if (tag == "artist"_L1) {
|
||||
value = song.artist();
|
||||
}
|
||||
else if (tag == QLatin1String("composer")) {
|
||||
else if (tag == "composer"_L1) {
|
||||
value = song.composer();
|
||||
}
|
||||
else if (tag == QLatin1String("performer")) {
|
||||
else if (tag == "performer"_L1) {
|
||||
value = song.performer();
|
||||
}
|
||||
else if (tag == QLatin1String("grouping")) {
|
||||
else if (tag == "grouping"_L1) {
|
||||
value = song.grouping();
|
||||
}
|
||||
else if (tag == QLatin1String("lyrics")) {
|
||||
else if (tag == "lyrics"_L1) {
|
||||
value = song.lyrics();
|
||||
}
|
||||
else if (tag == QLatin1String("genre")) {
|
||||
else if (tag == "genre"_L1) {
|
||||
value = song.genre();
|
||||
}
|
||||
else if (tag == QLatin1String("comment")) {
|
||||
else if (tag == "comment"_L1) {
|
||||
value = song.comment();
|
||||
}
|
||||
else if (tag == QLatin1String("year")) {
|
||||
else if (tag == "year"_L1) {
|
||||
value = QString::number(song.year());
|
||||
}
|
||||
else if (tag == QLatin1String("originalyear")) {
|
||||
else if (tag == "originalyear"_L1) {
|
||||
value = QString::number(song.effective_originalyear());
|
||||
}
|
||||
else if (tag == QLatin1String("track")) {
|
||||
else if (tag == "track"_L1) {
|
||||
value = QString::number(song.track());
|
||||
}
|
||||
else if (tag == QLatin1String("disc")) {
|
||||
else if (tag == "disc"_L1) {
|
||||
value = QString::number(song.disc());
|
||||
}
|
||||
else if (tag == QLatin1String("length")) {
|
||||
else if (tag == "length"_L1) {
|
||||
value = QString::number(song.length_nanosec() / kNsecPerSec);
|
||||
}
|
||||
else if (tag == QLatin1String("bitrate")) {
|
||||
else if (tag == "bitrate"_L1) {
|
||||
value = QString::number(song.bitrate());
|
||||
}
|
||||
else if (tag == QLatin1String("samplerate")) {
|
||||
else if (tag == "samplerate"_L1) {
|
||||
value = QString::number(song.samplerate());
|
||||
}
|
||||
else if (tag == QLatin1String("bitdepth")) {
|
||||
else if (tag == "bitdepth"_L1) {
|
||||
value = QString::number(song.bitdepth());
|
||||
}
|
||||
else if (tag == QLatin1String("extension")) {
|
||||
else if (tag == "extension"_L1) {
|
||||
value = QFileInfo(song.url().toLocalFile()).suffix();
|
||||
}
|
||||
else if (tag == QLatin1String("artistinitial")) {
|
||||
else if (tag == "artistinitial"_L1) {
|
||||
value = song.effective_albumartist().trimmed();
|
||||
if (!value.isEmpty()) {
|
||||
static const QRegularExpression regex_the(QStringLiteral("^the\\s+"), QRegularExpression::CaseInsensitiveOption);
|
||||
@ -305,19 +307,19 @@ QString OrganizeFormat::TagValue(const QString &tag, const Song &song) const {
|
||||
value = value[0].toUpper();
|
||||
}
|
||||
}
|
||||
else if (tag == QLatin1String("albumartist")) {
|
||||
else if (tag == "albumartist"_L1) {
|
||||
value = song.is_compilation() ? QStringLiteral("Various Artists") : song.effective_albumartist();
|
||||
}
|
||||
|
||||
if (value == QLatin1Char('0') || value == QLatin1String("-1")) value = QLatin1String("");
|
||||
if (value == u'0' || value == "-1"_L1) value = ""_L1;
|
||||
|
||||
// Prepend a 0 to single-digit track numbers
|
||||
if (tag == QLatin1String("track") && value.length() == 1) value.prepend(QLatin1Char('0'));
|
||||
if (tag == "track"_L1 && value.length() == 1) value.prepend(u'0');
|
||||
|
||||
// Replace characters that really shouldn't be in paths
|
||||
static const QRegularExpression regex_invalid_dir_characters(QString::fromLatin1(kInvalidDirCharactersRegex), QRegularExpression::PatternOption::CaseInsensitiveOption);
|
||||
value = value.remove(regex_invalid_dir_characters);
|
||||
if (remove_problematic_) value = value.remove(QLatin1Char('.'));
|
||||
if (remove_problematic_) value = value.remove(u'.');
|
||||
value = value.trimmed();
|
||||
|
||||
return value;
|
||||
|
@ -34,10 +34,10 @@ QValidator::State OrganizeFormatValidator::validate(QString &input, int &_pos) c
|
||||
// Make sure all the blocks match up
|
||||
int block_level = 0;
|
||||
for (int i = 0; i < input.length(); ++i) {
|
||||
if (input[i] == QLatin1Char('{')) {
|
||||
if (input[i] == u'{') {
|
||||
++block_level;
|
||||
}
|
||||
else if (input[i] == QLatin1Char('}')) {
|
||||
else if (input[i] == u'}') {
|
||||
--block_level;
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,8 @@
|
||||
#include "utilities/strutils.h"
|
||||
#include "covermanager/currentalbumcoverloader.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
const char *OSDBase::kSettingsGroup = "OSD";
|
||||
|
||||
OSDBase::OSDBase(SharedPtr<SystemTrayIcon> tray_icon, Application *app, QObject *parent)
|
||||
@ -169,7 +171,7 @@ void OSDBase::ShowPlaying(const Song &song, const QUrl &cover_url, const QImage
|
||||
#endif
|
||||
}
|
||||
|
||||
QString message = message_parts.join(QLatin1String(", "));
|
||||
QString message = message_parts.join(", "_L1);
|
||||
if (html_escaped) message = message.toHtmlEscaped();
|
||||
|
||||
if (show_art_) {
|
||||
@ -201,7 +203,7 @@ void OSDBase::Paused() {
|
||||
else {
|
||||
summary = last_song_.PrettyTitle();
|
||||
if (!last_song_.artist().isEmpty()) {
|
||||
summary.prepend(QLatin1String(" - "));
|
||||
summary.prepend(" - "_L1);
|
||||
summary.prepend(last_song_.artist());
|
||||
}
|
||||
if (behaviour_ == Behaviour::Pretty) {
|
||||
@ -246,7 +248,7 @@ void OSDBase::Stopped() {
|
||||
else {
|
||||
summary = last_song_.PrettyTitle();
|
||||
if (!last_song_.artist().isEmpty()) {
|
||||
summary.prepend(QLatin1String(" - "));
|
||||
summary.prepend(" - "_L1);
|
||||
summary.prepend(last_song_.artist());
|
||||
}
|
||||
if (behaviour_ == Behaviour::Pretty) {
|
||||
@ -379,7 +381,7 @@ QString OSDBase::ReplaceMessage(const MessageType type, const QString &message,
|
||||
#endif
|
||||
|
||||
bool html_escaped = false;
|
||||
QString newline = QLatin1String("");
|
||||
QString newline = ""_L1;
|
||||
|
||||
// We need different strings depending on notification type
|
||||
switch (behaviour_) {
|
||||
@ -392,12 +394,12 @@ QString OSDBase::ReplaceMessage(const MessageType type, const QString &message,
|
||||
switch (type) {
|
||||
case MessageType::Summary:{
|
||||
html_escaped = false;
|
||||
newline = QLatin1String("");
|
||||
newline = ""_L1;
|
||||
break;
|
||||
}
|
||||
case MessageType::Message:{
|
||||
html_escaped = true;
|
||||
newline = QLatin1String("<br />");
|
||||
newline = "<br />"_L1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -412,12 +414,12 @@ QString OSDBase::ReplaceMessage(const MessageType type, const QString &message,
|
||||
case Behaviour::TrayPopup:
|
||||
qLog(Debug) << "New line not supported by this notification type.";
|
||||
html_escaped = false;
|
||||
newline = QLatin1String("");
|
||||
newline = ""_L1;
|
||||
break;
|
||||
case Behaviour::Disabled: // When notifications are disabled, we force the PrettyOSD
|
||||
case Behaviour::Pretty:
|
||||
html_escaped = true;
|
||||
newline = QLatin1String("<br />");
|
||||
newline = "<br />"_L1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,8 @@
|
||||
#include "osdpretty.h"
|
||||
#include "ui_osdpretty.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
# include <windows.h>
|
||||
#endif
|
||||
@ -248,7 +250,7 @@ void OSDPretty::Load() {
|
||||
fading_enabled_ = s.value("fading", false).toBool();
|
||||
#endif
|
||||
|
||||
if (s.contains(QLatin1String("popup_screen"))) {
|
||||
if (s.contains("popup_screen"_L1)) {
|
||||
popup_screen_name_ = s.value("popup_screen").toString();
|
||||
if (screens_.contains(popup_screen_name_)) {
|
||||
popup_screen_ = screens_.value(popup_screen_name_);
|
||||
@ -264,7 +266,7 @@ void OSDPretty::Load() {
|
||||
if (current_screen()) popup_screen_name_ = current_screen()->name();
|
||||
}
|
||||
|
||||
if (s.contains(QLatin1String("popup_pos"))) {
|
||||
if (s.contains("popup_pos"_L1)) {
|
||||
popup_pos_ = s.value("popup_pos").toPoint();
|
||||
}
|
||||
else {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user