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

Allow to remove tracks by pressing Delete key #4330

Merged
merged 17 commits into from
Oct 20, 2021

Conversation

ninomp
Copy link
Contributor

@ninomp ninomp commented Sep 28, 2021

This PR is trying to fix a highly requested feature: ability to delete/remove tracks by pressing Delete key on the keyboard.

I have pointed this to 2.3, feel free to re-point to main if you think this should not go to stable branch.

This fixes:

@github-actions github-actions bot added the ui label Sep 28, 2021
@Be-ing Be-ing changed the base branch from 2.3 to main September 28, 2021 00:24
@Be-ing
Copy link
Contributor

Be-ing commented Sep 28, 2021

This is a new feature. It should definitely go to the main branch, not the stable branch.

@ronso0
Copy link
Member

ronso0 commented Sep 28, 2021

It's a new feature for 2.4 : )

@ronso0
Copy link
Member

ronso0 commented Sep 28, 2021

: )

@ninomp
Copy link
Contributor Author

ninomp commented Sep 28, 2021

OK I will rebase.

@ninomp ninomp force-pushed the del-key-to-remove-tracks branch from be02cbb to 490298d Compare September 28, 2021 00:28
@Be-ing Be-ing requested a review from uklotzde September 28, 2021 00:30
Copy link
Contributor

@uklotzde uklotzde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a straightforward and easy extension. Unfortunately, we cannot add it without a command history and undo support.

Situation: You want to quickly start a new search or simply delete the existing search query. Therefore you press Ctrl+A followed by Del. Unfortunately, you didn't notice that the track table was focused instead of the search edit field. Now your carefully crafted playlist or crate is gone, forever. No chance to restore it if you don't have a database backup.

@ronso0
Copy link
Member

ronso0 commented Sep 28, 2021

I think a confirm dialog could prevent that, incl. a checkbox [ ] Remember decision for this session.

@foss-
Copy link
Contributor

foss- commented Sep 28, 2021

Please keep in mind that for macOS laptop keyboards or compact external keyboards there is no del key. ⌘Backspace is what Apple uses in music app as keyboard shortcut to open the delete dialog.

And yes, a confirmation dialog is a requirement for any delete operation.

@ronso0
Copy link
Member

ronso0 commented Oct 2, 2021

@uklotzde
Do you think a warning dialog is sufficient to prevent purging playlists?
Maybe if we don't add the [ ] Remember decision for this session checkbox?
UX would be

  • select tracks
  • hit Del
  • hit Enter (or Esc)

I think requiring Enter is okay because it wouldn't affect the remove workflow much since Del and Enter are close on the keyboard.
And the popup is entirely unexpected if you meant to clear the seach.

Besides: how do you imagine the Undo history to be implemented?

@ronso0
Copy link
Member

ronso0 commented Oct 2, 2021

Idea to extend this feature:
in Tracks Del would hide tracks (incl. the same warning dialog I mentioned above), though I'd appreciate the "Remember decision.." checkbox then because hiding tracks can be reverted.

@ronso0
Copy link
Member

ronso0 commented Oct 3, 2021

@ninomp Please take a look at 7920898 and 68c8941, that's an easy way to show the shortcut in the menu to make it more discoverable.

@ronso0 ronso0 added the library label Oct 3, 2021
@ronso0
Copy link
Member

ronso0 commented Oct 3, 2021

Also, if we want to avoid merge conflicts I could cherry-pick this commit into #4347 and take care of the dialogs and stuff.

@ninomp
Copy link
Contributor Author

ninomp commented Oct 4, 2021

@ronso0 Sorry for delay. I'll try to finish this PR soon(ish), so it could be merged and then you can continue with your PR. Does this work for you?

@ronso0
Copy link
Member

ronso0 commented Oct 4, 2021

Sure, I just noticed that now that I have everything sorted out it would be super easy to incorporate your changes into my PR, as well as taking care of the dialogs.
But if you're still motivated and have time to finish it soonish I won't interfere further, except reviewing, of course ; )

@ninomp
Copy link
Contributor Author

ninomp commented Oct 7, 2021

This is ready for review.

@ronso0
Copy link
Member

ronso0 commented Oct 7, 2021

I'll leave some inline comments, but in general I'd like to know if @uklotzde considers this mergable with the confirmation dialogs instead of the undo history (which is way beyond the scope of this PR, of course).

src/util/defs.h Show resolved Hide resolved
@@ -767,6 +767,30 @@ void WTrackTableView::keyPressEvent(QKeyEvent* event) {
m_pTrackMenu->loadTrackModelIndices(indices);
m_pTrackMenu->slotShowDlgTrackInfo();
}
} else if (event->key() == kHideRemoveShortcutKey) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macOS

if (plibraryTableModel) {
// Hide tracks if this is the main library table
// confirmation dialog
pTrackModel->hideTracks(indices);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here we should also have a confirmation dialog, with the per-session checkbox I mentioned.
This would make the unhide function more discoverable.
What do you think?

// confirmation dialog
QMessageBox::StandardButton response;
response = QMessageBox::question(this,
tr("Confirm removal of track(s)"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tr("Confirm removal of track(s)"),
tr("Confirm track removal"),

to avoid singular/plural complexity?

Comment on lines 786 to 787
tr("Are you sure you want to remove this/these "
"track(s) from this crate/playlist?"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tr("Are you sure you want to remove this/these "
"track(s) from this crate/playlist?"));
tr("Are you sure you want to remove all selected "
"tracks from this crate/playlist?"));

same here?
Also, is it feasible to set QString crateOrPlaylist above, depending on the trackmodel, and use it as argument for this message?

m_pRemoveAct = new QAction(tr("Remove"), this);
m_pRemoveAct->setShortcut(QKeySequence(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we declare a constant for this particular key sequence instead of repeating it literally 4 times?

QMessageBox::StandardButton response;
response = QMessageBox::question(this,
tr("Confirm track removal"),
tr("Are you sure you want to remove all selected tracks from %1?")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work well for all languages? I suggest to use a separate i18n string for each message.

src/widget/wtracktableview.cpp Outdated Show resolved Hide resolved
src/widget/wtracktableview.cpp Outdated Show resolved Hide resolved
@ninomp
Copy link
Contributor Author

ninomp commented Oct 19, 2021

This is ready.

@ronso0
Copy link
Member

ronso0 commented Oct 19, 2021

LGTM
@uklotzde ?

@ronso0
Copy link
Member

ronso0 commented Oct 19, 2021

Squash into one commit to keep the git history clean?

@@ -170,6 +170,9 @@ void WTrackMenu::createMenus() {
}

void WTrackMenu::createActions() {
const QKeySequence hideRemoveKeySequence =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary repetition of the type. Please use const auto.

// 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 selected tracks?"));
Copy link
Contributor

@uklotzde uklotzde Oct 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You use the term "all selected" for the other messages but here only "selected". Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm This is just an oversight. I agree we should be consistent. Which one do you think we should use?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "the" to complete the sentence? Because "all" might be confusing and should be reserved for other use cases.

Copy link
Contributor Author

@ninomp ninomp Oct 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha So you are suggesting that this should read "Are you sure you want to hide the selected tracks?" and the other messages "Are you sure you want to remove the selected tracks from ..."?

@ninomp
Copy link
Contributor Author

ninomp commented Oct 19, 2021

This is again ready.

Copy link
Contributor

@uklotzde uklotzde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! LGTM

@uklotzde uklotzde merged commit 11fcfcd into mixxxdj:main Oct 20, 2021
@ninomp ninomp deleted the del-key-to-remove-tracks branch October 20, 2021 23:00
@ronso0
Copy link
Member

ronso0 commented Oct 20, 2021

@ninomp Thanks for adding this shortcut!

Please add the shortcut to https://manual.mixxx.org/2.4/en/chapters/appendix/keyboard_mapping_table.html#keyboard-mapping-table

Later, I'll take care of updating the keyboard PDF/image (there's #4359 and merge conflicts in SVGs are a pita).

@ninomp
Copy link
Contributor Author

ninomp commented Oct 20, 2021

@ronso0 OK Will do so.

@foss-
Copy link
Contributor

foss- commented Oct 21, 2021

Minor followup re confirmation dialog UI on macOS: https://bugs.launchpad.net/mixxx/+bug/1947992

@ninomp
Copy link
Contributor Author

ninomp commented Dec 23, 2021

@foss- Could you test #4577 to check whether it solves the minor issue on macOS you reported?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants