diff --git a/src/library/trackmodel.h b/src/library/trackmodel.h index ee4ae4dd978..c811114709a 100644 --- a/src/library/trackmodel.h +++ b/src/library/trackmodel.h @@ -25,7 +25,8 @@ class TrackModel { : m_db(db), m_settingsNamespace(settingsNamespace), m_iDefaultSortColumn(-1), - m_eDefaultSortOrder(Qt::AscendingOrder) { + m_eDefaultSortOrder(Qt::AscendingOrder), + m_confirmHideRemoveTracks(true) { } virtual ~TrackModel() {} @@ -219,6 +220,13 @@ class TrackModel { /// @param baseOnly return only a identifier for the whole subsystem virtual QString modelKey(bool noSearch) const = 0; + virtual bool getRequireConfirmationToHideRemoveTracks() { + return m_confirmHideRemoveTracks; + } + virtual void setRequireConfirmationToHideRemoveTracks(bool require) { + m_confirmHideRemoveTracks = require; + } + virtual bool updateTrackGenre( Track* pTrack, const QString& genre) const = 0; @@ -234,5 +242,6 @@ class TrackModel { QList m_emptyColumns; int m_iDefaultSortColumn; Qt::SortOrder m_eDefaultSortOrder; + bool m_confirmHideRemoveTracks; }; Q_DECLARE_OPERATORS_FOR_FLAGS(TrackModel::Capabilities) diff --git a/src/widget/wtracktableview.cpp b/src/widget/wtracktableview.cpp index a77762e7dab..2fa1d34a366 100644 --- a/src/widget/wtracktableview.cpp +++ b/src/widget/wtracktableview.cpp @@ -855,41 +855,70 @@ void WTrackTableView::hideOrRemoveSelectedTracks() { return; } - saveCurrentIndex(); - - QMessageBox::StandardButton response; + TrackModel::Capability cap; if (pTrackModel->hasCapabilities(TrackModel::Capability::Hide)) { - // Hide tracks if this is the main library table - response = QMessageBox::question(this, - tr("Confirm track hide"), - tr("Are you sure you want to hide the selected tracks?"), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No); - if (response == QMessageBox::Yes) { - pTrackModel->hideTracks(indices); - } + cap = TrackModel::Capability::Hide; + } else if (pTrackModel->hasCapabilities(TrackModel::Capability::Remove)) { + cap = TrackModel::Capability::Remove; + } else if (pTrackModel->hasCapabilities(TrackModel::Capability::RemoveCrate)) { + cap = TrackModel::Capability::RemoveCrate; + } else if (pTrackModel->hasCapabilities(TrackModel::Capability::RemovePlaylist)) { + cap = TrackModel::Capability::RemovePlaylist; } else { - // Else remove the tracks from AutoDJ/crate/playlist + return; + } + + if (pTrackModel->getRequireConfirmationToHideRemoveTracks()) { + QString title; QString message; - if (pTrackModel->hasCapabilities(TrackModel::Capability::Remove)) { - message = tr("Are you sure you want to remove the selected tracks from AutoDJ queue?"); - } else if (pTrackModel->hasCapabilities(TrackModel::Capability::RemoveCrate)) { - message = tr("Are you sure you want to remove the selected tracks from this crate?"); - } else if (pTrackModel->hasCapabilities(TrackModel::Capability::RemovePlaylist)) { - message = tr("Are you sure you want to remove the selected tracks from this playlist?"); + if (cap == TrackModel::Capability::Hide) { + // Hide tracks if this is the main library table + title = tr("Confirm track hide"); + message = tr("Are you sure you want to hide the selected tracks?"); } else { + title = tr("Confirm track removal"); + // Else remove the tracks from AutoDJ/crate/playlist + if (cap == TrackModel::Capability::Remove) { + message = + tr("Are you sure you want to remove the selected " + "tracks from AutoDJ queue?"); + } else if (cap == TrackModel::Capability::RemoveCrate) { + message = + tr("Are you sure you want to remove the selected " + "tracks from this crate?"); + } else { // TrackModel::Capability::RemovePlaylist + message = + tr("Are you sure you want to remove the selected " + "tracks from this playlist?"); + } + } + + QMessageBox msg; + msg.setIcon(QMessageBox::Question); + msg.setWindowTitle(title); + msg.setText(message); + QCheckBox notAgainCB(tr("Don't ask again during this session")); + notAgainCB.setCheckState(Qt::Unchecked); + msg.setCheckBox(¬AgainCB); + msg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msg.setDefaultButton(QMessageBox::Cancel); + if (msg.exec() != QMessageBox::Ok) { return; } - response = QMessageBox::question(this, - tr("Confirm track removal"), - message, - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No); - if (response == QMessageBox::Yes) { - pTrackModel->removeTracks(indices); + if (notAgainCB.isChecked()) { + pTrackModel->setRequireConfirmationToHideRemoveTracks(false); } } + + saveCurrentIndex(); + + if (cap == TrackModel::Capability::Hide) { + pTrackModel->hideTracks(indices); + } else { + pTrackModel->removeTracks(indices); + } + restoreCurrentIndex(); }