From c069700191d8b16f04c5a9c72ba9ea2f9c419f70 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Thu, 7 Sep 2023 17:06:16 +0200 Subject: [PATCH 1/3] Tag Fetcher: h-center covers and labels, adjust layout names --- src/library/dlgtagfetcher.ui | 53 +++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/library/dlgtagfetcher.ui b/src/library/dlgtagfetcher.ui index aad93e9b0ad..af628806011 100644 --- a/src/library/dlgtagfetcher.ui +++ b/src/library/dlgtagfetcher.ui @@ -137,6 +137,12 @@ + + + 1 + 1 + + QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed @@ -194,6 +200,9 @@ 0 + + Qt::AlignCenter + QLabel { font-weight: bold; } @@ -205,12 +214,15 @@ - + 250 250 + + Qt::AlignCenter + 0 @@ -229,9 +241,6 @@ 0 - - Qt::AlignRight|Qt::AlignTop|Qt::AlignCenter - @@ -243,6 +252,9 @@ 0 + + Qt::AlignCenter + QLabel { font-weight: bold; } @@ -254,12 +266,15 @@ - + 250 250 + + Qt::AlignCenter + 0 @@ -278,9 +293,6 @@ 0 - - Qt::AlignRight|Qt::AlignBottom|Qt::AlignCenter - @@ -289,12 +301,6 @@ Qt::Vertical - - - 20 - 40 - - @@ -304,9 +310,9 @@ - + - + QLayout::SetMaximumSize @@ -317,14 +323,17 @@ - + - + 0 0 + + Qt::AlignCenter + Qt::LeftToRight @@ -355,14 +364,8 @@ - + - - - 80 - 16777215 - - Retry From 3b32eff5297cbd6933bdea8fec27363bc750aeed Mon Sep 17 00:00:00 2001 From: ronso0 Date: Thu, 7 Sep 2023 17:07:13 +0200 Subject: [PATCH 2/3] Tag Fetcher: allow to apply only found cover --- src/library/dlgtagfetcher.cpp | 32 ++++++++++++++++++++++---------- src/library/dlgtagfetcher.h | 3 ++- src/library/dlgtagfetcher.ui | 10 +++++++++- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/library/dlgtagfetcher.cpp b/src/library/dlgtagfetcher.cpp index ca123c57312..33f5249bb30 100644 --- a/src/library/dlgtagfetcher.cpp +++ b/src/library/dlgtagfetcher.cpp @@ -142,7 +142,8 @@ void DlgTagFetcher::init() { btnPrev->hide(); } - connect(btnApply, &QPushButton::clicked, this, &DlgTagFetcher::apply); + connect(btnApply, &QPushButton::clicked, this, &DlgTagFetcher::applyTagsAndCover); + connect(btnApplyCover, &QPushButton::clicked, this, &DlgTagFetcher::applyCover); connect(btnQuit, &QPushButton::clicked, this, &DlgTagFetcher::quit); connect(btnRetry, &QPushButton::clicked, this, &DlgTagFetcher::retry); connect(tags, &QTreeWidget::currentItemChanged, this, &DlgTagFetcher::tagSelected); @@ -234,6 +235,7 @@ void DlgTagFetcher::loadTrack(const TrackPointer& pTrack) { btnRetry->setDisabled(true); btnApply->setDisabled(true); + btnApplyCover->setDisabled(true); statusMessage->setVisible(false); loadingProgressBar->setVisible(true); loadingProgressBar->setValue(kMinimumValueOfQProgressBar); @@ -261,7 +263,7 @@ void DlgTagFetcher::slotTrackChanged(TrackId trackId) { } } -void DlgTagFetcher::apply() { +void DlgTagFetcher::applyTagsAndCover() { int tagIndex = m_data.m_selectedTag; if (tagIndex < 0) { return; @@ -325,6 +327,19 @@ void DlgTagFetcher::apply() { } #endif // __EXTRA_METADATA__ + applyCover(); + + statusMessage->setText(tr("Selected metadata applied")); + + m_pTrack->replaceMetadataFromSource( + std::move(trackMetadata), + // Prevent re-import of outdated metadata from file tags + // by explicitly setting the synchronization time stamp + // to the current time. + QDateTime::currentDateTimeUtc()); +} + +void DlgTagFetcher::applyCover() { if (!m_fetchedCoverArtByteArrays.isNull()) { VERIFY_OR_DEBUG_ASSERT(m_isCoverArtCopyWorkerRunning == false) { return; @@ -371,19 +386,13 @@ void DlgTagFetcher::apply() { m_pWorker->start(); } - statusMessage->setText(tr("Selected metadata applied")); - - m_pTrack->replaceMetadataFromSource( - std::move(trackMetadata), - // Prevent re-import of outdated metadata from file tags - // by explicitly setting the synchronization time stamp - // to the current time. - QDateTime::currentDateTimeUtc()); + statusMessage->setText(tr("Selected cover art applied")); } void DlgTagFetcher::retry() { btnRetry->setDisabled(true); btnApply->setDisabled(true); + btnApplyCover->setDisabled(true); loadingProgressBar->setValue(kMinimumValueOfQProgressBar); m_tagFetcher.startFetch(m_pTrack); } @@ -434,6 +443,7 @@ void DlgTagFetcher::fetchTagFinished( return; } else { btnApply->setEnabled(true); + btnApplyCover->setEnabled(true); btnRetry->setEnabled(false); loadingProgressBar->setVisible(false); statusMessage->setVisible(true); @@ -589,6 +599,8 @@ void DlgTagFetcher::slotLoadBytesToLabel(const QByteArray& data) { m_pWFetchedCoverArtLabel->loadData( m_fetchedCoverArtByteArrays); // This data loaded because for full size. m_pWFetchedCoverArtLabel->setCoverArt(coverInfo, fetchedCoverArtPixmap); + + btnApplyCover->setEnabled(!data.isNull()); } void DlgTagFetcher::getCoverArt(const QString& url) { diff --git a/src/library/dlgtagfetcher.h b/src/library/dlgtagfetcher.h index 50be9e6ce48..c50a659eca0 100644 --- a/src/library/dlgtagfetcher.h +++ b/src/library/dlgtagfetcher.h @@ -47,7 +47,8 @@ class DlgTagFetcher : public QDialog, public Ui::DlgTagFetcher { void slotNetworkResult(int httpStatus, const QString& app, const QString& message, int code); // Called when apply is pressed. void slotTrackChanged(TrackId trackId); - void apply(); + void applyTagsAndCover(); + void applyCover(); void retry(); void quit(); void reject() override; diff --git a/src/library/dlgtagfetcher.ui b/src/library/dlgtagfetcher.ui index af628806011..acb163cc4d8 100644 --- a/src/library/dlgtagfetcher.ui +++ b/src/library/dlgtagfetcher.ui @@ -297,7 +297,14 @@ - + + + Apply Cover + + + + + Qt::Vertical @@ -428,6 +435,7 @@ submit_tree btnPrev btnNext + btnApplyCover btnApply btnQuit btnRetry From efe82faabda4a9a837230d195c97e7981ce25e55 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Wed, 27 Sep 2023 23:28:31 +0200 Subject: [PATCH 3/3] Tag Fetcher: enable apply buttons only if there's a valid tag set or cover --- src/library/dlgtagfetcher.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/library/dlgtagfetcher.cpp b/src/library/dlgtagfetcher.cpp index 33f5249bb30..cb2c849225e 100644 --- a/src/library/dlgtagfetcher.cpp +++ b/src/library/dlgtagfetcher.cpp @@ -166,6 +166,7 @@ void DlgTagFetcher::init() { loadingProgressBar->setMaximum(kMaximumValueOfQProgressBar); btnRetry->setDisabled(true); + btnApplyCover->setDisabled(true); CoverArtCache* pCache = CoverArtCache::instance(); if (pCache) { @@ -329,14 +330,14 @@ void DlgTagFetcher::applyTagsAndCover() { applyCover(); - statusMessage->setText(tr("Selected metadata applied")); - m_pTrack->replaceMetadataFromSource( std::move(trackMetadata), // Prevent re-import of outdated metadata from file tags // by explicitly setting the synchronization time stamp // to the current time. QDateTime::currentDateTimeUtc()); + + statusMessage->setText(tr("Selected metadata applied")); } void DlgTagFetcher::applyCover() { @@ -442,9 +443,9 @@ void DlgTagFetcher::fetchTagFinished( loadingProgressBar->setFormat(emptyMessage); return; } else { - btnApply->setEnabled(true); - btnApplyCover->setEnabled(true); - btnRetry->setEnabled(false); + btnApply->setDisabled(true); + btnApplyCover->setDisabled(true); + btnRetry->setDisabled(true); loadingProgressBar->setVisible(false); statusMessage->setVisible(true); @@ -524,6 +525,7 @@ void DlgTagFetcher::tagSelected() { m_pWFetchedCoverArtLabel->loadData(QByteArray()); m_pWFetchedCoverArtLabel->setCoverArt(CoverInfo{}, QPixmap(CoverArtUtils::defaultCoverLocation())); + btnApplyCover->setDisabled(true); const mixxx::musicbrainz::TrackRelease& trackRelease = m_data.m_tags[tagIndex]; QUuid selectedTagAlbumId = trackRelease.albumReleaseId; @@ -592,7 +594,7 @@ void DlgTagFetcher::slotLoadBytesToLabel(const QByteArray& data) { coverInfo.setImage(); loadingProgressBar->setVisible(false); - statusMessage->setText(tr("Cover art is ready to be applied")); + statusMessage->clear(); statusMessage->setVisible(true); m_fetchedCoverArtByteArrays = data; @@ -600,7 +602,7 @@ void DlgTagFetcher::slotLoadBytesToLabel(const QByteArray& data) { m_fetchedCoverArtByteArrays); // This data loaded because for full size. m_pWFetchedCoverArtLabel->setCoverArt(coverInfo, fetchedCoverArtPixmap); - btnApplyCover->setEnabled(!data.isNull()); + btnApplyCover->setDisabled(data.isNull()); } void DlgTagFetcher::getCoverArt(const QString& url) {