-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
This is a new feature. It should definitely go to the main branch, not the stable branch. |
It's a new feature for 2.4 : ) |
: ) |
OK I will rebase. |
be02cbb
to
490298d
Compare
There was a problem hiding this 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.
I think a confirm dialog could prevent that, incl. a checkbox |
Please keep in mind that for macOS laptop keyboards or compact external keyboards there is no del key. And yes, a confirmation dialog is a requirement for any delete operation. |
@uklotzde
I think requiring Besides: how do you imagine the Undo history to be implemented? |
Idea to extend this feature: |
Also, if we want to avoid merge conflicts I could cherry-pick this commit into #4347 and take care of the dialogs and stuff. |
@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? |
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. |
Co-authored-by: ronso0 <[email protected]>
This caused Delete key to always hide tracks.
This is ready for review. |
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/widget/wtracktableview.cpp
Outdated
@@ -767,6 +767,30 @@ void WTrackTableView::keyPressEvent(QKeyEvent* event) { | |||
m_pTrackMenu->loadTrackModelIndices(indices); | |||
m_pTrackMenu->slotShowDlgTrackInfo(); | |||
} | |||
} else if (event->key() == kHideRemoveShortcutKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
macOS
src/widget/wtracktableview.cpp
Outdated
if (plibraryTableModel) { | ||
// Hide tracks if this is the main library table | ||
// confirmation dialog | ||
pTrackModel->hideTracks(indices); |
There was a problem hiding this comment.
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?
src/widget/wtracktableview.cpp
Outdated
// confirmation dialog | ||
QMessageBox::StandardButton response; | ||
response = QMessageBox::question(this, | ||
tr("Confirm removal of track(s)"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tr("Confirm removal of track(s)"), | |
tr("Confirm track removal"), |
to avoid singular/plural complexity?
src/widget/wtracktableview.cpp
Outdated
tr("Are you sure you want to remove this/these " | ||
"track(s) from this crate/playlist?")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
src/widget/wtrackmenu.cpp
Outdated
m_pRemoveAct = new QAction(tr("Remove"), this); | ||
m_pRemoveAct->setShortcut(QKeySequence( |
There was a problem hiding this comment.
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?
src/widget/wtracktableview.cpp
Outdated
QMessageBox::StandardButton response; | ||
response = QMessageBox::question(this, | ||
tr("Confirm track removal"), | ||
tr("Are you sure you want to remove all selected tracks from %1?") |
There was a problem hiding this comment.
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.
This is ready. |
LGTM |
Squash into one commit to keep the git history clean? |
src/widget/wtrackmenu.cpp
Outdated
@@ -170,6 +170,9 @@ void WTrackMenu::createMenus() { | |||
} | |||
|
|||
void WTrackMenu::createActions() { | |||
const QKeySequence hideRemoveKeySequence = |
There was a problem hiding this comment.
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
.
src/widget/wtracktableview.cpp
Outdated
// 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?")); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ..."?
This is again ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! LGTM
@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). |
@ronso0 OK Will do so. |
Minor followup re confirmation dialog UI on macOS: https://bugs.launchpad.net/mixxx/+bug/1947992 |
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: