From 9fadb20b701c09288c09b86771e4875ebddae7eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nino=20Mi=C5=A1ki=C4=87-Pletenac?= Date: Wed, 21 Dec 2022 23:00:00 +0100 Subject: [PATCH] Sidebar: Cache AutoDJ feature title --- src/library/autodj/autodjfeature.cpp | 11 +++++++++-- src/library/autodj/autodjfeature.h | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/library/autodj/autodjfeature.cpp b/src/library/autodj/autodjfeature.cpp index d80f789c2e8..3e923211ea4 100644 --- a/src/library/autodj/autodjfeature.cpp +++ b/src/library/autodj/autodjfeature.cpp @@ -109,6 +109,8 @@ AutoDJFeature::AutoDJFeature(Library* pLibrary, &QAction::triggered, this, &AutoDJFeature::slotRemoveCrateFromAutoDj); + + updateTitle(); } AutoDJFeature::~AutoDJFeature() { @@ -117,6 +119,10 @@ AutoDJFeature::~AutoDJFeature() { } QVariant AutoDJFeature::title() { + return m_title; +} + +void AutoDJFeature::updateTitle() { QString title = tr("Auto DJ"); PlaylistSummary summary; @@ -127,7 +133,8 @@ QVariant AutoDJFeature::title() { summary.getTrackDurationText())); } - return title; + m_title = title; + emit featureIsLoading(this, false); } void AutoDJFeature::bindLibraryWidget( @@ -343,6 +350,6 @@ void AutoDJFeature::slotPlaylistsChanged(const QSet& playlistIds) { if (playlistIds.contains(m_iAutoDJPlaylistId)) { // If AutoDJ playlist was changed, notify that feature title has changed // since it contains duration of the AutoDJ playlist. - emit featureIsLoading(this, false); + updateTitle(); } } diff --git a/src/library/autodj/autodjfeature.h b/src/library/autodj/autodjfeature.h index 1a1eb3568e8..cd85de3c4ed 100644 --- a/src/library/autodj/autodjfeature.h +++ b/src/library/autodj/autodjfeature.h @@ -84,6 +84,10 @@ class AutoDJFeature : public LibraryFeature { QPointer m_pSidebarWidget; + QString m_title; + + void updateTitle(); + private slots: // Add a crate to the auto-DJ queue. void slotAddCrateToAutoDj(int iCrateId);