diff --git a/CMakeLists.txt b/CMakeLists.txt index ef1f3f1ed..44b2a82e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,8 +306,9 @@ optional_component(VLC ON "Engine: VLC backend" DEPENDS "libvlc" LIBVLC_FOUND ) -optional_component(CHROMAPRINT ON "Chromaprint (Tag fetching from Musicbrainz)" +optional_component(MUSICBRAINZ ON "MusicBrainz integration" DEPENDS "chromaprint" CHROMAPRINT_FOUND + DEPENDS "gstreamer" GSTREAMER_FOUND ) if (X11_FOUND OR HAVE_DBUS OR APPLE OR WIN32) @@ -324,6 +325,7 @@ optional_component(X11_GLOBALSHORTCUTS ON "X11 global shortcuts" optional_component(AUDIOCD ON "Devices: Audio CD support" DEPENDS "libcdio" LIBCDIO_FOUND + DEPENDS "gstreamer" GSTREAMER_FOUND ) optional_component(UDISKS2 ON "Devices: UDisks2 backend" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e802345bf..ad00b112b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -855,26 +855,26 @@ UI settings/transcodersettingspage.ui ) +# MusicBrainz +optional_source(HAVE_MUSICBRAINZ + SOURCES + musicbrainz/chromaprinter.cpp + musicbrainz/tagfetcher.cpp + HEADERS + musicbrainz/tagfetcher.h +) + # CDIO backend and device -if(HAVE_GSTREAMER) - optional_source(HAVE_CHROMAPRINT - SOURCES - musicbrainz/chromaprinter.cpp - musicbrainz/tagfetcher.cpp - HEADERS - musicbrainz/tagfetcher.h - ) - optional_source(HAVE_AUDIOCD - SOURCES - device/cddadevice.cpp - device/cddalister.cpp - device/cddasongloader.cpp - HEADERS - device/cddadevice.h - device/cddalister.h - device/cddasongloader.h - ) -endif() +optional_source(HAVE_AUDIOCD + SOURCES + device/cddadevice.cpp + device/cddalister.cpp + device/cddasongloader.cpp + HEADERS + device/cddadevice.h + device/cddalister.h + device/cddasongloader.h +) # Platform specific - macOS optional_source(APPLE @@ -1081,9 +1081,9 @@ if(HAVE_VLC) link_directories(${LIBVLC_LIBRARY_DIRS}) endif() -if(HAVE_CHROMAPRINT) +if(HAVE_MUSICBRAINZ) link_directories(${CHROMAPRINT_LIBRARY_DIRS}) -endif(HAVE_CHROMAPRINT) +endif(HAVE_MUSICBRAINZ) if(X11_FOUND) link_directories(${X11_LIBRARY_DIRS}) @@ -1195,10 +1195,10 @@ if(HAVE_VLC) target_link_libraries(strawberry_lib PRIVATE ${LIBVLC_LIBRARIES}) endif() -if(HAVE_CHROMAPRINT) +if(HAVE_MUSICBRAINZ) target_include_directories(strawberry_lib SYSTEM PRIVATE ${CHROMAPRINT_INCLUDE_DIRS}) target_link_libraries(strawberry_lib PRIVATE ${CHROMAPRINT_LIBRARIES}) -endif(HAVE_CHROMAPRINT) +endif(HAVE_MUSICBRAINZ) if(X11_FOUND) target_include_directories(strawberry_lib SYSTEM PRIVATE ${X11_INCLUDE_DIR}) diff --git a/src/config.h.in b/src/config.h.in index ad0b77a2d..a88f170ff 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -17,7 +17,7 @@ #cmakedefine HAVE_LIBPULSE #cmakedefine HAVE_SPARKLE #cmakedefine HAVE_QTSPARKLE -#cmakedefine HAVE_CHROMAPRINT +#cmakedefine HAVE_MUSICBRAINZ #cmakedefine HAVE_GLOBALSHORTCUTS #cmakedefine USE_INSTALL_PREFIX diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index 261ebfd01..12be36096 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -180,7 +180,7 @@ #include "scrobbler/audioscrobbler.h" #include "scrobbler/lastfmimport.h" -#if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) +#ifdef HAVE_MUSICBRAINZ # include "musicbrainz/tagfetcher.h" #endif @@ -486,7 +486,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd QObject::connect(ui_->action_renumber_tracks, &QAction::triggered, this, &MainWindow::RenumberTracks); QObject::connect(ui_->action_selection_set_value, &QAction::triggered, this, &MainWindow::SelectionSetValue); QObject::connect(ui_->action_edit_value, &QAction::triggered, this, &MainWindow::EditValue); -#if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) +#ifdef HAVE_MUSICBRAINZ QObject::connect(ui_->action_auto_complete_tags, &QAction::triggered, this, &MainWindow::AutoCompleteTags); #endif QObject::connect(ui_->action_settings, &QAction::triggered, this, &MainWindow::OpenSettingsDialog); @@ -697,7 +697,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd playlist_menu_->addAction(ui_->action_edit_value); playlist_menu_->addAction(ui_->action_renumber_tracks); playlist_menu_->addAction(ui_->action_selection_set_value); -#if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) +#ifdef HAVE_MUSICBRAINZ playlist_menu_->addAction(ui_->action_auto_complete_tags); #endif playlist_rescan_songs_ = playlist_menu_->addAction(IconLoader::Load("view-refresh"), tr("Rescan song(s)..."), this, &MainWindow::RescanSongs); @@ -1830,7 +1830,7 @@ void MainWindow::PlaylistRightClick(const QPoint &global_pos, const QModelIndex // this is available when we have one or many files and at least one of those is not CUE related ui_->action_edit_track->setEnabled(local_songs > 0 && editable > 0); ui_->action_edit_track->setVisible(local_songs > 0 && editable > 0); -#if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) +#ifdef HAVE_MUSICBRAINZ ui_->action_auto_complete_tags->setEnabled(local_songs > 0 && editable > 0); ui_->action_auto_complete_tags->setVisible(local_songs > 0 && editable > 0); #endif @@ -2865,7 +2865,7 @@ bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *r void MainWindow::AutoCompleteTags() { -#if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) +#ifdef HAVE_MUSICBRAINZ autocomplete_tag_items_.clear(); diff --git a/src/core/mainwindow.h b/src/core/mainwindow.h index 33daf61f4..cd1dfd1d7 100644 --- a/src/core/mainwindow.h +++ b/src/core/mainwindow.h @@ -84,7 +84,7 @@ class OrganizeDialog; class PlaylistListContainer; class QueueView; class SystemTrayIcon; -#if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) +#ifdef HAVE_MUSICBRAINZ class TagFetcher; #endif class TrackSelectionDialog; @@ -327,7 +327,7 @@ class MainWindow : public QMainWindow, public PlatformInterface { #endif Lazy add_stream_dialog_; -#if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) +#ifdef HAVE_MUSICBRAINZ std::unique_ptr tag_fetcher_; #endif std::unique_ptr track_selection_dialog_; diff --git a/src/device/cddasongloader.cpp b/src/device/cddasongloader.cpp index bd558d9ee..16151a88a 100644 --- a/src/device/cddasongloader.cpp +++ b/src/device/cddasongloader.cpp @@ -185,7 +185,7 @@ void CddaSongLoader::LoadSongs() { } emit SongsDurationLoaded(songs); -#ifdef HAVE_CHROMAPRINT +#ifdef HAVE_MUSICBRAINZ // Handle TAG message: generate MusicBrainz DiscId if (msg_tag) { GstTagList *tags = nullptr; @@ -211,7 +211,7 @@ void CddaSongLoader::LoadSongs() { } -#ifdef HAVE_CHROMAPRINT +#ifdef HAVE_MUSICBRAINZ void CddaSongLoader::AudioCDTagsLoaded(const QString &artist, const QString &album, const MusicBrainzClient::ResultList &results) { MusicBrainzClient *musicbrainz_client = qobject_cast(sender()); diff --git a/src/device/cddasongloader.h b/src/device/cddasongloader.h index 04db18b52..a75659079 100644 --- a/src/device/cddasongloader.h +++ b/src/device/cddasongloader.h @@ -36,7 +36,7 @@ #include #include "core/song.h" -#ifdef HAVE_CHROMAPRINT +#ifdef HAVE_MUSICBRAINZ # include "musicbrainz/musicbrainzclient.h" #endif @@ -63,7 +63,7 @@ class CddaSongLoader : public QObject { void SongsMetadataLoaded(SongList songs); private slots: -#ifdef HAVE_CHROMAPRINT +#ifdef HAVE_MUSICBRAINZ void AudioCDTagsLoaded(const QString &artist, const QString &album, const MusicBrainzClient::ResultList &results); #endif diff --git a/src/dialogs/edittagdialog.cpp b/src/dialogs/edittagdialog.cpp index c4ec76167..996e64fb2 100644 --- a/src/dialogs/edittagdialog.cpp +++ b/src/dialogs/edittagdialog.cpp @@ -81,7 +81,7 @@ #include "collection/collectionbackend.h" #include "playlist/playlist.h" #include "playlist/playlistdelegates.h" -#if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) +#ifdef HAVE_MUSICBRAINZ # include "musicbrainz/tagfetcher.h" # include "trackselectiondialog.h" #endif @@ -105,7 +105,7 @@ EditTagDialog::EditTagDialog(Application *app, QWidget *parent) ui_(new Ui_EditTagDialog), app_(app), album_cover_choice_controller_(new AlbumCoverChoiceController(this)), -#if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) +#ifdef HAVE_MUSICBRAINZ tag_fetcher_(new TagFetcher(this)), results_dialog_(new TrackSelectionDialog(this)), #endif @@ -121,7 +121,7 @@ EditTagDialog::EditTagDialog(Application *app, QWidget *parent) QObject::connect(app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &EditTagDialog::AlbumCoverLoaded); -#if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) +#ifdef HAVE_MUSICBRAINZ QObject::connect(tag_fetcher_, &TagFetcher::ResultAvailable, results_dialog_, &TrackSelectionDialog::FetchTagFinished, Qt::QueuedConnection); QObject::connect(tag_fetcher_, &TagFetcher::Progress, results_dialog_, &TrackSelectionDialog::FetchTagProgress); QObject::connect(results_dialog_, &TrackSelectionDialog::SongChosen, this, &EditTagDialog::FetchTagSongChosen); @@ -136,7 +136,7 @@ EditTagDialog::EditTagDialog(Application *app, QWidget *parent) ui_->label_lyrics->hide(); ui_->fetch_tag->setIcon(QPixmap::fromImage(QImage(":/pictures/musicbrainz.png"))); -#if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) +#ifdef HAVE_MUSICBRAINZ ui_->fetch_tag->setEnabled(true); #else ui_->fetch_tag->setEnabled(false); @@ -185,7 +185,7 @@ EditTagDialog::EditTagDialog(Application *app, QWidget *parent) QObject::connect(ui_->song_list->selectionModel(), &QItemSelectionModel::selectionChanged, this, &EditTagDialog::SelectionChanged); QObject::connect(ui_->button_box, &QDialogButtonBox::clicked, this, &EditTagDialog::ButtonClicked); QObject::connect(ui_->playcount_reset, &QPushButton::clicked, this, &EditTagDialog::ResetPlayCounts); -#if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) +#ifdef HAVE_MUSICBRAINZ QObject::connect(ui_->fetch_tag, &QPushButton::clicked, this, &EditTagDialog::FetchTag); #endif @@ -368,7 +368,7 @@ bool EditTagDialog::SetLoading(const QString &message) { ui_->button_box->setEnabled(!loading); ui_->tab_widget->setEnabled(!loading); ui_->song_list->setEnabled(!loading); -#if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) +#ifdef HAVE_MUSICBRAINZ ui_->fetch_tag->setEnabled(!loading); #endif ui_->loading_label->setVisible(loading); @@ -1263,7 +1263,7 @@ void EditTagDialog::ResetPlayCounts() { void EditTagDialog::FetchTag() { -#if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) +#ifdef HAVE_MUSICBRAINZ const QModelIndexList sel = ui_->song_list->selectionModel()->selectedIndexes(); @@ -1290,7 +1290,7 @@ void EditTagDialog::FetchTag() { void EditTagDialog::FetchTagSongChosen(const Song &original_song, const Song &new_metadata) { -#if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) +#ifdef HAVE_MUSICBRAINZ const QString filename = original_song.url().toLocalFile(); diff --git a/src/dialogs/edittagdialog.h b/src/dialogs/edittagdialog.h index b13c3ffab..79609008d 100644 --- a/src/dialogs/edittagdialog.h +++ b/src/dialogs/edittagdialog.h @@ -54,7 +54,7 @@ class QHideEvent; class Application; class AlbumCoverChoiceController; class Ui_EditTagDialog; -#if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) +#ifdef HAVE_MUSICBRAINZ class TrackSelectionDialog; class TagFetcher; #endif @@ -179,7 +179,7 @@ class EditTagDialog : public QDialog { Application *app_; AlbumCoverChoiceController *album_cover_choice_controller_; -#if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT) +#ifdef HAVE_MUSICBRAINZ TagFetcher *tag_fetcher_; TrackSelectionDialog *results_dialog_; #endif