diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6f12fbb48..cff5d2827 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -856,6 +856,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h) + qt5_wrap_cpp(MOC ${HEADERS}) qt5_wrap_ui(UIC ${UI}) qt5_add_resources(QRC ${RESOURCES}) diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index f2a072722..84aa00afa 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -2346,7 +2346,7 @@ void MainWindow::UnsetCover() { } void MainWindow::ShowCover() { - album_cover_choice_controller_->ShowCover(song_); + album_cover_choice_controller_->ShowCover(song_, image_original_); } void MainWindow::SearchCoverAutomatically() { diff --git a/src/covermanager/albumcoverchoicecontroller.cpp b/src/covermanager/albumcoverchoicecontroller.cpp index 2b51ae775..9a0c7bf0d 100644 --- a/src/covermanager/albumcoverchoicecontroller.cpp +++ b/src/covermanager/albumcoverchoicecontroller.cpp @@ -206,6 +206,26 @@ QString AlbumCoverChoiceController::UnsetCover(Song *song) { void AlbumCoverChoiceController::ShowCover(const Song &song) { + QPixmap pixmap = AlbumCoverLoader::TryLoadPixmap(song.art_automatic(), song.art_manual(), song.url().toLocalFile()); + ShowCover(song, pixmap); + +} + +void AlbumCoverChoiceController::ShowCover(const Song &song, const QImage image) { + + QUrl url_manual(song.art_manual()); + QUrl url_automatic(song.art_automatic()); + + if (url_manual.isLocalFile() || url_automatic.isLocalFile()) { + QPixmap pixmap = AlbumCoverLoader::TryLoadPixmap(song.art_automatic(), song.art_manual(), song.url().toLocalFile()); + ShowCover(song, pixmap); + } + else if (!image.isNull()) ShowCover(song, QPixmap::fromImage(image)); + +} + +void AlbumCoverChoiceController::ShowCover(const Song &song, const QPixmap &pixmap) { + QDialog *dialog = new QDialog(this); dialog->setAttribute(Qt::WA_DeleteOnClose, true); @@ -214,7 +234,7 @@ void AlbumCoverChoiceController::ShowCover(const Song &song) { if (!song.effective_album().isEmpty()) title_text += " - " + song.effective_album(); QLabel *label = new QLabel(dialog); - label->setPixmap(AlbumCoverLoader::TryLoadPixmap(song.art_automatic(), song.art_manual(), song.url().toLocalFile())); + label->setPixmap(pixmap); // Add (WxHpx) to the title before possibly resizing title_text += " (" + QString::number(label->pixmap()->width()) + "x" + QString::number(label->pixmap()->height()) + "px)"; @@ -329,6 +349,7 @@ bool AlbumCoverChoiceController::CanAcceptDrag(const QDragEnterEvent *e) { QString AlbumCoverChoiceController::SaveCover(Song *song, const QDropEvent *e) { for (const QUrl &url : e->mimeData()->urls()) { + const QString filename = url.toLocalFile(); const QString suffix = QFileInfo(filename).suffix().toLower(); diff --git a/src/covermanager/albumcoverchoicecontroller.h b/src/covermanager/albumcoverchoicecontroller.h index 8e66bf651..81bcd1414 100644 --- a/src/covermanager/albumcoverchoicecontroller.h +++ b/src/covermanager/albumcoverchoicecontroller.h @@ -101,6 +101,8 @@ class AlbumCoverChoiceController : public QWidget { // Shows the cover of given song in it's original size. void ShowCover(const Song &song); + void ShowCover(const Song &song, const QImage image); + void ShowCover(const Song &song, const QPixmap &pixmap); // Search for covers automatically void SearchCoverAutomatically(const Song &song); diff --git a/src/covermanager/musicbrainzcoverprovider.cpp b/src/covermanager/musicbrainzcoverprovider.cpp index e9fd6550a..0e6f5daad 100644 --- a/src/covermanager/musicbrainzcoverprovider.cpp +++ b/src/covermanager/musicbrainzcoverprovider.cpp @@ -55,7 +55,7 @@ bool MusicbrainzCoverProvider::StartSearch(const QString &artist, const QString QString query = QString("release:\"%1\" AND artist:\"%2\"").arg(album.trimmed().replace('"', "\\\"")).arg(artist.trimmed().replace('"', "\\\"")); QUrlQuery url_query; url_query.addQueryItem("query", query); - url_query.addQueryItem("limit", "15"); + url_query.addQueryItem("limit", "6"); QUrl url(kReleaseSearchUrl); url.setQuery(url_query); QNetworkRequest request(url); diff --git a/src/tidal/tidalsearch.cpp b/src/tidal/tidalsearch.cpp index ba0fb20a7..7960a87cb 100644 --- a/src/tidal/tidalsearch.cpp +++ b/src/tidal/tidalsearch.cpp @@ -261,7 +261,7 @@ void TidalSearch::HandleLoadedArt(int id, const QImage &image) { } QImage TidalSearch::ScaleAndPad(const QImage &image) { - + if (image.isNull()) return QImage(); const QSize target_size = QSize(kArtHeight, kArtHeight); diff --git a/src/tidal/tidalsearchview.cpp b/src/tidal/tidalsearchview.cpp index 81917ad58..0354dcfc6 100644 --- a/src/tidal/tidalsearchview.cpp +++ b/src/tidal/tidalsearchview.cpp @@ -274,7 +274,7 @@ void TidalSearchView::SwapModels() { } void TidalSearchView::LazyLoadArt(const QModelIndex &proxy_index) { - + if (!proxy_index.isValid() || proxy_index.model() != front_proxy_) { return; } diff --git a/src/widgets/fancytabwidget.h b/src/widgets/fancytabwidget.h index bcd9dc0e6..df2bd9939 100644 --- a/src/widgets/fancytabwidget.h +++ b/src/widgets/fancytabwidget.h @@ -109,8 +109,7 @@ private: float m_fader; }; -class FancyTabBar : public QWidget -{ +class FancyTabBar : public QWidget { Q_OBJECT public: @@ -139,7 +138,7 @@ class FancyTabBar : public QWidget QIcon tabIcon(int index) const {return m_tabs.at(index)->icon; } QString tabText(int index) const { return m_tabs.at(index)->text; } - int count() const {return m_tabs.count(); } + int count() const { return m_tabs.count(); } QRect tabRect(int index) const; signals: