From 6aab30ed73cce1943dd03b3233d4fecea6ec8877 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Fri, 8 Apr 2022 21:16:20 +0200 Subject: [PATCH 1/5] WTrackMenu: add UpdateReplayGain only if instantiated by track widgets --- src/widget/wtrackmenu.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/widget/wtrackmenu.cpp b/src/widget/wtrackmenu.cpp index 7d3e3895103..5418a7d5d4a 100644 --- a/src/widget/wtrackmenu.cpp +++ b/src/widget/wtrackmenu.cpp @@ -384,7 +384,10 @@ void WTrackMenu::createActions() { &WTrackMenu::slotClearBeats); } - if (featureIsEnabled(Feature::UpdateReplayGain)) { + // This action is only usable when m_deckGroup is set. That is true only + // for WTrackmenu instantiated by WTrackProperty and other deck widgets, thus + // don't create it if a track model is set. + if (!m_pTrackModel && featureIsEnabled(Feature::UpdateReplayGain)) { m_pUpdateReplayGain = new QAction(tr("Update ReplayGain from Deck Gain"), m_pClearMetadataMenu); connect(m_pUpdateReplayGain, @@ -526,7 +529,9 @@ void WTrackMenu::setupActions() { addMenu(m_pClearMetadataMenu); } - if (featureIsEnabled(Feature::UpdateReplayGain)) { + // This action is created only for menus instantiated by deck widgets (e.g. + // WTrackProperty) and if UpdateReplayGain is supported. + if (m_pUpdateReplayGain) { addAction(m_pUpdateReplayGain); } @@ -763,7 +768,10 @@ void WTrackMenu::updateMenus() { } } - if (featureIsEnabled(Feature::UpdateReplayGain)) { + // This action is created only for menus instantiated by deck widgets (e.g. + // WTrackProperty) and if UpdateReplayGain is supported. + // Disable it if no deck group was set. + if (m_pUpdateReplayGain) { m_pUpdateReplayGain->setEnabled(!m_deckGroup.isEmpty()); } From 95b043aee3ccc8f3f312ae777370daf7dd95ba99 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Fri, 8 Apr 2022 21:17:05 +0200 Subject: [PATCH 2/5] WTrackMenu: fix header format --- src/widget/wtrackmenu.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/widget/wtrackmenu.h b/src/widget/wtrackmenu.h index 2b635993427..074e3015105 100644 --- a/src/widget/wtrackmenu.h +++ b/src/widget/wtrackmenu.h @@ -289,14 +289,15 @@ class WTrackMenu : public QMenu { struct UpdateExternalTrackCollection { QPointer externalTrackCollection; QAction* action{}; - }; - QList m_updateInExternalTrackCollections; + }; - bool m_bPlaylistMenuLoaded; - bool m_bCrateMenuLoaded; + QList m_updateInExternalTrackCollections; - Features m_eActiveFeatures; - const Features m_eTrackModelFeatures; - }; + bool m_bPlaylistMenuLoaded; + bool m_bCrateMenuLoaded; + + Features m_eActiveFeatures; + const Features m_eTrackModelFeatures; +}; Q_DECLARE_OPERATORS_FOR_FLAGS(WTrackMenu::Features) From a3286f192665ae93813752f1b2ed4be28e758204 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Fri, 8 Apr 2022 22:12:24 +0200 Subject: [PATCH 3/5] Revert "WTrackMenu::featureIsEnabled(): Fix unhandled case" This reverts commit 576e2cf97fbdb1e2e17ed5bb921f31158e4d0667. --- src/widget/wtrackmenu.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/widget/wtrackmenu.cpp b/src/widget/wtrackmenu.cpp index 5418a7d5d4a..a9da4c1f4d4 100644 --- a/src/widget/wtrackmenu.cpp +++ b/src/widget/wtrackmenu.cpp @@ -2106,8 +2106,6 @@ bool WTrackMenu::featureIsEnabled(Feature flag) const { return m_pTrackModel->hasCapabilities(TrackModel::Capability::EditMetadata); case Feature::SearchRelated: return m_pLibrary != nullptr; - case Feature::UpdateReplayGain: - return m_pTrackModel->hasCapabilities(TrackModel::Capability::EditMetadata); default: DEBUG_ASSERT(!"unreachable"); return false; From 49207caeabf066d994a0cd8b04ab087052aaf7fe Mon Sep 17 00:00:00 2001 From: ronso0 Date: Wed, 13 Apr 2022 22:03:17 +0200 Subject: [PATCH 4/5] WTrackMenu: rename m_pUpdateReplayGain > m_pUpdateReplayGainAct --- src/widget/wtrackmenu.cpp | 12 ++++++------ src/widget/wtrackmenu.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/widget/wtrackmenu.cpp b/src/widget/wtrackmenu.cpp index a9da4c1f4d4..2f2058271b4 100644 --- a/src/widget/wtrackmenu.cpp +++ b/src/widget/wtrackmenu.cpp @@ -388,9 +388,9 @@ void WTrackMenu::createActions() { // for WTrackmenu instantiated by WTrackProperty and other deck widgets, thus // don't create it if a track model is set. if (!m_pTrackModel && featureIsEnabled(Feature::UpdateReplayGain)) { - m_pUpdateReplayGain = + m_pUpdateReplayGainAct = new QAction(tr("Update ReplayGain from Deck Gain"), m_pClearMetadataMenu); - connect(m_pUpdateReplayGain, + connect(m_pUpdateReplayGainAct, &QAction::triggered, this, &WTrackMenu::slotUpdateReplayGainFromPregain); @@ -531,8 +531,8 @@ void WTrackMenu::setupActions() { // This action is created only for menus instantiated by deck widgets (e.g. // WTrackProperty) and if UpdateReplayGain is supported. - if (m_pUpdateReplayGain) { - addAction(m_pUpdateReplayGain); + if (m_pUpdateReplayGainAct) { + addAction(m_pUpdateReplayGainAct); } addSeparator(); @@ -771,8 +771,8 @@ void WTrackMenu::updateMenus() { // This action is created only for menus instantiated by deck widgets (e.g. // WTrackProperty) and if UpdateReplayGain is supported. // Disable it if no deck group was set. - if (m_pUpdateReplayGain) { - m_pUpdateReplayGain->setEnabled(!m_deckGroup.isEmpty()); + if (m_pUpdateReplayGainAct) { + m_pUpdateReplayGainAct->setEnabled(!m_deckGroup.isEmpty()); } if (featureIsEnabled(Feature::Color)) { diff --git a/src/widget/wtrackmenu.h b/src/widget/wtrackmenu.h index 074e3015105..74b773bd4d7 100644 --- a/src/widget/wtrackmenu.h +++ b/src/widget/wtrackmenu.h @@ -220,7 +220,7 @@ class WTrackMenu : public QMenu { QMenu* m_pRemoveFromDiskMenu{}; // Update ReplayGain from Track - QAction* m_pUpdateReplayGain{}; + QAction* m_pUpdateReplayGainAct{}; // Reload Track Metadata Action: QAction* m_pImportMetadataFromFileAct{}; From 1c64319766b39fd0dbcf7341f5cde9d1148ad7d0 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Thu, 14 Apr 2022 01:18:11 +0200 Subject: [PATCH 5/5] WTrackMenu: rename feature UpdateReplayGain > UpdateReplayGainFromPregain --- src/widget/wtrackmenu.cpp | 6 +++--- src/widget/wtrackmenu.h | 4 ++-- src/widget/wtrackproperty.cpp | 2 +- src/widget/wtracktext.cpp | 2 +- src/widget/wtrackwidgetgroup.cpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/widget/wtrackmenu.cpp b/src/widget/wtrackmenu.cpp index 2f2058271b4..1dae22dd2f6 100644 --- a/src/widget/wtrackmenu.cpp +++ b/src/widget/wtrackmenu.cpp @@ -387,7 +387,7 @@ void WTrackMenu::createActions() { // This action is only usable when m_deckGroup is set. That is true only // for WTrackmenu instantiated by WTrackProperty and other deck widgets, thus // don't create it if a track model is set. - if (!m_pTrackModel && featureIsEnabled(Feature::UpdateReplayGain)) { + if (!m_pTrackModel && featureIsEnabled(Feature::UpdateReplayGainFromPregain)) { m_pUpdateReplayGainAct = new QAction(tr("Update ReplayGain from Deck Gain"), m_pClearMetadataMenu); connect(m_pUpdateReplayGainAct, @@ -530,7 +530,7 @@ void WTrackMenu::setupActions() { } // This action is created only for menus instantiated by deck widgets (e.g. - // WTrackProperty) and if UpdateReplayGain is supported. + // WTrackProperty) and if UpdateReplayGainFromPregain is supported. if (m_pUpdateReplayGainAct) { addAction(m_pUpdateReplayGainAct); } @@ -769,7 +769,7 @@ void WTrackMenu::updateMenus() { } // This action is created only for menus instantiated by deck widgets (e.g. - // WTrackProperty) and if UpdateReplayGain is supported. + // WTrackProperty) and if UpdateReplayGainFromPregain is supported. // Disable it if no deck group was set. if (m_pUpdateReplayGainAct) { m_pUpdateReplayGainAct->setEnabled(!m_deckGroup.isEmpty()); diff --git a/src/widget/wtrackmenu.h b/src/widget/wtrackmenu.h index 74b773bd4d7..c85d6fd5c2d 100644 --- a/src/widget/wtrackmenu.h +++ b/src/widget/wtrackmenu.h @@ -49,11 +49,11 @@ class WTrackMenu : public QMenu { FileBrowser = 1 << 11, Properties = 1 << 12, SearchRelated = 1 << 13, - UpdateReplayGain = 1 << 14, + UpdateReplayGainFromPregain = 1 << 14, TrackModelFeatures = Remove | HideUnhidePurge, All = AutoDJ | LoadTo | Playlist | Crate | Remove | Metadata | Reset | BPM | Color | HideUnhidePurge | RemoveFromDisk | FileBrowser | - Properties | SearchRelated | UpdateReplayGain + Properties | SearchRelated | UpdateReplayGainFromPregain }; Q_DECLARE_FLAGS(Features, Feature) diff --git a/src/widget/wtrackproperty.cpp b/src/widget/wtrackproperty.cpp index 580fc8b8576..2b0ac29f8de 100644 --- a/src/widget/wtrackproperty.cpp +++ b/src/widget/wtrackproperty.cpp @@ -21,7 +21,7 @@ constexpr WTrackMenu::Features kTrackMenuFeatures = WTrackMenu::Feature::RemoveFromDisk | WTrackMenu::Feature::FileBrowser | WTrackMenu::Feature::Properties | - WTrackMenu::Feature::UpdateReplayGain; + WTrackMenu::Feature::UpdateReplayGainFromPregain; } // namespace WTrackProperty::WTrackProperty( diff --git a/src/widget/wtracktext.cpp b/src/widget/wtracktext.cpp index 93db0d62ff9..e54213494c0 100644 --- a/src/widget/wtracktext.cpp +++ b/src/widget/wtracktext.cpp @@ -20,7 +20,7 @@ constexpr WTrackMenu::Features kTrackMenuFeatures = WTrackMenu::Feature::Color | WTrackMenu::Feature::FileBrowser | WTrackMenu::Feature::Properties | - WTrackMenu::Feature::UpdateReplayGain; + WTrackMenu::Feature::UpdateReplayGainFromPregain; } // namespace WTrackText::WTrackText(QWidget* pParent, diff --git a/src/widget/wtrackwidgetgroup.cpp b/src/widget/wtrackwidgetgroup.cpp index ebdb9adfd3a..b27305b15cd 100644 --- a/src/widget/wtrackwidgetgroup.cpp +++ b/src/widget/wtrackwidgetgroup.cpp @@ -24,7 +24,7 @@ constexpr WTrackMenu::Features kTrackMenuFeatures = WTrackMenu::Feature::Color | WTrackMenu::Feature::FileBrowser | WTrackMenu::Feature::Properties | - WTrackMenu::Feature::UpdateReplayGain; + WTrackMenu::Feature::UpdateReplayGainFromPregain; } // anonymous namespace