From 50e8b017983cb44cd531c7555a85f4d4b49043b8 Mon Sep 17 00:00:00 2001 From: cotman Date: Tue, 9 Apr 2019 20:22:06 +0100 Subject: [PATCH] User MusicBrainz for Cover Art lookup. --- .gitignore | 4 + CMakeLists.txt | 9 +- audex.kcfg | 2 +- cmake/modules/FindCoverArt.cmake | 29 ++++++ cmake/modules/FindMusicBrainz.cmake | 29 ++++++ dialogs/coverbrowserdialog.cpp | 8 +- dialogs/coverbrowserdialog.h | 2 +- mainwindow.cpp | 2 +- utils/coverfetcher.cpp | 136 +++++++++------------------- utils/coverfetcher.h | 15 +-- utils/musicbrainzjob.cpp | 99 ++++++++++++++++++++ utils/musicbrainzjob.h | 51 +++++++++++ widgets/cddaheaderwidget.cpp | 48 +++++----- widgets/cddaheaderwidget.h | 4 +- 14 files changed, 302 insertions(+), 136 deletions(-) create mode 100644 .gitignore create mode 100644 cmake/modules/FindCoverArt.cmake create mode 100644 cmake/modules/FindMusicBrainz.cmake create mode 100644 utils/musicbrainzjob.cpp create mode 100644 utils/musicbrainzjob.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..4fbd3ebf --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.kdev4/ +audex.kdev4 +build/ + diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ee55281..16732e6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,8 +22,8 @@ find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h) -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -g") -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fexceptions -Wall -g") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fexceptions") include(KDEInstallDirs) include(KDECMakeSettings) @@ -58,6 +58,8 @@ set_package_properties(KF5Cddb PROPERTIES PURPOSE "libkcddb is used to retrieve audio CD meta data from the internet." ) find_package(Cdparanoia REQUIRED) +find_package(MusicBrainz REQUIRED) +find_package(CoverArt REQUIRED) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} @@ -92,6 +94,7 @@ set(audex_SRCS utils/cuesheetwriter.cpp utils/tmpdir.cpp utils/discidcalculator.cpp + utils/musicbrainzjob.cpp widgets/cddaheaderwidget.cpp widgets/generalsettingswidget.cpp widgets/devicewidget.cpp @@ -168,6 +171,8 @@ target_link_libraries(audex KF5::XmlGui KF5::Cddb ${CDPARANOIA_LIBRARIES} + ${MUSICBRAINZ_LIBRARIES} + ${COVERART_LIBRARIES} ) install(TARGETS audex DESTINATION ${BIN_INSTALL_DIR}) diff --git a/audex.kcfg b/audex.kcfg index 1fb21055..29481778 100644 --- a/audex.kcfg +++ b/audex.kcfg @@ -27,7 +27,7 @@ true - + true diff --git a/cmake/modules/FindCoverArt.cmake b/cmake/modules/FindCoverArt.cmake new file mode 100644 index 00000000..fe39449f --- /dev/null +++ b/cmake/modules/FindCoverArt.cmake @@ -0,0 +1,29 @@ +# - Try to find the CoverArt library +# Once done this will define +# +# COVERART_FOUND - system has CoverArt +# COVERART_INCLUDE_DIR - the CoverArt include directory +# COVERART_LIBRARIES - Link these to use CoverArt +# + +if (COVERART_INCLUDE_DIR AND COVERART_LIBRARIES) + # in cache already + SET(COVERART_FOUND TRUE) + +else (COVERART_INCLUDE_DIR AND COVERART_LIBRARIES) + + FIND_PATH(COVERART_INCLUDE_DIR coverart/caa_c.h) + + FIND_LIBRARY(COVERART_LIBRARY coverartcc) + + IF (COVERART_LIBRARY) + SET(COVERART_LIBRARIES ${COVERART_LIBRARY} "-lm") + ENDIF (COVERART_LIBRARY) + + INCLUDE(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(CoverArt DEFAULT_MSG + COVERART_LIBRARIES COVERART_INCLUDE_DIR) + + MARK_AS_ADVANCED(COVERART_INCLUDE_DIR COVERART_LIBRARIES) + +endif (COVERART_INCLUDE_DIR AND COVERART_LIBRARIES) diff --git a/cmake/modules/FindMusicBrainz.cmake b/cmake/modules/FindMusicBrainz.cmake new file mode 100644 index 00000000..b614bf35 --- /dev/null +++ b/cmake/modules/FindMusicBrainz.cmake @@ -0,0 +1,29 @@ +# - Try to find the MusicBrainz library +# Once done this will define +# +# MUSICBRAINZ_FOUND - system has MusicBrainz +# MUSICBRAINZ_INCLUDE_DIR - the MusicBrainz include directory +# MUSICBRAINZ_LIBRARIES - Link these to use MusicBrainz +# + +if (MUSICBRAINZ_INCLUDE_DIR AND MUSICBRAINZ_LIBRARIES) + # in cache already + SET(MUSICBRAINZ_FOUND TRUE) + +else (MUSICBRAINZ_INCLUDE_DIR AND MUSICBRAINZ_LIBRARIES) + + FIND_PATH(MUSICBRAINZ_INCLUDE_DIR musicbrainz5/mb5_c.h) + + FIND_LIBRARY(MUSICBRAINZ_LIBRARY musicbrainz5cc) + + IF (MUSICBRAINZ_LIBRARY) + SET(MUSICBRAINZ_LIBRARIES ${MUSICBRAINZ_LIBRARY} "-lm") + ENDIF (MUSICBRAINZ_LIBRARY) + + INCLUDE(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(MusicBrainz DEFAULT_MSG + MUSICBRAINZ_LIBRARIES MUSICBRAINZ_INCLUDE_DIR) + + MARK_AS_ADVANCED(MUSICBRAINZ_INCLUDE_DIR MUSICBRAINZ_LIBRARIES) + +endif (MUSICBRAINZ_INCLUDE_DIR AND MUSICBRAINZ_LIBRARIES) diff --git a/dialogs/coverbrowserdialog.cpp b/dialogs/coverbrowserdialog.cpp index b15e7093..09914a2d 100644 --- a/dialogs/coverbrowserdialog.cpp +++ b/dialogs/coverbrowserdialog.cpp @@ -33,11 +33,11 @@ CoverBrowserDialog::~CoverBrowserDialog() { } -void CoverBrowserDialog::fetchThumbnails(const QString& searchstring, const int fetchCount) { +void CoverBrowserDialog::fetchThumbnails(const QString& searchArtist, const QString& searchAlbum, const int fetchCount) { if (fetchCount == 0) - cover_fetcher.startFetchThumbnails(searchstring, Preferences::fetchCount()); + cover_fetcher.startFetchThumbnails(searchArtist, searchAlbum, Preferences::fetchCount()); else - cover_fetcher.startFetchThumbnails(searchstring, fetchCount); + cover_fetcher.startFetchThumbnails(searchArtist, searchAlbum, fetchCount); ui.label->setText(i18n("Searching for covers...")); } @@ -97,7 +97,7 @@ void CoverBrowserDialog::setup() { static const int constIconSize=128; - setWindowTitle(i18n("Fetch Cover From Google")); + setWindowTitle(i18n("Fetch Cover From MusicBrainz")); QVBoxLayout *mainLayout = new QVBoxLayout; setLayout(mainLayout); diff --git a/dialogs/coverbrowserdialog.h b/dialogs/coverbrowserdialog.h index 6fa1aba5..6c6c490b 100644 --- a/dialogs/coverbrowserdialog.h +++ b/dialogs/coverbrowserdialog.h @@ -44,7 +44,7 @@ class CoverBrowserDialog : public QDialog { inline int count() { return cover_fetcher.count(); } public slots: - void fetchThumbnails(const QString& searchstring, const int fetchCount = 0); + void fetchThumbnails(const QString& searchArtist, const QString& searchAlbum, const int fetchCount = 0); void startFetchCover(const int no); signals: diff --git a/mainwindow.cpp b/mainwindow.cpp index 5ae31ec0..80e81321 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -213,7 +213,7 @@ void MainWindow::cddb_lookup_done(const bool successful) { } update_layout(); disable_submit(); - if (Preferences::coverLookupAuto()) cdda_header_widget->googleAuto(); + if (Preferences::coverLookupAuto()) cdda_header_widget->musicBrainzAuto(); } void MainWindow::update_layout() { diff --git a/utils/coverfetcher.cpp b/utils/coverfetcher.cpp index 70e70f06..9fbddaff 100644 --- a/utils/coverfetcher.cpp +++ b/utils/coverfetcher.cpp @@ -23,6 +23,7 @@ */ #include "coverfetcher.h" +#include "musicbrainzjob.h" #include #include #include @@ -38,60 +39,53 @@ CoverFetcher::~CoverFetcher() { clear(); } -void CoverFetcher::fetched_external_ip(KJob* job) { +void CoverFetcher::startFetchThumbnails(const QString& searchArtist, const QString& searchAlbum, const int fetchNo) { - qDebug() << "got IP..."; - if (!job) { - qDebug() << "no job error ..."; - emit nothingFetched(); - return; - } else if (job && job->error()) { - qDebug() << "reply error ..."; - emit nothingFetched(); - return; + qDebug() << "Fetch Thumbs ..."; + if (_status != NOS || fetchNo == 0) + { + emit nothingFetched(); + return; } - // http://www.telize.com/ip returns plaintext ip address - KIO::StoredTransferJob* const storedJob = static_cast(job); - external_ip = ((QString) storedJob->data()).trimmed(); - - qDebug() << "IP " << external_ip; - // Max images per request on Google API is 8, thus the std::min - QString url; - url= QString("https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=%1&rsz=%2&userip=%3") - .arg(QUrl::toPercentEncoding(search_string, "/").data()) - .arg(std::min(fetch_no,8)) - .arg(QUrl::toPercentEncoding(external_ip).data()); - - qDebug() << "searching covers (" << url << ")..."; + fetch_no = fetchNo; _status = SEARCHING; emit statusChanged(SEARCHING); - - job = KIO::storedGet(url); - connect(job, SIGNAL(result(KJob*)), SLOT(fetched_html_data(KJob*))); + + musicbrainz_job = new MusicBrainzJob(searchArtist, searchAlbum, fetchNo); + connect(musicbrainz_job, SIGNAL(finished()), SLOT(fetched_musicbrainz_cover_art_urls())); + musicbrainz_job->fetchCoverArtURLs(); } -void CoverFetcher::startFetchThumbnails(const QString& searchstring, const int fetchNo) { +void CoverFetcher::fetched_musicbrainz_cover_art_urls() { - qDebug() << "Fetch Thumbs ..."; - if (_status != NOS || fetchNo == 0) - { - emit nothingFetched(); - return; - } + switch (_status) { - fetch_no = fetchNo; + case SEARCHING : { + qDebug() << "searching finished."; + + QMap::iterator it; + + int cover_name = 0; + + for (it = musicbrainz_job->cover_art_urls.begin(); it != musicbrainz_job->cover_art_urls.end(); it++) + { + cover_urls_thumbnails << it.key(); + cover_urls << it.value(); + cover_name++; + cover_names << QString::number(cover_name); + } - search_string = searchstring; - search_string.replace("&", ""); + _status = NOS; emit statusChanged(NOS); + fetch_cover_thumbnail(); + } break; - // Google requires the user IP - QString url("http://www.telize.com/ip"); + case NOS : break; - job = KIO::storedGet(url); - connect(job, SIGNAL(result(KJob*)), SLOT(fetched_external_ip(KJob*))); + default : break; + } } @@ -105,6 +99,7 @@ void CoverFetcher::stopFetchThumbnails() { } + void CoverFetcher::startFetchCover(const int no) { if (_status != NOS) return; @@ -137,8 +132,8 @@ void CoverFetcher::fetched_html_data(KJob* job) { QByteArray buffer; if (job && job->error()) { - qDebug() << "There was an error communicating with Google. "<< job->errorString(); - emit error(i18n("There was an error communicating with Google."), i18n("Try again later. Otherwise make a bug report.")); + qDebug() << "There was an error communicating with MusicBrainz. "<< job->errorString(); + emit error(i18n("There was an error communicating with MusicBrainz."), i18n("Try again later. Otherwise make a bug report.")); _status = NOS; emit statusChanged(NOS); emit nothingFetched(); return; @@ -149,8 +144,8 @@ void CoverFetcher::fetched_html_data(KJob* job) { } if (buffer.count() == 0) { - qDebug() << "Google server: empty response"; - emit error(i18n("Google server: Empty response."), + qDebug() << "MusicBrainz server: empty response"; + emit error(i18n("MusicBrainz server: Empty response."), i18n("Try again later. Make a bug report.")); _status = NOS; emit statusChanged(NOS); return; @@ -158,14 +153,6 @@ void CoverFetcher::fetched_html_data(KJob* job) { switch (_status) { - case SEARCHING : { - qDebug() << "searching finished."; - //qDebug() << QString::fromUtf8(buffer.data()); - parse_html_response(QString::fromUtf8(buffer.data())); - _status = NOS; emit statusChanged(NOS); - fetch_cover_thumbnail(); - } break; - case FETCHING_THUMBNAIL : { qDebug() << "cover thumbnail fetched."; cover_thumbnails.append(buffer); @@ -182,58 +169,19 @@ void CoverFetcher::fetched_html_data(KJob* job) { case FETCHING_COVER : { qDebug() << "cover fetched."; - _status = NOS; emit statusChanged(NOS); + _status = NOS; emit statusChanged(NOS); emit fetchedCover(buffer); } break; case NOS : break; + default : break; + } } -void CoverFetcher::parse_html_response(const QString& xml) { - - cover_urls_thumbnails.clear(); - cover_urls.clear(); - cover_names.clear(); - cover_tbnids.clear(); - cover_thumbnails.clear(); - - QScriptValue responseData; - QScriptEngine engine; - responseData = engine.evaluate("("+xml+")"); - - - QScriptValue resultsData=responseData.property("responseData").property("results"); - - if (resultsData.isArray()) { - - QScriptValueIterator it(resultsData); - - while (it.hasNext()) { - - it.next(); - if (it.flags() & QScriptValue::SkipInEnumeration) continue; - - QScriptValue entry = it.value(); - - QString link = QUrl::fromPercentEncoding(entry.property("url").toString().toAscii()); - QString thumbUrl = QUrl::fromPercentEncoding(entry.property("tbUrl").toString().toAscii()); - QString w = entry.property("width").toString(); - QString h = entry.property("height").toString(); - - cover_urls << link; - cover_names << i18n("%1x%2", w, h); - cover_urls_thumbnails << thumbUrl; - - qDebug() << "URL " << link << "- " << thumbUrl<< " -"< #include +#include "preferences.h" +#include "musicbrainzjob.h" + class CoverFetcher : public QObject { Q_OBJECT public: CoverFetcher(QObject *parent = 0); ~CoverFetcher(); - void startFetchThumbnails(const QString& searchstring, const int fetchNo = 8); + void fetchMusicBrainzCoverArtURLs(const QString& searchArtist, const QString& searchAlbum, const int fetchNo = 8); + void startFetchThumbnails(const QString& searchArtist, const QString& searchAlbum, const int fetchNo = 8); void stopFetchThumbnails(); void startFetchCover(const int no); const QByteArray thumbnail(int index); const QString caption(int index); - const QString tbnid(int index); inline int count() { return cover_names.count(); } enum Status { @@ -60,25 +63,24 @@ class CoverFetcher : public QObject { void statusChanged(Status status); - void error(const QString& description, - const QString& solution = QString()); + void error(const QString& description, const QString& solution = QString()); void warning(const QString& description); void info(const QString& description); private slots: + void fetched_musicbrainz_cover_art_urls(); void fetched_html_data(KJob* job); - void fetched_external_ip(KJob* job); private: int fetch_no; QStringList cover_urls_thumbnails; QStringList cover_urls; QStringList cover_names; - QStringList cover_tbnids; QList cover_thumbnails; void clear() { cover_thumbnails.clear(); } KIO::TransferJob* job; + MusicBrainzJob* musicbrainz_job; Status _status; @@ -86,7 +88,6 @@ private slots: QString external_ip; QString search_string; - void parse_html_response(const QString& html); bool fetch_cover_thumbnail(); bool fetch_cover(const int no); diff --git a/utils/musicbrainzjob.cpp b/utils/musicbrainzjob.cpp new file mode 100644 index 00000000..6c847c7b --- /dev/null +++ b/utils/musicbrainzjob.cpp @@ -0,0 +1,99 @@ +/* AUDEX CDDA EXTRACTOR + * Copyright (C) 2007-2015 Marco Nelles (audex@maniatek.com) + * + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include "musicbrainzjob.h" + + +MusicBrainzJob::MusicBrainzJob(const QString& search_artist, const QString& search_album, const int cover_art_limit) { + + this->search_artist = search_artist; + this->search_album = search_album; + this->cover_art_limit = cover_art_limit; + +} + +void MusicBrainzJob::fetchCoverArtURLs() { + + // Format: '"" artist:""' + QString search_string = "'" + this->search_album + "'" + " artist:'" + this->search_artist + "'"; + qDebug() << "MusicBrainz search string: \'" << search_string; + + MusicBrainz5::CQuery Query("audex-query"); + MusicBrainz5::CQuery::tParamMap Params; + Params["query"] = search_string.toUtf8().constData(); + Params["limit"] = 25; + + CoverArtArchive::CCoverArt CoverArt("audex-query"); + + // First get a list of Releases that match the search criteria + MusicBrainz5::CMetadata Metadata = Query.Query("release", "", "", Params); + MusicBrainz5::CReleaseList *ReleaseList = Metadata.ReleaseList(); + + int cover_art_found = 0; + + // Iterate the list of Releases and, for each, pluck out the unique Release ID + for (int release_count = 0; release_count < ReleaseList->NumItems(); release_count++) + { + if (cover_art_found == this->cover_art_limit) + { + break; + } + + MusicBrainz5::CRelease *Release = ReleaseList->Item(release_count); + + try + { + CoverArtArchive::CReleaseInfo ReleaseInfo = CoverArt.ReleaseInfo(Release->ID()); + CoverArtArchive::CImageList* ImageList = ReleaseInfo.ImageList(); + + for (int image_count = 0; image_count < ImageList->NumItems(); image_count++) + { + if (cover_art_found == this->cover_art_limit) + { + break; + } + + CoverArtArchive::CImage* Image = ImageList->Item(image_count); + CoverArtArchive::CThumbnails* Thumbnails = Image->Thumbnails(); + + if (!Image->Front() || Thumbnails->Small().empty()) + { + continue; + } + + QString image_thumbnail_url = QString::fromStdString(Thumbnails->Small()); + QString image_full_url = QString::fromStdString(Image->Image()); + + this->cover_art_urls.insert(image_thumbnail_url, image_full_url); + cover_art_found++; + + qDebug() << "Thumbnail: " << image_thumbnail_url; + qDebug() << "Full: " << image_full_url; + } + } + catch (...) + { + // No appropriate images were found for the Release ID, but we continue to check any others, + // provided we haven't exceeded the past in limit + } + } + + emit finished(); + qDebug() << "MusicBrainz fetch finished"; +} diff --git a/utils/musicbrainzjob.h b/utils/musicbrainzjob.h new file mode 100644 index 00000000..b3489d71 --- /dev/null +++ b/utils/musicbrainzjob.h @@ -0,0 +1,51 @@ +/* AUDEX CDDA EXTRACTOR + * Copyright (C) 2007-2015 Marco Nelles (audex@maniatek.com) + * + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef MUSICBRAINZJOB_HEADER +#define MUSICBRAINZJOB_HEADER + +#include +#include +#include +#include "musicbrainz5/Query.h" +#include "musicbrainz5/Release.h" +#include "coverart/CoverArt.h" +#include "coverart/Image.h" +#include "coverart/ImageList.h" +#include "coverart/Thumbnails.h" + +class MusicBrainzJob : public QObject { + Q_OBJECT + +public: + MusicBrainzJob(const QString& search_artist, const QString& search_album, const int cover_art_limit); + void fetchCoverArtURLs(); + QMap cover_art_urls; + +private: + QString search_artist; + QString search_album; + int cover_art_limit; + +signals: + void finished(); + +}; + +#endif + diff --git a/widgets/cddaheaderwidget.cpp b/widgets/cddaheaderwidget.cpp index c3f31809..a8b7055e 100644 --- a/widgets/cddaheaderwidget.cpp +++ b/widgets/cddaheaderwidget.cpp @@ -388,9 +388,9 @@ void CDDAHeaderWidget::setEnabled(bool enabled) { repaint(); } -void CDDAHeaderWidget::googleAuto() { +void CDDAHeaderWidget::musicBrainzAuto() { - qDebug() << "Google AUTO cover fetch" ; + qDebug() << "MusicBrainz AUTO cover fetch" ; if ((cdda_model->empty()) || (fetching_cover_in_progress)) return; @@ -411,7 +411,7 @@ void CDDAHeaderWidget::googleAuto() { title = title.left(lastColonPos); lastColonPos = title.lastIndexOf(':'); } - cover_browser_dialog->fetchThumbnails(QString("%1 %2").arg(artist).arg(title), 1); + cover_browser_dialog->fetchThumbnails(artist, title, 1); } @@ -564,13 +564,13 @@ void CDDAHeaderWidget::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { if ((cursor_on_cover) && (!fetching_cover_in_progress)) { if (cdda_model->isCoverEmpty()) { - if (cdda_model->empty()) { - load(); - } else { - google(); - } + if (cdda_model->empty()) { + load(); + } else { + musicbrainz(); + } } else { - view_cover(); + view_cover(); } } if (cursor_on_link1) edit_data(); @@ -608,16 +608,16 @@ void CDDAHeaderWidget::trigger_repaint() { scale_factor -= 0.08; if (qFuzzyCompare(scale_factor, .7) || scale_factor < .7) { scale_down = false; - fade_out = true; + fade_out = true; } } else if (fade_out) { opacity_factor -= 0.16; if (qFuzzyCompare(opacity_factor, 0) || opacity_factor < 0) { opacity_factor = 0; - fade_out = false; - animation_down = false; - timer.stop(); - emit coverDown(); + fade_out = false; + animation_down = false; + timer.stop(); + emit coverDown(); } } @@ -627,16 +627,16 @@ void CDDAHeaderWidget::trigger_repaint() { opacity_factor += 0.16; if (qFuzzyCompare(opacity_factor, 1) || opacity_factor > 1) { opacity_factor = 1; - fade_in = false; - scale_up = true; + fade_in = false; + scale_up = true; } } else if (scale_up) { scale_factor += 0.08; if (qFuzzyCompare(scale_factor, 1) || scale_factor > 1) { scale_up = false; - animation_up = false; - timer.stop(); - emit coverUp(); + animation_up = false; + timer.stop(); + emit coverUp(); } } @@ -655,9 +655,9 @@ void CDDAHeaderWidget::cover_is_down() { timer.start(); } -void CDDAHeaderWidget::google() { +void CDDAHeaderWidget::musicbrainz() { - qDebug() << "Google cover fetch" ; + qDebug() << "MusicBrainz cover fetch" ; if ((cdda_model->empty()) || (fetching_cover_in_progress)) return; @@ -678,7 +678,7 @@ void CDDAHeaderWidget::google() { title = title.left(lastColonPos); lastColonPos = title.lastIndexOf(':'); } - cover_browser_dialog->fetchThumbnails(QString("%1 %2").arg(artist).arg(title)); + cover_browser_dialog->fetchThumbnails(artist, title); if (cover_browser_dialog->exec() != QDialog::Accepted) { fetching_cover_in_progress = false; @@ -836,9 +836,9 @@ void CDDAHeaderWidget::setup_actions() { action_collection = new KActionCollection(this); QAction * fetchCoverAction = new QAction(this); - fetchCoverAction->setText(i18n("Fetch cover from Google...")); + fetchCoverAction->setText(i18n("Fetch cover from MusicBrainz...")); action_collection->addAction("fetch", fetchCoverAction); - connect(fetchCoverAction, SIGNAL(triggered(bool)), this, SLOT(google())); + connect(fetchCoverAction, SIGNAL(triggered(bool)), this, SLOT(musicbrainz())); QAction * loadCoverAction = new QAction(this); loadCoverAction->setText(i18n("Set Custom Cover...")); diff --git a/widgets/cddaheaderwidget.h b/widgets/cddaheaderwidget.h index f3865a71..8d5be6b9 100644 --- a/widgets/cddaheaderwidget.h +++ b/widgets/cddaheaderwidget.h @@ -80,7 +80,7 @@ class CDDAHeaderWidget : public QWidget { public slots: void setEnabled(bool enabled); - void googleAuto(); + void musicBrainzAuto(); signals: void headerDataChanged(); @@ -101,7 +101,7 @@ private slots: void trigger_repaint(); void cover_is_down(); - void google(); + void musicbrainz(); void load(); void save(); void view_cover();