-
-
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 |
I'll try this soonish. Regardless when this will be merged, you can run a personal branch with all PRs merged that you need. |
Thank you! I'm still figuring out how this project "ticks", and which way of contributing (small, frequent PRs vs. longer, larger ones) works best. Thanks for the feedback!
Had a bit of trouble setting it up, because I'm running my production version of Mixxx as a Flatpak application (on an atomic Fedora Silverblue/Bluefin desktop) and the upstream for that only supports 2.4.x and Qt 5 right now... but I've got a CI Flatpak build of my personal I have a few more changesets lined up related to improving keyboard navigation in different areas, quality-of-life improvements for the Auto DJ feature, sound device management and additional hotcue buttons (and probably more stuff in the future), so feel free to tell me in which way you would prefer to receive those. |
Yeah, there's no general receipt, developer time is.. fluctuating. Sometimes quick/small PRs get merged rather quickly, sometimes the sit for ages like big/hard-to-review PRs. And there may also been more relevant/pressing WIP that require attention. (like I need to delay this PR for now and try finish my own work first) |
Ping @ronso0: Any chance of getting this merged ( AFAIK there are no remaining objections, as the issue of dynamically updating the shortcuts in the context menus has been deferred to #13082 to avoid a half-baked attempt here. |
…tem-shortcut Adapts the code to the changes introduced by mixxxdj#13335 in commit 55fa9af.
58bd25c
to
e5e1a6d
Compare
Update No. 2: Build errors and issues related to #13335 should be fixed now. |
Yes, IMO this is ready for merge.
What do you think about adding |
You mean making it so In addition to that, I'd still argue for making the edit key rebindable through the keyboard mapping when keyboard shortcuts are enabled. This leaves the issue of dynamically updating the displayed shortcuts, but as the code for a proper implementation of that would be 80% identical to #13082, I'd still defer that to that PR, or a similar PR extracted from it. |
Yup.
Sure, I'm just saying that it would be helpful / consistent to have the permanent R shortcut. |
This PR is marked as stale because it has been open 90 days with no activity. |
…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! :) |
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.