AlbumCoverLoaderResult: Use enum class for type
This commit is contained in:
@@ -216,7 +216,7 @@ void AlbumCoverLoader::NextState(Task *task) {
|
||||
}
|
||||
else {
|
||||
// Give up
|
||||
emit AlbumCoverLoaded(task->id, AlbumCoverLoaderResult(false, AlbumCoverLoaderResult::Type_None, AlbumCoverImageResult(task->options.default_output_image_), task->options.default_scaled_image_, task->options.default_thumbnail_image_, task->art_updated));
|
||||
emit AlbumCoverLoaded(task->id, AlbumCoverLoaderResult(false, AlbumCoverLoaderResult::Type::None, AlbumCoverImageResult(task->options.default_output_image_), task->options.default_scaled_image_, task->options.default_thumbnail_image_, task->art_updated));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -225,7 +225,7 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(Task *task) {
|
||||
|
||||
// Only scale and pad.
|
||||
if (task->album_cover.is_valid()) {
|
||||
return TryLoadResult(false, true, AlbumCoverLoaderResult::Type_Embedded, task->album_cover);
|
||||
return TryLoadResult(false, true, AlbumCoverLoaderResult::Type::Embedded, task->album_cover);
|
||||
}
|
||||
|
||||
// For local files and streams initialize art if found.
|
||||
@@ -246,16 +246,16 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(Task *task) {
|
||||
}
|
||||
}
|
||||
|
||||
AlbumCoverLoaderResult::Type type(AlbumCoverLoaderResult::Type_None);
|
||||
AlbumCoverLoaderResult::Type type = AlbumCoverLoaderResult::Type::None;
|
||||
QUrl cover_url;
|
||||
switch (task->state) {
|
||||
case State::None:
|
||||
case State::Automatic:
|
||||
type = AlbumCoverLoaderResult::Type_Automatic;
|
||||
type = AlbumCoverLoaderResult::Type::Automatic;
|
||||
cover_url = task->song.art_automatic();
|
||||
break;
|
||||
case State::Manual:
|
||||
type = AlbumCoverLoaderResult::Type_Manual;
|
||||
type = AlbumCoverLoaderResult::Type::Manual;
|
||||
cover_url = task->song.art_manual();
|
||||
break;
|
||||
}
|
||||
@@ -263,17 +263,17 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(Task *task) {
|
||||
|
||||
if (!cover_url.isEmpty() && !cover_url.path().isEmpty()) {
|
||||
if (cover_url.path() == Song::kManuallyUnsetCover) {
|
||||
return TryLoadResult(false, true, AlbumCoverLoaderResult::Type_ManuallyUnset, AlbumCoverImageResult(cover_url, QString(), QByteArray(), task->options.default_output_image_));
|
||||
return TryLoadResult(false, true, AlbumCoverLoaderResult::Type::ManuallyUnset, AlbumCoverImageResult(cover_url, QString(), QByteArray(), task->options.default_output_image_));
|
||||
}
|
||||
else if (cover_url.path() == Song::kEmbeddedCover && task->song.url().isLocalFile()) {
|
||||
QByteArray image_data = TagReaderClient::Instance()->LoadEmbeddedArtBlocking(task->song.url().toLocalFile());
|
||||
if (!image_data.isEmpty()) {
|
||||
QImage image;
|
||||
if (!image_data.isEmpty() && task->options.get_image_ && image.loadFromData(image_data)) {
|
||||
return TryLoadResult(false, !image.isNull(), AlbumCoverLoaderResult::Type_Embedded, AlbumCoverImageResult(cover_url, QString(), image_data, image));
|
||||
return TryLoadResult(false, !image.isNull(), AlbumCoverLoaderResult::Type::Embedded, AlbumCoverImageResult(cover_url, QString(), image_data, image));
|
||||
}
|
||||
else {
|
||||
return TryLoadResult(false, !image_data.isEmpty(), AlbumCoverLoaderResult::Type_Embedded, AlbumCoverImageResult(cover_url, QString(), image_data, image));
|
||||
return TryLoadResult(false, !image_data.isEmpty(), AlbumCoverLoaderResult::Type::Embedded, AlbumCoverImageResult(cover_url, QString(), image_data, image));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -334,7 +334,7 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(Task *task) {
|
||||
}
|
||||
}
|
||||
|
||||
return TryLoadResult(false, false, AlbumCoverLoaderResult::Type_None, AlbumCoverImageResult(cover_url, QString(), QByteArray(), task->options.default_output_image_));
|
||||
return TryLoadResult(false, false, AlbumCoverLoaderResult::Type::None, AlbumCoverImageResult(cover_url, QString(), QByteArray(), task->options.default_output_image_));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ class AlbumCoverLoader : public QObject {
|
||||
protected:
|
||||
|
||||
struct Task {
|
||||
explicit Task() : id(0), state(State::None), type(AlbumCoverLoaderResult::Type_None), art_updated(false), redirects(0) {}
|
||||
explicit Task() : id(0), state(State::None), type(AlbumCoverLoaderResult::Type::None), art_updated(false), redirects(0) {}
|
||||
|
||||
AlbumCoverLoaderOptions options;
|
||||
|
||||
@@ -115,7 +115,7 @@ class AlbumCoverLoader : public QObject {
|
||||
struct TryLoadResult {
|
||||
explicit TryLoadResult(const bool _started_async = false,
|
||||
const bool _loaded_success = false,
|
||||
const AlbumCoverLoaderResult::Type _type = AlbumCoverLoaderResult::Type_None,
|
||||
const AlbumCoverLoaderResult::Type _type = AlbumCoverLoaderResult::Type::None,
|
||||
const AlbumCoverImageResult &_album_cover = AlbumCoverImageResult()) :
|
||||
started_async(_started_async),
|
||||
loaded_success(_loaded_success),
|
||||
|
||||
@@ -29,17 +29,17 @@
|
||||
|
||||
struct AlbumCoverLoaderResult {
|
||||
|
||||
enum Type {
|
||||
Type_None,
|
||||
Type_ManuallyUnset,
|
||||
Type_Embedded,
|
||||
Type_Automatic,
|
||||
Type_Manual,
|
||||
Type_Remote,
|
||||
enum class Type {
|
||||
None,
|
||||
ManuallyUnset,
|
||||
Embedded,
|
||||
Automatic,
|
||||
Manual,
|
||||
Remote
|
||||
};
|
||||
|
||||
explicit AlbumCoverLoaderResult(const bool _success = false,
|
||||
const Type _type = Type_None,
|
||||
const Type _type = Type::None,
|
||||
const AlbumCoverImageResult &_album_cover = AlbumCoverImageResult(),
|
||||
const QImage &_image_scaled = QImage(),
|
||||
const QImage &_image_thumbnail = QImage(),
|
||||
|
||||
@@ -449,7 +449,7 @@ void AlbumCoverManager::AlbumCoverLoaded(const quint64 id, const AlbumCoverLoade
|
||||
|
||||
AlbumItem *item = cover_loading_tasks_.take(id);
|
||||
|
||||
if (!result.success || result.image_scaled.isNull() || result.type == AlbumCoverLoaderResult::Type_ManuallyUnset) {
|
||||
if (!result.success || result.image_scaled.isNull() || result.type == AlbumCoverLoaderResult::Type::ManuallyUnset) {
|
||||
item->setIcon(icon_nocover_item_);
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user