Skip to content

Commit

Permalink
Merge commit '6eb12c02d2e60e9128cd0d20672b489c3394c155' into select-i…
Browse files Browse the repository at this point in the history
…n-library
  • Loading branch information
ninomp committed Apr 24, 2022
2 parents e0066cd + 6eb12c0 commit d294c9e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
24 changes: 15 additions & 9 deletions src/widget/wtrackmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,13 @@ void WTrackMenu::createActions() {
&WTrackMenu::slotClearBeats);
}

if (featureIsEnabled(Feature::UpdateReplayGain)) {
m_pUpdateReplayGain =
// 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::UpdateReplayGainFromPregain)) {
m_pUpdateReplayGainAct =
new QAction(tr("Update ReplayGain from Deck Gain"), m_pClearMetadataMenu);
connect(m_pUpdateReplayGain,
connect(m_pUpdateReplayGainAct,
&QAction::triggered,
this,
&WTrackMenu::slotUpdateReplayGainFromPregain);
Expand Down Expand Up @@ -535,8 +538,10 @@ void WTrackMenu::setupActions() {
addMenu(m_pClearMetadataMenu);
}

if (featureIsEnabled(Feature::UpdateReplayGain)) {
addAction(m_pUpdateReplayGain);
// This action is created only for menus instantiated by deck widgets (e.g.
// WTrackProperty) and if UpdateReplayGainFromPregain is supported.
if (m_pUpdateReplayGainAct) {
addAction(m_pUpdateReplayGainAct);
}

addSeparator();
Expand Down Expand Up @@ -777,8 +782,11 @@ void WTrackMenu::updateMenus() {
}
}

if (featureIsEnabled(Feature::UpdateReplayGain)) {
m_pUpdateReplayGain->setEnabled(!m_deckGroup.isEmpty());
// This action is created only for menus instantiated by deck widgets (e.g.
// WTrackProperty) and if UpdateReplayGainFromPregain is supported.
// Disable it if no deck group was set.
if (m_pUpdateReplayGainAct) {
m_pUpdateReplayGainAct->setEnabled(!m_deckGroup.isEmpty());
}

if (featureIsEnabled(Feature::Color)) {
Expand Down Expand Up @@ -2141,8 +2149,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);
case Feature::SelectInLibrary:
return m_pTrack != nullptr;
default:
Expand Down
21 changes: 11 additions & 10 deletions src/widget/wtrackmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ class WTrackMenu : public QMenu {
FileBrowser = 1 << 11,
Properties = 1 << 12,
SearchRelated = 1 << 13,
UpdateReplayGain = 1 << 14,
UpdateReplayGainFromPregain = 1 << 14,
SelectInLibrary = 1 << 15,
TrackModelFeatures = Remove | HideUnhidePurge,
All = AutoDJ | LoadTo | Playlist | Crate | Remove | Metadata | Reset |
BPM | Color | HideUnhidePurge | RemoveFromDisk | FileBrowser |
Properties | SearchRelated | UpdateReplayGain | SelectInLibrary
Properties | SearchRelated | UpdateReplayGainFromPregain | SelectInLibrary
};
Q_DECLARE_FLAGS(Features, Feature)

Expand Down Expand Up @@ -223,7 +223,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{};
Expand Down Expand Up @@ -296,14 +296,15 @@ class WTrackMenu : public QMenu {
struct UpdateExternalTrackCollection {
QPointer<ExternalTrackCollection> externalTrackCollection;
QAction* action{};
};
QList<UpdateExternalTrackCollection> m_updateInExternalTrackCollections;
};

bool m_bPlaylistMenuLoaded;
bool m_bCrateMenuLoaded;
QList<UpdateExternalTrackCollection> 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)
2 changes: 1 addition & 1 deletion src/widget/wtrackproperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ constexpr WTrackMenu::Features kTrackMenuFeatures =
WTrackMenu::Feature::RemoveFromDisk |
WTrackMenu::Feature::FileBrowser |
WTrackMenu::Feature::Properties |
WTrackMenu::Feature::UpdateReplayGain |
WTrackMenu::Feature::UpdateReplayGainFromPregain |
WTrackMenu::Feature::SelectInLibrary;
} // namespace

Expand Down
2 changes: 1 addition & 1 deletion src/widget/wtracktext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/widget/wtrackwidgetgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d294c9e

Please sign in to comment.