-
-
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
Usability/Keyboard: Add a rebindable keyboard shortcut for editing items as a replacement for F2 #13148
base: main
Are you sure you want to change the base?
Usability/Keyboard: Add a rebindable keyboard shortcut for editing items as a replacement for F2 #13148
Conversation
Welcome at Mixxx! |
Done 👍 (signed under my real name, i.e. Lukas Waslowski) |
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 for working on this!
I left some notes.
Please also check the CI remarks.
src/widget/wtracktableview.cpp
Outdated
void WTrackTableView::editSelectedItem() { | ||
if (state() != EditingState) { | ||
QKeyEvent keyEvent(QEvent::Type::KeyPress, Qt::Key_F2, Qt::NoModifier); | ||
edit(currentIndex(), EditKeyPressed, &keyEvent); |
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.
Why not use the simple method edit(index)
?
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 for the suggestion. I replaced the keyEvent
with nullptr
in the new (rebased) version of this PR (because I ended up not needing foitr the future follow-up PR related to StarEditor
). The EditKeyPressed
flag on the other hand is specified for two reasons:
- The edit is triggered because of the user pressing the platform edit key (resp. a replacement for that key), so it makes sense to pass that knowledge along using the API provided for this.
- I need the flag in the follow-up PR to distinguish certain user-triggered invocations of
edit()
from those that are triggered internally byQAbstractItemView
.
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.
IIUC you don't need it for this use case. The simple implementation with just the index calls the base function with AllEditTriggers
https://github.com/qt/qtbase/blob/e7362764d4931f255d2377462df8ac7a0d4e7c84/src/widgets/itemviews/qabstractitemview.cpp#L1233-L1240
and that starts editing except the trigger is DoubleClicked or SelectedClicked.
https://github.com/qt/qtbase/blob/e7362764d4931f255d2377462df8ac7a0d4e7c84/src/widgets/itemviews/qabstractitemview.cpp#L2749
The EditKey is already enabled here btw, and IIUC that is captured in keyPressEvent and is not relevant for this new slot editSelectedItem
.
mixxx/src/widget/wlibrarytableview.cpp
Line 31 in 67a41d9
setEditTriggers(QAbstractItemView::SelectedClicked|QAbstractItemView::EditKeyPressed); |
Tl;dr
IMO we don't need the trigger here and I'm curious about your follow-up ; )
Do you mind sharing a link to your WIP branch?
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.
Apart from that this PR looks good to me btw.
13393f9
to
b4f4a3c
Compare
…ard shortcut The default platform edit key F2 is often already mapped to other commands when keyboard shortcuts are enabled, so we want to be able to specify a custom key instead to allow full control via keyboards.
All other simple single-key shortcuts are actually taken, and mapping the action to e.g. Ctrl+e would incur the risk of accidentally invoking the loop_double action that is mapped to "e" - especially when you are bulk-editing a lot of tracks.
b4f4a3c
to
faf60e6
Compare
I integrated the review suggestions and fixed the build failures (and have setup the CI pipeline on my fork, so the latter shouldn't happen anymore for future PRs). Thanks for the quick reaction! |
src/widget/wlibrarysidebar.cpp
Outdated
@@ -176,6 +176,20 @@ void WLibrarySidebar::dropEvent(QDropEvent * event) { | |||
} | |||
} | |||
|
|||
void WLibrarySidebar::editSelectedItem() { |
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.
should better be renameItem()
since that's all it does (compared to the table view where we can indeed use "edit" because we don't rename the track, just the metadata item)
isExpanded() is not a good way to check for root nodes, because it returns false for root nodes that are not currently expanded. SidebarModel::renameItem will handle root nodes appropriately anyway.
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.
The code looks good. I have not tested yet.
@ronso0 does that fit into our keyboard layout?
In window explorer renaming is on F2
Yep, we only have Ctrl+R for Recording. The idea is to have an alternative for F2 because it's mapped to rate_temp_up. |
Haven't tested it either, yet, will do so next week. |
IIUC we now need to query the keyboard config via KeyboardEventFilter in order to show the correct shortcut in the sidebar context menu. I.e. show either F2 (keyboard disabled) or R/custom key (keyboard enabled). This happens here for playlists
and here for crates
An example is in WMainMenubar or LegacySkinParser Updating the shortcut when toggling the keyboard is a bit more tricky. Please also check #13082 (not sure if it conflicts) |
I think, with current main, we need to pass a CoreServices (or KeyboardEventFilter) pointer to the library features that need to access the keyboard cfg, and maybe update the sidebar action shortcuts as required in every call of Connecting the |
@ronso0 I've written a quick-and-dirty implementation based on your code, which I will share shortly (as soon as it has built on my machine). I think the most clean way is to "register" the actions that have to be updated with the The code looks quite clean and natural this way. Additions like using a proxy to control lifetimes etc. are also easily possible, but probably not needed anyway. It should probably suffice to use |
@ronso0 Update: The code can be found here: cr7pt0gr4ph7/mixxx@44a12a8...efc7cd1 (branch is wip-fix-star-rating-merge) (By the way, I am building Mixxx on my Linux machine inside a VS Code DevContainer, and its sloooooooooow as soon as multiple files are affected. Do you maybe have any tips for speeding the builds up? I am still waiting on the rebuild to finish... |
I have looked into the issue of trying to display the correct shortcuts on context menu items etc. Here's my current conclusion:
I would therefore argue for keeping this PR self-contained and getting it merged, and deferring the issue of displaying the shortcuts to a separate PR. |
Thank you, that sounds reasonable. |
I have no idea. I'm using Eclipse on Linux with cmake and ccache. With that only changed files (and those units including them) are rebuilt. |
Yup, like it's done for the menu bar actions in #13082 |
See one of my previous comments for a prototype of that 😉 A bit of care has to be taken to drop references to |
…board shortcuts are disabled.
…eyboard shortcuts are disabled.
bb51a0a
to
1306068
Compare
@ronso0 Finally got around to integrating the requested changes.
Should be ready to merge |
@ronso0 Friendly ping :) Could you have a final look so we can get this merged? Thank you :) |
Can I do anything to move this PR forward / get it merged? Thanks! :) |
I can confirm the issue. F2 is the edit shortcut if shortcuts are disabled. What is the reason not to use F2 for the edit feature when shortcuts are enabled? |
Because that's mapped to "rate_perm_up" or similar for ages? |
I think the underlying issue is now the move of the expected hotkey for Edit. |
case kRenameSidebarItemShortcutKey: // F2 | ||
case kRenameSidebarItemAlternativeShortcutKey: { // R |
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.
For my understanding R is the adjustable shortcut alternative via kbd.cfg. We should not hard code it here.
case kRenameSidebarItemShortcutKey: // F2 | |
case kRenameSidebarItemAlternativeShortcutKey: { // R | |
case kRenameSidebarItemShortcutKey: { // F2 |
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.
R already works without this line in case shortcuts are enabled.
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 can confirm the issue.
F2
is the edit shortcut if shortcuts are disabled. What is the reason not to useF2
for the edit feature when shortcuts are enabled?
As previously discussed by you and @ronso, F1
through F8
are bound to actions relating to pitch bending/bpm changes, so an alternative was needed.
The reasoning for why r
was chosen is explained in the PR description. I've been using it for a while now, and can confirm the usability turns out pretty well, especially when editing a number of tracks.
For my understanding
R
is the adjustable shortcut alternative via kbd.cfg. We should not hard code it here.R
already works without this line in case shortcuts are enabled.
Yes, you are correct. The newly introduced adjustable keyboard shortcut defaults to R
.
Hardcoding R
in addition to F2
so R
always works, even when keyboard shortcuts are disabled, was an explicit request by @ronso0. I can see the underlying reasoning, but don't feel strongly either way.
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 don't see this request in the linked post.
At least it is wrong to maintain a hard coded R here, while it can be actually any key on users choice.
We consider the kind.cfg files a user configuration.
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. Left some comments.
case kRenameSidebarItemShortcutKey: // F2 | ||
case kRenameSidebarItemAlternativeShortcutKey: { // R |
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.
R already works without this line in case shortcuts are enabled.
m_pRenamePlaylistAction->setShortcuts(QList<QKeySequence>{ | ||
QKeySequence(kRenameSidebarItemShortcutKey), | ||
QKeySequence(kRenameSidebarItemAlternativeShortcutKey)}); |
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.
m_pRenamePlaylistAction->setShortcuts(QList<QKeySequence>{ | |
QKeySequence(kRenameSidebarItemShortcutKey), | |
QKeySequence(kRenameSidebarItemAlternativeShortcutKey)}); |
If we want to show the short cut, we need to change it form F2 to the value which is picked in kbd.cfg.
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.
Updated the code to display the correct shortcut in the context menu (though it does not dynamically react to toggling keyboard shortcuts on/off at runtime, as that requires the infrastructure implemented in #13082). This aligns with the current implementation e.g. in AutoDJFeature.
Displaying the shortcut in the context menu was an explicit request by @ronso0 during review. The decision to postpone dynamically updating the displayed shortcuts until a Mixxx-wide approach (i.e. #13082) is available was also made here together with @ronso0.
m_pRenameCrateAction->setShortcuts(QList<QKeySequence>{ | ||
QKeySequence(kRenameSidebarItemShortcutKey), | ||
QKeySequence(kRenameSidebarItemAlternativeShortcutKey)}); |
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.
m_pRenameCrateAction->setShortcuts(QList<QKeySequence>{ | |
QKeySequence(kRenameSidebarItemShortcutKey), | |
QKeySequence(kRenameSidebarItemAlternativeShortcutKey)}); |
same here. Either show the correct value or nothing.
@@ -41,3 +41,4 @@ constexpr Qt::Key kHideRemoveShortcutKey = Qt::Key_Delete; | |||
#endif | |||
|
|||
constexpr Qt::Key kRenameSidebarItemShortcutKey = Qt::Key_F2; | |||
constexpr Qt::Key kRenameSidebarItemAlternativeShortcutKey = Qt::Key_R; |
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.
constexpr Qt::Key kRenameSidebarItemAlternativeShortcutKey = Qt::Key_R; |
This is not a constexpr it is set by kbd.cfg
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.
See my previous response for why r
was hardcoded.
Can you squash the last commits into one? |
@@ -695,6 +695,19 @@ void BasePlaylistFeature::bindLibraryWidget(WLibrary* pLibraryWidget, | |||
&BasePlaylistFeature::htmlLinkClicked); | |||
m_pLibraryWidget = QPointer(pLibraryWidget); | |||
m_pLibraryWidget->registerView(m_rootViewName, pEdit); | |||
|
|||
// Update shortcuts displayed in the context menu | |||
if (pKeyboard->getKeyboardConfig()->exists(ConfigKey("[Library]", "EditItem"))) { |
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 doers not work, because we can have the situation that there is no "Edit item" configured.
You need either to show the correct active short cuts or nothing. Showing a not working short cut is a bug IMHO
case kRenameSidebarItemShortcutKey: // F2 | ||
case kRenameSidebarItemAlternativeShortcutKey: { // R |
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 don't see this request in the linked post.
At least it is wrong to maintain a hard coded R here, while it can be actually any key on users choice.
We consider the kind.cfg files a user configuration.
I think it would be good to have static shortcuts, ie. at least one shortcut that works regardless (user) shortcuts being enabled. |
I can confirm that. I am also not particularly happy about the changing meaning of F2. A straight forward solution would be to not use F2 in kbd.cfg. Then everything is consistent. F2 is anyway cumbersome for any perfomace hot key, because at least in case of Laptop Keyboard the key kan be permanently mapped to FN (Volume down) in my case. If we want to srick with "R" which is clearly in the region of other keyboard mappings, and not a system wide key I will not oppose. They may for example map F2 to "[Library], EditItem" to make it alwas work the same. In this case a static mapping to "R" in potions of the code is missleading. |
Given that most arguments have already been made, I propose the following - provided you (@ronso0 and @daschuer) both agree:
Sorry about the noise... I'll clean up the commit history as soon as a decision has been made regarding the points above, as that might lead to the removal of some other commits. |
Yup, I agree as well. |
Issue Statement
Right now, one cannot easily use a keyboard shortcut to begin editing a track table cell when keyboard shortcuts are enabled, because the usual F2 key is bound to something else by default the default
.kbd.cfg
files provided.Use Case
I am currently setting up my music library, and it is quite annoying that I can't use keyboard shortcuts to both play a track in the preview deck using
p
(which is only possible when keyboard shortcuts are enabled) and then enter edit mode using the keyboard too (the F2 key is only bound to this function when keyboard shortcuts are disabled).Proposed Solution (as implemented)
Add a keyboard-triggerable
EditItem
action (name is up for debate, but matches the existingGoToItem
action) that can be remapped usingCustom.kbd.cfg
. The default keyboard mappings bindEditItem
to ther
key,basically because it was the only easily-reachable key not bound yet, but due to being able to rebind it myself, I am open for other suggestions. What I considered so far:
EditItem
toCtrl+Shift+Return
: Makes sense from the viewpoint of consistency (becauseCtrl+Enter
is already bound to opening the track menu, andEnter
is interpreted as "edit this shell" e.g. in Excel and Google Sheets.EditItem
toCtrl+e
: Would work, is easily reachable, but incurs the risk of mistiming theCtrl
press and invokingloop_double
(which is mapped toe
) instead when editing a lot of tracks.EditItem
tor
: The key is easily reachable, not mapped to anything important yet, and has the mnemonic of Rename to remember it by.Further Work
Adapt the keyboard shortcut table at mixxxdj/manual once the default key binding has been agreed upon.
Making the "Star Rating" column editable by keyboard: I'm already working on this, and have a PR nearly ready, but due to the "special" behavior of the star rating column that allows you to edit it simply by hovering over & clicking a star without focusing the cell first, care has to be taken so that the feature works as expected in all circumstances.
Open a context menu providing the option to clear the playing count when attempting to edit the playing count column.
Possibly adding a toggle option (or separate command) that keeps the "editor mode" active not only when navigating horizontally using
Tab
/Shift+Tab
, but also when navigating vertically using theUp
andDown
arrow keys.