Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WTrackMenu > Reset: add action to clear the comment field #4722

Merged
merged 1 commit into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/track/track.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 29 additions & 1 deletion src/widget/wtrackmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand All @@ -531,6 +535,7 @@ void WTrackMenu::setupActions() {
}

addSeparator();

if (featureIsEnabled(Feature::HideUnhidePurge)) {
if (m_pTrackModel->hasCapabilities(TrackModel::Capability::Hide)) {
addAction(m_pHideAct);
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/widget/wtrackmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class WTrackMenu : public QMenu {
void slotClearBeats();
void slotClearPlayCount();
void slotClearRating();
void slotClearComment();
void slotClearMainCue();
void slotClearHotCues();
void slotClearIntroCue();
Expand Down Expand Up @@ -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{};
Expand Down