Fix show album cover from Tidal

This commit is contained in:
Jonas Kvinge 2018-09-10 21:58:57 +02:00
parent f9379961e9
commit e479e7e113
8 changed files with 31 additions and 8 deletions

View File

@ -856,6 +856,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in
${CMAKE_CURRENT_BINARY_DIR}/version.h) ${CMAKE_CURRENT_BINARY_DIR}/version.h)
qt5_wrap_cpp(MOC ${HEADERS}) qt5_wrap_cpp(MOC ${HEADERS})
qt5_wrap_ui(UIC ${UI}) qt5_wrap_ui(UIC ${UI})
qt5_add_resources(QRC ${RESOURCES}) qt5_add_resources(QRC ${RESOURCES})

View File

@ -2346,7 +2346,7 @@ void MainWindow::UnsetCover() {
} }
void MainWindow::ShowCover() { void MainWindow::ShowCover() {
album_cover_choice_controller_->ShowCover(song_); album_cover_choice_controller_->ShowCover(song_, image_original_);
} }
void MainWindow::SearchCoverAutomatically() { void MainWindow::SearchCoverAutomatically() {

View File

@ -206,6 +206,26 @@ QString AlbumCoverChoiceController::UnsetCover(Song *song) {
void AlbumCoverChoiceController::ShowCover(const 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); QDialog *dialog = new QDialog(this);
dialog->setAttribute(Qt::WA_DeleteOnClose, true); 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(); if (!song.effective_album().isEmpty()) title_text += " - " + song.effective_album();
QLabel *label = new QLabel(dialog); 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 // Add (WxHpx) to the title before possibly resizing
title_text += " (" + QString::number(label->pixmap()->width()) + "x" + QString::number(label->pixmap()->height()) + "px)"; 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) { QString AlbumCoverChoiceController::SaveCover(Song *song, const QDropEvent *e) {
for (const QUrl &url : e->mimeData()->urls()) { for (const QUrl &url : e->mimeData()->urls()) {
const QString filename = url.toLocalFile(); const QString filename = url.toLocalFile();
const QString suffix = QFileInfo(filename).suffix().toLower(); const QString suffix = QFileInfo(filename).suffix().toLower();

View File

@ -101,6 +101,8 @@ class AlbumCoverChoiceController : public QWidget {
// Shows the cover of given song in it's original size. // Shows the cover of given song in it's original size.
void ShowCover(const Song &song); 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 // Search for covers automatically
void SearchCoverAutomatically(const Song &song); void SearchCoverAutomatically(const Song &song);

View File

@ -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('"', "\\\"")); QString query = QString("release:\"%1\" AND artist:\"%2\"").arg(album.trimmed().replace('"', "\\\"")).arg(artist.trimmed().replace('"', "\\\""));
QUrlQuery url_query; QUrlQuery url_query;
url_query.addQueryItem("query", query); url_query.addQueryItem("query", query);
url_query.addQueryItem("limit", "15"); url_query.addQueryItem("limit", "6");
QUrl url(kReleaseSearchUrl); QUrl url(kReleaseSearchUrl);
url.setQuery(url_query); url.setQuery(url_query);
QNetworkRequest request(url); QNetworkRequest request(url);

View File

@ -109,8 +109,7 @@ private:
float m_fader; float m_fader;
}; };
class FancyTabBar : public QWidget class FancyTabBar : public QWidget {
{
Q_OBJECT Q_OBJECT
public: public:
@ -139,7 +138,7 @@ class FancyTabBar : public QWidget
QIcon tabIcon(int index) const {return m_tabs.at(index)->icon; } QIcon tabIcon(int index) const {return m_tabs.at(index)->icon; }
QString tabText(int index) const { return m_tabs.at(index)->text; } 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; QRect tabRect(int index) const;
signals: signals: