Use C++11 enum class

This commit is contained in:
Jonas Kvinge
2023-02-18 14:09:27 +01:00
parent e6c5f76872
commit dd72fb4ca5
237 changed files with 2915 additions and 2840 deletions

View File

@@ -98,8 +98,8 @@ AlbumCoverChoiceController::AlbumCoverChoiceController(QWidget *parent)
separator2_(nullptr),
show_cover_(nullptr),
search_cover_auto_(nullptr),
save_cover_type_(CollectionSettingsPage::SaveCoverType_Cache),
save_cover_filename_(CollectionSettingsPage::SaveCoverFilename_Pattern),
save_cover_type_(CollectionSettingsPage::SaveCoverType::Cache),
save_cover_filename_(CollectionSettingsPage::SaveCoverFilename::Pattern),
cover_overwrite_(false),
cover_lowercase_(true),
cover_replace_spaces_(true),
@@ -146,8 +146,8 @@ void AlbumCoverChoiceController::ReloadSettings() {
QSettings s;
s.beginGroup(CollectionSettingsPage::kSettingsGroup);
save_cover_type_ = CollectionSettingsPage::SaveCoverType(s.value("save_cover_type", CollectionSettingsPage::SaveCoverType_Cache).toInt());
save_cover_filename_ = CollectionSettingsPage::SaveCoverFilename(s.value("save_cover_filename", CollectionSettingsPage::SaveCoverFilename_Pattern).toInt());
save_cover_type_ = static_cast<CollectionSettingsPage::SaveCoverType>(s.value("save_cover_type", static_cast<int>(CollectionSettingsPage::SaveCoverType::Cache)).toInt());
save_cover_filename_ = static_cast<CollectionSettingsPage::SaveCoverFilename>(s.value("save_cover_filename", static_cast<int>(CollectionSettingsPage::SaveCoverFilename::Pattern)).toInt());
cover_pattern_ = s.value("cover_pattern", "%albumartist-%album").toString();
cover_overwrite_ = s.value("cover_overwrite", false).toBool();
cover_lowercase_ = s.value("cover_lowercase", false).toBool();
@@ -214,14 +214,14 @@ QUrl AlbumCoverChoiceController::LoadCoverFromFile(Song *song) {
if (QImage(cover_file).isNull()) return QUrl();
switch (get_save_album_cover_type()) {
case CollectionSettingsPage::SaveCoverType_Embedded:
case CollectionSettingsPage::SaveCoverType::Embedded:
if (song->save_embedded_cover_supported()) {
SaveCoverEmbeddedAutomatic(*song, cover_file);
return QUrl::fromLocalFile(Song::kEmbeddedCover);
}
[[fallthrough]];
case CollectionSettingsPage::SaveCoverType_Cache:
case CollectionSettingsPage::SaveCoverType_Album:{
case CollectionSettingsPage::SaveCoverType::Cache:
case CollectionSettingsPage::SaveCoverType::Album:{
QUrl cover_url = QUrl::fromLocalFile(cover_file);
SaveArtManualToSong(song, cover_url);
return cover_url;
@@ -540,7 +540,7 @@ void AlbumCoverChoiceController::SaveArtAutomaticToSong(Song *song, const QUrl &
song->clear_art_manual();
}
if (song->source() == Song::Source_Collection) {
if (song->source() == Song::Source::Collection) {
app_->collection_backend()->UpdateAutomaticAlbumArtAsync(song->effective_albumartist(), song->album(), art_automatic, song->has_embedded_cover());
}
@@ -559,20 +559,20 @@ void AlbumCoverChoiceController::SaveArtManualToSong(Song *song, const QUrl &art
// Update the backends.
switch (song->source()) {
case Song::Source_Collection:
case Song::Source::Collection:
app_->collection_backend()->UpdateManualAlbumArtAsync(song->effective_albumartist(), song->album(), art_manual, clear_art_automatic);
break;
case Song::Source_LocalFile:
case Song::Source_CDDA:
case Song::Source_Device:
case Song::Source_Stream:
case Song::Source_RadioParadise:
case Song::Source_SomaFM:
case Song::Source_Unknown:
case Song::Source::LocalFile:
case Song::Source::CDDA:
case Song::Source::Device:
case Song::Source::Stream:
case Song::Source::RadioParadise:
case Song::Source::SomaFM:
case Song::Source::Unknown:
break;
case Song::Source_Tidal:
case Song::Source_Qobuz:
case Song::Source_Subsonic:
case Song::Source::Tidal:
case Song::Source::Qobuz:
case Song::Source::Subsonic:
InternetService *service = app_->internet_services()->ServiceBySource(song->source());
if (!service) break;
if (service->artists_collection_backend()) {
@@ -618,7 +618,7 @@ QUrl AlbumCoverChoiceController::SaveCoverToFileAutomatic(const Song::Source sou
QFile file(filepath);
// Don't overwrite when saving in album dir if the filename is set to pattern unless "force_overwrite" is set.
if (source == Song::Source_Collection && !cover_overwrite_ && !force_overwrite && get_save_album_cover_type() == CollectionSettingsPage::SaveCoverType_Album && save_cover_filename_ == CollectionSettingsPage::SaveCoverFilename_Pattern && file.exists()) {
if (source == Song::Source::Collection && !cover_overwrite_ && !force_overwrite && get_save_album_cover_type() == CollectionSettingsPage::SaveCoverType::Album && save_cover_filename_ == CollectionSettingsPage::SaveCoverFilename::Pattern && file.exists()) {
while (file.exists()) {
QFileInfo fileinfo(file.fileName());
file.setFileName(fileinfo.path() + "/0" + fileinfo.fileName());
@@ -653,7 +653,7 @@ QUrl AlbumCoverChoiceController::SaveCoverToFileAutomatic(const Song::Source sou
void AlbumCoverChoiceController::SaveCoverEmbeddedAutomatic(const Song &song, const AlbumCoverImageResult &result) {
if (song.source() == Song::Source_Collection) {
if (song.source() == Song::Source::Collection) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QFuture<SongList> future = QtConcurrent::run(&CollectionBackend::GetAlbumSongs, app_->collection_backend(), song.effective_albumartist(), song.effective_album(), CollectionFilterOptions());
#else
@@ -698,7 +698,7 @@ void AlbumCoverChoiceController::SaveCoverEmbeddedAutomatic(const Song &song, co
void AlbumCoverChoiceController::SaveCoverEmbeddedAutomatic(const Song &song, const QString &cover_filename) {
if (song.source() == Song::Source_Collection) {
if (song.source() == Song::Source::Collection) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QFuture<SongList> future = QtConcurrent::run(&CollectionBackend::GetAlbumSongs, app_->collection_backend(), song.effective_albumartist(), song.effective_album(), CollectionFilterOptions());
#else
@@ -758,7 +758,7 @@ QUrl AlbumCoverChoiceController::SaveCover(Song *song, const QDropEvent *e) {
const QString suffix = QFileInfo(filename).suffix().toLower();
if (IsKnownImageExtension(suffix)) {
if (get_save_album_cover_type() == CollectionSettingsPage::SaveCoverType_Embedded && song->save_embedded_cover_supported()) {
if (get_save_album_cover_type() == CollectionSettingsPage::SaveCoverType::Embedded && song->save_embedded_cover_supported()) {
SaveCoverEmbeddedAutomatic(*song, filename);
return QUrl::fromLocalFile(Song::kEmbeddedCover);
}
@@ -784,7 +784,7 @@ QUrl AlbumCoverChoiceController::SaveCoverAutomatic(Song *song, const AlbumCover
QUrl cover_url;
switch(get_save_album_cover_type()) {
case CollectionSettingsPage::SaveCoverType_Embedded:{
case CollectionSettingsPage::SaveCoverType::Embedded:{
if (song->save_embedded_cover_supported()) {
SaveCoverEmbeddedAutomatic(*song, result);
cover_url = QUrl::fromLocalFile(Song::kEmbeddedCover);
@@ -792,8 +792,8 @@ QUrl AlbumCoverChoiceController::SaveCoverAutomatic(Song *song, const AlbumCover
}
}
[[fallthrough]];
case CollectionSettingsPage::SaveCoverType_Cache:
case CollectionSettingsPage::SaveCoverType_Album:{
case CollectionSettingsPage::SaveCoverType::Cache:
case CollectionSettingsPage::SaveCoverType::Album:{
cover_url = SaveCoverToFileAutomatic(song, result);
if (!cover_url.isEmpty()) SaveArtManualToSong(song, cover_url);
break;

View File

@@ -69,7 +69,7 @@ class AlbumCoverChoiceController : public QWidget {
void Init(Application *app);
void ReloadSettings();
CollectionSettingsPage::SaveCoverType get_save_album_cover_type() const { return (save_embedded_cover_override_ ? CollectionSettingsPage::SaveCoverType_Embedded : save_cover_type_); }
CollectionSettingsPage::SaveCoverType get_save_album_cover_type() const { return (save_embedded_cover_override_ ? CollectionSettingsPage::SaveCoverType::Embedded : save_cover_type_); }
CollectionSettingsPage::SaveCoverType get_collection_save_album_cover_type() const { return save_cover_type_; }
// Getters for all QActions implemented by this controller.

View File

@@ -52,9 +52,9 @@ AlbumCoverExport::DialogResult AlbumCoverExport::Exec() {
// Restore last accepted settings
ui_->fileName->setText(s.value("fileName", "cover").toString());
ui_->doNotOverwrite->setChecked(s.value("overwrite", OverwriteMode_None).toInt() == OverwriteMode_None);
ui_->overwriteAll->setChecked(s.value("overwrite", OverwriteMode_All).toInt() == OverwriteMode_All);
ui_->overwriteSmaller->setChecked(s.value("overwrite", OverwriteMode_Smaller).toInt() == OverwriteMode_Smaller);
ui_->doNotOverwrite->setChecked(static_cast<OverwriteMode>(s.value("overwrite", static_cast<int>(OverwriteMode::None)).toInt()) == OverwriteMode::None);
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", "").toString());
ui_->height->setText(s.value("height", "").toString());
@@ -71,13 +71,13 @@ AlbumCoverExport::DialogResult AlbumCoverExport::Exec() {
if (fileName.isEmpty()) {
fileName = "cover";
}
OverwriteMode overwrite = ui_->doNotOverwrite->isChecked() ? OverwriteMode_None : (ui_->overwriteAll->isChecked() ? OverwriteMode_All : OverwriteMode_Smaller);
OverwriteMode overwrite_mode = ui_->doNotOverwrite->isChecked() ? OverwriteMode::None : (ui_->overwriteAll->isChecked() ? OverwriteMode::All : OverwriteMode::Smaller);
bool forceSize = ui_->forceSize->isChecked();
QString width = ui_->width->text();
QString height = ui_->height->text();
s.setValue("fileName", fileName);
s.setValue("overwrite", overwrite);
s.setValue("overwrite", static_cast<int>(overwrite_mode));
s.setValue("forceSize", forceSize);
s.setValue("width", width);
s.setValue("height", height);
@@ -85,7 +85,7 @@ AlbumCoverExport::DialogResult AlbumCoverExport::Exec() {
s.setValue("export_embedded", ui_->export_embedded->isChecked());
result.filename_ = fileName;
result.overwrite_ = overwrite;
result.overwrite_ = overwrite_mode;
result.forcesize_ = forceSize;
result.width_ = width.toInt();
result.height_ = height.toInt();

View File

@@ -39,10 +39,10 @@ class AlbumCoverExport : public QDialog {
explicit AlbumCoverExport(QWidget *parent = nullptr);
~AlbumCoverExport() override;
enum OverwriteMode {
OverwriteMode_None = 0,
OverwriteMode_All = 1,
OverwriteMode_Smaller = 2
enum class OverwriteMode {
None = 0,
All = 1,
Smaller = 2
};
struct DialogResult {
@@ -63,7 +63,7 @@ class AlbumCoverExport : public QDialog {
}
bool RequiresCoverProcessing() const {
return IsSizeForced() || overwrite_ == OverwriteMode_Smaller;
return IsSizeForced() || overwrite_ == OverwriteMode::Smaller;
}
};

View File

@@ -100,7 +100,7 @@ Q_DECLARE_METATYPE(CoverProviderSearchResult)
// This is a complete result of a single search request (a list of results, each describing one image, actually).
using CoverProviderSearchResults = QList<CoverProviderSearchResult>;
Q_DECLARE_METATYPE(QList<CoverProviderSearchResult>)
Q_DECLARE_METATYPE(CoverProviderSearchResults)
// This class searches for album covers for a given query or artist/album and returns URLs. It's NOT thread-safe.
class AlbumCoverFetcher : public QObject {

View File

@@ -63,8 +63,8 @@ AlbumCoverLoader::AlbumCoverLoader(QObject *parent)
load_image_async_id_(1),
save_image_async_id_(1),
network_(new NetworkAccessManager(this)),
save_cover_type_(CollectionSettingsPage::SaveCoverType_Cache),
save_cover_filename_(CollectionSettingsPage::SaveCoverFilename_Pattern),
save_cover_type_(CollectionSettingsPage::SaveCoverType::Cache),
save_cover_filename_(CollectionSettingsPage::SaveCoverFilename::Pattern),
cover_overwrite_(false),
cover_lowercase_(true),
cover_replace_spaces_(true),
@@ -94,8 +94,8 @@ void AlbumCoverLoader::ReloadSettings() {
QSettings s;
s.beginGroup(CollectionSettingsPage::kSettingsGroup);
save_cover_type_ = CollectionSettingsPage::SaveCoverType(s.value("save_cover_type", CollectionSettingsPage::SaveCoverType_Cache).toInt());
save_cover_filename_ = CollectionSettingsPage::SaveCoverFilename(s.value("save_cover_filename", CollectionSettingsPage::SaveCoverFilename_Pattern).toInt());
save_cover_type_ = static_cast<CollectionSettingsPage::SaveCoverType>(s.value("save_cover_type", static_cast<int>(CollectionSettingsPage::SaveCoverType::Cache)).toInt());
save_cover_filename_ = static_cast<CollectionSettingsPage::SaveCoverFilename>(s.value("save_cover_filename", static_cast<int>(CollectionSettingsPage::SaveCoverFilename::Pattern)).toInt());
cover_pattern_ = s.value("cover_pattern", "%albumartist-%album").toString();
cover_overwrite_ = s.value("cover_overwrite", false).toBool();
cover_lowercase_ = s.value("cover_lowercase", false).toBool();
@@ -132,7 +132,7 @@ QString AlbumCoverLoader::CoverFilePath(const Song &song, const QString &album_d
QString AlbumCoverLoader::CoverFilePath(const Song::Source source, const QString &artist, const QString &album, const QString &album_id, const QString &album_dir, const QUrl &cover_url, const QString &extension) {
QString path;
if (source == Song::Source_Collection && save_cover_type_ == CollectionSettingsPage::SaveCoverType_Album && !album_dir.isEmpty()) {
if (source == Song::Source::Collection && save_cover_type_ == CollectionSettingsPage::SaveCoverType::Album && !album_dir.isEmpty()) {
path = album_dir;
}
else {
@@ -150,9 +150,9 @@ QString AlbumCoverLoader::CoverFilePath(const Song::Source source, const QString
}
QString filename;
if (source == Song::Source_Collection &&
save_cover_type_ == CollectionSettingsPage::SaveCoverType_Album &&
save_cover_filename_ == CollectionSettingsPage::SaveCoverFilename_Pattern &&
if (source == Song::Source::Collection &&
save_cover_type_ == CollectionSettingsPage::SaveCoverType::Album &&
save_cover_filename_ == CollectionSettingsPage::SaveCoverFilename::Pattern &&
!cover_pattern_.isEmpty()) {
filename = CoverFilenameFromVariable(artist, album);
filename.remove(OrganizeFormat::kInvalidFatCharacters).remove('/').remove('\\');
@@ -179,27 +179,27 @@ QString AlbumCoverLoader::CoverFilenameFromSource(const Song::Source source, con
QString filename;
switch (source) {
case Song::Source_Tidal:
case Song::Source::Tidal:
if (!album_id.isEmpty()) {
filename = album_id + "-" + cover_url.fileName();
break;
}
[[fallthrough]];
case Song::Source_Subsonic:
case Song::Source_Qobuz:
case Song::Source::Subsonic:
case Song::Source::Qobuz:
if (!album_id.isEmpty()) {
filename = album_id;
break;
}
[[fallthrough]];
case Song::Source_Collection:
case Song::Source_LocalFile:
case Song::Source_CDDA:
case Song::Source_Device:
case Song::Source_Stream:
case Song::Source_SomaFM:
case Song::Source_RadioParadise:
case Song::Source_Unknown:
case Song::Source::Collection:
case Song::Source::LocalFile:
case Song::Source::CDDA:
case Song::Source::Device:
case Song::Source::Stream:
case Song::Source::SomaFM:
case Song::Source::RadioParadise:
case Song::Source::Unknown:
filename = Utilities::Sha1CoverHash(artist, album).toHex();
break;
}
@@ -380,7 +380,7 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(Task *task) {
}
// For local files and streams initialize art if found.
if ((task->song.source() == Song::Source_LocalFile || task->song.is_radio()) && !task->song.art_manual_is_valid() && !task->song.art_automatic_is_valid()) {
if ((task->song.source() == Song::Source::LocalFile || task->song.is_radio()) && !task->song.art_manual_is_valid() && !task->song.art_automatic_is_valid()) {
switch (task->state) {
case State_None:
break;

View File

@@ -74,7 +74,7 @@ class AlbumCoverLoader : public QObject {
QString CoverFilePath(const Song::Source source, const QString &artist, const QString &album, const QString &album_id, const QString &album_dir, const QUrl &cover_url, const QString &extension = QString());
quint64 LoadImageAsync(const AlbumCoverLoaderOptions &options, const Song &song);
quint64 LoadImageAsync(const AlbumCoverLoaderOptions &options, const QUrl &art_automatic, const QUrl &art_manual, const QUrl &song_url = QUrl(), const Song::Source song_source = Song::Source_Unknown);
quint64 LoadImageAsync(const AlbumCoverLoaderOptions &options, const QUrl &art_automatic, const QUrl &art_manual, const QUrl &song_url = QUrl(), const Song::Source song_source = Song::Source::Unknown);
quint64 LoadImageAsync(const AlbumCoverLoaderOptions &options, const AlbumCoverImageResult &album_cover);
quint64 LoadImageAsync(const AlbumCoverLoaderOptions &options, const QImage &image);

View File

@@ -317,7 +317,7 @@ void AlbumCoverManager::SaveSettings() {
s.beginGroup(kSettingsGroup);
s.setValue("geometry", saveGeometry());
s.setValue("splitter_state", ui_->splitter->saveState());
s.setValue("save_cover_type", album_cover_choice_controller_->get_save_album_cover_type());
s.setValue("save_cover_type", static_cast<int>(album_cover_choice_controller_->get_save_album_cover_type()));
s.endGroup();
}
@@ -417,7 +417,7 @@ void AlbumCoverManager::ArtistChanged(QListWidgetItem *current) {
AlbumItem *item = new AlbumItem(icon_nocover_item_, display_text, ui_->albums);
item->setData(Role_AlbumArtist, info.album_artist);
item->setData(Role_Album, info.album);
item->setData(Role_Filetype, info.filetype);
item->setData(Role_Filetype, QVariant::fromValue(info.filetype));
item->setData(Role_CuePath, info.cue_path);
item->setData(Qt::TextAlignmentRole, QVariant(Qt::AlignTop | Qt::AlignHCenter));
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled);
@@ -469,12 +469,12 @@ void AlbumCoverManager::UpdateFilter() {
const bool hide_with_covers = filter_without_covers_->isChecked();
const bool hide_without_covers = filter_with_covers_->isChecked();
HideCovers hide = Hide_None;
HideCovers hide_covers = HideCovers::None;
if (hide_with_covers) {
hide = Hide_WithCovers;
hide_covers = HideCovers::WithCovers;
}
else if (hide_without_covers) {
hide = Hide_WithoutCovers;
hide_covers = HideCovers::WithoutCovers;
}
qint32 total_count = 0;
@@ -482,7 +482,7 @@ void AlbumCoverManager::UpdateFilter() {
for (int i = 0; i < ui_->albums->count(); ++i) {
AlbumItem *item = static_cast<AlbumItem*>(ui_->albums->item(i));
bool should_hide = ShouldHide(*item, filter, hide);
bool should_hide = ShouldHide(*item, filter, hide_covers);
item->setHidden(should_hide);
if (!should_hide) {
@@ -498,13 +498,13 @@ void AlbumCoverManager::UpdateFilter() {
}
bool AlbumCoverManager::ShouldHide(const AlbumItem &item, const QString &filter, HideCovers hide) const {
bool AlbumCoverManager::ShouldHide(const AlbumItem &item, const QString &filter, const HideCovers hide_covers) const {
bool has_cover = ItemHasCover(item);
if (hide == Hide_WithCovers && has_cover) {
if (hide_covers == HideCovers::WithCovers && has_cover) {
return true;
}
else if (hide == Hide_WithoutCovers && !has_cover) {
else if (hide_covers == HideCovers::WithoutCovers && !has_cover) {
return true;
}
@@ -642,7 +642,7 @@ Song AlbumCoverManager::GetFirstSelectedAsSong() {
Song AlbumCoverManager::ItemAsSong(AlbumItem *item) {
Song result(Song::Source_Collection);
Song result(Song::Source::Collection);
QString title = item->data(Role_Album).toString();
QString artist_name = item->data(Role_AlbumArtist).toString();
@@ -781,13 +781,13 @@ void AlbumCoverManager::SaveImageToAlbums(Song *song, const AlbumCoverImageResul
QUrl cover_url = result.cover_url;
switch (album_cover_choice_controller_->get_save_album_cover_type()) {
case CollectionSettingsPage::SaveCoverType_Cache:
case CollectionSettingsPage::SaveCoverType_Album:
case CollectionSettingsPage::SaveCoverType::Cache:
case CollectionSettingsPage::SaveCoverType::Album:
if (cover_url.isEmpty() || !cover_url.isValid() || !cover_url.isLocalFile()) {
cover_url = album_cover_choice_controller_->SaveCoverToFileAutomatic(song, result);
}
break;
case CollectionSettingsPage::SaveCoverType_Embedded:
case CollectionSettingsPage::SaveCoverType::Embedded:
cover_url = QUrl::fromLocalFile(Song::kEmbeddedCover);
break;
}
@@ -798,14 +798,14 @@ void AlbumCoverManager::SaveImageToAlbums(Song *song, const AlbumCoverImageResul
for (QListWidgetItem *item : context_menu_items_) {
AlbumItem *album_item = static_cast<AlbumItem*>(item);
switch (album_cover_choice_controller_->get_save_album_cover_type()) {
case CollectionSettingsPage::SaveCoverType_Cache:
case CollectionSettingsPage::SaveCoverType_Album:{
case CollectionSettingsPage::SaveCoverType::Cache:
case CollectionSettingsPage::SaveCoverType::Album:{
Song current_song = ItemAsSong(album_item);
album_cover_choice_controller_->SaveArtManualToSong(&current_song, cover_url);
UpdateCoverInList(album_item, cover_url);
break;
}
case CollectionSettingsPage::SaveCoverType_Embedded:{
case CollectionSettingsPage::SaveCoverType::Embedded:{
urls << album_item->urls;
album_items << album_item;
break;
@@ -813,7 +813,7 @@ void AlbumCoverManager::SaveImageToAlbums(Song *song, const AlbumCoverImageResul
}
}
if (album_cover_choice_controller_->get_save_album_cover_type() == CollectionSettingsPage::SaveCoverType_Embedded && !urls.isEmpty()) {
if (album_cover_choice_controller_->get_save_album_cover_type() == CollectionSettingsPage::SaveCoverType::Embedded && !urls.isEmpty()) {
quint64 id = -1;
if (result.is_jpeg()) {
id = app_->album_cover_loader()->SaveEmbeddedCoverAsync(urls, result.image_data);
@@ -971,7 +971,7 @@ void AlbumCoverManager::SaveAndSetCover(AlbumItem *item, const AlbumCoverImageRe
const Song::FileType filetype = static_cast<Song::FileType>(item->data(Role_Filetype).toInt());
const bool has_cue = !item->data(Role_CuePath).toString().isEmpty();
if (album_cover_choice_controller_->get_save_album_cover_type() == CollectionSettingsPage::SaveCoverType_Embedded && Song::save_embedded_cover_supported(filetype) && !has_cue) {
if (album_cover_choice_controller_->get_save_album_cover_type() == CollectionSettingsPage::SaveCoverType::Embedded && Song::save_embedded_cover_supported(filetype) && !has_cue) {
if (result.is_jpeg()) {
quint64 id = app_->album_cover_loader()->SaveEmbeddedCoverAsync(urls, result.image_data);
cover_save_tasks_.insert(id, item);
@@ -991,7 +991,7 @@ void AlbumCoverManager::SaveAndSetCover(AlbumItem *item, const AlbumCoverImageRe
cover_url = result.cover_url;
}
else if (!result.image_data.isEmpty() || !result.image.isNull()) {
cover_url = album_cover_choice_controller_->SaveCoverToFileAutomatic(Song::Source_Collection, albumartist, album, QString(), urls.first().adjusted(QUrl::RemoveFilename).path(), result, false);
cover_url = album_cover_choice_controller_->SaveCoverToFileAutomatic(Song::Source::Collection, albumartist, album, QString(), urls.first().adjusted(QUrl::RemoveFilename).path(), result, false);
}
if (cover_url.isEmpty()) return;

View File

@@ -116,10 +116,10 @@ class AlbumCoverManager : public QMainWindow {
Role_Image
};
enum HideCovers {
Hide_None,
Hide_WithCovers,
Hide_WithoutCovers
enum class HideCovers {
None,
WithCovers,
WithoutCovers
};
void LoadGeometry();
@@ -136,7 +136,7 @@ class AlbumCoverManager : public QMainWindow {
static Song ItemAsSong(AlbumItem *item);
void UpdateStatusText();
bool ShouldHide(const AlbumItem &item, const QString &filter, HideCovers hide) const;
bool ShouldHide(const AlbumItem &item, const QString &filter, const HideCovers hide_covers) const;
void SaveAndSetCover(AlbumItem *item, const AlbumCoverImageResult &result);
void SaveImageToAlbums(Song *song, const AlbumCoverImageResult &result);

View File

@@ -122,16 +122,16 @@ void CoverExportRunnable::ProcessAndExportCover() {
QString new_file = dir + '/' + dialog_result_.filename_ + '.' + (cover_path == Song::kEmbeddedCover ? "jpg" : extension);
// If the file exists, do not override!
if (dialog_result_.overwrite_ == AlbumCoverExport::OverwriteMode_None && QFile::exists(new_file)) {
if (dialog_result_.overwrite_ == AlbumCoverExport::OverwriteMode::None && QFile::exists(new_file)) {
EmitCoverSkipped();
return;
}
// we're handling overwrite as remove + copy so we need to delete the old file first
if (QFile::exists(new_file) && dialog_result_.overwrite_ != AlbumCoverExport::OverwriteMode_None) {
if (QFile::exists(new_file) && dialog_result_.overwrite_ != AlbumCoverExport::OverwriteMode::None) {
// if the mode is "overwrite smaller" then skip the cover if a bigger one is already available in the folder
if (dialog_result_.overwrite_ == AlbumCoverExport::OverwriteMode_Smaller) {
if (dialog_result_.overwrite_ == AlbumCoverExport::OverwriteMode::Smaller) {
QImage existing;
existing.load(new_file);
@@ -168,13 +168,13 @@ void CoverExportRunnable::ExportCover() {
QString new_file = dir + '/' + dialog_result_.filename_ + '.' + (cover_path == Song::kEmbeddedCover ? "jpg" : extension);
// If the file exists, do not override!
if (dialog_result_.overwrite_ == AlbumCoverExport::OverwriteMode_None && QFile::exists(new_file)) {
if (dialog_result_.overwrite_ == AlbumCoverExport::OverwriteMode::None && QFile::exists(new_file)) {
EmitCoverSkipped();
return;
}
// We're handling overwrite as remove + copy so we need to delete the old file first
if (dialog_result_.overwrite_ != AlbumCoverExport::OverwriteMode_None && QFile::exists(new_file)) {
if (dialog_result_.overwrite_ != AlbumCoverExport::OverwriteMode::None && QFile::exists(new_file)) {
if (!QFile::remove(new_file)) {
EmitCoverSkipped();
return;

View File

@@ -128,10 +128,10 @@ void DiscogsCoverProvider::SendSearchRequest(std::shared_ptr<DiscogsCoverSearchC
<< Param("release_title", search->album.toLower());
switch (search->type) {
case DiscogsCoverType_Master:
case DiscogsCoverType::Master:
params << Param("type", "master");
break;
case DiscogsCoverType_Release:
case DiscogsCoverType::Release:
params << Param("type", "release");
break;
}
@@ -296,8 +296,8 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
}
if (search->requests_release_.count() == 0) {
if (search->type == DiscogsCoverType_Master) {
search->type = DiscogsCoverType_Release;
if (search->type == DiscogsCoverType::Master) {
search->type = DiscogsCoverType::Release;
queue_search_requests_.enqueue(search);
}
else {

View File

@@ -55,9 +55,9 @@ class DiscogsCoverProvider : public JsonCoverProvider {
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
void CancelSearch(const int id) override;
enum DiscogsCoverType {
DiscogsCoverType_Master,
DiscogsCoverType_Release,
enum class DiscogsCoverType {
Master,
Release
};
struct DiscogsCoverReleaseContext {
@@ -67,7 +67,7 @@ class DiscogsCoverProvider : public JsonCoverProvider {
QUrl url;
};
struct DiscogsCoverSearchContext {
explicit DiscogsCoverSearchContext(const int _id = 0, const QString &_artist = QString(), const QString &_album = QString(), const DiscogsCoverType _type = DiscogsCoverType_Master) : id(_id), artist(_artist), album(_album), type(_type) {}
explicit DiscogsCoverSearchContext(const int _id = 0, const QString &_artist = QString(), const QString &_album = QString(), const DiscogsCoverType _type = DiscogsCoverType::Master) : id(_id), artist(_artist), album(_album), type(_type) {}
int id;
QString artist;
QString album;

View File

@@ -48,7 +48,7 @@ class LastFmCoverProvider : public JsonCoverProvider {
void QueryFinished(QNetworkReply *reply, const int id, const QString &type);
private:
enum LastFmImageSize {
enum class LastFmImageSize {
Unknown,
Small = 34,
Medium = 64,