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

(fix) Library track menu: show Hide action also in Playlist & Crates #11901

Merged
merged 1 commit into from
Apr 23, 2024
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
6 changes: 4 additions & 2 deletions src/library/playlisttablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ TrackModel::Capabilities PlaylistTableModel::getCapabilities() const {
Capability::LoadToPreviewDeck |
Capability::ResetPlayed |
Capability::RemoveFromDisk |
Capability::Hide |
Capability::Analyze;

if (m_iPlaylistId !=
Expand All @@ -382,8 +383,9 @@ TrackModel::Capabilities PlaylistTableModel::getCapabilities() const {
if (m_pTrackCollectionManager->internalCollection()
->getPlaylistDAO()
.getHiddenType(m_iPlaylistId) == PlaylistDAO::PLHT_SET_LOG) {
// Disable track reordering and adding tracks via drag'n'drop for history playlists
caps &= ~(Capability::ReceiveDrops | Capability::Reorder);
// Disallow reordering and hiding tracks, as well as adding tracks via
// drag'n'drop for history playlists
caps &= ~(Capability::ReceiveDrops | Capability::Reorder | Capability::Hide);
}
bool locked = m_pTrackCollectionManager->internalCollection()->getPlaylistDAO().isPlaylistLocked(m_iPlaylistId);
if (locked) {
Expand Down
1 change: 1 addition & 0 deletions src/library/trackset/crate/cratetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ TrackModel::Capabilities CrateTableModel::getCapabilities() const {
Capability::LoadToPreviewDeck |
Capability::RemoveCrate |
Capability::ResetPlayed |
Capability::Hide |
Capability::RemoveFromDisk |
Capability::Analyze;

Expand Down
11 changes: 7 additions & 4 deletions src/widget/wtrackmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ void WTrackMenu::createActions() {
m_pHideAct = new QAction(tr("Hide from Library"), this);
// This is just for having the shortcut displayed next to the action in the menu.
// The actual keypress is handled in WTrackTableView::keyPressEvent().
m_pHideAct->setShortcut(hideRemoveKeySequence);
// Note: don't show the hotkey for more than one action
if (!featureIsEnabled(Feature::Remove)) {
m_pHideAct->setShortcut(hideRemoveKeySequence);
}
connect(m_pHideAct, &QAction::triggered, this, &WTrackMenu::slotHide);

m_pUnhideAct = new QAction(tr("Unhide from Library"), this);
Expand Down Expand Up @@ -1001,9 +1004,9 @@ void WTrackMenu::updateMenus() {

if (featureIsEnabled(Feature::HideUnhidePurge)) {
bool locked = m_pTrackModel->hasCapabilities(TrackModel::Capability::Locked);
if (m_pTrackModel->hasCapabilities(TrackModel::Capability::Hide)) {
m_pHideAct->setEnabled(!locked);
}
// Note: Hide action is enabled regardless the locked state.
// Like in Tracks, in locked playlists A confirmation dialog pops up:
// "Hiding track ... will remove it from the following playlists: ..."
if (m_pTrackModel->hasCapabilities(TrackModel::Capability::Unhide)) {
m_pUnhideAct->setEnabled(!locked);
}
Expand Down
27 changes: 20 additions & 7 deletions src/widget/wtracktableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,22 +913,35 @@ void WTrackTableView::hideOrRemoveSelectedTracks() {
}

TrackModel::Capability cap;
// Hide is the primary action if allowed. Else we test for remove capability
if (pTrackModel->hasCapabilities(TrackModel::Capability::Hide)) {
cap = TrackModel::Capability::Hide;
} else if (pTrackModel->isLocked()) { // Locked playlists and crates
return;
}
// Remove is the primary action if allowed (playlists and crates).
// Else we test for remove capability.
// In the track menu the hotkey is shown for 'Remove ..' actions, or if there
// is no remove action, for 'Hide ..'. Hence, to match the hotkey, do Hide
// only if the track model doesn't support any Remove actions.
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 if (pTrackModel->hasCapabilities(TrackModel::Capability::Hide)) {
cap = TrackModel::Capability::Hide;
} else { // Locked playlists and crates
return;
}

switch (cap) {
case TrackModel::Capability::Remove:
case TrackModel::Capability::RemoveCrate:
case TrackModel::Capability::RemovePlaylist: {
if (pTrackModel->isLocked()) {
return;
}
default:
break;
}
}

if (pTrackModel->getRequireConfirmationToHideRemoveTracks()) {
QString title;
QString message;
Expand Down
Loading