From d1e37aa582ad9ba8ad24f36deee124584b07cef0 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Mon, 11 Apr 2022 22:11:42 +0200 Subject: [PATCH] WTrackMenu > Reset: add action to clear the comment field --- src/track/track.h | 4 ++++ src/widget/wtrackmenu.cpp | 30 +++++++++++++++++++++++++++++- src/widget/wtrackmenu.h | 2 ++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/track/track.h b/src/track/track.h index e5ff5e9934a..3dcecd7263a 100644 --- a/src/track/track.h +++ b/src/track/track.h @@ -206,6 +206,10 @@ class Track : public QObject { QString getComment() const; // Sets the user commnet void setComment(const QString&); + // Clear comment + void clearComment() { + setComment(QString()); + } // Return composer QString getComposer() const; // Set composer diff --git a/src/widget/wtrackmenu.cpp b/src/widget/wtrackmenu.cpp index 7d3e3895103..13f40891b4c 100644 --- a/src/widget/wtrackmenu.cpp +++ b/src/widget/wtrackmenu.cpp @@ -340,6 +340,9 @@ void WTrackMenu::createActions() { m_pClearWaveformAction = new QAction(tr("Waveform"), m_pClearMetadataMenu); connect(m_pClearWaveformAction, &QAction::triggered, this, &WTrackMenu::slotClearWaveform); + m_pClearCommentAction = new QAction(tr("Comment"), m_pClearMetadataMenu); + connect(m_pClearCommentAction, &QAction::triggered, this, &WTrackMenu::slotClearComment); + m_pClearAllMetadataAction = new QAction(tr("All"), m_pClearMetadataMenu); connect(m_pClearAllMetadataAction, &QAction::triggered, this, &WTrackMenu::slotClearAllMetadata); } @@ -512,11 +515,12 @@ void WTrackMenu::setupActions() { m_pClearMetadataMenu->addAction(m_pClearBeatsAction); m_pClearMetadataMenu->addAction(m_pClearPlayCountAction); m_pClearMetadataMenu->addAction(m_pClearRatingAction); - // FIXME: Why is clearing the loop not working? + m_pClearMetadataMenu->addAction(m_pClearCommentAction); m_pClearMetadataMenu->addAction(m_pClearMainCueAction); m_pClearMetadataMenu->addAction(m_pClearHotCuesAction); m_pClearMetadataMenu->addAction(m_pClearIntroCueAction); m_pClearMetadataMenu->addAction(m_pClearOutroCueAction); + // FIXME: Why is clearing the loop not working? //m_pClearMetadataMenu->addAction(m_pClearLoopAction); m_pClearMetadataMenu->addAction(m_pClearKeyAction); m_pClearMetadataMenu->addAction(m_pClearReplayGainAction); @@ -531,6 +535,7 @@ void WTrackMenu::setupActions() { } addSeparator(); + if (featureIsEnabled(Feature::HideUnhidePurge)) { if (m_pTrackModel->hasCapabilities(TrackModel::Capability::Hide)) { addAction(m_pHideAct); @@ -1466,6 +1471,29 @@ void WTrackMenu::slotClearRating() { namespace { +class ClearCommentTrackPointerOperation : public mixxx::TrackPointerOperation { + private: + void doApply( + const TrackPointer& pTrack) const override { + pTrack->clearComment(); + } +}; + +} // anonymous namespace + +//slot for clearing the comment field of one or more tracks +void WTrackMenu::slotClearComment() { + const auto progressLabelText = + tr("Clearing comment of %n track(s)", "", getTrackCount()); + const auto trackOperator = + ClearCommentTrackPointerOperation(); + applyTrackPointerOperation( + progressLabelText, + &trackOperator); +} + +namespace { + class RemoveCuesOfTypeTrackPointerOperation : public mixxx::TrackPointerOperation { public: explicit RemoveCuesOfTypeTrackPointerOperation(mixxx::CueType cueType) diff --git a/src/widget/wtrackmenu.h b/src/widget/wtrackmenu.h index 2b635993427..c649f24ce1d 100644 --- a/src/widget/wtrackmenu.h +++ b/src/widget/wtrackmenu.h @@ -96,6 +96,7 @@ class WTrackMenu : public QMenu { void slotClearBeats(); void slotClearPlayCount(); void slotClearRating(); + void slotClearComment(); void slotClearMainCue(); void slotClearHotCues(); void slotClearIntroCue(); @@ -276,6 +277,7 @@ class WTrackMenu : public QMenu { QAction* m_pClearOutroCueAction{}; QAction* m_pClearLoopAction{}; QAction* m_pClearWaveformAction{}; + QAction* m_pClearCommentAction{}; QAction* m_pClearKeyAction{}; QAction* m_pClearReplayGainAction{}; QAction* m_pClearAllMetadataAction{};