Skip to content

Commit

Permalink
Library track menu: show Hide action also in Playlist & Crates
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Aug 30, 2023
1 parent 32ee9ed commit 542b76a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/library/playlisttablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ TrackModel::Capabilities PlaylistTableModel::getCapabilities() const {
Capability::LoadToSampler |
Capability::LoadToPreviewDeck |
Capability::ResetPlayed |
Capability::Hide |
Capability::Analyze;

if (m_iPlaylistId !=
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
5 changes: 4 additions & 1 deletion src/widget/wtrackmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,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
9 changes: 6 additions & 3 deletions src/widget/wtracktableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -856,14 +856,17 @@ void WTrackTableView::hideOrRemoveSelectedTracks() {
}

TrackModel::Capability cap;
if (pTrackModel->hasCapabilities(TrackModel::Capability::Hide)) {
cap = TrackModel::Capability::Hide;
} else if (pTrackModel->hasCapabilities(TrackModel::Capability::Remove)) {
// 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 if (pTrackModel->hasCapabilities(TrackModel::Capability::Hide)) {
cap = TrackModel::Capability::Hide;
} else {
return;
}
Expand Down

0 comments on commit 542b76a

Please sign in to comment.